<script id='redback/user-edit-tmpl' type='text/x-jquery-tmpl'>
-
- <div class="row">
- <div class="span10 columns">
- <form id="user-create">
- <fieldset id="user-create-fieldset">
- <div class="clearfix">
- <label for="username">${i18n('username')}</label>
- <div class="input" id="username-div">
- {{if $data.username.length>0}}
- <span class="uneditable-input">${$data.username}</span>
- {{else}}
- <input type="text" id="username" name="username" size="30" class="required" data-bind="value: username"/>
- {{/if}}
- </div>
- </div>
- <div class="clearfix">
- <label for="fullname">${i18n('full.name')}</label>
- <div class="input">
- <input type="text" id="fullname" name="fullname" size="30" class="required" data-bind="value: fullName"/>
- </div>
- </div>
- <div class="clearfix">
- <label for="password">${i18n('password')}</label>
- <div class="input">
- <input type="password" id="password" name="password" class="required" data-bind="value: password"/>
- </div>
- </div>
- <div class="clearfix">
- <label for="confirmPassword">${i18n('confirm.password')}</label>
- <div class="input">
- <input type="password" id="confirmPassword" name="confirmPassword" data-bind="value: confirmPassword"/>
- </div>
- </div>
- <div class="clearfix">
- <label for="email">${i18n('email.address')}</label>
- <div class="input">
- <input type="text" id="email" name="email" class="required email" data-bind="value: email"/>
- </div>
- </div>
- <div class="clearfix">
- <label for="validated">${i18n('validated')}</label>
- <div class="input">
- <input type="checkbox" id="validated" name="validated" data-bind="checked: validated"/>
- </div>
- </div>
- <div class="clearfix">
- <label for="locked">${i18n('locked')}</label>
- <div class="input">
- <input type="checkbox" id="locked" name="locked" data-bind="checked: locked"/>
- </div>
+<div id="edit-user-details-pills">
+ <ul id="edit_user_details_pills_headers" class="pills">
+ <li class="active" id="user-view-detail-li">
+ <a href="#user-create-div">${$.i18n.prop('user.details.edit')}</a>
+ </li>
+ <li id="user-edit-roles-edit-li">
+ <a href="#user-edit-roles-edit">${$.i18n.prop('effective.roles.edit')}</a>
+ </li>
+ </ul>
+ <div class="pill-content" id="edit-user-details-pills-content">
+ <div id="user-create-div" class="active">
+ <div class="row">
+ <div class="span8 columns">
+ <form id="user-create">
+ <fieldset id="user-create-fieldset">
+ <div class="clearfix">
+ <label for="username">${i18n('username')}</label>
+ <div class="input" id="username-div">
+ {{if $data.username.length>0}}
+ <span class="uneditable-input">${$data.username}</span>
+ {{else}}
+ <input type="text" id="username" name="username" size="30" class="required" data-bind="value: username"/>
+ {{/if}}
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="fullname">${i18n('full.name')}</label>
+ <div class="input">
+ <input type="text" id="fullname" name="fullname" size="30" class="required" data-bind="value: fullName"/>
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="password">${i18n('password')}</label>
+ <div class="input">
+ <input type="password" id="password" name="password" class="required" data-bind="value: password"/>
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="confirmPassword">${i18n('confirm.password')}</label>
+ <div class="input">
+ <input type="password" id="confirmPassword" name="confirmPassword" data-bind="value: confirmPassword"/>
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="email">${i18n('email.address')}</label>
+ <div class="input">
+ <input type="text" id="email" name="email" class="required email" data-bind="value: email"/>
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="validated">${i18n('validated')}</label>
+ <div class="input">
+ <input type="checkbox" id="validated" name="validated" data-bind="checked: validated"/>
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="locked">${i18n('locked')}</label>
+ <div class="input">
+ <input type="checkbox" id="locked" name="locked" data-bind="checked: locked"/>
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="passwordChangeRequired">${i18n('passwordChangeRequired')}</label>
+ <div class="input">
+ <input type="checkbox" id="passwordChangeRequired" name="passwordChangeRequired" data-bind="checked: passwordChangeRequired"/>
+ </div>
+ </div>
+ </fieldset>
+ <button data-bind="click: save" class="btn" id="user-create-form-register-button">${i18n('save')}</button>
+ <button class="btn" id="user-create-form-cancel-button">${i18n('cancel')}</button>
+ </form>
</div>
- <div class="clearfix">
- <label for="passwordChangeRequired">${i18n('passwordChangeRequired')}</label>
- <div class="input">
- <input type="checkbox" id="passwordChangeRequired" name="passwordChangeRequired" data-bind="checked: passwordChangeRequired"/>
- </div>
+ <div class="span8 columns" id="user-edit-roles">
+ <div id="user-edit-roles-view"></div>
</div>
- </fieldset>
- <button data-bind="click: save" class="btn" id="user-create-form-register-button">${i18n('save')}</button>
- <button class="btn" id="user-create-form-cancel-button">${i18n('cancel')}</button>
- </form>
- </div>
- <div class="span6 columns" id="user-edit-roles" style="display:none">
- <div class="page-header">
- <h3>${$.i18n.prop('effective.roles')}</h3>
</div>
- <div id="user-edit-roles-view"></div>
</div>
- </div>
+ <div id="user-edit-roles-edit">
+ roles edit
+ </div>
+ </div>
+</div>
</script>
+<script id="user_edit_roles_tmpl" type="text/x-jquery-tmpl">
+ <div class="page-header">
+ <h3>${$.i18n.prop('effective.roles')}</h3>
+ </div>
+ <div>
+ <ul>
+ {{each $data.roles}}
+ <li>${$value.name}</li>
+ {{/each}}
+ </ul>
+ </div>
+</script>
this.addUser=function() {
clearUserMessages();
window.redbackModel.createUser=true;
+ $("#createUserForm").html("");
$("#main-content #user-edit").remove();
$('#main-content #user-create').show();
ko.renderTemplate("redback/user-edit-tmpl", new User(), null, $("#createUserForm").get(0),"replaceChildren");
$("#main-content #createUserForm #user-create").delegate("#user-create-form-register-button", "click keydown", function(e) {
e.preventDefault();
});
+
+ // desactivate roles pill when adding user
+ $("#edit_user_details_pills_headers").hide();
+
};
this.lock = function(user){
this.editUserBox=function(user) {
window.redbackModel.createUser=false;
clearUserMessages();
+ activateUsersEditTab();
+ // if already created before
+ //$("#main-content #createUserForm").accordion("destroy");
+ $("#main-content #createUserForm").html("");
$("#main-content #createUserForm").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}');
- var viewModel = new userViewModel(user);
+ var viewModel = new UserViewModel(user);
ko.applyBindings(viewModel,$("#main-content #createUserForm").get(0));
- activateUsersEditTab();
-
- $("#users-view-tabs-li-user-edit a").html($.i18n.prop("user.edit"));
+ $("#main-content #users-view-tabs-li-user-edit a").html($.i18n.prop("user.edit"));
$("#main-content #user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
e.preventDefault();
user.update();
});
- $("#user-edit-roles").show();
- $( "#user-edit-roles-view" ).append(smallSpinnerImg());
+ $( "#main-content #user-edit-roles-view" ).append(smallSpinnerImg());
$.ajax("restServices/redbackServices/roleManagementService/getEffectivelyAssignedRoles/"+encodeURIComponent(user.username()), {
type: "GET",
async: false,
dataType: 'json',
success: function(data) {
- $("#user-edit-roles-view").show();
+ //$("#user-edit-roles-view").show();
var mappedRoles = $.map(data.role, function(item) {
return mapRole(item);
});
- //$( "#user-edit-roles-view" ).append( jQuery("#user_edit_roles_tmpl" ).tmpl( data.role ) );
viewModel.roles=mappedRoles;
- $( "#user-edit-roles-view").attr("data-bind",'template: {name:"user_edit_roles_tmpl"}');
+ $("#main-content #user-edit-roles-view").attr("data-bind",'template: {name:"user_edit_roles_tmpl"}');
ko.applyBindings(viewModel,$("#user-edit-roles-view").get(0));
- removeSmallSpinnerImg();
+ $("#main-content #edit-user-details-pills-headers").pills();
}
}
);
}
}
- userViewModel=function(user) {
+ UserViewModel=function(user) {
this.user=user;
this.roles = ko.observableArray(new Array());
}
window.redbackModel.usersViewModel = new usersViewModel();
window.redbackModel.usersViewModel.loadUsers();
ko.applyBindings(window.redbackModel.usersViewModel,jQuery("#main-content").get(0));
- $("#users-view-tabs").tabs();
- $("#users-view-tabs").bind('change', function (e) {
+ $("#main-content #users-view-tabs").tabs();
+ $("#main-content #users-view-tabs").bind('change', function (e) {
//$.log( $(e.target).attr("href") ); // activated tab
//e.relatedTarget // previous tab
if ($(e.target).attr("href")=="#createUserForm") {
window.redbackModel.usersViewModel.addUser();
}
if ($(e.target).attr("href")=="#users-view") {
- $("#users-view-tabs-li-user-edit a").html($.i18n.prop("user.add"));
+ $("#main-content #users-view-tabs-li-user-edit a").html($.i18n.prop("user.add"));
}
})
- $("#users-view-tabs-content #users-view").addClass("active");
+ $("#main-content #users-view-tabs-content #users-view").addClass("active");
}
activateUsersGridTab=function(){