X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=security%2Fruntime%2Forg.argeo.security.ria%2Fsrc%2Fargeo-ria-lib%2Fsecurity%2Fclass%2Forg%2Fargeo%2Fsecurity%2Fria%2Fmodel%2FUser.js;h=4595fbcb5b103829aa9487fff848afbe0253eb10;hb=1af54f2dad396ac71d9872d82c2981e4ac9c2281;hp=9355388631334b6f880b50d00f9c2921b683607b;hpb=b9d6c8b6386de221d1a316f8e2c1ffec4b7bffce;p=lgpl%2Fargeo-commons.git diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/model/User.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/model/User.js index 935538863..4595fbcb5 100644 --- a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/model/User.js +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/model/User.js @@ -27,11 +27,49 @@ qx.Class.define("org.argeo.security.ria.model.User", { this.setNatures(data.userNatures); this.setRawData(data); }, + getSaveService : function(){ + var userService = org.argeo.security.ria.SecurityAPI.getUpdateUserService(this.toJSON()); + userService.addListener("completed", function(response){ + if(!response || !response.username) return; + this.load(response.getContent(), "json"); + }, this); + return userService; + }, toJSON : function(){ var rawData = this.getRawData(); rawData.username = this.getName(); rawData.roles = this.getRoles(); rawData.userNatures = this.getNatures(); + return rawData; + }, + _getNatureByType : function(natureType){ + var found = false; + this.getNatures().forEach(function(el){ + if(el.type == natureType){ + found = el; + } + }); + return found; + }, + addNature : function(nature){ + if(this._getNatureByType(nature.type)){ + return; + } + this.getNatures().push(nature); + }, + removeNature : function(natureType){ + var foundNature = this._getNatureByType(natureType) + if(foundNature){ + qx.lang.Array.remove(this.getNatures(), foundNature); + } + }, + updateNature : function(nature){ + var natures = this.getNatures(); + for(var i=0;i