From bc60b7e7cade96cffbd3758be9cad4f0b1a1eae2 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Wed, 13 Jan 2016 20:27:07 +0100 Subject: [PATCH] Several template improvements - Move Languages services from site.js to base.js Now the detected browser language is used as projector language. - Use verboseName instead of agendaSupplement. - Show submitters on projector (load Users on Controller). - Improve list of speakers (slide and item detail). --- openslides/agenda/static/js/agenda/base.js | 4 +- openslides/agenda/static/js/agenda/site.js | 21 ++++- .../static/templates/agenda/item-detail.html | 89 ++++++++++--------- .../agenda/slide-list-of-speakers.html | 33 ++++--- .../assignments/static/js/assignments/base.js | 1 - openslides/core/static/css/app.css | 22 ++++- openslides/core/static/css/projector.css | 30 ++++++- openslides/core/static/js/core/base.js | 63 +++++++++++++ openslides/core/static/js/core/site.js | 69 ++------------ openslides/motions/static/js/motions/base.js | 3 +- .../motions/static/js/motions/projector.js | 3 +- 11 files changed, 210 insertions(+), 128 deletions(-) diff --git a/openslides/agenda/static/js/agenda/base.js b/openslides/agenda/static/js/agenda/base.js index e4582fa00..366393f3d 100644 --- a/openslides/agenda/static/js/agenda/base.js +++ b/openslides/agenda/static/js/agenda/base.js @@ -52,8 +52,8 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users']) // in the DS store. title = this.title; } - if (this.getContentResource().agendaSupplement) { - title = gettextCatalog.getString(this.getContentResource().agendaSupplement) + ' ' + title; + if (this.getContentResource().verboseName) { + title = gettextCatalog.getString(this.getContentResource().verboseName) + ' ' + title; } if (this.item_number) { title = this.item_number + ' ' + title; diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js index 85f160a45..1f6639153 100644 --- a/openslides/agenda/static/js/agenda/site.js +++ b/openslides/agenda/static/js/agenda/site.js @@ -184,10 +184,11 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) '$filter', '$http', '$state', + 'operator', 'Agenda', 'User', 'item', - function ($scope, $filter, $http, $state, Agenda, User, item) { + function ($scope, $filter, $http, $state, operator, Agenda, User, item) { Agenda.bindOne(item.id, $scope, 'item'); User.bindAll({}, $scope, 'users'); $scope.speakerSelectBox = {}; @@ -199,7 +200,6 @@ 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', @@ -242,6 +242,23 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) $scope.speakers = item.speakers; }; + // check if user is allowed to see 'add me' / 'remove me' button + $scope.isAllowed = function (action) { + var nextUsers = []; + var nextSpeakers = $filter('filter')($scope.speakers, {'begin_time': null}); + angular.forEach(nextSpeakers, function (speaker) { + nextUsers.push(speaker.user_id); + }); + if (action == 'add') { + return (operator.hasPerms('agenda.can_be_speaker') && + !item.speaker_list_closed && + $.inArray(operator.user.id, nextUsers) == -1); + } + if (action == 'remove') { + return ($.inArray(operator.user.id, nextUsers) != -1); + } + } + // begin speech of selected/next speaker $scope.beginSpeech = function (speakerId) { $http.put('/rest/agenda/item/' + item.id + '/speak/', {'speaker': speakerId}) diff --git a/openslides/agenda/static/templates/agenda/item-detail.html b/openslides/agenda/static/templates/agenda/item-detail.html index c250a768b..8e1cb7b7d 100644 --- a/openslides/agenda/static/templates/agenda/item-detail.html +++ b/openslides/agenda/static/templates/agenda/item-detail.html @@ -7,7 +7,7 @@ - {{item.getContentResource().verboseName}} + {{ item.getContentResource().verboseName }} + {{ item.getContentResource().verboseName }}

{{ item.getTitle() }}

-

List of speakers

+

+ List of speakers + Closed +

-
+
- +
-
+ +
+

Last speakers

-

Old speakers:

-
    +
    1. {{ speaker.user.get_full_name() }} @@ -78,46 +81,50 @@ {{ speaker.end_time | date:'yyyy-MM-dd HH:mm:ss' }}]
-

Current speaker:

- + +

Current speaker

+ {{ speaker.user.get_full_name() }} - + -

Next speakers:

-
-
+ +

Next speakers

+
+
  1. {{ $index + 1 }}. {{ speaker.user.get_full_name() }} - +
+
{{ alert.msg }} @@ -137,12 +144,12 @@
-

- - diff --git a/openslides/agenda/static/templates/agenda/slide-list-of-speakers.html b/openslides/agenda/static/templates/agenda/slide-list-of-speakers.html index e84a5d98d..18fc7b90e 100644 --- a/openslides/agenda/static/templates/agenda/slide-list-of-speakers.html +++ b/openslides/agenda/static/templates/agenda/slide-list-of-speakers.html @@ -1,19 +1,28 @@

-

- {{ item.title }} - List of speakers - Closed -

- - + + +
+

{{ item.getTitle() }}

+

+ List of speakers + + – {{ (item.speakers | filter: {begin_time: null}).length }} speakers + Closed +

+
+ + +

+ {{ speaker.user.get_full_name() }} -

- - {{ speaker.user.get_full_name() }} - +

+ {{ speaker.user.get_full_name() }} + -

    +
    1. {{ speaker.user.get_full_name() }}
    diff --git a/openslides/assignments/static/js/assignments/base.js b/openslides/assignments/static/js/assignments/base.js index f8dc2dcbd..6c00b822a 100644 --- a/openslides/assignments/static/js/assignments/base.js +++ b/openslides/assignments/static/js/assignments/base.js @@ -80,7 +80,6 @@ angular.module('OpenSlidesApp.assignments', []) name: name, useClass: jsDataModel, verboseName: gettext('Election'), - agendaSupplement: this.verboseName, phases: phases, getPhases: function () { if (!this.phases) { diff --git a/openslides/core/static/css/app.css b/openslides/core/static/css/app.css index d625c0641..6edb3c492 100644 --- a/openslides/core/static/css/app.css +++ b/openslides/core/static/css/app.css @@ -348,7 +348,7 @@ img { .col2 .projector_min .icon a { color: #fff; display: block; - } +} .col2 .projector_full { margin-left: 30px; @@ -534,6 +534,26 @@ img { padding-left: 20px; } +.slimlabel.label { + padding: 0px 10px; +} + +.indentation, .indentation20 { + margin-left: 20px; +} + +.indentation-lg { + margin-left: 35px !important; +} + +.halfWidth { + width: 50%; +} + +.listOfSpeakers h3 { + padding-bottom: 0; +} + .smallhr { margin-top: 5px; margin-bottom: 5px; diff --git a/openslides/core/static/css/projector.css b/openslides/core/static/css/projector.css index 2447f5230..c2b481ed5 100644 --- a/openslides/core/static/css/projector.css +++ b/openslides/core/static/css/projector.css @@ -60,7 +60,6 @@ body{ bottom: 0; height: 35px; color: #F5F5F5; - opacity: 0.8; width: 100%; font-size: 16px; padding-left: 50px; @@ -69,6 +68,9 @@ body{ overflow: hidden; text-align: right; } +#footer span { + opacity: 0.8; +} /*** CONTENT with base style elements ***/ .content { @@ -252,4 +254,28 @@ tr.elected td { font-size: 140%; } .spacer-top { - margin-top: 25px; + margin-top: 25px; +} + +/*** List of speakers ***/ +.slimlabel.label { + padding: 0px 10px; +} + +.lastSpeakers { + color: #9a9898; + margin-left: 27px; +} +.currentSpeaker { + font-weight: bold; + margin-left: 0px; +} +.currentSpeaker i { + padding-right: 5px; +} +.nextSpeakers { + margin-left: 8px; +} +.nextSpeakers li { + line-height: 150%; +} diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 916386b98..57d570357 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -66,6 +66,69 @@ angular.module('OpenSlidesApp.core', [ } ]) +// gets all in OpenSlides available languages +.factory('Languages', [ + 'gettext', + 'gettextCatalog', + function (gettext, gettextCatalog) { + return { + // get all available languages + getLanguages: function () { + var current = gettextCatalog.getCurrentLanguage(); + // Define here new languages... + var languages = [ + { code: 'en', name: gettext('English') }, + { code: 'de', name: gettext('German') }, + { code: 'fr', name: gettext('French') } + ]; + angular.forEach(languages, function (language) { + if (language.code == current) + language.selected = true; + }); + return languages + }, + // get detected browser language code + getBrowserLanguage: function () { + var lang = navigator.language || navigator.userLanguage; + if (lang.indexOf('-') !== -1) + lang = lang.split('-')[0]; + if (lang.indexOf('_') !== -1) + lang = lang.split('_')[0]; + return lang; + }, + // set current language and return updated languages object array + setCurrentLanguage: function (lang) { + var languages = this.getLanguages(); + angular.forEach(languages, function (language) { + language.selected = false; + if (language.code == lang) { + language.selected = true; + gettextCatalog.setCurrentLanguage(lang); + if (lang != 'en') { + gettextCatalog.loadRemote("static/i18n/" + lang + ".json"); + } + } + }); + return languages; + } + } + } +]) + +// set browser language as default language for OpenSlides +.run([ + 'gettextCatalog', + 'Languages', + function(gettextCatalog, Languages) { + // set detected browser language as default language (fallback: 'en') + Languages.setCurrentLanguage(Languages.getBrowserLanguage()); + + // Set this to true for debug. Helps to find untranslated strings by + // adding "[MISSING]:". + gettextCatalog.debug = false; + } +]) + .run(['DS', 'autoupdate', function(DS, autoupdate) { autoupdate.on_message(function(data) { // TODO: when MODEL.find() is called after this diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index b42db9bf0..5aa3e5cfb 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -63,19 +63,6 @@ angular.module('OpenSlidesApp.core.site', [ } ]) -// set browser language as default language for OpenSlides -.run([ - 'gettextCatalog', - 'Languages', - function(gettextCatalog, Languages) { - // set detected browser language as default language (fallback: 'en') - Languages.setCurrentLanguage(Languages.getBrowserLanguage()); - - // Set this to true for debug. Helps to find untranslated strings by - // adding "[MISSING]:". - gettextCatalog.debug = false; - } -]) .config([ 'mainMenuProvider', 'gettext', @@ -367,55 +354,6 @@ angular.module('OpenSlidesApp.core.site', [ } ]) -// gets all in OpenSlides available languages -.factory('Languages', [ - 'gettext', - 'gettextCatalog', - function (gettext, gettextCatalog) { - return { - // get all available languages - getLanguages: function () { - var current = gettextCatalog.getCurrentLanguage(); - // Define here new languages... - var languages = [ - { code: 'en', name: gettext('English') }, - { code: 'de', name: gettext('German') }, - { code: 'fr', name: gettext('French') } - ]; - angular.forEach(languages, function (language) { - if (language.code == current) - language.selected = true; - }); - return languages - }, - // get detected browser language code - getBrowserLanguage: function () { - var lang = navigator.language || navigator.userLanguage; - if (lang.indexOf('-') !== -1) - lang = lang.split('-')[0]; - if (lang.indexOf('_') !== -1) - lang = lang.split('_')[0]; - return lang; - }, - // set current language and return updated languages object array - setCurrentLanguage: function (lang) { - var languages = this.getLanguages(); - angular.forEach(languages, function (language) { - language.selected = false; - if (language.code == lang) { - language.selected = true; - gettextCatalog.setCurrentLanguage(lang); - if (lang != 'en') { - gettextCatalog.loadRemote("static/i18n/" + lang + ".json"); - } - } - }); - return languages; - } - } - } -]) - .controller("LanguageCtrl", function ($scope, gettextCatalog, Languages, filterFilter) { $scope.languages = Languages.getLanguages(); $scope.selectedLanguage = filterFilter($scope.languages, {selected: true}); @@ -689,10 +627,13 @@ angular.module('OpenSlidesApp.core.site', [ }; $scope.editCurrentSlide = function () { $.each(Projector.get(1).elements, function(key, value) { - if (value.name != 'core/clock' && + if (value.name == 'agenda/list-of-speakers') { + $state.go('agenda.item.detail', {id: value.id}); + } else if ( + value.name != 'core/clock' && value.name != 'core/countdown' && value.name != 'core/message' ) { - $state.go(value.name.replace('/', '.')+'.detail.update', {id: value.id }); + $state.go(value.name.replace('/', '.')+'.detail.update', {id: value.id}); } }); }; diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index 1be5b0a48..6f69ff070 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -169,7 +169,6 @@ angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users']) name: name, useClass: jsDataModel, verboseName: gettext('Motion'), - agendaSupplement: this.verboseName, methods: { getResourceName: function () { return name; @@ -200,7 +199,7 @@ angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users']) if (this.identifier) { value = ' ' + this.identifier; } - return value + ': ' + this.getTitle(); + return "Motion " + value + ': ' + this.getTitle(); }, isAllowed: function (action) { /* diff --git a/openslides/motions/static/js/motions/projector.js b/openslides/motions/static/js/motions/projector.js index c2916fbea..923f34cae 100644 --- a/openslides/motions/static/js/motions/projector.js +++ b/openslides/motions/static/js/motions/projector.js @@ -10,12 +10,13 @@ angular.module('OpenSlidesApp.motions.projector', ['OpenSlidesApp.motions']) }); }) -.controller('SlideMotionCtrl', function($scope, Motion) { +.controller('SlideMotionCtrl', function($scope, Motion, User) { // 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.id; Motion.find(id); + User.findAll(); Motion.bindOne(id, $scope, 'motion'); });