From 694ed6f1cc3658d0b885da5058081503b0f66bd8 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Thu, 14 Jan 2016 22:43:49 +0100 Subject: [PATCH] Motion template fixes - Add has_votes to motion serializer and add poll.has_votes check in motion detail view. - Fix motion meta box 3 column layout. - Added missing intents - Show motionPoll edit form in dialog. Moved into new template. - Clean up assignmentpoll form (like motionPoll) --- .../assignments/static/js/assignments/site.js | 50 +-- .../assignments/assignmentpoll-form.html | 13 +- openslides/motions/serializers.py | 10 +- openslides/motions/static/js/motions/site.js | 157 +++++++-- .../templates/motions/motion-detail.html | 309 ++++++++---------- 5 files changed, 293 insertions(+), 246 deletions(-) diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js index 0a231361a..456ad18aa 100644 --- a/openslides/assignments/static/js/assignments/site.js +++ b/openslides/assignments/static/js/assignments/site.js @@ -136,40 +136,6 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) } ]) -// Provide generic assignmentpoll form fields for create and update view -.factory('AssignmentPollFormFieldFactory', [ - 'gettextCatalog', - function (gettextCatalog) { - return { - getFormFields: function () { - return [ - { - key: 'description', - type: 'input', - templateOptions: { - label: gettextCatalog.getString('Comment on the ballot paper') - } - }, - { - key: 'yes', - type: 'input', - templateOptions: { - label: gettextCatalog.getString('Yes'), - type: 'number', - required: true - } - }, - { - key: 'poll_description_default', - type: 'input', - templateOptions: { - label: gettextCatalog.getString('Default comment on the ballot paper') - } - }]; - } - } - } -]) .controller('AssignmentListCtrl', [ '$scope', 'ngDialog', @@ -340,6 +306,8 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) template: 'static/templates/assignments/assignmentpoll-form.html', controller: 'AssignmentPollUpdateCtrl', className: 'ngdialog-theme-default', + closeByEscape: false, + closeByDocument: false, resolve: { assignmentpoll: function (AssignmentPoll) { return AssignmentPoll.find(poll.id); @@ -443,6 +411,8 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) $scope.model = assignmentpoll; $scope.ballot = ballot; $scope.formFields = []; + $scope.alert = {}; + // add dynamic form fields assignmentpoll.options.forEach(function(option) { if (assignmentpoll.yesnoabstain) { @@ -528,9 +498,7 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) } ); - - - // save assignment + // save assignmentpoll $scope.save = function (poll) { var votes = []; if (assignmentpoll.yesnoabstain) { @@ -556,8 +524,16 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) votescast: poll.votescast }) .then(function(success) { + $scope.alert.show = false; $scope.closeThisDialog(); }) + .catch(function(error) { + var message = ''; + for (var e in error.data) { + message += e + ': ' + error.data[e] + ' '; + } + $scope.alert = { type: 'danger', msg: message, show: true }; + }); }; } ]); diff --git a/openslides/assignments/static/templates/assignments/assignmentpoll-form.html b/openslides/assignments/static/templates/assignments/assignmentpoll-form.html index 867013e21..36c7a61f9 100644 --- a/openslides/assignments/static/templates/assignments/assignmentpoll-form.html +++ b/openslides/assignments/static/templates/assignments/assignmentpoll-form.html @@ -1,8 +1,17 @@

Ballot {{ ballot }}

-
+ + {{ alert.msg }} + + +

+ Special values: + -1 = majority + -2 = undocumented + + - + + + + +

+ +

Category

+ {{ motion.category.name }} + + +

Tags

+ + {{ tag.name }}{{$last ? '' : ', '}} + + + +

State

+ + {{ motion.state.name | translate }} + +
+ + +
+
+
+

Voting result

+
    +
  1. + Vote + + + + + +
    + + + + + + + + +
    + + + Yes: + {{ poll.yes }} {{ poll.getYesPercent() }} +
    + +
    + +
    + + + No: + {{ poll.no }} {{ poll.getNoPercent() }} +
    + +
    + +
    + + + Abstain: + {{ poll.abstain }} {{ poll.getAbstainPercent() }} +
    + +
    + +
    + + + Valid votes: + {{ poll.votesvalid }} {{ poll.getVotesValidPercent() }} + +
    + + + Invalid votes: + {{ poll.votesinvalid }} {{ poll.getVotesInvalidPercent() }} + +
    + + + Votes cast: + {{ poll.votescast }} {{ poll.getVotesCastPercent() }} +
- - - - -
+ +
-
- -

Category

- {{ motion.category.name }} - - -

Tags

- - {{ tag.name }}{{$last ? '' : ', '}} - - - -

State

- - {{ motion.state.name | translate }} - -
- - -
-
-
-

Voting result

-
    -
  1. - Vote - - -
    - -

    - Special values:
    - -1 = majority
    - -2 = undocumented -

    - - {{alert.msg}} - - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    - - -
    - -
    -
    - - - - - - - - -
    - - - Yes: - {{ poll.yes }} {{ poll.getYesPercent() }} -
    - -
    - -
    - - - No: - {{ poll.no }} {{ poll.getNoPercent() }} -
    - -
    - -
    - - - Abstain: - {{ poll.abstain }} {{ poll.getAbstainPercent() }} -
    - -
    - -
    - - - Valid votes: - {{ poll.votesvalid }} {{ poll.getVotesValidPercent() }} - -
    - - - Invalid votes: - {{ poll.votesinvalid }} {{ poll.getVotesInvalidPercent() }} - -
    - - - Votes cast: - {{ poll.votescast }} {{ poll.getVotesCastPercent() }} -
    -
- -
-
-