this.setNatures(data.userNatures);\r
this.setRawData(data);\r
},\r
+ getSaveService : function(){\r
+ var userService = org.argeo.security.ria.SecurityAPI.getUpdateUserService(this.toJSON());\r
+ userService.addListener("completed", function(response){\r
+ if(!response || !response.username) return;\r
+ this.load(response.getContent(), "json");\r
+ }, this);\r
+ return userService; \r
+ },\r
toJSON : function(){\r
var rawData = this.getRawData();\r
rawData.username = this.getName();\r
rawData.roles = this.getRoles();\r
rawData.userNatures = this.getNatures();\r
+ return rawData;\r
+ },\r
+ _getNatureByType : function(natureType){\r
+ var found = false;\r
+ this.getNatures().forEach(function(el){\r
+ if(el.type == natureType){\r
+ found = el;\r
+ }\r
+ }); \r
+ return found;\r
+ },\r
+ addNature : function(nature){\r
+ if(this._getNatureByType(nature.type)){\r
+ return;\r
+ }\r
+ this.getNatures().push(nature);\r
+ },\r
+ removeNature : function(natureType){\r
+ var foundNature = this._getNatureByType(natureType)\r
+ if(foundNature){\r
+ qx.lang.Array.remove(this.getNatures(), foundNature);\r
+ }\r
+ },\r
+ updateNature : function(nature){\r
+ var natures = this.getNatures();\r
+ for(var i=0;i<natures;i++){\r
+ if(natures[i].type == nature.type){\r
+ natures[i] = nature;\r
+ }\r
+ }\r
}\r
}\r
\r