More select mode options for users

This commit is contained in:
FinnStutzenstein 2016-12-20 09:14:33 +01:00
parent c6fb710fb9
commit 365c122edd
3 changed files with 56 additions and 34 deletions

View File

@ -64,6 +64,7 @@ Users:
- Added new field for participant number. - Added new field for participant number.
- Added new field 'is_committee' and new default group 'Committees'. - Added new field 'is_committee' and new default group 'Committees'.
- Improved users CSV import (use group names instead of id). - Improved users CSV import (use group names instead of id).
- Added more multiselect actions.
Other: Other:
- Django 1.10 is now supported. Dropped support for Django 1.8 and 1.9. - Django 1.10 is now supported. Dropped support for Django 1.8 and 1.9.

View File

@ -516,8 +516,8 @@ angular.module('OpenSlidesApp.users.site', [
isCommittee: { isCommittee: {
value: undefined, value: undefined,
displayName: gettext('Committee'), displayName: gettext('Committee'),
choiceYes: gettext('Is committee'), choiceYes: gettext('Is a committee'),
choiceNo: gettext('Is not committee'), choiceNo: gettext('Is not a committee'),
}, },
}; };
@ -591,6 +591,10 @@ angular.module('OpenSlidesApp.users.site', [
$scope.alert = { type: 'danger', msg: message, show: true }; $scope.alert = { type: 'danger', msg: message, show: true };
}); });
}; };
// delete single user
$scope.delete = function (user) {
User.destroy(user.id);
};
// *** select mode functions *** // *** select mode functions ***
$scope.isSelectMode = false; $scope.isSelectMode = false;
// check all checkboxes // check all checkboxes
@ -609,60 +613,60 @@ angular.module('OpenSlidesApp.users.site', [
}); });
} }
}; };
// delete all selected users var selectModeAction = function (predicate) {
$scope.deleteMultiple = function () { angular.forEach($scope.usersFiltered, function (user) {
angular.forEach($scope.users, function (user) {
if (user.selected) { if (user.selected) {
User.destroy(user.id); predicate(user);
} }
}); });
$scope.isSelectMode = false; $scope.isSelectMode = false;
$scope.uncheckAll(); $scope.uncheckAll();
}; };
// delete single user // delete all selected users
$scope.delete = function (user) { $scope.deleteMultiple = function () {
User.destroy(user.id); selectModeAction(function (user) {
$scope.delete(user);
});
}; };
// add group for selected users // add group for selected users
$scope.addGroupMultiple = function (group) { $scope.addGroupMultiple = function (group) {
angular.forEach($scope.users, function (user) { if (group) {
if (user.selected) { selectModeAction(function (user) {
user.groups_id.push(group); user.groups_id.push(group);
User.save(user); User.save(user);
} });
}); }
$scope.isSelectMode = false;
$scope.uncheckAll();
}; };
// remove group for selected users // remove group for selected users
$scope.removeGroupMultiple = function (group) { $scope.removeGroupMultiple = function (group) {
angular.forEach($scope.users, function (user) { if (group) {
if (user.selected) { selectModeAction(function (user) {
var groupIndex = user.groups_id.indexOf(parseInt(group)); var groupIndex = _.indexOf(user.groups_id, parseInt(group));
if (groupIndex > -1) { if (groupIndex > -1) {
user.groups_id.splice(groupIndex, 1); user.groups_id.splice(groupIndex, 1);
User.save(user); User.save(user);
} }
} });
}); }
$scope.isSelectMode = false;
$scope.uncheckAll();
}; };
// generate new passwords // generate new passwords
$scope.generateNewPasswordsMultiple = function () { $scope.generateNewPasswordsMultiple = function () {
angular.forEach($scope.users, function (user) { selectModeAction(function (user) {
if (user.selected) { var newPassword = PasswordGenerator.generate();
var newPassword = PasswordGenerator.generate(); user.default_password = newPassword;
user.default_password = newPassword; User.save(user);
User.save(user); $http.post(
$http.post( '/rest/users/user/' + user.id + '/reset_password/',
'/rest/users/user/' + user.id + '/reset_password/', {'password': newPassword}
{'password': newPassword} );
); });
} };
// set boolean properties (is_active, is_present, is_committee)
$scope.setBoolPropertyMultiple = function (property, value) {
selectModeAction(function (user) {
user[property] = value;
User.save(user);
}); });
$scope.isSelectMode = false;
$scope.uncheckAll();
}; };
// Export as PDF // Export as PDF

View File

@ -71,6 +71,9 @@
<option value="addGroup" translate>Add group</option> <option value="addGroup" translate>Add group</option>
<option value="removeGroup" translate>Remove group</option> <option value="removeGroup" translate>Remove group</option>
<option value="generatePasswords" translate>Generate new passwords</option> <option value="generatePasswords" translate>Generate new passwords</option>
<option value="is_active" translate>Set/Unset is active</option>
<option value="is_present" translate>Set/Unset is present</option>
<option value="is_committee" translate>Set/Unset is a committee</option>
</select> </select>
<!-- delete button --> <!-- delete button -->
<a ng-show="selectedAction == 'delete'" <a ng-show="selectedAction == 'delete'"
@ -104,6 +107,20 @@
<i class="fa fa-magic"></i> <i class="fa fa-magic"></i>
<translate>Generate new passwords</translate> <translate>Generate new passwords</translate>
</a> </a>
<!-- set bool property button -->
<a ng-show="inArray(['is_active', 'is_present', 'is_committee'], selectedAction)"
ng-click="setBoolPropertyMultiple(selectedAction, true)" class="btn btn-default">
<span ng-if="selectedAction == 'is_active'" translate>Set active</span>
<span ng-if="selectedAction == 'is_present'" translate>Set present</span>
<span ng-if="selectedAction == 'is_committee'" translate>Set committee</span>
</a>
<!-- unset bool property button -->
<a ng-show="inArray(['is_active', 'is_present', 'is_committee'], selectedAction)"
ng-click="setBoolPropertyMultiple(selectedAction, false)" class="btn btn-default">
<span ng-if="selectedAction == 'is_active'" translate>Unset active</span>
<span ng-if="selectedAction == 'is_present'" translate>Unset present</span>
<span ng-if="selectedAction == 'is_committee'" translate>Unset committee</span>
</a>
</div> </div>
</div> </div>