From fac45fbf2adf7a1faaf19896e169139ae0c9a79f Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Thu, 15 Oct 2015 17:27:59 +0200 Subject: [PATCH] Added multiselection delete mode for users list view. Fix users import: Allows multiple groups. --- openslides/agenda/static/js/agenda/agenda.js | 2 +- .../static/templates/agenda/item-list.html | 6 +- openslides/users/static/js/users/users.js | 90 +++++++++++++----- .../static/templates/users/user-import.html | 2 +- .../static/templates/users/user-list.html | 93 ++++++++++++------- 5 files changed, 128 insertions(+), 65 deletions(-) diff --git a/openslides/agenda/static/js/agenda/agenda.js b/openslides/agenda/static/js/agenda/agenda.js index 6a77f0445..e4cb5ce68 100644 --- a/openslides/agenda/static/js/agenda/agenda.js +++ b/openslides/agenda/static/js/agenda/agenda.js @@ -222,7 +222,7 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) // open detail view link $scope.openDetail = function (id) { $state.go('agenda.item.detail', {id: id}); - } + }; // save changed item $scope.save = function (item) { diff --git a/openslides/agenda/static/templates/agenda/item-list.html b/openslides/agenda/static/templates/agenda/item-list.html index a5dd80d6a..555181c74 100644 --- a/openslides/agenda/static/templates/agenda/item-list.html +++ b/openslides/agenda/static/templates/agenda/item-list.html @@ -73,7 +73,7 @@ - @@ -100,10 +100,10 @@ - + - {{ item.item_number }} {{ item.title }} + {{ item.item_number }} {{ item.title }}
{{ item.comment }}
diff --git a/openslides/users/static/js/users/users.js b/openslides/users/static/js/users/users.js index af2aa45e6..0c6aa0a2a 100644 --- a/openslides/users/static/js/users/users.js +++ b/openslides/users/static/js/users/users.js @@ -350,33 +350,66 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) } ]) -.controller('UserListCtrl', function($scope, User, Group) { - User.bindAll({}, $scope, 'users'); - Group.bindAll({}, $scope, 'groups'); +.controller('UserListCtrl', [ + '$scope', + '$state', + 'User', + 'Group', + function($scope, $state, User, Group) { + User.bindAll({}, $scope, 'users'); + Group.bindAll({}, $scope, 'groups'); - // setup table sorting - $scope.sortColumn = 'first_name'; //TODO: sort by first OR last name - $scope.filterPresent = ''; - $scope.reverse = false; - // function to sort by clicked column - $scope.toggleSort = function ( column ) { - if ( $scope.sortColumn === column ) { - $scope.reverse = !$scope.reverse; - } - $scope.sortColumn = column; - }; + // setup table sorting + $scope.sortColumn = 'first_name'; //TODO: sort by first OR last name + $scope.filterPresent = ''; + $scope.reverse = false; + // function to sort by clicked column + $scope.toggleSort = function ( column ) { + if ( $scope.sortColumn === column ) { + $scope.reverse = !$scope.reverse; + } + $scope.sortColumn = column; + }; - // save changed user - $scope.togglePresent = function (user) { - //the value was changed by the template (checkbox) - User.save(user); - }; + // open detail view link + $scope.openDetail = function (id) { + $state.go('users.user.detail', {id: id}); + }; - // delete selected user - $scope.delete = function (user) { - User.destroy(user.id); - }; -}) + // save changed user + $scope.togglePresent = function (user) { + //the value was changed by the template (checkbox) + User.save(user); + }; + + // *** delete mode functions *** + $scope.isDeleteMode = false; + // check all checkboxes + $scope.checkAll = function () { + angular.forEach($scope.users, function (user) { + user.selected = $scope.selectedAll; + }); + }; + // uncheck all checkboxes if isDeleteMode is closed + $scope.uncheckAll = function () { + if (!$scope.isDeleteMode) { + $scope.selectedAll = false; + angular.forEach($scope.users, function (user) { + user.selected = false; + }); + } + }; + // delete selected user + $scope.delete = function () { + angular.forEach($scope.users, function (user) { + if (user.selected) + User.destroy(user.id); + }); + $scope.isDeleteMode = false; + $scope.uncheckAll(); + }; + } +]) .controller('UserDetailCtrl', function($scope, User, user, Group) { User.bindOne(user.id, $scope, 'user'); @@ -469,7 +502,14 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) user.first_name = obj[i].first_name; user.last_name = obj[i].last_name; user.structure_level = obj[i].structure_level; - user.groups = obj[i].groups; + user.groups = []; + if (obj[i].groups != '') { + var groups = obj[i].groups.replace('"','').split(","); + groups.forEach(function(group) { + user.groups.push(group); + console.log(group); + }); + } user.comment = obj[i].comment; User.create(user).then( function(success) { diff --git a/openslides/users/static/templates/users/user-import.html b/openslides/users/static/templates/users/user-import.html index d7d6c3e3f..7033d7b2e 100644 --- a/openslides/users/static/templates/users/user-import.html +++ b/openslides/users/static/templates/users/user-import.html @@ -86,7 +86,7 @@ Keep each person in a single line.

- Back to agenda overview + Back to users overview

diff --git a/openslides/users/static/templates/users/user-list.html b/openslides/users/static/templates/users/user-list.html index 6a80aab38..63b8a4097 100644 --- a/openslides/users/static/templates/users/user-list.html +++ b/openslides/users/static/templates/users/user-list.html @@ -38,23 +38,45 @@

- - Is present +
+ +
+ + + +
+ + + + Delete selected users + + + + Is present +
- +
+
+ +
- -
- Present - - + + + + + Name @@ -71,37 +93,38 @@ - - Actions + + Present + +
- {{ user.get_short_name() }} -
{{ user.comment }}
+ orderBy: sortColumn:reverse" + ng-click="openDetail(user.id)" + ng-class="{ 'activeline': user.isProjected() }" + class="pointer"> + +
+ + + + + + + + {{ user.get_short_name() }} +
+ {{ user.comment }} +
{{ user.structure_level }}
{{ (groups | filter: {id: group})[0].name }}
-
- - - - - - - - - - - - +