KEYCLOAK-362 - fixing the select2 with req user actions

This commit is contained in:
Viliam Rockai 2014-03-11 16:07:48 +01:00
parent 03a0cce119
commit ccc4f5a114
2 changed files with 4 additions and 27 deletions

View file

@ -179,38 +179,13 @@ module.controller('UserDetailCtrl', function($scope, realm, user, User, $locatio
$scope.changed = false; // $scope.create;
// ID - Name map for required actions. IDs are enum names.
var userReqActionList = [
$scope.userReqActionList = [
{id: "VERIFY_EMAIL", text: "Verify Email"},
{id: "UPDATE_PROFILE", text: "Update Profile"},
{id: "CONFIGURE_TOTP", text: "Configure Totp"},
{id: "UPDATE_PASSWORD", text: "Update Password"}
];
// Options for the req actions tag selector
$scope.userReqActionsOptions = {
'multiple' : true,
'tags' : userReqActionList
};
// Model for the req actions tag selector
$scope.userActions = [];
for (var i = 0; i < userReqActionList.length; i++){
var action = userReqActionList[i];
if ($scope.user.requiredActions && $scope.user.requiredActions.indexOf(action.id) > -1){
$scope.userActions.push({id: action.id, text: action.text});
}
}
// Watching ui-select2 model to properly format the req actions for user
$scope.$watch("userActions", function(newValue, oldValue) {
$scope.user.requiredActions = [];
for (var i=0; i < newValue.length; i++){
var action = newValue[i];
$scope.user.requiredActions.push(action.id);
}
});
$scope.$watch('user', function() {
if (!angular.equals($scope.user, user)) {
$scope.changed = true;

View file

@ -76,7 +76,9 @@
<label class="col-sm-2 control-label" for="reqActions">Required User Actions</label>
<div class="col-sm-4">
<input type="text" ui-select2="userReqActionsOptions" ng-model="userActions" id="reqActions"/>
<select ui-select2 ng-model="user.requiredActions" data-placeholder="Select an action..." multiple>
<option ng-repeat="action in userReqActionList" value="{{action.id}}">{{action.text}}</option>
</select>
</div>
</div>
</fieldset>