Collection name to CamelCase (fixes #2983)
This commit is contained in:
parent
4d3a45c8fb
commit
5374b2f398
@ -55,7 +55,9 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
|
|||||||
'Projector',
|
'Projector',
|
||||||
'gettextCatalog',
|
'gettextCatalog',
|
||||||
'gettext',
|
'gettext',
|
||||||
function($http, DS, Speaker, jsDataModel, Projector, gettextCatalog, gettext) {
|
'CamelCase',
|
||||||
|
'EditForm',
|
||||||
|
function($http, DS, Speaker, jsDataModel, Projector, gettextCatalog, gettext, CamelCase, EditForm) {
|
||||||
var name = 'agenda/item';
|
var name = 'agenda/item';
|
||||||
return DS.defineResource({
|
return DS.defineResource({
|
||||||
name: name,
|
name: name,
|
||||||
@ -68,6 +70,13 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
|
|||||||
getContentObject: function () {
|
getContentObject: function () {
|
||||||
return DS.get(this.content_object.collection, this.content_object.id);
|
return DS.get(this.content_object.collection, this.content_object.id);
|
||||||
},
|
},
|
||||||
|
getContentObjectDetailState: function () {
|
||||||
|
return CamelCase(this.content_object.collection).replace('/', '.') +
|
||||||
|
'.detail({id: ' + this.content_object.id + '})';
|
||||||
|
},
|
||||||
|
getContentObjectForm: function () {
|
||||||
|
return EditForm.fromCollectionString(this.content_object.collection);
|
||||||
|
},
|
||||||
getContentResource: function () {
|
getContentResource: function () {
|
||||||
return DS.definitions[this.content_object.collection];
|
return DS.definitions[this.content_object.collection];
|
||||||
},
|
},
|
||||||
|
@ -81,7 +81,6 @@ angular.module('OpenSlidesApp.agenda.site', [
|
|||||||
'$filter',
|
'$filter',
|
||||||
'$http',
|
'$http',
|
||||||
'$state',
|
'$state',
|
||||||
'$injector',
|
|
||||||
'DS',
|
'DS',
|
||||||
'operator',
|
'operator',
|
||||||
'ngDialog',
|
'ngDialog',
|
||||||
@ -97,7 +96,7 @@ angular.module('OpenSlidesApp.agenda.site', [
|
|||||||
'osTableFilter',
|
'osTableFilter',
|
||||||
'AgendaCsvExport',
|
'AgendaCsvExport',
|
||||||
'PdfCreate',
|
'PdfCreate',
|
||||||
function($scope, $filter, $http, $state, $injector, DS, operator, ngDialog, Agenda, TopicForm,
|
function($scope, $filter, $http, $state, DS, operator, ngDialog, Agenda, TopicForm,
|
||||||
AgendaTree, Projector, ProjectionDefault, AgendaContentProvider, PdfMakeDocumentProvider,
|
AgendaTree, Projector, ProjectionDefault, AgendaContentProvider, PdfMakeDocumentProvider,
|
||||||
gettextCatalog, gettext, osTableFilter, AgendaCsvExport, PdfCreate) {
|
gettextCatalog, gettext, osTableFilter, AgendaCsvExport, PdfCreate) {
|
||||||
// Bind agenda tree to the scope
|
// Bind agenda tree to the scope
|
||||||
@ -269,21 +268,8 @@ angular.module('OpenSlidesApp.agenda.site', [
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.getDetailStatePrefix = function (item) {
|
|
||||||
var prefix = item.content_object.collection.replace('/','.');
|
|
||||||
// Hotfix for Issue 2566.
|
|
||||||
// The changes could be reverted if Issue 2480 is closed.
|
|
||||||
prefix = prefix.replace('motion-block', 'motionBlock');
|
|
||||||
return prefix;
|
|
||||||
};
|
|
||||||
$scope.edit = function (item) {
|
$scope.edit = function (item) {
|
||||||
var formName = item.content_object.collection.split('/')[1];
|
ngDialog.open(item.getContentObjectForm().getDialog({id: item.content_object.id}));
|
||||||
// Hotfix for Issue 2566.
|
|
||||||
// The changes could be reverted if Issue 2480 is closed.
|
|
||||||
formName = formName.replace('motion-block', 'motionBlock');
|
|
||||||
formName = formName.charAt(0).toUpperCase() + formName.slice(1) + 'Form';
|
|
||||||
var form = $injector.get(formName);
|
|
||||||
ngDialog.open(form.getDialog({id: item.content_object.id}));
|
|
||||||
};
|
};
|
||||||
// export
|
// export
|
||||||
$scope.pdfExport = function () {
|
$scope.pdfExport = function () {
|
||||||
|
@ -271,7 +271,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- ID and title -->
|
<!-- ID and title -->
|
||||||
<div>
|
<div>
|
||||||
<a class="title" ui-sref="{{ getDetailStatePrefix(item) }}.detail({id: item.content_object.id})" ng-show="isAllowedToSeeOpenLink(item)">
|
<a class="title" ui-sref="{{ item.getContentObjectDetailState() }}" ng-show="isAllowedToSeeOpenLink(item)">
|
||||||
{{ item.getListViewTitle() }}
|
{{ item.getListViewTitle() }}
|
||||||
</a>
|
</a>
|
||||||
<span class="title" ng-hide="isAllowedToSeeOpenLink(item)">
|
<span class="title" ng-hide="isAllowedToSeeOpenLink(item)">
|
||||||
|
@ -682,9 +682,9 @@ angular.module('OpenSlidesApp.core', [
|
|||||||
.factory('Projector', [
|
.factory('Projector', [
|
||||||
'DS',
|
'DS',
|
||||||
'$http',
|
'$http',
|
||||||
'$injector',
|
'EditForm',
|
||||||
'Config',
|
'Config',
|
||||||
function(DS, $http, $injector, Config) {
|
function(DS, $http, EditForm, Config) {
|
||||||
return DS.defineResource({
|
return DS.defineResource({
|
||||||
name: 'core/projector',
|
name: 'core/projector',
|
||||||
onConflict: 'replace',
|
onConflict: 'replace',
|
||||||
@ -716,14 +716,9 @@ angular.module('OpenSlidesApp.core', [
|
|||||||
value.name != 'core/countdown' &&
|
value.name != 'core/countdown' &&
|
||||||
value.name != 'core/projector-message' &&
|
value.name != 'core/projector-message' &&
|
||||||
value.name != 'agenda/current-list-of-speakers' ) {
|
value.name != 'agenda/current-list-of-speakers' ) {
|
||||||
var formName = value.name.split('/')[1];
|
|
||||||
// Hotfix for Issue 2566.
|
|
||||||
// The changes could be reverted if Issue 2480 is closed.
|
|
||||||
formName = formName.replace('motion-block', 'motionBlock');
|
|
||||||
formName = formName.charAt(0).toUpperCase() + formName.slice(1) + 'Form';
|
|
||||||
return_dict = {
|
return_dict = {
|
||||||
form: $injector.get(formName),
|
form: EditForm.fromCollectionString(value.name),
|
||||||
id: value.id
|
id: value.id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -953,6 +948,34 @@ angular.module('OpenSlidesApp.core', [
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
/* Converts a snake-case string to camelCase. Example:
|
||||||
|
* 'motion-block-config' -> 'motionBlockConfig' */
|
||||||
|
.factory('CamelCase', [
|
||||||
|
function () {
|
||||||
|
return function (str) {
|
||||||
|
return str.replace(/-([a-z])/g, function (match) {
|
||||||
|
return match[1].toUpperCase();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
/* Return the specific EditForm for a given model. */
|
||||||
|
.factory('EditForm', [
|
||||||
|
'$injector',
|
||||||
|
'CamelCase',
|
||||||
|
function ($injector, CamelCase) {
|
||||||
|
return {
|
||||||
|
fromCollectionString: function (collection) {
|
||||||
|
var modelName = CamelCase(collection).split('/')[1];
|
||||||
|
// Convert modelModel to ModelModelForm
|
||||||
|
var formName = modelName.charAt(0).toUpperCase() + modelName.slice(1) + 'Form';
|
||||||
|
return $injector.get(formName);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
/* Converts number of seconds into string "h:mm:ss" or "mm:ss" */
|
/* Converts number of seconds into string "h:mm:ss" or "mm:ss" */
|
||||||
.filter('osSecondsToTime', [
|
.filter('osSecondsToTime', [
|
||||||
'HumanTimeConverter',
|
'HumanTimeConverter',
|
||||||
|
@ -17,9 +17,7 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides
|
|||||||
title: gettext('Topics'),
|
title: gettext('Topics'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
.state('topics.topic', {
|
.state('topics.topic', {
|
||||||
url: '/topic',
|
|
||||||
abstract: true,
|
abstract: true,
|
||||||
template: "<ui-view/>",
|
template: "<ui-view/>",
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user