Merge pull request #2801 from FinnStutzenstein/Issue2754
More select mode options for users
This commit is contained in:
commit
7b0dca84d2
@ -65,6 +65,7 @@ Users:
|
||||
- Added new field for participant number.
|
||||
- Added new field 'is_committee' and new default group 'Committees'.
|
||||
- Improved users CSV import (use group names instead of id).
|
||||
- Added more multiselect actions.
|
||||
|
||||
Other:
|
||||
- Django 1.10 is now supported. Dropped support for Django 1.8 and 1.9.
|
||||
|
@ -516,8 +516,8 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
isCommittee: {
|
||||
value: undefined,
|
||||
displayName: gettext('Committee'),
|
||||
choiceYes: gettext('Is committee'),
|
||||
choiceNo: gettext('Is not committee'),
|
||||
choiceYes: gettext('Is a committee'),
|
||||
choiceNo: gettext('Is not a committee'),
|
||||
},
|
||||
|
||||
};
|
||||
@ -591,6 +591,10 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
$scope.alert = { type: 'danger', msg: message, show: true };
|
||||
});
|
||||
};
|
||||
// delete single user
|
||||
$scope.delete = function (user) {
|
||||
User.destroy(user.id);
|
||||
};
|
||||
// *** select mode functions ***
|
||||
$scope.isSelectMode = false;
|
||||
// check all checkboxes
|
||||
@ -609,60 +613,60 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
});
|
||||
}
|
||||
};
|
||||
// delete all selected users
|
||||
$scope.deleteMultiple = function () {
|
||||
angular.forEach($scope.users, function (user) {
|
||||
var selectModeAction = function (predicate) {
|
||||
angular.forEach($scope.usersFiltered, function (user) {
|
||||
if (user.selected) {
|
||||
User.destroy(user.id);
|
||||
predicate(user);
|
||||
}
|
||||
});
|
||||
$scope.isSelectMode = false;
|
||||
$scope.uncheckAll();
|
||||
};
|
||||
// delete single user
|
||||
$scope.delete = function (user) {
|
||||
User.destroy(user.id);
|
||||
// delete all selected users
|
||||
$scope.deleteMultiple = function () {
|
||||
selectModeAction(function (user) {
|
||||
$scope.delete(user);
|
||||
});
|
||||
};
|
||||
// add group for selected users
|
||||
$scope.addGroupMultiple = function (group) {
|
||||
angular.forEach($scope.users, function (user) {
|
||||
if (user.selected) {
|
||||
if (group) {
|
||||
selectModeAction(function (user) {
|
||||
user.groups_id.push(group);
|
||||
User.save(user);
|
||||
}
|
||||
});
|
||||
$scope.isSelectMode = false;
|
||||
$scope.uncheckAll();
|
||||
});
|
||||
}
|
||||
};
|
||||
// remove group for selected users
|
||||
$scope.removeGroupMultiple = function (group) {
|
||||
angular.forEach($scope.users, function (user) {
|
||||
if (user.selected) {
|
||||
var groupIndex = user.groups_id.indexOf(parseInt(group));
|
||||
if (group) {
|
||||
selectModeAction(function (user) {
|
||||
var groupIndex = _.indexOf(user.groups_id, parseInt(group));
|
||||
if (groupIndex > -1) {
|
||||
user.groups_id.splice(groupIndex, 1);
|
||||
User.save(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
$scope.isSelectMode = false;
|
||||
$scope.uncheckAll();
|
||||
});
|
||||
}
|
||||
};
|
||||
// generate new passwords
|
||||
$scope.generateNewPasswordsMultiple = function () {
|
||||
angular.forEach($scope.users, function (user) {
|
||||
if (user.selected) {
|
||||
var newPassword = PasswordGenerator.generate();
|
||||
user.default_password = newPassword;
|
||||
User.save(user);
|
||||
$http.post(
|
||||
'/rest/users/user/' + user.id + '/reset_password/',
|
||||
{'password': newPassword}
|
||||
);
|
||||
}
|
||||
selectModeAction(function (user) {
|
||||
var newPassword = PasswordGenerator.generate();
|
||||
user.default_password = newPassword;
|
||||
User.save(user);
|
||||
$http.post(
|
||||
'/rest/users/user/' + user.id + '/reset_password/',
|
||||
{'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
|
||||
|
@ -71,6 +71,9 @@
|
||||
<option value="addGroup" translate>Add group</option>
|
||||
<option value="removeGroup" translate>Remove group</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>
|
||||
<!-- delete button -->
|
||||
<a ng-show="selectedAction == 'delete'"
|
||||
@ -104,6 +107,20 @@
|
||||
<i class="fa fa-magic"></i>
|
||||
<translate>Generate new passwords</translate>
|
||||
</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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user