diff --git a/bower.json b/bower.json index 44c77e312..796dad8bc 100644 --- a/bower.json +++ b/bower.json @@ -13,7 +13,7 @@ "angular-csv-import": "~0.0.15", "angular-loading-bar": "~0.7.1", "angular-ui-router": "~0.2.13", - "angular-ui-select": "~0.11.2", + "angular-ui-select": "~0.12", "angular-ui-tree": "~2.2.0", "angular-gettext": "~2.0.2", "angular-sanitize": "~1.3.15", diff --git a/openslides/agenda/static/js/agenda/agenda.js b/openslides/agenda/static/js/agenda/agenda.js index 414bbcc84..b35c2750a 100644 --- a/openslides/agenda/static/js/agenda/agenda.js +++ b/openslides/agenda/static/js/agenda/agenda.js @@ -116,9 +116,33 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) }; }) -.controller('ItemDetailCtrl', function($scope, Agenda, User, item) { +.controller('ItemDetailCtrl', function($scope, $http, Agenda, User, item) { Agenda.bindOne(item.id, $scope, 'item'); User.bindAll({}, $scope, 'users'); + $scope.speaker = {}; + $scope.alert = {}; + + // close/open list of speakers of current item + $scope.closeList = function (listClosed) { + item.speakerListClosed = listClosed; + Agenda.save(item); + }; + // add user to list of speakers + $scope.addSpeaker = function (userId) { + $http.post('/rest/agenda/item/' + item.id + '/manage_speaker/', {'user': userId}) + .success(function(data){ + $scope.alert.show = false; + }) + .error(function(data){ + $scope.alert = { type: 'danger', msg: data.detail, show: true }; + }); + }; + // delete speaker(!) from list of speakers + $scope.removeSpeaker = function (speakerId) { + $http.delete('/rest/agenda/item/' + item.id + '/manage_speaker/', + {headers: {'Content-Type': 'application/json'}, + data: JSON.stringify({speaker: speakerId})}); + }; }) .controller('ItemCreateCtrl', function($scope, $state, Agenda, types) { diff --git a/openslides/agenda/static/templates/agenda/item-detail.html b/openslides/agenda/static/templates/agenda/item-detail.html index a7267d2f5..1d7ed4ea1 100644 --- a/openslides/agenda/static/templates/agenda/item-detail.html +++ b/openslides/agenda/static/templates/agenda/item-detail.html @@ -31,26 +31,52 @@ -

List of speakers

+

List of speakers + closed + + + + +

+ -
-
- +
    +
  1. + {{ (users | filter: {id: speaker.user})[0].get_full_name() }} + +
  2. +
+ +
+ {{alert.msg}} +
+ - {{ $select.selected.get_short_name() }} + {{ $select.selected.get_full_name() }} - -
- + +
+ + + + +
- diff --git a/openslides/core/static/js/app.js b/openslides/core/static/js/app.js index 238773954..fc65c1f37 100644 --- a/openslides/core/static/js/app.js +++ b/openslides/core/static/js/app.js @@ -45,4 +45,8 @@ angular.module('OpenSlidesApp.site', [ // Combine the django csrf system with the angular csrf system $httpProvider.defaults.xsrfCookieName = 'csrftoken'; $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; +}) + +.config(function(uiSelectConfig) { + uiSelectConfig.theme = 'bootstrap'; }); diff --git a/openslides/users/static/js/users/users.js b/openslides/users/static/js/users/users.js index ca86ef893..d64d347be 100644 --- a/openslides/users/static/js/users/users.js +++ b/openslides/users/static/js/users/users.js @@ -37,6 +37,24 @@ angular.module('OpenSlidesApp.users', []) } return name; }, + get_full_name: function() { + // should be the same as in the python user model. + var firstName = _.trim(this.first_name), + lastName = _.trim(this.last_name), + structure_level = _.trim(this.structure_level), + name; + + if (firstName && lastName) { + // TODO: check config + name = [firstName, lastName].join(' '); + } else { + name = firstName || lastName || this.username; + } + if (structure_level) { + name = name + " (" + structure_level + ")"; + } + return name; + }, getPerms: function() { var allPerms = []; _.forEach(this.groups, function(groupId) {