From f75516c7bb795a1d671968e3546a7fa0c24c49fa Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Thu, 25 Jun 2015 10:19:38 +0200 Subject: [PATCH] Agenda slide templates. Some template improvements. - User import - show linebreaks for long text - some style work - item detail and agenda list slide --- openslides/agenda/static/js/agenda/agenda.js | 69 +++++++++++++++++-- .../static/templates/agenda/item-detail.html | 12 ++-- .../static/templates/agenda/item-list.html | 26 ++++--- .../static/templates/agenda/slide_agenda.html | 11 +++ .../static/templates/agenda/slide_item.html | 4 ++ .../assignments/assignment-detail.html | 9 ++- .../assignments/slide_assignment.html | 2 +- openslides/core/static/css/projector.css | 26 +++++-- openslides/core/static/js/app.js | 2 +- .../templates/core/slide_customslide.html | 2 +- .../templates/motions/motion-detail.html | 11 +-- .../templates/motions/slide_motion.html | 2 +- openslides/users/static/js/users/users.js | 18 ++++- .../static/templates/users/group-list.html | 7 +- .../static/templates/users/user-detail.html | 24 +++++-- .../static/templates/users/user-import.html | 4 +- 16 files changed, 180 insertions(+), 49 deletions(-) create mode 100644 openslides/agenda/static/templates/agenda/slide_agenda.html create mode 100644 openslides/agenda/static/templates/agenda/slide_item.html diff --git a/openslides/agenda/static/js/agenda/agenda.js b/openslides/agenda/static/js/agenda/agenda.js index b35c2750a..05e9f7c12 100644 --- a/openslides/agenda/static/js/agenda/agenda.js +++ b/openslides/agenda/static/js/agenda/agenda.js @@ -1,9 +1,16 @@ angular.module('OpenSlidesApp.agenda', []) -.factory('Agenda', function(DS) { +.factory('Agenda', function(DS, jsDataModel) { + var name = 'agenda/item' return DS.defineResource({ - name: 'agenda/item', - endpoint: '/rest/agenda/item/' + name: name, + endpoint: '/rest/agenda/item/', + useClass: jsDataModel, + methods: { + getResourceName: function () { + return name; + } + } }); }) @@ -81,7 +88,7 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) }); }) -.controller('ItemListCtrl', function($scope, Agenda, tree) { +.controller('ItemListCtrl', function($scope, $http, Agenda, tree, Projector) { Agenda.bindAll({}, $scope, 'items'); // get a 'flat' (ordered) array of agenda tree to display in table @@ -114,6 +121,23 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) $scope.delete = function (id) { Agenda.destroy(id); }; + // project agenda + $scope.projectAgenda = function () { + $http.post('/rest/core/projector/1/prune_elements/', + [{name: 'agenda/agenda'}]); + }; + // check if agenda is projected + $scope.isAgendaProjected = function () { + // Returns true if there is a projector element with the same + // name and agenda is active. + var projector = Projector.get(id=1); + if (typeof projector === 'undefined') return false; + var self = this; + return _.findIndex(projector.elements, function(element) { + return element.name == 'agenda/agenda' + }) > -1; + + }; }) .controller('ItemDetailCtrl', function($scope, $http, Agenda, User, item) { @@ -235,3 +259,40 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) }; }); + + +angular.module('OpenSlidesApp.agenda.projector', ['OpenSlidesApp.agenda']) + +.config(function(slidesProvider) { + slidesProvider.registerSlide('agenda/item', { + template: 'static/templates/agenda/slide_item.html', + }); + slidesProvider.registerSlide('agenda/agenda', { + template: 'static/templates/agenda/slide_agenda.html', + }); +}) + +.controller('SlideItemCtrl', function($scope, Agenda) { + // Attention! Each object that is used here has to be dealt on server side. + // Add it to the coresponding get_requirements method of the ProjectorElement + // class. + var id = $scope.element.context.id; + Agenda.find(id); + Agenda.bindOne(id, $scope, 'item'); +}) + +.controller('SlideAgendaCtrl', function($scope, $http, Agenda) { + // Attention! Each object that is used here has to be dealt on server side. + // Add it to the coresponding get_requirements method of the ProjectorElement + // class. + Agenda.findAll(); + Agenda.bindAll({}, $scope, 'items'); + $scope.ids = []; + var tree = $http.get('/rest/agenda/item/tree/').success(function(data) { + var ids = []; + angular.forEach(data,function(element) { + ids.push(element.id) + }); + $scope.ids = ids; + }) +}); diff --git a/openslides/agenda/static/templates/agenda/item-detail.html b/openslides/agenda/static/templates/agenda/item-detail.html index 1d7ed4ea1..208cde250 100644 --- a/openslides/agenda/static/templates/agenda/item-detail.html +++ b/openslides/agenda/static/templates/agenda/item-detail.html @@ -5,9 +5,11 @@ Back to overview - - + + @@ -18,7 +20,7 @@ -{{ item.text }} +
{{ item.text }}

Duration

@@ -27,7 +29,7 @@

Comment

- {{ item.comment }} +
{{ item.comment }}
diff --git a/openslides/agenda/static/templates/agenda/item-list.html b/openslides/agenda/static/templates/agenda/item-list.html index cd3fcab3e..9eda8b96c 100644 --- a/openslides/agenda/static/templates/agenda/item-list.html +++ b/openslides/agenda/static/templates/agenda/item-list.html @@ -25,6 +25,13 @@
Actions - + @@ -53,20 +61,20 @@ {{ (items | filter: {id: node.id})[0].item_number }} {{ (items | filter: {id: node.id})[0].title }} - +
+ {{ (items | filter: {id: node.id})[0].comment }} +
{{ (items | filter: {id: node.id})[0].duration }} min - - + + diff --git a/openslides/agenda/static/templates/agenda/slide_agenda.html b/openslides/agenda/static/templates/agenda/slide_agenda.html new file mode 100644 index 000000000..8f6561703 --- /dev/null +++ b/openslides/agenda/static/templates/agenda/slide_agenda.html @@ -0,0 +1,11 @@ +
+

Agenda

+ + + +
+ {{ (items | filter: {id: id})[0].item_number }} + + {{ (items | filter: {id: id})[0].title }} +
+
diff --git a/openslides/agenda/static/templates/agenda/slide_item.html b/openslides/agenda/static/templates/agenda/slide_item.html new file mode 100644 index 000000000..e88453002 --- /dev/null +++ b/openslides/agenda/static/templates/agenda/slide_item.html @@ -0,0 +1,4 @@ +
+

{{ item.title }}

+
{{ item.text }}
+
diff --git a/openslides/assignments/static/templates/assignments/assignment-detail.html b/openslides/assignments/static/templates/assignments/assignment-detail.html index 592646e05..f0fc71128 100644 --- a/openslides/assignments/static/templates/assignments/assignment-detail.html +++ b/openslides/assignments/static/templates/assignments/assignment-detail.html @@ -9,8 +9,11 @@ PDF - + + @@ -22,7 +25,7 @@

Description

-{{ assignment.description }} +
{{ assignment.description }}

Candidates

diff --git a/openslides/assignments/static/templates/assignments/slide_assignment.html b/openslides/assignments/static/templates/assignments/slide_assignment.html index 4818aabd1..4ff0f65f6 100644 --- a/openslides/assignments/static/templates/assignments/slide_assignment.html +++ b/openslides/assignments/static/templates/assignments/slide_assignment.html @@ -1,4 +1,4 @@

{{ assignment.title }}

- {{ assignment.description }} +
{{ assignment.description }}
diff --git a/openslides/core/static/css/projector.css b/openslides/core/static/css/projector.css index 10281a52c..189ee17a6 100644 --- a/openslides/core/static/css/projector.css +++ b/openslides/core/static/css/projector.css @@ -124,6 +124,9 @@ hr { .nobr { white-space: nowrap; } +.white-space-pre-line { + white-space: pre-line; +} /*** Overlay ***/ @@ -166,7 +169,7 @@ hr { /*** Table style ***/ -table { +.table { border-collapse:collapse; border-color:#CCCCCC -moz-use-text-color #CCCCCC #CCCCCC; border-style:solid none solid solid; @@ -174,7 +177,7 @@ table { margin:0; border-spacing:0px; } -table th { +.table th { border-right:1px solid #CCCCCC; color:#333333; font-weight:normal; @@ -182,10 +185,10 @@ table th { text-align:left; text-transform:uppercase; } -table tr.odd td { +.table tr.odd td { background:none repeat scroll 0 0 #F1F1F1; } -table td { +.table td { background:none repeat scroll 0 0 #F7F7F7; border-right:1px solid #CCCCCC; line-height:120%; @@ -199,3 +202,18 @@ tr.total td { tr.elected td { background-color: #BED4DE !important; } + +/*** Table list ***/ +.tablelist { + font-size: 130%; +} +.tablelist td { + padding: 5px; +} +.tablelist .leftcolumn { + padding-right: 15px; + vertical-align: top; +} +.tablelist td.closed { + text-decoration: line-through; +} diff --git a/openslides/core/static/js/app.js b/openslides/core/static/js/app.js index 71dcf1fbb..7d26154e6 100644 --- a/openslides/core/static/js/app.js +++ b/openslides/core/static/js/app.js @@ -10,7 +10,7 @@ angular.module('OpenSlidesApp', [ angular.module('OpenSlidesApp.projector', [ 'OpenSlidesApp', 'OpenSlidesApp.core.projector', - 'OpenSlidesApp.agenda', + 'OpenSlidesApp.agenda.projector', 'OpenSlidesApp.motions.projector', 'OpenSlidesApp.assignments.projector', 'OpenSlidesApp.users.projector', diff --git a/openslides/core/static/templates/core/slide_customslide.html b/openslides/core/static/templates/core/slide_customslide.html index 2601287c3..4890dd0b7 100644 --- a/openslides/core/static/templates/core/slide_customslide.html +++ b/openslides/core/static/templates/core/slide_customslide.html @@ -1,4 +1,4 @@

{{ customslide.title }}

- {{ customslide.text }} +
{{ customslide.text }}
diff --git a/openslides/motions/static/templates/motions/motion-detail.html b/openslides/motions/static/templates/motions/motion-detail.html index 449a16e41..9d1a0a95a 100644 --- a/openslides/motions/static/templates/motions/motion-detail.html +++ b/openslides/motions/static/templates/motions/motion-detail.html @@ -15,8 +15,11 @@ PDF - + + @@ -30,10 +33,10 @@

Text

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

Reason

- {{ motion.getReason() }} +
{{ motion.getReason() }}
diff --git a/openslides/motions/static/templates/motions/slide_motion.html b/openslides/motions/static/templates/motions/slide_motion.html index f10135723..99c1497c5 100644 --- a/openslides/motions/static/templates/motions/slide_motion.html +++ b/openslides/motions/static/templates/motions/slide_motion.html @@ -1,4 +1,4 @@

{{ motion.getTitle() }}

- {{ motion.getText() }} +
{{ motion.getText() }}
diff --git a/openslides/users/static/js/users/users.js b/openslides/users/static/js/users/users.js index 51663a2bb..4e310a90c 100644 --- a/openslides/users/static/js/users/users.js +++ b/openslides/users/static/js/users/users.js @@ -121,6 +121,9 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) resolve: { user: function(User, $stateParams) { return User.find($stateParams.id); + }, + groups: function(Group) { + return Group.findAll(); } } }) @@ -313,8 +316,9 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) }; }) -.controller('UserDetailCtrl', function($scope, User, user) { +.controller('UserDetailCtrl', function($scope, User, user, Group) { User.bindOne(user.id, $scope, 'user'); + Group.bindAll({}, $scope, 'groups'); }) .controller('UserCreateCtrl', function($scope, $state, User, Group) { @@ -353,7 +357,17 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) $scope.users = $scope.userlist[0].split("\n"); $scope.importcounter = 0; $scope.users.forEach(function(name) { - var user = {last_name: name, groups: []}; // use default group 'Registered' (#2) + // Split each full name in first and last name. + // The last word is set as last name, rest is the first name(s). + // (e.g.: "Max Martin Mustermann" -> last_name = "Mustermann") + var names = name.split(" "); + var last_name = names.slice(-1)[0]; + var first_name = names.slice(0, -1).join(" "); + var user = { + first_name: first_name, + last_name: last_name, + groups: [] + }; User.create(user).then( function(success) { $scope.importcounter++; diff --git a/openslides/users/static/templates/users/group-list.html b/openslides/users/static/templates/users/group-list.html index 4e2c7cb24..2d76ec452 100644 --- a/openslides/users/static/templates/users/group-list.html +++ b/openslides/users/static/templates/users/group-list.html @@ -34,12 +34,7 @@ {{ group.id }} {{ group.name }} - - - - - + Back to overview + + + + + + + +
@@ -13,10 +26,11 @@ {{ user.structure_level }} - {{ user.groups }} - +
+ {{ (groups | filter: {id: group})[0].name }} +
- {{ user.about_me }} +
{{ user.about_me }}
@@ -24,8 +38,6 @@ {{ user.username }} - {{ user.comment }} - - {{ user.last_login }} +
{{ user.comment }}
diff --git a/openslides/users/static/templates/users/user-import.html b/openslides/users/static/templates/users/user-import.html index 3b54ffb79..d7d6c3e3f 100644 --- a/openslides/users/static/templates/users/user-import.html +++ b/openslides/users/static/templates/users/user-import.html @@ -19,8 +19,8 @@ Keep each person in a single line.

-
- +
+ {{ importcounter }} / {{ users.length }} {{ "imported" | translate }}