]>
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
: org
.argeo
.security
.ria
.components
.UserEditor
,
11 implement
: [org
.argeo
.ria
.components
.IView
],
13 construct : function(){
20 * The viewPane inside which this applet is added.
26 * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
32 icon
: "org.argeo.security.ria/document-save.png",
33 shortcut
: "Control+s",
37 callback : function(e
){
38 // CALL SERVICE AND GET UP TO DATE USER
41 selectionChange : function(viewName
, data
){
42 if(viewName
!= "editor") return;
43 var iApplet
= org
.argeo
.ria
.components
.ViewsManager
.getInstance().getViewPaneById("editor").getContent();
44 this.setEnabled(iApplet
.getModified());
49 label
: "Add Nature ...",
50 icon
: "org.argeo.security.ria/list-add.png",
55 callback : function(e
){
57 submenuCallback : function(commandClass
){
58 this._addNatureTab(commandClass
, null, true);
61 {"label" : "Totot", "icon":"","commandId" : "toto"},
62 {"label" : "Totot", "icon":"","commandId" : "toto"}
64 selectionChange : function(viewName
, data
){
65 if(viewName
!= "editor") return;
66 var iApplet
= org
.argeo
.ria
.components
.ViewsManager
.getInstance().getViewPaneById("editor").getContent();
67 if(iApplet
&& iApplet
.getCurrentNatureTabs() && iApplet
.getAvailableNatures()
68 && iApplet
.getCurrentNatureTabs().length
< qx
.lang
.Object
.getLength(iApplet
.getAvailableNatures())){
69 this.setEnabled(true);
71 this.setEnabled(false);
77 label
: "Remove Nature",
78 icon
: "org.argeo.security.ria/list-remove.png",
83 callback : function(e
){
84 this.removeSelectedTab();
86 selectionChange : function(viewName
, data
){
87 if(viewName
!= "editor") return;
88 var iApplet
= org
.argeo
.ria
.components
.ViewsManager
.getInstance().getViewPaneById("editor").getContent();
89 if(iApplet
&& iApplet
.getSelectedNatureTab() && iApplet
.getSelectedNatureTab().getUserData("NATURE_CLASS")){
90 this.setEnabled(true);
92 this.setEnabled(false);
99 icon
: "org.argeo.security.ria/window-close.png",
100 shortcut
: "Control+w",
104 callback : function(e
){
105 // Call service to delete
106 var iApplet
= org
.argeo
.ria
.components
.ViewsManager
.getInstance().getViewPaneById("editor").getContent();
107 if(!iApplet
.getModified() && !iApplet
.getNaturesModified()){
108 this.getView().closeCurrent();
111 var modal
= new org
.argeo
.ria
.components
.Modal("Warning");
112 modal
.addConfirm("There are unsaved changes!\n Are you sure you want to close?");
113 modal
.addListener("ok", function(){
114 this.getView().closeCurrent();
116 modal
.attachAndShow();
124 check
:"org.argeo.ria.components.ViewSelection"
128 event
: "changeInstanceId"
132 event
: "changeInstanceLabel"
139 * Called at applet creation. Just registers viewPane.
140 * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane.
142 init : function(viewPane
, data
){
144 var now
= new Date();
145 this.setInstanceId(now
.getTime());
146 this.setInstanceLabel("New User");
148 this.setInstanceId(data
.USER
);
149 this.setInstanceLabel("User " + data
.USER
);
151 this.setView(viewPane
);
152 this.setViewSelection(new org
.argeo
.ria
.components
.ViewSelection(viewPane
.getViewId()));
154 this.initGUI(data
.ROLES_LIST
);
156 this.addListener("savedUser", function(e
){
157 if(this.getCurrentUser()){
158 this.setInstanceLabel("User " + this.getCurrentUser().getName());
159 this.setInstanceId(this.getCurrentUser().getName());
166 * Load a given row : the data passed must be a simple data array.
167 * @param data {Element} The text xml description.
169 load : function(userName
){
170 if(this.getLoaded()){
173 // MUST BE DONE AFTER COMMANDS ARE INITIALIZED!
174 var commands
= this.getCommands();
175 var saveButton
= commands
["save_user"].command
.getFormButton();
176 var closeButton
= commands
["close"].command
.getFormButton();
177 var removeButton
= commands
["remove_nature"].command
.getFormButton();
178 var natureButton
= commands
["add_nature"].command
.getFormButton();
180 var detectedNatures
= this.getAvailableNatures();
182 for(var key
in detectedNatures
){
183 newMenu
.push({"label" : detectedNatures
[key
].NATURE_LABEL
, "icon":"", "commandId" : detectedNatures
[key
]});
185 commands
["add_nature"].command
.setMenu(newMenu
);
187 natureButton
.setShow("icon");
188 removeButton
.setShow("icon");
189 saveButton
.setShow("icon");
190 closeButton
.setShow("icon");
192 this.buttonGB
.add(saveButton
);
193 this.buttonGB
.add(closeButton
);
194 this.natureButtonGB
.add(natureButton
);
195 this.natureButtonGB
.add(removeButton
);
198 this.loadUserData(userName
);
199 this._setGuiInCreateMode(false);
201 this.setCurrentUser(new org
.argeo
.security
.ria
.model
.User());
202 this._setGuiInCreateMode(true);
203 this._attachListeners();
204 this.setModified(true);
208 this.setLoaded(true);
212 _applyDetailsModified : function(value
){
213 if(value
) this.getViewSelection().triggerEvent();
216 _applyNaturesModified : function(value
){
217 if(value
) this.getViewSelection().triggerEvent();
220 addScroll : function(){