]>
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
2 * A simple Hello World applet for documentation purpose.
3 * The only associated command is the "Close" command.
5 /* *************************************************
6 #asset(resource/org.argeo.security.ria/*)
7 ****************************************************/
8 qx
.Class
.define("org.argeo.security.ria.UserEditorApplet",
10 extend
: qx
.ui
.container
.Composite
,
11 implement
: [org
.argeo
.ria
.components
.IView
],
13 construct : function(){
15 this.setLayout(new qx
.ui
.layout
.VBox());
16 //this.setDecorator("tabview-pane");
22 * The viewPane inside which this applet is added.
28 * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
34 icon
: "org.argeo.security.ria/document-save.png",
35 shortcut
: "Control+s",
39 callback : function(e
){
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));
53 icon
: "org.argeo.security.ria/window-close.png",
54 shortcut
: "Control+w",
58 callback : function(e
){
59 // Call service to delete
60 var iApplet
= org
.argeo
.ria
.components
.ViewsManager
.getInstance().getViewPaneById("editor").getContent();
61 if(!iApplet
.getModified()){
62 this.getView().closeCurrent();
65 var modal
= new org
.argeo
.ria
.components
.Modal("Warning");
66 modal
.addConfirm("There are unsaved changes!\n Are you sure you want to close?");
67 modal
.addListener("ok", function(){
68 this.getView().closeCurrent();
70 modal
.attachAndShow();
78 check
:"org.argeo.ria.components.ViewSelection"
86 instanceId
: {init
:""},
87 instanceLabel
: {init
:"Editor"}
93 * Called at applet creation. Just registers viewPane.
94 * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane.
96 init : function(viewPane
, data
){
99 this.setInstanceId(now
.getTime());
100 this.setInstanceLabel("New User");
102 this.setInstanceId(data
);
103 this.setInstanceLabel("User " + data
);
105 this.setView(viewPane
);
106 this.setViewSelection(new org
.argeo
.ria
.components
.ViewSelection(viewPane
.getViewId()));
109 this.basicGB
= new qx
.ui
.groupbox
.GroupBox("Base Informations");
110 var grid
= new qx
.ui
.layout
.Grid(5,5);
111 this.basicGB
.setLayout(grid
);
112 grid
.setColumnFlex(0,1);
113 grid
.setColumnAlign(0,"right", "middle");
114 grid
.setColumnFlex(1,2);
115 this._initializeGroupBox(this.basicGB
);
117 this.passGB
= new qx
.ui
.groupbox
.GroupBox("Set/Modify Password");
118 this.passGB
.setLayout(new qx
.ui
.layout
.VBox());
119 this._initializeGroupBox(this.passGB
);
121 this.naturesGB
= new qx
.ui
.groupbox
.GroupBox("User Natures");
122 this.naturesGB
.setLayout(new qx
.ui
.layout
.Dock());
123 this._initializeGroupBox(this.naturesGB
);
125 this.add(this.basicGB
);
126 this.add(this.passGB
);
127 this.add(this.naturesGB
, {flex
:1});
130 this.usernameField
= new qx
.ui
.form
.TextField();
131 this.basicGB
.add(new qx
.ui
.basic
.Label("Username"), {row
:0,column
:0});
132 this.basicGB
.add(this.usernameField
, {row
:0,column
:1});
134 this.rolesField
= new org
.argeo
.ria
.components
.ui
.MultipleComboBox();
135 this.rolesField
.setChoiceValues(["ROLE_ADMIN", "ROLE_USER", "ROLE_USER1"]);
136 this.basicGB
.add(new qx
.ui
.basic
.Label("Roles"), {row
:1,column
:0});
137 this.basicGB
.add(this.rolesField
, {row
:1,column
:1});
139 this.passPane
= new org
.argeo
.security
.ria
.components
.PasswordCredentialImpl();
140 this.passGB
.add(this.passPane
.getContainer());
142 this.naturesTab
= new qx
.ui
.tabview
.TabView("top");
143 this.simpleNature
= new org
.argeo
.security
.ria
.components
.SimpleUserNatureImpl();
145 var page1
= new qx
.ui
.tabview
.Page(this.simpleNature
.getNatureLabel());
146 page1
.setLayout(new qx
.ui
.layout
.Dock());
147 page1
.add(this.simpleNature
.getContainer(), {edge
:"center"});
148 this.naturesTab
.add(page1
);
149 this.naturesGB
.add(this.naturesTab
, {edge
:"center"});
153 _attachListeners : function(){
154 this.usernameField
.addListener("changeValue", function(){
155 this.setModified(true);
157 this.rolesField
.addListener("changeValue", function(){
158 this.setModified(true);
160 this.passPane
.addListener("modified", function(){
161 this.setModified(true);
163 this.simpleNature
.addListener("modified", function(){
164 this.setModified(true);
168 _initializeGroupBox: function(groupBox
){
169 groupBox
.setPadding(0);
170 groupBox
.getChildrenContainer().setPadding(8);
174 * Load a given row : the data passed must be a simple data array.
175 * @param data {Element} The text xml description.
177 load : function(userData
){
179 this.usernameField
.setValue(userData
);
181 this.setRolesList(["ROLE_ADMIN", "ROLE_USER"]);
182 this._attachListeners();
185 addScroll : function(){