* The only associated command is the "Close" command.
*/
/* *************************************************
-#asset(resource/org.argeo.security.ria/*)
+#asset(resource/org/argeo/security/ria/*)
****************************************************/
qx.Class.define("org.argeo.security.ria.components.UserEditor",
{
properties :
{
+ selfEdition : {
+ init : false
+ },
modified : {
init : false,
apply : "_applyDetailsModified"
},
currentNatureTabs : {
},
- availableNatures : {
+ naturesManager : {
+ check : "org.argeo.security.ria.components.NaturesManager"
},
selectedNatureTab : {
nullable : true
{
initGUI : function(ROLES_LIST){
- this.naturesManager = new org.argeo.security.ria.components.NaturesManager();
- var detectedNatures = this.naturesManager.getDetectedNatures();
- this.setAvailableNatures(detectedNatures);
+ var naturesManager = new org.argeo.security.ria.components.NaturesManager();
+ this.setNaturesManager(naturesManager);
// TOOLBAR
this.buttonGB = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, "right"));
this.basicGB.add(new qx.ui.basic.Label("Roles"), {row:1,column:0});
this.basicGB.add(this.rolesField, {row:1,column:1});
- this.passPane = new org.argeo.security.ria.components.PasswordCredentialImpl();
+ this.passPane = new org.argeo.security.ria.components.PasswordCredentialImpl(this.getSelfEdition());
this.passGB.add(this.passPane.getContainer());
//this.naturesTab.add(this.basicPage);
this.fakePane.setMarginTop(30);
this.add(this.fakePane, {flex:1});
- title = new qx.ui.basic.Atom("User Details", "org.argeo.security.ria/preferences-users.png");
+ title = new qx.ui.basic.Atom("User Details", "org/argeo/security/ria/preferences-users.png");
title.setFont(qx.bom.Font.fromString("16px sans-serif bold"));
this.buttonGB.add(title);
this.buttonGB.add(new qx.ui.core.Spacer(), {flex:1});
- var title2 = new qx.ui.basic.Atom("User Natures", "org.argeo.security.ria/identity.png");
+ var title2 = new qx.ui.basic.Atom("User Natures", "org/argeo/security/ria/identity.png");
title2.setFont(qx.bom.Font.fromString("16px sans-serif bold"));
this.natureButtonGB.add(title2);
this.natureButtonGB.add(new qx.ui.core.Spacer(), {flex:1});
if(pass != null && !this.passPane.validate()){
this.error("Warning, passwords differ!");
return;
- }
+ }
}
this.passPane.clear();
var saveCompletedCallback = qx.lang.Function.bind(function(){
this.setModified(false);
this.fireDataEvent("savedUser", user);
}, this);
- var userService = user.getSaveService();
+ var userService = user.getSaveService(this.getSelfEdition());
userService.addListener("completed", function(response){
if(response.getContent().status && response.getContent().status == "ERROR"){
return;
}
user.load(response.getContent(), "json");
if(pass!=null){
- var passService = org.argeo.security.ria.SecurityAPI.getUpdateUserPassService(user.getName(), pass);
+ var passService;
+ if(!this.getSelfEdition()){
+ passService = org.argeo.security.ria.SecurityAPI.getUpdateUserPassService(user.getName(), pass);
+ }else{
+ passService = org.argeo.security.ria.SecurityAPI.getUpdatePassService(pass.oldPass, pass.newPass);
+ }
passService.addListener("completed", function(response){
- if(response.getContent().status){
+ if(response.getContent().status != "ERROR"){
this.info(response.getContent().message);
}
saveCompletedCallback();
page.setLayout(new qx.ui.layout.Dock());
page.setUserData("NATURE_CLASS", natureClass);
var newClass = new natureClass();
- page.add(newClass.getContainer(), {edge:"center"});
+ page.add(new qx.ui.container.Scroll(newClass.getContainer()), {edge:"center"});
buttons = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, "center"));
- var editB = new qx.ui.form.Button("Edit this Nature", "org.argeo.security.ria/document-properties-22.png");
- var saveB = new qx.ui.form.Button("Save", "org.argeo.security.ria/dialog-apply.png");
- var cancelB = new qx.ui.form.Button("Cancel", "org.argeo.security.ria/dialog-cancel.png");
+ var editB = new qx.ui.form.Button("Edit this Nature", "org/argeo/security/ria/document-properties-22.png");
+ var saveB = new qx.ui.form.Button("Save", "org/argeo/security/ria/dialog-apply.png");
+ var cancelB = new qx.ui.form.Button("Cancel", "org/argeo/security/ria/dialog-cancel.png");
buttons.add(editB);
buttons.add(saveB);
buttons.add(cancelB);
this.usernameField.setValue(user.getName());
this.usernameField.setReadOnly(true);
this.rolesField.setValue(user.getRoles());
- var userNatureTabs = this.naturesManager.detectNaturesInData(user.getNatures());
+ var userNatureTabs = this.getNaturesManager().detectNaturesInData(user.getNatures());
if(userNatureTabs.length){
userNatureTabs.forEach(function(el){
this._addNatureTab(el.NATURE_CLASS, el.NATURE_DATA);
userDataService.send();
},
+ clearUserData : function(){
+ this.usernameField.setValue("");
+ this.rolesField.setValue([]);
+ this.removeAllTabs();
+ },
+
partialRefreshUser : function(user, target){
if(!qx.lang.Type.isArray(target)) target = [target];
var selectedTab = this.getSelectedNatureTab().getUserData("NATURE_CLASS");
}
this.removeAllTabs();
- var userNatureTabs = this.naturesManager.detectNaturesInData(user.getNatures());
+ var userNatureTabs = this.getNaturesManager().detectNaturesInData(user.getNatures());
if(userNatureTabs.length){
userNatureTabs.forEach(function(el){
this._addNatureTab(el.NATURE_CLASS, el.NATURE_DATA, (selectedTab && selectedTab == el.NATURE_CLASS));