diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js index 7f0bc7e96..09f9f0a11 100644 --- a/openslides/agenda/static/js/agenda/site.js +++ b/openslides/agenda/static/js/agenda/site.js @@ -37,17 +37,6 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) } } }) - .state('agenda.item.create', { - resolve: { - types: function($http) { - // get all item types - return $http({ 'method': 'OPTIONS', 'url': '/rest/agenda/item/' }); - }, - tags: function(Tag) { - return Tag.findAll(); - } - } - }) .state('agenda.item.detail', { resolve: { item: function(Agenda, $stateParams) { @@ -61,17 +50,6 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) } } }) - .state('agenda.item.detail.update', { - views: { - '@agenda.item': {} - }, - resolve: { - types: function($http) { - // get all item types - return $http({ 'method': 'OPTIONS', 'url': '/rest/agenda/item/' }); - } - } - }) .state('agenda.item.sort', { resolve: { items: function(Agenda) { @@ -115,7 +93,7 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) ); }; - // open new customslide dialog + // open new dialog $scope.newDialog = function () { ngDialog.open({ template: 'static/templates/core/customslide-form.html', @@ -123,32 +101,18 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) className: 'ngdialog-theme-default wide-form' }); }; + // open edit dialog + $scope.editDialog = function (item) { + $state.go(item.content_object.collection.replace('/','.')+'.detail.update', + {id: item.content_object.id}); + }; // detail view of related item (content object) $scope.open = function (item) { $state.go(item.content_object.collection.replace('/','.')+'.detail', {id: item.content_object.id}); }; - // edit view of related item (content object) - $scope.edit = function (item) { - if (item.content_object.collection == "core/customslide") { - ngDialog.open({ - template: 'static/templates/core/customslide-form.html', - controller: 'CustomslideUpdateCtrl', - className: 'ngdialog-theme-default wide-form', - resolve: { - customslide: function(Customslide) { - return Customslide.find(item.content_object.id); - } - } - }); - } - else { - $state.go(item.content_object.collection.replace('/','.')+'.detail.update', - {id: item.content_object.id}); - } - }; - // update changed item - $scope.update = function (item) { + // save changed item + $scope.save = function (item) { Agenda.save(item).then( function(success) { item.quickEdit = false; @@ -286,48 +250,6 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) } ]) -.controller('ItemCreateCtrl', [ - '$scope', - '$state', - 'Agenda', - 'Tag', - 'types', - function($scope, $state, Agenda, Tag, types) { - $scope.types = types.data.actions.POST.type.choices; // get all item types - Tag.bindAll({}, $scope, 'tags'); - $scope.save = function (item) { - if (!item) - return null; - Agenda.create(item).then( - function(success) { - $state.go('agenda.item.list'); - } - ); - }; - } -]) - -.controller('ItemUpdateCtrl', [ - '$scope', - '$state', - 'Agenda', - 'Tag', - 'types', - 'item', - function($scope, $state, Agenda, Tag, types, item) { - $scope.types = types.data.actions.POST.type.choices; // get all item types - Tag.bindAll({}, $scope, 'tags'); - $scope.item = item; - $scope.save = function (item) { - Agenda.save(item).then( - function(success) { - $state.go('agenda.item.list'); - } - ); - }; - } -]) - .controller('AgendaSortCtrl', [ '$scope', '$http', diff --git a/openslides/agenda/static/templates/agenda/item-list.html b/openslides/agenda/static/templates/agenda/item-list.html index e7bb4de2c..4889f377f 100644 --- a/openslides/agenda/static/templates/agenda/item-list.html +++ b/openslides/agenda/static/templates/agenda/item-list.html @@ -131,7 +131,7 @@
List of speakers | QuickEdit | - Edit + Edit | h - + -
+

{{ item.getTitle() }} – QuickEdit

{{alert.msg}} diff --git a/openslides/assignments/serializers.py b/openslides/assignments/serializers.py index e54dc3166..65229cd57 100644 --- a/openslides/assignments/serializers.py +++ b/openslides/assignments/serializers.py @@ -102,10 +102,13 @@ class AssignmentAllPollSerializer(ModelSerializer): Customized update method for polls. To update votes use the write only field 'votes'. - Example data for a 'yesnoabstain' poll with two candidates: + Example data for a 'yesnoabstain'=true poll with two candidates: "votes": [{"Yes": 10, "No": 4, "Abstain": -2}, {"Yes": -1, "No": 0, "Abstain": -2}] + + Example data for a 'yesnoabstain'=false poll with two candidates: + "votes": [{"Votes": 10}, {"Votes": 0}] """ # Update votes. votes = validated_data.get('votes') diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js index b57af132f..2a942f190 100644 --- a/openslides/assignments/static/js/assignments/site.js +++ b/openslides/assignments/static/js/assignments/site.js @@ -38,7 +38,6 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) } } }) - .state('assignments.assignment.create', {}) .state('assignments.assignment.detail', { controller: 'AssignmentDetailCtrl', resolve: { @@ -51,9 +50,15 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) } }) .state('assignments.assignment.detail.update', { - views: { - '@assignments.assignment': {} - } + onEnter: ['$stateParams', 'ngDialog', 'Assignment', function($stateParams, ngDialog, Assignment) { + ngDialog.open({ + template: 'static/templates/assignments/assignment-form.html', + controller: 'AssignmentUpdateCtrl', + className: 'ngdialog-theme-default wide-form', + resolve: { assignment: function() { + return Assignment.find($stateParams.id) }} + }); + }] }); }) @@ -157,7 +162,7 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) $scope.sortColumn = column; }; - // open new customslide dialog + // open new dialog $scope.newDialog = function () { ngDialog.open({ template: 'static/templates/assignments/assignment-form.html', @@ -165,7 +170,7 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) className: 'ngdialog-theme-default wide-form' }); }; - // edit view of related item (content object) + // open edit dialog $scope.editDialog = function (assignment) { ngDialog.open({ template: 'static/templates/assignments/assignment-form.html', @@ -178,7 +183,7 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) } }); }; - // save changed item + // save changed assignment $scope.save = function (assignment) { Assignment.save(assignment).then( function(success) { @@ -193,6 +198,23 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) $scope.alert = { type: 'danger', msg: message, show: true }; }); }; + // *** delete mode functions *** + $scope.isDeleteMode = false; + // check all checkboxes + $scope.checkAll = function () { + angular.forEach($scope.assignments, function (assignment) { + assignment.selected = $scope.selectedAll; + }); + }; + // uncheck all checkboxes if isDeleteMode is closed + $scope.uncheckAll = function () { + if (!$scope.isDeleteMode) { + $scope.selectedAll = false; + angular.forEach($scope.assignments, function (assignment) { + assignment.selected = false; + }); + } + }; // delete all selected assignments $scope.deleteMultiple = function () { angular.forEach($scope.assignments, function (assignment) { @@ -329,7 +351,6 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) 'Assignment', 'AssignmentFormFieldFactory', function($scope, $state, Assignment, AssignmentFormFieldFactory) { - $scope.assignment = {}; // get all form fields $scope.formFields = AssignmentFormFieldFactory.getFormFields(); @@ -379,7 +400,8 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) $scope.formFields = []; // add dynamic form fields assignmentpoll.options.forEach(function(option) { - $scope.formFields.push( + if (assignmentpoll.yesnoabstain) { + $scope.formFields.push( { noFormControl: true, template: '' + option.candidate.get_full_name() + '' @@ -410,8 +432,19 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) type: 'number', required: true } - } - ); + }); + } else { + $scope.formFields.push( + { + key: 'vote_' + option.candidate_id, + type: 'input', + templateOptions: { + label: option.candidate.get_full_name(), + type: 'number', + required: true + } + }); + } }); // add general form fields $scope.formFields.push( @@ -455,13 +488,21 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) // save assignment $scope.save = function (poll) { var votes = []; - assignmentpoll.options.forEach(function(option) { - votes.push({ - "Yes": poll['yes_' + option.candidate_id], - "No": poll['no_' + option.candidate_id], - "Abstain": poll['abstain_' + option.candidate_id] + if (assignmentpoll.yesnoabstain) { + assignmentpoll.options.forEach(function(option) { + votes.push({ + "Yes": poll['yes_' + option.candidate_id], + "No": poll['no_' + option.candidate_id], + "Abstain": poll['abstain_' + option.candidate_id] + }); }); - }); + } else { + assignmentpoll.options.forEach(function(option) { + votes.push({ + "Votes": poll['vote_' + option.candidate_id], + }); + }); + } poll.DSUpdate({ assignment_id: poll.assignment_id, votes: votes, diff --git a/openslides/assignments/static/templates/assignments/assignment-detail.html b/openslides/assignments/static/templates/assignments/assignment-detail.html index 34daf7427..34af5bcc0 100644 --- a/openslides/assignments/static/templates/assignments/assignment-detail.html +++ b/openslides/assignments/static/templates/assignments/assignment-detail.html @@ -9,6 +9,11 @@ PDF
+ + + + List of speakers +
- User#{{ option.candidate_id }} + {{ option.candidate.get_full_name() }}
{{ vote.value}}: {{ vote.weight}} diff --git a/openslides/assignments/static/templates/assignments/assignment-form.html b/openslides/assignments/static/templates/assignments/assignment-form.html index f704d678a..7f0932d5f 100644 --- a/openslides/assignments/static/templates/assignments/assignment-form.html +++ b/openslides/assignments/static/templates/assignments/assignment-form.html @@ -1,5 +1,5 @@ -

Edit election

-

New election

+

Edit election

+

New election

diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index b744a72be..0b4bfa38f 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -227,6 +227,17 @@ angular.module('OpenSlidesApp.core.site', [ } } }) + .state('core.customslide.detail.update', { + onEnter: ['$stateParams', 'ngDialog', 'Customslide', function($stateParams, ngDialog, Customslide) { + ngDialog.open({ + template: 'static/templates/core/customslide-form.html', + controller: 'CustomslideUpdateCtrl', + className: 'ngdialog-theme-default wide-form', + resolve: { customslide: function() { + return Customslide.find($stateParams.id) }} + }); + }] + }) // tag .state('core.tag', { url: '/tag', diff --git a/openslides/core/static/templates/core/customslide-form.html b/openslides/core/static/templates/core/customslide-form.html index 16726d4a1..e4a905470 100644 --- a/openslides/core/static/templates/core/customslide-form.html +++ b/openslides/core/static/templates/core/customslide-form.html @@ -1,5 +1,5 @@ -

Edit agenda item

-

New agenda item

+

Edit agenda item

+

New agenda item

diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html index 1f247198e..62d4be574 100644 --- a/openslides/core/static/templates/index.html +++ b/openslides/core/static/templates/index.html @@ -59,13 +59,13 @@
-
-
- -