From 9a117999ef6d61aa45a51ca9666a826d7964b7e7 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Wed, 17 Jun 2015 18:30:30 +0200 Subject: [PATCH] Updated motion list, form and detail views. --- .../motions/static/js/motions/motions.js | 52 +++++++++++++++++-- .../templates/motions/motion-detail.html | 36 ++++++++++--- .../static/templates/motions/motion-form.html | 14 +++-- .../static/templates/motions/motion-list.html | 29 ++++++++++- openslides/users/static/js/users/users.js | 18 +++++++ 5 files changed, 133 insertions(+), 16 deletions(-) diff --git a/openslides/motions/static/js/motions/motions.js b/openslides/motions/static/js/motions/motions.js index 6666f2d76..cb5e281d2 100644 --- a/openslides/motions/static/js/motions/motions.js +++ b/openslides/motions/static/js/motions/motions.js @@ -3,7 +3,29 @@ angular.module('OpenSlidesApp.motions', []) .factory('Motion', function(DS) { return DS.defineResource({ name: 'motions/motion', - endpoint: '/rest/motions/motion/' + endpoint: '/rest/motions/motion/', + methods: { + getVersion: function(versionId) { + versionId = versionId || this.active_version; + if (versionId == -1) { + index = this.versions.length - 1; + } else { + index = _.findIndex(this.versions, function(element) { + return element.id == versionId + }); + } + return this.versions[index]; + }, + getTitle: function(versionId) { + return this.getVersion(versionId).title; + }, + getText: function(versionId) { + return this.getVersion(versionId).text; + }, + getReason: function(versionId) { + return this.getVersion(versionId).reason; + } + } }); }) .factory('Category', function(DS) { @@ -39,6 +61,12 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) resolve: { motions: function(Motion) { return Motion.findAll(); + }, + categories: function(Category) { + return Category.findAll(); + }, + users: function(User) { + return User.findAll(); } } }) @@ -68,6 +96,12 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) resolve: { motion: function(Motion, $stateParams) { return Motion.find($stateParams.id); + }, + categories: function(Category) { + return Category.findAll(); + }, + users: function(User) { + return User.findAll(); } } }) @@ -128,8 +162,10 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) }) }) -.controller('MotionListCtrl', function($scope, Motion) { +.controller('MotionListCtrl', function($scope, Motion, Category, User) { Motion.bindAll({}, $scope, 'motions'); + Category.bindAll({}, $scope, 'categories'); + User.bindAll({}, $scope, 'users'); // setup table sorting $scope.sortColumn = 'identifier'; @@ -157,8 +193,10 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) }; }) -.controller('MotionDetailCtrl', function($scope, Motion, motion) { +.controller('MotionDetailCtrl', function($scope, Motion, Category, User, motion) { Motion.bindOne(motion.id, $scope, 'motion'); + Category.bindAll({}, $scope, 'categories'); + User.bindAll({}, $scope, 'users'); }) .controller('MotionCreateCtrl', @@ -174,6 +212,9 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) $scope.save = function (motion) { motion.tags = []; // TODO: REST API should do it! (Bug in Django REST framework) motion.attachments = []; // TODO: REST API should do it! (Bug in Django REST framework) + if (!motion.supporters) { + motion.supporters = []; // TODO: REST API should do it! (Bug in Django REST framework) + } Motion.create(motion).then( function(success) { $state.go('motions.motion.list'); @@ -192,6 +233,11 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) Mediafile.bindAll({}, $scope, 'mediafiles'); $scope.motion = motion; + // get latest version for edit + $scope.motion.title = $scope.motion.getTitle(-1); + $scope.motion.text = $scope.motion.getText(-1); + $scope.motion.reason = $scope.motion.getReason(-1); + $scope.save = function (motion) { motion.tags = []; // TODO: REST API should do it! (Bug in Django REST framework) motion.attachments = []; // TODO: REST API should do it! (Bug in Django REST framework) diff --git a/openslides/motions/static/templates/motions/motion-detail.html b/openslides/motions/static/templates/motions/motion-detail.html index 14621087f..449a16e41 100644 --- a/openslides/motions/static/templates/motions/motion-detail.html +++ b/openslides/motions/static/templates/motions/motion-detail.html @@ -1,4 +1,10 @@ -

{{ motion.identifier }}

+

+ {{ motion.getTitle() }} + + Motion {{ motion.identifier }} + | Version {{ (motion.versions | filter: {id: motion.active_version})[0].version_number }} + +

+
+
+

Text

+ {{ motion.getText() }} -

Category

-{{ motion.category }} +

Reason

+ {{ motion.getReason() }} +
-

Submitters

- +
+
+

Submitters

+
+ {{ (users | filter: {id: submitter})[0].get_full_name() }}
+
+ +

Category

+ {{ (categories | filter: {id: motion.category})[0].name }} + +

Voting result

+ - +
+
+
diff --git a/openslides/motions/static/templates/motions/motion-form.html b/openslides/motions/static/templates/motions/motion-form.html index 54ec0f588..72b7b0e28 100644 --- a/openslides/motions/static/templates/motions/motion-form.html +++ b/openslides/motions/static/templates/motions/motion-form.html @@ -21,7 +21,11 @@
- + +
-
+
- +
-