]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - ria/model/User.js
1 qx
.Class
.define("org.argeo.security.ria.model.User", {
2 extend
: qx
.core
.Object
,
22 construct : function(){
26 this.setRawData({"password":"{SHA}ieSV55Qc+eQOaYDRSha/AjzNTJE="});
29 load : function(data
, format
){
30 this.setCreate(false);
31 this.setName(data
.username
);
32 this.setRoles(data
.roles
);
33 this.setNatures(data
.userNatures
);
34 this.setRawData(data
);
36 getSaveService : function(){
38 var userService
= org
.argeo
.security
.ria
.SecurityAPI
.getCreateUserService(this.toJSON());
40 var userService
= org
.argeo
.security
.ria
.SecurityAPI
.getUpdateUserService(this.toJSON());
42 userService
.addListener("completed", function(response
){
43 if(!response
|| !response
.username
) return;
44 this.load(response
.getContent(), "json");
49 var rawData
= this.getRawData();
50 rawData
.username
= this.getName();
51 rawData
.roles
= this.getRoles();
52 rawData
.userNatures
= this.getNatures();
55 _getNatureByType : function(natureType
){
57 this.getNatures().forEach(function(el
){
58 if(el
.type
== natureType
){
64 addNature : function(nature
){
65 if(this._getNatureByType(nature
.type
)){
68 this.getNatures().push(nature
);
70 removeNature : function(natureType
){
71 var foundNature
= this._getNatureByType(natureType
)
73 qx
.lang
.Array
.remove(this.getNatures(), foundNature
);
76 updateNature : function(nature
){
77 var natures
= this.getNatures();
78 for(var i
=0;i
<natures
;i
++){
79 if(natures
[i
].type
== nature
.type
){