From 93e2296bdc0784beb36e202ce0849cc3f249292f Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Sun, 10 Jan 2016 13:47:59 +0100 Subject: [PATCH] A lot of template fixes - Reset password from current (unsaved) value of default_password. - MotionForm, AssignmentForm and UserForm factory for open ngDialog. Fixes edit url redirect problem. - Added back-to-detail-view-button to list of speakers view. - Add translation context. - Fixed (missing) translation strings. - Fixed tags and category list views. - motion detail: Use select box for changing state. - motion slide updated --- openslides/agenda/static/js/agenda/site.js | 12 +- .../static/templates/agenda/item-detail.html | 6 +- .../static/templates/agenda/item-list.html | 6 +- .../assignments/static/js/assignments/base.js | 3 +- .../assignments/static/js/assignments/site.js | 98 ++++++++------ .../assignments/assignment-detail.html | 11 +- .../assignments/assignment-form.html | 2 +- .../assignments/assignment-list.html | 10 +- .../assignments/assignmentpoll-form.html | 2 +- openslides/core/static/js/core/base.js | 4 +- openslides/core/static/js/core/site.js | 12 +- .../templates/core/customslide-form.html | 2 +- .../static/templates/core/tag-detail.html | 14 ++ .../core/static/templates/core/tag-list.html | 4 +- .../mediafiles/static/js/mediafiles/site.js | 1 - openslides/motions/static/js/motions/base.js | 3 +- openslides/motions/static/js/motions/site.js | 125 ++++++++++-------- .../templates/motions/category-detail.html | 1 + .../templates/motions/category-list.html | 45 +++---- .../templates/motions/motion-detail.html | 33 +++-- .../static/templates/motions/motion-form.html | 2 +- .../static/templates/motions/motion-list.html | 11 +- .../templates/motions/slide_motion.html | 10 +- openslides/users/static/js/users/site.js | 82 ++++++------ .../static/templates/users/group-list.html | 3 +- .../static/templates/users/user-detail.html | 2 +- .../static/templates/users/user-form.html | 2 +- .../static/templates/users/user-list.html | 8 +- openslides/users/views.py | 4 +- tests/integration/users/test_viewset.py | 19 ++- 30 files changed, 320 insertions(+), 217 deletions(-) create mode 100644 openslides/core/static/templates/core/tag-detail.html diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js index 1b84d22b3..85f160a45 100644 --- a/openslides/agenda/static/js/agenda/site.js +++ b/openslides/agenda/static/js/agenda/site.js @@ -101,7 +101,7 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) // detail view of related item (content object) $scope.open = function (item) { $state.go(item.content_object.collection.replace('/','.')+'.detail', - {id: item.content_object.id}); + {id: item.content_object.id}); }; // save changed item $scope.save = function (item) { @@ -183,10 +183,11 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) '$scope', '$filter', '$http', + '$state', 'Agenda', 'User', 'item', - function ($scope, $filter, $http, Agenda, User, item) { + function ($scope, $filter, $http, $state, Agenda, User, item) { Agenda.bindOne(item.id, $scope, 'item'); User.bindAll({}, $scope, 'users'); $scope.speakerSelectBox = {}; @@ -198,6 +199,13 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) $scope.speakers = $filter('orderBy')(item.speakers, 'weight'); }); + + // go to detail view of related item (content object) + $scope.open = function (item) { + $state.go(item.content_object.collection.replace('/','.')+'.detail', + {id: item.content_object.id}); + }; + // close/open list of speakers of current item $scope.closeList = function (listClosed) { item.speaker_list_closed = listClosed; diff --git a/openslides/agenda/static/templates/agenda/item-detail.html b/openslides/agenda/static/templates/agenda/item-detail.html index f6a30f444..c250a768b 100644 --- a/openslides/agenda/static/templates/agenda/item-detail.html +++ b/openslides/agenda/static/templates/agenda/item-detail.html @@ -3,7 +3,11 @@ @@ -159,7 +159,7 @@ - +

{{ item.getTitle() }} – QuickEdit

diff --git a/openslides/assignments/static/js/assignments/base.js b/openslides/assignments/static/js/assignments/base.js index 9abaa1671..f8dc2dcbd 100644 --- a/openslides/assignments/static/js/assignments/base.js +++ b/openslides/assignments/static/js/assignments/base.js @@ -79,7 +79,8 @@ angular.module('OpenSlidesApp.assignments', []) return DS.defineResource({ name: name, useClass: jsDataModel, - agendaSupplement: gettext('Election'), + verboseName: gettext('Election'), + agendaSupplement: this.verboseName, phases: phases, getPhases: function () { if (!this.phases) { diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js index 393f91d51..0a231361a 100644 --- a/openslides/assignments/static/js/assignments/site.js +++ b/openslides/assignments/static/js/assignments/site.js @@ -50,24 +50,54 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) } } }) + // redirects to assignment detail and opens assignment edit form dialog, uses edit url, + // used by ui-sref links from agenda only + // (from assignment controller use AssignmentForm factory instead to open dialog in front + // of current view without redirect) .state('assignments.assignment.detail.update', { - 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) }} - }); - }] + onEnter: ['$stateParams', '$state', 'ngDialog', 'Assignment', + function($stateParams, $state, ngDialog, Assignment) { + ngDialog.open({ + template: 'static/templates/assignments/assignment-form.html', + controller: 'AssignmentUpdateCtrl', + className: 'ngdialog-theme-default wide-form', + closeByEscape: false, + closeByDocument: false, + resolve: { + assignment: function() {return Assignment.find($stateParams.id)} + }, + preCloseCallback: function() { + $state.go('assignments.assignment.detail', {assignment: $stateParams.id}); + return true; + } + }); + } + ] }); }) -// Provide generic assignment form fields for create and update view -.factory('AssignmentFormFieldFactory', [ +// Service for generic assignment form (create and update) +.factory('AssignmentForm', [ 'gettextCatalog', function (gettextCatalog) { return { + // ngDialog for assignment form + getDialog: function (assignment) { + if (assignment) { + var resolve = { + assignment: function(Assignment) {return Assignment.find(assignment.id);} + }; + } + 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 : null + } + }, + // angular-formly fields for assignment form getFormFields: function () { return [ { @@ -143,9 +173,10 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) .controller('AssignmentListCtrl', [ '$scope', 'ngDialog', + 'AssignmentForm', 'Assignment', 'phases', - function($scope, ngDialog, Assignment, phases) { + function($scope, ngDialog, AssignmentForm, Assignment, phases) { Assignment.bindAll({}, $scope, 'assignments'); // get all item types via OPTIONS request $scope.phases = phases.data.actions.POST.phase.choices; @@ -163,26 +194,9 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) $scope.sortColumn = column; }; - // open new dialog - $scope.newDialog = function () { - ngDialog.open({ - template: 'static/templates/assignments/assignment-form.html', - controller: 'AssignmentCreateCtrl', - className: 'ngdialog-theme-default wide-form' - }); - }; - // open edit dialog - $scope.editDialog = function (assignment) { - ngDialog.open({ - template: 'static/templates/assignments/assignment-form.html', - controller: 'AssignmentUpdateCtrl', - className: 'ngdialog-theme-default wide-form', - resolve: { - assignment: function(Assignment) { - return Assignment.find(assignment.id); - } - } - }); + // open new/edit dialog + $scope.openDialog = function (assignment) { + ngDialog.open(AssignmentForm.getDialog(assignment)); }; // save changed assignment $scope.save = function (assignment) { @@ -237,16 +251,22 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) '$http', 'gettext', 'ngDialog', + 'AssignmentForm', 'operator', 'Assignment', 'User', 'assignment', - function($scope, $http, gettext, ngDialog, operator, Assignment, User, assignment) { + function($scope, $http, gettext, ngDialog, AssignmentForm, operator, Assignment, User, assignment) { User.bindAll({}, $scope, 'users'); Assignment.bindOne(assignment.id, $scope, 'assignment'); Assignment.loadRelations(assignment, 'agenda_item'); $scope.candidateSelectBox = {}; $scope.alert = {}; + + // open edit dialog + $scope.openDialog = function (assignment) { + ngDialog.open(AssignmentForm.getDialog(assignment)); + }; // add (nominate) candidate $scope.addCandidate = function (userId) { $http.post('/rest/assignments/assignment/' + assignment.id + '/candidature_other/', {'user': userId}) @@ -369,13 +389,13 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) '$scope', '$state', 'Assignment', - 'AssignmentFormFieldFactory', - function($scope, $state, Assignment, AssignmentFormFieldFactory) { + 'AssignmentForm', + function($scope, $state, Assignment, AssignmentForm) { $scope.model = {}; // set default value for open posts form field $scope.model.open_posts = 1; // get all form fields - $scope.formFields = AssignmentFormFieldFactory.getFormFields(); + $scope.formFields = AssignmentForm.getFormFields(); // save assignment $scope.save = function(assignment) { @@ -392,13 +412,13 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) '$scope', '$state', 'Assignment', - 'AssignmentFormFieldFactory', + 'AssignmentForm', 'assignment', - function($scope, $state, Assignment, AssignmentFormFieldFactory, assignment) { + function($scope, $state, Assignment, AssignmentForm, assignment) { // set initial values for form model $scope.model = assignment; // get all form fields - $scope.formFields = AssignmentFormFieldFactory.getFormFields(); + $scope.formFields = AssignmentForm.getFormFields(); // save assignment $scope.save = function (assignment) { diff --git a/openslides/assignments/static/templates/assignments/assignment-detail.html b/openslides/assignments/static/templates/assignments/assignment-detail.html index 4d6b97885..c1c8de64f 100644 --- a/openslides/assignments/static/templates/assignments/assignment-detail.html +++ b/openslides/assignments/static/templates/assignments/assignment-detail.html @@ -3,7 +3,7 @@

{{ assignment.title }}

- Election – - Agenda: {{ assignment.agenda_item.item_number }} + Election + + – + Agenda: {{ assignment.agenda_item.item_number }} +

diff --git a/openslides/assignments/static/templates/assignments/assignment-form.html b/openslides/assignments/static/templates/assignments/assignment-form.html index 7f0932d5f..76244282a 100644 --- a/openslides/assignments/static/templates/assignments/assignment-form.html +++ b/openslides/assignments/static/templates/assignments/assignment-form.html @@ -4,7 +4,7 @@
- Edit election ... diff --git a/openslides/assignments/static/templates/assignments/assignmentpoll-form.html b/openslides/assignments/static/templates/assignments/assignmentpoll-form.html index 48f4c6e00..867013e21 100644 --- a/openslides/assignments/static/templates/assignments/assignmentpoll-form.html +++ b/openslides/assignments/static/templates/assignments/assignmentpoll-form.html @@ -3,7 +3,7 @@ - - + +

Voting result

  1. - Vote + Vote