]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ria/components/SimpleUserNatureImpl.js
Prepare next development cycle
[lgpl/argeo-commons.git] / ria / components / SimpleUserNatureImpl.js
1 qx.Class.define("org.argeo.security.ria.components.SimpleUserNatureImpl", {
2 extend : qx.ui.container.Composite,
3 implement : [org.argeo.security.ria.components.INaturePane],
4 events : {
5 "modified" : "qx.event.type.Event"
6 },
7 statics : {
8 NATURE_TYPE : "org.argeo.security.nature.SimpleUserNature",
9 NATURE_LABEL : "Simple User",
10 NATURE_ICON : ""
11 },
12 properties : {
13 valid : {
14 init : false
15 },
16 dataMap : {
17
18 },
19 editMode : {
20 init : true,
21 apply : "_applyEditMode",
22 event : "changeEditMode"
23 },
24 isNew : {
25 init : false,
26 check : "Boolean"
27 }
28 },
29
30 construct : function(){
31 this.base(arguments);
32 this.setDataMap({
33 type:"org.argeo.security.nature.SimpleUserNature"
34 });
35 this._createGui();
36 this.setEditMode(false);
37 },
38
39 members : {
40
41 _createGui : function(){
42 var grid = new qx.ui.layout.Grid(5,5);
43 this.setLayout(grid);
44 grid.setColumnFlex(0,1);
45 grid.setColumnAlign(0,"right", "middle");
46 grid.setColumnFlex(1,3);
47
48 this.mailField = new qx.ui.form.TextField();
49 this.fNameField = new qx.ui.form.TextField();
50 this.nameField = new qx.ui.form.TextField();
51
52 var labels = ["Email", "First Name", "Last Name"];
53 this.fields = {
54 "email" : this.mailField,
55 "firstName": this.fNameField,
56 "lastName" : this.nameField
57 };
58
59 for(var i=0;i<labels.length;i++){
60 this.add(new qx.ui.basic.Label(labels[i]), {row:i,column:0});
61 }
62 var j=0;
63 for(var key in this.fields){
64 this.fields[key].addListener("changeValue", function(e){this.fireEvent("modified");}, this);
65 this.add(this.fields[key], {row:j,column:1});
66 j++;
67 }
68 },
69
70 _applyEditMode : function(value){
71 for(var key in this.fields){
72 this.fields[key].setEnabled(value);
73 }
74 },
75
76 getContainer : function(){
77 return this;
78 },
79 setData : function(dataMap, format){
80 for(var key in this.fields){
81 if(dataMap[key]){
82 this.fields[key].setValue(dataMap[key]);
83 }
84 }
85 this.setDataMap(dataMap);
86 },
87 getData : function(format){
88 var dataMap = this.getDataMap();
89 for(var key in this.fields){
90 dataMap[key] = this.fields[key].getValue();
91 }
92 this.setDataMap(dataMap);
93 return dataMap;
94 },
95 validate : function(){return true;}
96 }
97 });