* @param ownerViewModel
*/
User=function(username, password, confirmPassword,fullName,email,permanent,validated,timestampAccountCreation,
- timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel) {
+ timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel,readOnly) {
var self=this;
// Potentially Editable Field.
this.username = ko.observable(username);
this.modified=ko.observable(false);
+ this.readOnly=readOnly;
+
this.rememberme=false;
this.logged=false;
$("#modal-password-change").focus();
}
+ EditUserDetailViewModel=function(user){
+ this.user=user;
+ }
+
/**
* display modal box for updating current user details
*/
});
}
var currentUser = getUserFromLoginCookie();
- $("#modal-user-edit").find("#username").html(currentUser.username);
+ /*$("#modal-user-edit").find("#username").html(currentUser.username);
$("#modal-user-edit").find("#fullname").val(currentUser.fullName);
- $("#modal-user-edit").find("#email").val(currentUser.email);
+ $("#modal-user-edit").find("#email").val(currentUser.email);*/
+
+ $("#modal-user-edit-content" ).attr("data-bind",'template: {name:"modal-user-edit-tmpl"}');
+
+ var editUserDetailViewModel=new EditUserDetailViewModel(currentUser);
+ ko.applyBindings(editUserDetailViewModel,$("#modal-user-edit-content").get(0));
+
+ //$("#modal-user-edit-content").html($("#modal-user-edit-tmpl").tmpl({user: currentUser} ));
+
window.modalEditUserBox.modal('show');
$("#user-edit-form").validate({
rules: {
dataType: 'json',
success: function(result) {
var created = result;
- // FIXME i18n
if (created == true) {
displaySuccessMessage( $.i18n.prop("user.details.updated"));
window.modalEditUserBox.modal('hide');
mapUser=function(data) {
return new User(data.username, data.password, null,data.fullName,data.email,data.permanent,data.validated,
data.timestampAccountCreation,data.timestampLastLogin,data.timestampLastPasswordChange,
- data.locked,data.passwordChangeRequired,self);
+ data.locked,data.passwordChangeRequired,self,data.readOnly);
}
<h3>${$.i18n.prop('password.section.title')}</h3>
</div>
<div class="modal-body" id="modal-user-edit-content">
- <form id="user-edit-form" class="form-horizontal">
- <div id="modal-user-edit-err-message" class="alert-message error" style="display:none"></div>
- <fieldset>
- <div class="control-group">
- <label class="control-label" for="username">${$.i18n.prop('username')}</label>
- <div class="controls" id="username-div">
- <span class="uneditable-input" id="username"></span>
- </div>
+
+ </div>
+ <div class="modal-footer" id="modal-user-edit-footer">
+ <button class="btn primary" onclick="return" id="modal-user-edit-ok">${$.i18n.prop('ok')}</button>
+ </div>
+</div>
+
+<script type="text/html" id="modal-user-edit-tmpl">
+
+ <form id="user-edit-form" class="form-horizontal">
+ <div id="modal-user-edit-err-message" class="alert-message error" style="display:none"></div>
+ <fieldset>
+ <div class="control-group">
+ <label class="control-label" for="username">${$.i18n.prop('username')}</label>
+ <div class="controls" id="username-div">
+ <span class="uneditable-input" data-bind="text: user.username"></span>
</div>
- <div class="control-group">
- <label class="control-label" for="fullname">${$.i18n.prop('full.name')}</label>
- <div class="controls">
- <input type="text" id="fullname" name="fullname" size="30" class="required"/>
- </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="fullname">${$.i18n.prop('full.name')}</label>
+ <div class="controls">
+ <input type="text" id="fullname" name="fullname" size="30" class="required" data-bind="value: user.fullName"/>
</div>
- <div class="control-group">
- <label class="control-label" for="email">${$.i18n.prop('email.address')}</label>
- <div class="controls">
- <input type="text" id="email" name="email" size="30" class="required email"/>
- </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="email">${$.i18n.prop('email.address')}</label>
+ <div class="controls">
+ <input type="text" id="email" name="email" size="30" class="required email" data-bind="value: user.email"/>
</div>
- <div class="control-group" id="user-edit-form-current-password-div">
- <label class="control-label" for="userEditFormCurrentPassword">${$.i18n.prop('password.existing')}</label>
- <div class="controls">
- <input type="password" id="userEditFormCurrentPassword" name="userEditFormCurrentPassword" class="required" value=""/>
- </div>
+ </div>
+ <div class="control-group" id="user-edit-form-current-password-div">
+ <label class="control-label" for="userEditFormCurrentPassword">${$.i18n.prop('password.existing')}</label>
+ <div class="controls">
+ <input type="password" id="userEditFormCurrentPassword" name="userEditFormCurrentPassword" class="required" value=""/>
</div>
+ </div>
- <div class="control-group">
- <label class="control-label" for="userEditFormNewPassword">${$.i18n.prop('password.new')}</label>
- <div class="controls">
- <input type="password" id="userEditFormNewPassword" name="userEditFormNewPassword" class="" value=""/>
- </div>
+ <div class="control-group">
+ <label class="control-label" for="userEditFormNewPassword">${$.i18n.prop('password.new')}</label>
+ <div class="controls">
+ <input type="password" id="userEditFormNewPassword" name="userEditFormNewPassword" class="" value=""/>
</div>
+ </div>
- <div class="control-group">
- <label class="control-label" for="userEditFormNewPasswordConfirm">${$.i18n.prop('password.new.confirm')}</label>
- <div class="controls">
- <input type="password" id="userEditFormNewPasswordConfirm" name="userEditFormNewPasswordConfirm" class="" value=""/>
- </div>
+ <div class="control-group">
+ <label class="control-label" for="userEditFormNewPasswordConfirm">${$.i18n.prop('password.new.confirm')}</label>
+ <div class="controls">
+ <input type="password" id="userEditFormNewPasswordConfirm" name="userEditFormNewPasswordConfirm" class="" value=""/>
</div>
- </fieldset>
- </form>
- </div>
- <div class="modal-footer" id="modal-user-edit-footer">
- <button class="btn primary" onclick="return" id="modal-user-edit-ok">${$.i18n.prop('ok')}</button>
- </div>
-</div>
+ </div>
+ </fieldset>
+ </form>
+
+</script>