From 683e06230d208197ee0ba7c864ce418999ef5090 Mon Sep 17 00:00:00 2001 From: Charles du Jeu Date: Wed, 24 Feb 2010 17:17:20 +0000 Subject: [PATCH] Fixes on natures management git-svn-id: https://svn.argeo.org/commons/trunk@3404 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../argeo/security/ria/UserEditorApplet.js | 22 ++++++++++++------- .../ria/components/CoworkerNatureImpl.js | 3 ++- .../security/ria/components/INaturePane.js | 3 ++- .../security/ria/components/NaturesManager.js | 21 +++++++++++++++--- .../ria/components/SimpleUserNatureImpl.js | 19 ++++++++++++---- .../security/ria/components/UserEditor.js | 12 +++++----- 6 files changed, 57 insertions(+), 23 deletions(-) diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js index 8e0eab7e1..829822829 100644 --- a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js @@ -64,8 +64,8 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet", selectionChange : function(viewName, data){ if(viewName != "editor") return; var iApplet = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("editor").getContent(); - if(iApplet && iApplet.getCurrentNatureTabs() && iApplet.getAvailableNatures() - && iApplet.getCurrentNatureTabs().length < qx.lang.Object.getLength(iApplet.getAvailableNatures())){ + if(iApplet && iApplet.getCurrentNatureTabs() && iApplet.getNaturesManager().getDetectedNatures() + && iApplet.getCurrentNatureTabs().length < qx.lang.Object.getLength(iApplet.getNaturesManager().getDetectedNatures())){ this.setEnabled(true); }else{ this.setEnabled(false); @@ -177,12 +177,18 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet", var removeButton = commands["remove_nature"].command.getFormButton(); var natureButton = commands["add_nature"].command.getFormButton(); - var detectedNatures = this.getAvailableNatures(); - var newMenu = []; - for(var key in detectedNatures){ - newMenu.push({"label" : detectedNatures[key].NATURE_LABEL, "icon":"", "commandId" : detectedNatures[key]}); - } - commands["add_nature"].command.setMenu(newMenu); + this.getNaturesManager().addListener("changeNonAssignedNatures", function(event){ + var natures = event.getData(); + var newMenu = []; + for(var key in natures){ + newMenu.push({ + "label" : natures[key].NATURE_LABEL, + "icon":"", + "commandId" : natures[key] + }); + } + commands["add_nature"].command.setMenu(newMenu); + }, this); natureButton.setShow("icon"); removeButton.setShow("icon"); diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/CoworkerNatureImpl.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/CoworkerNatureImpl.js index fff406806..c91e61ab2 100644 --- a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/CoworkerNatureImpl.js +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/CoworkerNatureImpl.js @@ -3,7 +3,8 @@ qx.Class.define("org.argeo.security.ria.components.CoworkerNatureImpl", { statics : { NATURE_TYPE : "org.argeo.security.nature.CoworkerNature", NATURE_LABEL : "Co-Worker", - NATURE_ICON : "" + NATURE_ICON : "", + NATURE_RANK : 1 }, construct : function(){ diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/INaturePane.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/INaturePane.js index 1938fa727..713f31417 100644 --- a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/INaturePane.js +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/INaturePane.js @@ -3,7 +3,8 @@ qx.Interface.define("org.argeo.security.ria.components.INaturePane", { statics : { NATURE_TYPE : "", NATURE_LABEL : "", - NATURE_ICON : "" + NATURE_ICON : "", + NATURE_RANK : 0 }, properties : { editMode : { diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/NaturesManager.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/NaturesManager.js index f15bb336b..8e21466fd 100644 --- a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/NaturesManager.js +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/NaturesManager.js @@ -2,7 +2,11 @@ qx.Class.define("org.argeo.security.ria.components.NaturesManager",{ extend : qx.core.Object, properties : { detectedNatures : { - check : "Map" + check : "Map" + }, + nonAssignedNatures : { + check : "Map", + event : "changeNonAssignedNatures" } }, construct : function(){ @@ -12,18 +16,27 @@ qx.Class.define("org.argeo.security.ria.components.NaturesManager",{ members : { detectNatures : function(){ var natures = {}; + var sortedNatures = {}; + var ranks = {}; for (var key in qx.Bootstrap.$$registry) { if (qx.Class.hasInterface(qx.Bootstrap.$$registry[key], org.argeo.security.ria.components.INaturePane)) { // FILTER BY ROLE HERE! var klass = qx.Bootstrap.$$registry[key]; natures[klass.NATURE_TYPE] = klass; + ranks[klass.NATURE_TYPE] = klass.NATURE_RANK; } } - this.setDetectedNatures(natures); + org.argeo.ria.util.Utils.asort(ranks); + for(var key in ranks){ + sortedNatures[key] = natures[key]; + } + this.setDetectedNatures(sortedNatures); + this.setNonAssignedNatures(sortedNatures); }, detectNaturesInData : function(userNaturesList){ var detected = this.getDetectedNatures(); var userDetected = []; + var nonAssigned = qx.lang.Object.clone(detected); for(var i = 0;i