]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js
7f18caaed2e49245245013ef2315273c636feb2e
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.ria / src / argeo-ria-lib / security / class / org / argeo / security / ria / UserEditorApplet.js
1 /**
2 * A simple Hello World applet for documentation purpose.
3 * The only associated command is the "Close" command.
4 */
5 /* *************************************************
6 #asset(resource/org.argeo.ria.sample/window-close.png)
7 ****************************************************/
8 qx.Class.define("org.argeo.security.ria.UserEditorApplet",
9 {
10 extend : qx.ui.container.Composite,
11 implement : [org.argeo.ria.components.IView],
12
13 construct : function(){
14 this.base(arguments);
15 this.setLayout(new qx.ui.layout.VBox());
16 //this.setDecorator("tabview-pane");
17 },
18
19 properties :
20 {
21 /**
22 * The viewPane inside which this applet is added.
23 */
24 view : {
25 init : null
26 },
27 /**
28 * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
29 */
30 commands : {
31 init : {
32 "save_user" : {
33 label : "Save",
34 icon : "ria/window-close.png",
35 shortcut : "Control+s",
36 enabled : true,
37 menu : "Users",
38 toolbar : "user",
39 callback : function(e){
40
41 },
42 selectionChange : function(viewName, data){
43 if(viewName != "editor") return;
44 var iApplet = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("editor").getContent();
45 if(iApplet == null) this.setEnabled(true);
46 this.setEnabled(iApplet.getModified());
47 //this.setEnabled(!(data == null || !data.length || data.length > 1));
48 },
49 command : null
50 },
51 "close" : {
52 label : "Close",
53 icon : "org.argeo.ria.sample/window-close.png",
54 shortcut : "Control+w",
55 enabled : true,
56 menu : "Users",
57 toolbar : "user",
58 callback : function(e){
59 // Call service to delete
60 this.getView().closeCurrent();
61 },
62 command : null
63 }
64 }
65 },
66 viewSelection : {
67 nullable:false,
68 check:"org.argeo.ria.components.ViewSelection"
69 },
70 modified : {
71 init : false
72 },
73 rolesList : {
74
75 },
76 instanceId : {init:""},
77 instanceLabel : {init:"Editor"}
78 },
79
80 members :
81 {
82 /**
83 * Called at applet creation. Just registers viewPane.
84 * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane.
85 */
86 init : function(viewPane, data){
87 if(!data){
88 var now = new Date();
89 this.setInstanceId(now.getTime());
90 this.setInstanceLabel("New User");
91 }else{
92 this.setInstanceId(data);
93 this.setInstanceLabel("User " + data);
94 }
95 this.setView(viewPane);
96 this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
97
98 // GROUPBOXES
99 this.basicGB = new qx.ui.groupbox.GroupBox("Base Informations");
100 var grid = new qx.ui.layout.Grid(5,5);
101 this.basicGB.setLayout(grid);
102 grid.setColumnFlex(0,1);
103 grid.setColumnAlign(0,"right", "middle");
104 grid.setColumnFlex(1,2);
105 this._initializeGroupBox(this.basicGB);
106
107 this.passGB = new qx.ui.groupbox.GroupBox("Set/Modify Password");
108 this.passGB.setLayout(new qx.ui.layout.VBox());
109 this._initializeGroupBox(this.passGB);
110
111 this.naturesGB = new qx.ui.groupbox.GroupBox("User Natures");
112 this.naturesGB.setLayout(new qx.ui.layout.Dock());
113 this._initializeGroupBox(this.naturesGB);
114
115 this.add(this.basicGB);
116 this.add(this.passGB);
117 this.add(this.naturesGB, {flex:1});
118
119 // FIELDS
120 this.usernameField = new qx.ui.form.TextField();
121 this.usernameField.addListener("changeValue", function(){
122 this.setModified(true);
123 this.getViewSelection().triggerEvent();
124 }, this);
125 this.basicGB.add(new qx.ui.basic.Label("Username"), {row:0,column:0});
126 this.basicGB.add(this.usernameField, {row:0,column:1});
127
128 this.rolesField = new org.argeo.ria.components.ui.MultipleComboBox();
129 this.rolesField.setChoiceValues(["ROLE_ADMIN", "ROLE_USER", "ROLE_USER1"]);
130 this.basicGB.add(new qx.ui.basic.Label("Roles"), {row:1,column:0});
131 this.basicGB.add(this.rolesField, {row:1,column:1});
132
133 this.passPane = new org.argeo.security.ria.components.PasswordCredentialImpl();
134 this.passGB.add(this.passPane.getContainer());
135
136 this.naturesTab = new qx.ui.tabview.TabView("top");
137 this.simpleNature = new org.argeo.security.ria.components.SimpleUserNatureImpl();
138 var page1 = new qx.ui.tabview.Page(this.simpleNature.getNatureLabel());
139 page1.setLayout(new qx.ui.layout.Dock());
140 page1.add(this.simpleNature.getContainer(), {edge:"center"});
141 this.naturesTab.add(page1);
142 this.naturesGB.add(this.naturesTab, {edge:"center"});
143
144 },
145
146 _initializeGroupBox: function(groupBox){
147 groupBox.setPadding(0);
148 groupBox.getChildrenContainer().setPadding(8);
149 },
150
151 /**
152 * Load a given row : the data passed must be a simple data array.
153 * @param data {Element} The text xml description.
154 */
155 load : function(userData){
156 if(userData){
157 this.usernameField.setValue(userData);
158 }
159 this.setRolesList(["ROLE_ADMIN", "ROLE_USER"]);
160 },
161
162 addScroll : function(){
163 return false;
164 },
165
166 close : function(){
167 return false;
168 }
169
170 }
171 });