diff --git a/openslides/agenda/static/js/agenda/base.js b/openslides/agenda/static/js/agenda/base.js index 38a4a1ced..84912cb81 100644 --- a/openslides/agenda/static/js/agenda/base.js +++ b/openslides/agenda/static/js/agenda/base.js @@ -23,21 +23,26 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users']) .factory('AgendaUpdate',[ 'Agenda', - function(Agenda) { + 'operator', + function(Agenda, operator) { return { saveChanges: function (item_id, changes) { - Agenda.find(item_id).then(function(item) { - var something = false; - _.each(changes, function(change) { - if (change.value !== item[change.key]) { - item[change.key] = change.value; - something = true; + // change agenda item only if user has the permission to do that + if (operator.hasPerms('agenda.can_manage agenda.can_see_hidden_items')) { + Agenda.find(item_id).then(function (item) { + console.log(item); + var something = false; + _.each(changes, function(change) { + if (change.value !== item[change.key]) { + item[change.key] = change.value; + something = true; + } + }); + if (something === true) { + Agenda.save(item); } }); - if (something === true) { - Agenda.save(item); - } - }); + } } }; } diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js index 981de0c9e..1985f3b0d 100644 --- a/openslides/agenda/static/js/agenda/site.js +++ b/openslides/agenda/static/js/agenda/site.js @@ -40,58 +40,21 @@ angular.module('OpenSlidesApp.agenda.site', [ abstract: true, template: "", }) - .state('agenda.item.list', { - resolve: { - items: function(Agenda) { - return Agenda.findAll(); - } - } - }) + .state('agenda.item.list', {}) .state('agenda.item.detail', { resolve: { - item: function(Agenda, $stateParams) { - return Agenda.find($stateParams.id).catch( - function () { - return null; - } - ); - }, - users: function(User) { - return User.findAll().catch( - function () { - return null; - } - ); - }, - tags: function(Tag) { - return Tag.findAll(); - } + itemId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }], } }) .state('agenda.item.sort', { - resolve: { - items: function(Agenda) { - return Agenda.findAll(); - } - }, url: '/sort', controller: 'AgendaSortCtrl', }) .state('agenda.current-list-of-speakers', { url: '/speakers', controller: 'ListOfSpeakersViewCtrl', - resolve: { - users: function(User) { - return User.findAll().catch( - function () { - return null; - } - ); - }, - items: function(Agenda) { - return Agenda.findAll(); - } - }, data: { title: gettext('Current list of speakers'), }, @@ -421,10 +384,11 @@ angular.module('OpenSlidesApp.agenda.site', [ 'operator', 'Agenda', 'User', - 'item', + 'itemId', 'Projector', 'ProjectionDefault', - function ($scope, $filter, $http, $state, operator, Agenda, User, item, Projector, ProjectionDefault) { + function ($scope, $filter, $http, $state, operator, Agenda, User, itemId, Projector, ProjectionDefault) { + var item = Agenda.get(itemId); Agenda.bindOne(item.id, $scope, 'item'); User.bindAll({}, $scope, 'users'); $scope.$watch(function () { diff --git a/openslides/agenda/static/templates/agenda/item-list.html b/openslides/agenda/static/templates/agenda/item-list.html index 438379eae..5e2f7fb4d 100644 --- a/openslides/agenda/static/templates/agenda/item-list.html +++ b/openslides/agenda/static/templates/agenda/item-list.html @@ -8,11 +8,14 @@ New - + - - Import - + + Import + + diff --git a/openslides/assignments/static/js/assignments/base.js b/openslides/assignments/static/js/assignments/base.js index c6be1e718..719c6c880 100644 --- a/openslides/assignments/static/js/assignments/base.js +++ b/openslides/assignments/static/js/assignments/base.js @@ -316,6 +316,8 @@ angular.module('OpenSlidesApp.assignments', []) verboseName: gettext('Election'), verboseNamePlural: gettext('Elections'), phases: phases, + // TODO (Issue 2885): Do not query this from server. It should be included in the startup data. + // Remove than all 'phases' injections from resolvers. getPhases: function () { if (!this.phases) { this.phases = $http({ 'method': 'OPTIONS', 'url': '/rest/assignments/assignment/' }) diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js index 7ac8e528b..3f8a74362 100644 --- a/openslides/assignments/static/js/assignments/site.js +++ b/openslides/assignments/static/js/assignments/site.js @@ -42,48 +42,20 @@ angular.module('OpenSlidesApp.assignments.site', [ }) .state('assignments.assignment.list', { resolve: { - assignments: function(Assignment) { - return Assignment.findAll(); - }, - tags: function(Tag) { - return Tag.findAll(); - }, - items: function(Agenda) { - return Agenda.findAll().catch( - function() { - return null; - } - ); - }, - phases: function(Assignment) { + phases: ['Assignment', function (Assignment) { return Assignment.getPhases(); - } + }], } }) .state('assignments.assignment.detail', { controller: 'AssignmentDetailCtrl', resolve: { - assignment: function(Assignment, $stateParams) { - return Assignment.find($stateParams.id).then(function(assignment) { - return assignment; - }); - }, - users: function(User) { - return User.findAll(); - }, - tags: function(Tag) { - return Tag.findAll(); - }, - items: function(Agenda) { - return Agenda.findAll().catch( - function() { - return null; - } - ); - }, - phases: function(Assignment) { + assignmentId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }], + phases: ['Assignment', function (Assignment) { return Assignment.getPhases(); - } + }], } }) // redirects to assignment detail and opens assignment edit form dialog, uses edit url, @@ -91,8 +63,8 @@ angular.module('OpenSlidesApp.assignments.site', [ // (from assignment controller use AssignmentForm factory instead to open dialog in front // of current view without redirect) .state('assignments.assignment.detail.update', { - onEnter: ['$stateParams', '$state', 'ngDialog', 'Assignment', - function($stateParams, $state, ngDialog, Assignment) { + onEnter: ['$stateParams', '$state', 'ngDialog', + function($stateParams, $state, ngDialog) { ngDialog.open({ template: 'static/templates/assignments/assignment-form.html', controller: 'AssignmentUpdateCtrl', @@ -100,16 +72,8 @@ angular.module('OpenSlidesApp.assignments.site', [ closeByEscape: false, closeByDocument: false, resolve: { - assignment: function() { - return Assignment.find($stateParams.id).then(function(assignment) { - return Assignment.loadRelations(assignment, 'agenda_item'); - }); - }, - items: function(Agenda) { - return Agenda.findAll().catch( - function() { - return null; - }); + assignmentId: function() { + return $stateParams.id; }, }, preCloseCallback: function() { @@ -135,25 +99,15 @@ angular.module('OpenSlidesApp.assignments.site', [ return { // ngDialog for assignment form getDialog: function (assignment) { - var resolve = {}; - if (assignment) { - resolve.assignment = function () { - return assignment; - }; - resolve.agenda_item = function () { - return Assignment.loadRelations(assignment, 'agenda_item'); - }; - } - resolve.items = function() { - return Agenda.getAll(); - }; return { template: 'static/templates/assignments/assignment-form.html', controller: (assignment) ? 'AssignmentUpdateCtrl' : 'AssignmentCreateCtrl', className: 'ngdialog-theme-default wide-form', closeByEscape: false, closeByDocument: false, - resolve: resolve + resolve: { + assignmentId: function () {return assignment ? assignment.id : void 0;} + }, }; }, // angular-formly fields for assignment form @@ -298,7 +252,6 @@ angular.module('OpenSlidesApp.assignments.site', [ 'Assignment', 'Tag', 'Agenda', - 'phases', 'Projector', 'ProjectionDefault', 'gettextCatalog', @@ -309,9 +262,10 @@ angular.module('OpenSlidesApp.assignments.site', [ 'osTableFilter', 'osTableSort', 'gettext', - function($scope, ngDialog, AssignmentForm, Assignment, Tag, Agenda, phases, Projector, ProjectionDefault, + 'phases', + function($scope, ngDialog, AssignmentForm, Assignment, Tag, Agenda, Projector, ProjectionDefault, gettextCatalog, AssignmentContentProvider, AssignmentCatalogContentProvider, PdfMakeDocumentProvider, - User, osTableFilter, osTableSort, gettext) { + User, osTableFilter, osTableSort, gettext, phases) { Assignment.bindAll({}, $scope, 'assignments'); Tag.bindAll({}, $scope, 'tags'); $scope.$watch(function () { @@ -419,21 +373,19 @@ angular.module('OpenSlidesApp.assignments.site', [ }; // create the PDF List $scope.makePDF_assignmentList = function () { - User.findAll().then( function(users) { - var filename = gettextCatalog.getString("Elections") + ".pdf"; - var assignmentContentProviderArray = []; + var filename = gettextCatalog.getString("Elections") + ".pdf"; + var assignmentContentProviderArray = []; - //convert the filtered assignments to content providers - angular.forEach($scope.assignmentsFiltered, function(assignment) { - assignmentContentProviderArray.push(AssignmentContentProvider.createInstance(assignment)); - }); - - var assignmentCatalogContentProvider = - AssignmentCatalogContentProvider.createInstance(assignmentContentProviderArray); - var documentProvider = - PdfMakeDocumentProvider.createInstance(assignmentCatalogContentProvider); - pdfMake.createPdf(documentProvider.getDocument()).download(filename); + //convert the filtered assignments to content providers + angular.forEach($scope.assignmentsFiltered, function(assignment) { + assignmentContentProviderArray.push(AssignmentContentProvider.createInstance(assignment)); }); + + var assignmentCatalogContentProvider = + AssignmentCatalogContentProvider.createInstance(assignmentContentProviderArray); + var documentProvider = + PdfMakeDocumentProvider.createInstance(assignmentCatalogContentProvider); + pdfMake.createPdf(documentProvider.getDocument()).download(filename); }; } ]) @@ -449,7 +401,7 @@ angular.module('OpenSlidesApp.assignments.site', [ 'operator', 'Assignment', 'User', - 'assignment', + 'assignmentId', 'phases', 'Projector', 'ProjectionDefault', @@ -459,8 +411,9 @@ angular.module('OpenSlidesApp.assignments.site', [ 'PdfMakeBallotPaperProvider', 'gettextCatalog', function($scope, $http, $filter, filterFilter, gettext, ngDialog, AssignmentForm, operator, Assignment, - User, assignment, phases, Projector, ProjectionDefault, AssignmentContentProvider, BallotContentProvider, + User, assignmentId, phases, Projector, ProjectionDefault, AssignmentContentProvider, BallotContentProvider, PdfMakeDocumentProvider, PdfMakeBallotPaperProvider, gettextCatalog) { + var assignment = Assignment.get(assignmentId); User.bindAll({}, $scope, 'users'); Assignment.loadRelations(assignment, 'agenda_item'); $scope.$watch(function () { @@ -584,12 +537,7 @@ angular.module('OpenSlidesApp.assignments.site', [ closeByEscape: false, closeByDocument: false, resolve: { - assignmentpoll: function (AssignmentPoll) { - return AssignmentPoll.find(poll.id); - }, - ballot: function () { - return ballot; - } + assignmentpollId: function () {return poll.id;} } }); }; @@ -703,8 +651,9 @@ angular.module('OpenSlidesApp.assignments.site', [ 'AssignmentForm', 'Agenda', 'AgendaUpdate', - 'assignment', - function($scope, Assignment, AssignmentForm, Agenda, AgendaUpdate, assignment) { + 'assignmentId', + function($scope, Assignment, AssignmentForm, Agenda, AgendaUpdate, assignmentId) { + var assignment = Assignment.get(assignmentId); $scope.alert = {}; // set initial values for form model by create deep copy of assignment object // so list/detail view is not updated while editing @@ -753,12 +702,13 @@ angular.module('OpenSlidesApp.assignments.site', [ '$filter', 'gettextCatalog', 'AssignmentPoll', - 'assignmentpoll', + 'assignmentpollId', 'ballot', - function($scope, $filter, gettextCatalog, AssignmentPoll, assignmentpoll, ballot) { + function($scope, $filter, gettextCatalog, AssignmentPoll, assignmentpollId, ballot) { // set initial values for form model by create deep copy of assignmentpoll object // so detail view is not updated while editing poll - $scope.model = angular.copy(assignmentpoll); + var assignmentpoll = angular.copy(AssignmentPoll.get(assignmentpollId)); + $scope.model = assignmentpoll; $scope.ballot = ballot; $scope.formFields = []; $scope.alert = {}; diff --git a/openslides/core/static/js/core/projector.js b/openslides/core/static/js/core/projector.js index 0130477f6..ec83bac23 100644 --- a/openslides/core/static/js/core/projector.js +++ b/openslides/core/static/js/core/projector.js @@ -171,7 +171,7 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core']) var STEPS = 5; $scope.scroll = 0; var setScroll = function (scroll) { - scroll = 80 * scroll; + scroll = -80 * scroll; if ($scope.scrollTimeout) { $timeout.cancel($scope.scrollTimeout); } diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index a0ef4cefc..1122eda61 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -336,22 +336,21 @@ angular.module('OpenSlidesApp.core.site', [ title: gettext('Tags'), }, }) - .state('core.tag.list', { - resolve: { - tags: function(Tag) { - return Tag.findAll(); - } - } - }) + .state('core.tag.list', {}) .state('core.tag.create', {}) .state('core.tag.detail', { resolve: { - tag: function(Tag, $stateParams) { - return Tag.find($stateParams.id); - } + tagId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }], } }) .state('core.tag.detail.update', { + resolve: { + tagId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }], + }, views: { '@core.tag': {} } @@ -381,8 +380,8 @@ angular.module('OpenSlidesApp.core.site', [ closeByEscape: false, closeByDocument: false, resolve: { - projectorMessage: function () { - return message; + projectorMessageId: function () { + return message.id; } }, }; @@ -1136,12 +1135,12 @@ angular.module('OpenSlidesApp.core.site', [ .controller('ProjectorMessageEditCtrl', [ '$scope', - 'projectorMessage', + 'projectorMessageId', 'ProjectorMessage', 'ProjectorMessageForm', - function ($scope, projectorMessage, ProjectorMessage, ProjectorMessageForm) { + function ($scope, projectorMessageId, ProjectorMessage, ProjectorMessageForm) { $scope.formFields = ProjectorMessageForm.getFormFields(); - $scope.model = angular.copy(projectorMessage); + $scope.model = angular.copy(ProjectorMessage.get(projectorMessageId)); $scope.save = function (message) { ProjectorMessage.inject(message); @@ -1336,9 +1335,9 @@ angular.module('OpenSlidesApp.core.site', [ .controller('TagDetailCtrl', [ '$scope', 'Tag', - 'tag', - function($scope, Tag, tag) { - Tag.bindOne(tag.id, $scope, 'tag'); + 'tagId', + function($scope, Tag, tagId) { + Tag.bindOne(tagId, $scope, 'tag'); } ]) @@ -1362,9 +1361,9 @@ angular.module('OpenSlidesApp.core.site', [ '$scope', '$state', 'Tag', - 'tag', - function($scope, $state, Tag, tag) { - $scope.tag = tag; + 'tagId', + function($scope, $state, Tag, tagId) { + $scope.tag = Tag.get(tagId); $scope.save = function (tag) { Tag.save(tag).then( function(success) { diff --git a/openslides/core/static/templates/core/tag-list.html b/openslides/core/static/templates/core/tag-list.html index 4b583df56..3a91fd8d3 100644 --- a/openslides/core/static/templates/core/tag-list.html +++ b/openslides/core/static/templates/core/tag-list.html @@ -37,7 +37,7 @@ {{ tag.name }}
- Edit | + Edit · ", }) - .state('mediafiles.mediafile.list', { - resolve: { - mediafiles: function (Mediafile) { - return Mediafile.findAll(); - }, - users: function (User) { - return User.findAll().catch( - function () { - return null; - } - ); - }, - } - }); + .state('mediafiles.mediafile.list', {}); } ]); diff --git a/openslides/motions/static/js/motions/motion-block.js b/openslides/motions/static/js/motions/motion-block.js index fcd2d0774..83595f2c6 100644 --- a/openslides/motions/static/js/motions/motion-block.js +++ b/openslides/motions/static/js/motions/motion-block.js @@ -46,9 +46,7 @@ angular.module('OpenSlidesApp.motions.motionBlock', []) .run(['MotionBlock', function(MotionBlock) {}]) - // MotionBlock views (list view, create dialog, update dialog) - .factory('MotionBlockForm', [ '$http', 'gettextCatalog', @@ -65,9 +63,7 @@ angular.module('OpenSlidesApp.motions.motionBlock', []) closeByEscape: false, closeByDocument: false, resolve: { - motionBlock: function () { - return motionBlock; - } + motionBlockId: function () {return motionBlock ? motionBlock.id : void 0;} } }; }, @@ -133,11 +129,11 @@ angular.module('OpenSlidesApp.motions.motionBlock', []) 'Motion', 'MotionBlockForm', 'MotionBlock', - 'motionBlock', + 'motionBlockId', 'Projector', 'ProjectionDefault', - function($scope, $http, ngDialog, Motion, MotionBlockForm, MotionBlock, motionBlock, Projector, ProjectionDefault) { - MotionBlock.bindOne(motionBlock.id, $scope, 'motionBlock'); + function($scope, $http, ngDialog, Motion, MotionBlockForm, MotionBlock, motionBlockId, Projector, ProjectionDefault) { + MotionBlock.bindOne(motionBlockId, $scope, 'motionBlock'); Motion.bindAll({}, $scope, 'motions'); $scope.$watch(function () { return Projector.lastModified(); @@ -211,14 +207,15 @@ angular.module('OpenSlidesApp.motions.motionBlock', []) 'MotionBlock', 'MotionBlockForm', 'AgendaUpdate', - 'motionBlock', - function($scope, $state, MotionBlock, MotionBlockForm, AgendaUpdate, motionBlock) { + 'motionBlockId', + function($scope, $state, MotionBlock, MotionBlockForm, AgendaUpdate, motionBlockId) { // TODO: Check #2486 and remove some agenda related code. //MotionBlock.loadRelations(motionBlock, 'agenda_item'); $scope.alert = {}; // Prepare form. Set initial values by creating a deep copy of // motionBlock object so list/detail view is not updated while editing. + var motionBlock = MotionBlock.get(motionBlockId); $scope.model = angular.copy(motionBlock); // Get all form fields. diff --git a/openslides/motions/static/js/motions/site.js b/openslides/motions/static/js/motions/site.js index 0df4fafb5..f3b56a01b 100644 --- a/openslides/motions/static/js/motions/site.js +++ b/openslides/motions/static/js/motions/site.js @@ -43,82 +43,12 @@ angular.module('OpenSlidesApp.motions.site', [ abstract: true, template: "", }) - .state('motions.motion.list', { - resolve: { - motions: function(Motion) { - return Motion.findAll().then(function(motions) { - angular.forEach(motions, function(motion) { - Motion.loadRelations(motion, 'agenda_item'); - }); - }); - }, - categories: function(Category) { - return Category.findAll(); - }, - motionBlocks: function(MotionBlock) { - return MotionBlock.findAll(); - }, - tags: function(Tag) { - return Tag.findAll(); - }, - users: function(User) { - return User.findAll().catch( - function () { - return null; - }); - }, - workflows: function(Workflow) { - return Workflow.findAll(); - }, - items: function(Agenda) { - return Agenda.findAll().catch( - function () { - return null; - }); - } - } - }) + .state('motions.motion.list', {}) .state('motions.motion.detail', { resolve: { - motion: function(Motion, $stateParams) { - return Motion.find($stateParams.id); - }, - motions: function(Motion) { - return Motion.findAll(); - }, - categories: function(Category) { - return Category.findAll(); - }, - motionBlocks: function(MotionBlock) { - return MotionBlock.findAll(); - }, - users: function(User) { - return User.findAll().catch( - function () { - return null; - } - ); - }, - items: function(Agenda) { - return Agenda.findAll().catch( - function () { - return null; - } - ); - }, - mediafiles: function(Mediafile) { - return Mediafile.findAll().catch( - function () { - return null; - } - ); - }, - tags: function(Tag) { - return Tag.findAll(); - }, - change_recommendations: function(MotionChangeRecommendation, motion) { - return MotionChangeRecommendation.findAll({'where': {'motion_version_id': {'==': motion.active_version}}}); - } + motionId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }], } }) // redirects to motion detail and opens motion edit form dialog, uses edit url, @@ -135,20 +65,9 @@ angular.module('OpenSlidesApp.motions.site', [ closeByEscape: false, closeByDocument: false, resolve: { - motion: function() { - return Motion.find($stateParams.id).then(function(motion) { - return Motion.loadRelations(motion, 'agenda_item'); - }); - }, - items: function(Agenda) { - return Agenda.findAll().catch( - function() { - return null; - } - ); - } + motionId: function () {return $stateParams.id;}, }, - preCloseCallback: function() { + preCloseCallback: function () { $state.go('motions.motion.detail', {motion: $stateParams.id}); return true; } @@ -159,17 +78,6 @@ angular.module('OpenSlidesApp.motions.site', [ .state('motions.motion.import', { url: '/import', controller: 'MotionImportCtrl', - resolve: { - motions: function(Motion) { - return Motion.findAll(); - }, - categories: function(Category) { - return Category.findAll(); - }, - users: function(User) { - return User.findAll(); - } - } }) // categories .state('motions.category', { @@ -180,19 +88,13 @@ angular.module('OpenSlidesApp.motions.site', [ title: gettext('Categories'), }, }) - .state('motions.category.list', { - resolve: { - categories: function(Category) { - return Category.findAll(); - } - } - }) + .state('motions.category.list', {}) .state('motions.category.create', {}) .state('motions.category.detail', { resolve: { - category: function(Category, $stateParams) { - return Category.find($stateParams.id); - } + categoryId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }] } }) .state('motions.category.detail.update', { @@ -202,16 +104,13 @@ angular.module('OpenSlidesApp.motions.site', [ }) .state('motions.category.sort', { url: '/sort/{id}', - resolve: { - category: function(Category, $stateParams) { - return Category.find($stateParams.id); - }, - motions: function(Motion) { - return Motion.findAll(); - } - }, controller: 'CategorySortCtrl', - templateUrl: 'static/templates/motions/category-sort.html' + templateUrl: 'static/templates/motions/category-sort.html', + resolve: { + categoryId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }], + }, }) // MotionBlock .state('motions.motionBlock', { @@ -222,38 +121,12 @@ angular.module('OpenSlidesApp.motions.site', [ title: gettext('Motion blocks'), }, }) - .state('motions.motionBlock.list', { - resolve: { - motionBlocks: function (MotionBlock) { - return MotionBlock.findAll(); - }, - motions: function(Motion) { - return Motion.findAll(); - }, - items: function(Agenda) { - return Agenda.findAll().catch( - function () { - return null; - } - ); - } - } - }) + .state('motions.motionBlock.list', {}) .state('motions.motionBlock.detail', { resolve: { - motionBlock: function(MotionBlock, $stateParams) { - return MotionBlock.find($stateParams.id); - }, - motions: function(Motion) { - return Motion.findAll(); - }, - items: function(Agenda) { - return Agenda.findAll().catch( - function () { - return null; - } - ); - } + motionBlockId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }], } }) // redirects to motionBlock detail and opens motionBlock edit form dialog, uses edit url, @@ -261,8 +134,8 @@ angular.module('OpenSlidesApp.motions.site', [ // (from motionBlock controller use MotionBlockForm factory instead to open dialog in front // of current view without redirect) .state('motions.motionBlock.detail.update', { - onEnter: ['$stateParams', '$state', 'ngDialog', 'MotionBlock', - function($stateParams, $state, ngDialog, MotionBlock) { + onEnter: ['$stateParams', '$state', 'ngDialog', + function($stateParams, $state, ngDialog) { ngDialog.open({ template: 'static/templates/motions/motion-block-form.html', controller: 'MotionBlockUpdateCtrl', @@ -270,8 +143,8 @@ angular.module('OpenSlidesApp.motions.site', [ closeByEscape: false, closeByDocument: false, resolve: { - motionBlock: function () { - return MotionBlock.find($stateParams.id); + motionBlockId: function () { + return $stateParams.id; } }, preCloseCallback: function() { @@ -417,28 +290,15 @@ angular.module('OpenSlidesApp.motions.site', [ return { // ngDialog for motion form getDialog: function (motion) { - var resolve = {}; - if (motion) { - resolve = { - motion: function() { - MotionComment.populateFields(motion); - return motion; - }, - agenda_item: function(Motion) { - return Motion.loadRelations(motion, 'agenda_item'); - } - }; - } - resolve.mediafiles = function (Mediafile) { - return Mediafile.findAll(); - }; return { template: 'static/templates/motions/motion-form.html', - controller: (motion) ? 'MotionUpdateCtrl' : 'MotionCreateCtrl', + controller: motion ? 'MotionUpdateCtrl' : 'MotionCreateCtrl', className: 'ngdialog-theme-default wide-form', closeByEscape: false, closeByDocument: false, - resolve: (resolve) ? resolve : null + resolve: { + motionId: function () {return motion ? motion.id : void 0;}, + }, }; }, // angular-formly fields for motion form @@ -1090,21 +950,21 @@ angular.module('OpenSlidesApp.motions.site', [ 'User', 'Workflow', 'Config', - 'motion', + 'motionId', 'MotionInlineEditing', 'MotionCommentsInlineEditing', 'Projector', 'ProjectionDefault', function($scope, $http, operator, ngDialog, MotionForm, ChangeRecommmendationCreate, ChangeRecommmendationView, MotionChangeRecommendation, MotionPDFExport, - Motion, MotionComment, Category, Mediafile, Tag, User, Workflow, Config, motion, MotionInlineEditing, + Motion, MotionComment, Category, Mediafile, Tag, User, Workflow, Config, motionId, MotionInlineEditing, MotionCommentsInlineEditing, Projector, ProjectionDefault) { + var motion = Motion.get(motionId); Category.bindAll({}, $scope, 'categories'); Mediafile.bindAll({}, $scope, 'mediafiles'); Tag.bindAll({}, $scope, 'tags'); User.bindAll({}, $scope, 'users'); Workflow.bindAll({}, $scope, 'workflows'); - Motion.loadRelations(motion, 'agenda_item'); $scope.$watch(function () { return MotionChangeRecommendation.lastModified(); }, function () { @@ -1122,9 +982,9 @@ angular.module('OpenSlidesApp.motions.site', [ $scope.defaultProjectorId = ProjectionDefault.filter({name: 'motions'})[0].projector_id; }); $scope.$watch(function () { - return Motion.lastModified(motion.id); + return Motion.lastModified(motionId); }, function () { - $scope.motion = Motion.get(motion.id); + $scope.motion = Motion.get(motionId); MotionComment.populateFields($scope.motion); }); $scope.projectionModes = [ @@ -1288,8 +1148,8 @@ angular.module('OpenSlidesApp.motions.site', [ closeByEscape: false, closeByDocument: false, resolve: { - motionpoll: function (MotionPoll) { - return MotionPoll.find(poll.id); + motionpollId: function () { + return poll.id; }, voteNumber: function () { return voteNumber; @@ -1454,7 +1314,8 @@ angular.module('OpenSlidesApp.motions.site', [ 'Workflow', 'Agenda', 'AgendaUpdate', - function($scope, $state, gettext, gettextCatalog, operator, Motion, MotionForm, Category, Config, Mediafile, Tag, User, Workflow, Agenda, AgendaUpdate) { + function($scope, $state, gettext, gettextCatalog, operator, Motion, MotionForm, + Category, Config, Mediafile, Tag, User, Workflow, Agenda, AgendaUpdate) { Category.bindAll({}, $scope, 'categories'); Mediafile.bindAll({}, $scope, 'mediafiles'); Tag.bindAll({}, $scope, 'tags'); @@ -1489,14 +1350,11 @@ angular.module('OpenSlidesApp.motions.site', [ $scope.save = function (motion) { Motion.create(motion).then( function(success) { - // change agenda item only if user has the permission to do that - if (operator.hasPerms('agenda.can_manage')) { - // type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item, - // see openslides.agenda.models.Item.ITEM_TYPE. - var changes = [{key: 'type', value: (motion.showAsAgendaItem ? 1 : 2)}, - {key: 'parent_id', value: motion.agenda_parent_item_id}]; - AgendaUpdate.saveChanges(success.agenda_item_id, changes); - } + // type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item, + // see openslides.agenda.models.Item.ITEM_TYPE. + var changes = [{key: 'type', value: (motion.showAsAgendaItem ? 1 : 2)}, + {key: 'parent_id', value: motion.agenda_parent_item_id}]; + AgendaUpdate.saveChanges(success.agenda_item_id, changes); if (isAmendment) { $state.go('motions.motion.detail', {id: success.id}); } @@ -1519,8 +1377,8 @@ angular.module('OpenSlidesApp.motions.site', [ 'Workflow', 'Agenda', 'AgendaUpdate', - 'motion', - function($scope, Motion, Category, Config, Mediafile, MotionForm, Tag, User, Workflow, Agenda, AgendaUpdate, motion) { + 'motionId', + function($scope, Motion, Category, Config, Mediafile, MotionForm, Tag, User, Workflow, Agenda, AgendaUpdate, motionId) { Category.bindAll({}, $scope, 'categories'); Mediafile.bindAll({}, $scope, 'mediafiles'); Tag.bindAll({}, $scope, 'tags'); @@ -1530,6 +1388,7 @@ angular.module('OpenSlidesApp.motions.site', [ // set initial values for form model by create deep copy of motion object // so list/detail view is not updated while editing + var motion = Motion.get(motionId); $scope.model = angular.copy(motion); $scope.model.disable_versioning = false; $scope.model.more = false; @@ -1581,14 +1440,12 @@ angular.module('OpenSlidesApp.motions.site', [ // save change motion object on server Motion.save(motion, { method: 'PATCH' }).then( function(success) { - Agenda.find(success.agenda_item_id).then(function(item) { - // type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item, - // see openslides.agenda.models.Item.ITEM_TYPE. - var changes = [{key: 'type', value: (motion.showAsAgendaItem ? 1 : 2)}, - {key: 'parent_id', value: motion.agenda_parent_item_id}]; - AgendaUpdate.saveChanges(success.agenda_item_id,changes); - $scope.closeThisDialog(); - }); + // type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item, + // see openslides.agenda.models.Item.ITEM_TYPE. + var changes = [{key: 'type', value: (motion.showAsAgendaItem ? 1 : 2)}, + {key: 'parent_id', value: motion.agenda_parent_item_id}]; + AgendaUpdate.saveChanges(success.agenda_item_id,changes); + $scope.closeThisDialog(); }, function (error) { // save error: revert all changes by restore @@ -1610,11 +1467,12 @@ angular.module('OpenSlidesApp.motions.site', [ 'gettextCatalog', 'MotionPoll', 'MotionPollForm', - 'motionpoll', + 'motionpollId', 'voteNumber', - function($scope, gettextCatalog, MotionPoll, MotionPollForm, motionpoll, voteNumber) { + function($scope, gettextCatalog, MotionPoll, MotionPollForm, motionpollId, voteNumber) { // set initial values for form model by create deep copy of motionpoll object // so detail view is not updated while editing poll + var motionpoll = MotionPoll.get(motionpollId); $scope.model = angular.copy(motionpoll); $scope.voteNumber = voteNumber; $scope.formFields = MotionPollForm.getFormFields(); @@ -1900,9 +1758,9 @@ angular.module('OpenSlidesApp.motions.site', [ .controller('CategoryDetailCtrl', [ '$scope', 'Category', - 'category', - function($scope, Category, category) { - Category.bindOne(category.id, $scope, 'category'); + 'categoryId', + function($scope, Category, categoryId) { + Category.bindOne(categoryId, $scope, 'category'); } ]) @@ -1926,9 +1784,9 @@ angular.module('OpenSlidesApp.motions.site', [ '$scope', '$state', 'Category', - 'category', - function($scope, $state, Category, category) { - $scope.category = category; + 'categoryId', + function($scope, $state, Category, categoryId) { + $scope.category = Category.get(categoryId); $scope.save = function (category) { Category.save(category).then( function(success) { @@ -1945,13 +1803,12 @@ angular.module('OpenSlidesApp.motions.site', [ '$http', 'MotionList', 'Category', - 'category', + 'categoryId', 'Motion', - 'motions', - function($scope, $stateParams, $http, MotionList, Category, category, Motion, motions) { - Category.bindOne(category.id, $scope, 'category'); + function($scope, $stateParams, $http, MotionList, Category, categoryId, Motion) { + Category.bindOne(categoryId, $scope, 'category'); Motion.bindAll({}, $scope, 'motions'); - $scope.filter = { category_id: category.id, + $scope.filter = { category_id: categoryId, parent_id: null, orderBy: 'identifier' }; diff --git a/openslides/topics/static/js/topics/site.js b/openslides/topics/static/js/topics/site.js index f5ab4cd17..9106e12ba 100644 --- a/openslides/topics/static/js/topics/site.js +++ b/openslides/topics/static/js/topics/site.js @@ -25,12 +25,9 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides }) .state('topics.topic.detail', { resolve: { - topic: function(Topic, $stateParams) { - return Topic.find($stateParams.id); - }, - items: function(Agenda) { - return Agenda.findAll(); - } + topicId: ['$stateParams', function($stateParams) { + return $stateParams.id; + }], } }) // redirects to topic detail and opens topic edit form dialog, uses edit url, @@ -38,8 +35,8 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides // (from topic controller use TopicForm factory instead to open dialog in front // of current view without redirect) .state('topics.topic.detail.update', { - onEnter: ['$stateParams', '$state', 'ngDialog', 'Topic', - function($stateParams, $state, ngDialog, Topic) { + onEnter: ['$stateParams', '$state', 'ngDialog', + function($stateParams, $state, ngDialog) { ngDialog.open({ template: 'static/templates/topics/topic-form.html', controller: 'TopicUpdateCtrl', @@ -47,16 +44,9 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides closeByEscape: false, closeByDocument: false, resolve: { - topic: function() { - return Topic.find($stateParams.id); + topicId: function() { + return $stateParams.id; }, - items: function(Agenda) { - return Agenda.findAll().catch( - function() { - return null; - } - ); - } }, preCloseCallback: function() { $state.go('topics.topic.detail', {topic: $stateParams.id}); @@ -82,22 +72,15 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides return { // ngDialog for topic form getDialog: function (topic) { - var resolve = {}; - if (topic) { - resolve = { - topic: function (Topic) {return Topic.find(topic.id);} - }; - } - resolve.mediafiles = function (Mediafile) { - return Mediafile.findAll(); - }; return { template: 'static/templates/topics/topic-form.html', controller: (topic) ? 'TopicUpdateCtrl' : 'TopicCreateCtrl', className: 'ngdialog-theme-default wide-form', closeByEscape: false, closeByDocument: false, - resolve: (resolve) ? resolve : null + resolve: { + topicId: function () {return topic ? topic.id: void 0;} + }, }; }, getFormFields: function (isCreateForm) { @@ -169,11 +152,11 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides 'ngDialog', 'TopicForm', 'Topic', - 'topic', + 'topicId', 'Projector', 'ProjectionDefault', - function($scope, ngDialog, TopicForm, Topic, topic, Projector, ProjectionDefault) { - Topic.bindOne(topic.id, $scope, 'topic'); + function($scope, ngDialog, TopicForm, Topic, topicId, Projector, ProjectionDefault) { + Topic.bindOne(topicId, $scope, 'topic'); $scope.$watch(function () { return Projector.lastModified(); }, function () { @@ -182,7 +165,6 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides $scope.defaultProjectorId = projectiondefault.projector_id; } }); - Topic.loadRelations(topic, 'agenda_item'); $scope.openDialog = function (topic) { ngDialog.open(TopicForm.getDialog(topic)); }; @@ -224,9 +206,9 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides 'TopicForm', 'Agenda', 'AgendaUpdate', - 'topic', - function($scope, $state, Topic, TopicForm, Agenda, AgendaUpdate, topic) { - Topic.loadRelations(topic, 'agenda_item'); + 'topicId', + function($scope, $state, Topic, TopicForm, Agenda, AgendaUpdate, topicId) { + var topic = Topic.get(topicId); $scope.alert = {}; // set initial values for form model by create deep copy of topic object // so list/detail view is not updated while editing @@ -273,7 +255,8 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides 'Topic', 'HumanTimeConverter', 'TopicsCsvExample', - function($scope, gettext, Agenda, Topic, HumanTimeConverter, TopicsCsvExample) { + 'AgendaUpdate', + function($scope, gettext, Agenda, Topic, HumanTimeConverter, TopicsCsvExample, AgendaUpdate) { // Big TODO: Change wording from "item" to "topic". // import from textarea $scope.importByLine = function () { @@ -285,13 +268,9 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides // TODO: create all items in bulk mode Topic.create(item).then( function(success) { - // find related agenda item - Agenda.find(success.agenda_item_id).then(function(item) { - // import all items as type AGENDA_ITEM = 1 - item.type = 1; - item.weight = 1000 + index; - Agenda.save(item); - }); + var changes = [{key: 'type', value: 1}, + {key: 'weight', value: 1000 + index}]; + AgendaUpdate.saveChanges(success.agenda_item_id, changes); $scope.importcounter++; } ); @@ -376,15 +355,12 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides if (item.selected && !item.importerror) { Topic.create(item).then( function(success) { + var changes = [{key: 'duration', value: item.duration}, + {key: 'comment', value: item.comment}, + {key: 'type', value: item.type}, + {key: 'weight', value: item.weight}]; + AgendaUpdate.saveChanges(success.agenda_item_id, changes); item.imported = true; - // find related agenda item - Agenda.find(success.agenda_item_id).then(function(agendaItem) { - agendaItem.duration = item.duration; - agendaItem.comment = item.comment; - agendaItem.type = item.type; - agendaItem.weight = item.weight; - Agenda.save(agendaItem); - }); } ); } diff --git a/openslides/users/static/js/users/base.js b/openslides/users/static/js/users/base.js index c08351892..137395e97 100644 --- a/openslides/users/static/js/users/base.js +++ b/openslides/users/static/js/users/base.js @@ -132,6 +132,8 @@ angular.module('OpenSlidesApp.users', []) return DS.defineResource({ name: 'users/group', permissions: permissions, + // TODO (Issue 2862): Do not query the permissions from server. They should be included + // in the startup data. Then remove 'permission' injection from group list controller. getPermissions: function() { if (!this.permissions) { this.permissions = $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' }) diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index cefe67812..8a6fa2bac 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -751,9 +751,9 @@ angular.module('OpenSlidesApp.users.site', [ '$state', 'Editor', 'User', - 'user', - function($scope, $state, Editor, User, user) { - $scope.user = user; // autoupdate is not activated + 'userId', + function($scope, $state, Editor, User, userId) { + $scope.user = angular.copy(User.get(userId)); $scope.ckeditorOptions = Editor.getOptions(); $scope.save = function (user) { User.save(user).then( @@ -805,10 +805,8 @@ angular.module('OpenSlidesApp.users.site', [ '$scope', '$state', '$http', - 'user', - function($scope, $state, $http, user) { - $scope.user = user; // autoupdate is not activated - $scope.save = function (user) { + function($scope, $state, $http) { + $scope.save = function () { if ($scope.newPassword != $scope.newPassword2) { $scope.newPassword = $scope.newPassword2 = ''; $scope.formError = 'Password confirmation does not match.'; diff --git a/openslides/users/static/templates/users/user-detail-password.html b/openslides/users/static/templates/users/user-detail-password.html index 6c2ae2dff..a67c24e6b 100644 --- a/openslides/users/static/templates/users/user-detail-password.html +++ b/openslides/users/static/templates/users/user-detail-password.html @@ -33,7 +33,7 @@ name="inputNewPassword2" required>
-