]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/NaturesManager.js
Lot of changes in the user editor
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.ria / src / argeo-ria-lib / security / class / org / argeo / security / ria / components / NaturesManager.js
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
new file mode 100644 (file)
index 0000000..f15bb33
--- /dev/null
@@ -0,0 +1,39 @@
+qx.Class.define("org.argeo.security.ria.components.NaturesManager",{\r
+       extend : qx.core.Object,\r
+       properties : {\r
+               detectedNatures : {\r
+                       check : "Map"\r
+               }\r
+       },\r
+       construct : function(){\r
+               this.base(arguments);\r
+               this.detectNatures();\r
+       },\r
+       members : {\r
+               detectNatures : function(){                     \r
+                       var natures = {};\r
+                       for (var key in qx.Bootstrap.$$registry) {\r
+                               if (qx.Class.hasInterface(qx.Bootstrap.$$registry[key], org.argeo.security.ria.components.INaturePane)) {\r
+                                       // FILTER BY ROLE HERE!\r
+                                       var klass = qx.Bootstrap.$$registry[key];\r
+                                       natures[klass.NATURE_TYPE] = klass;\r
+                               }\r
+                       }\r
+                       this.setDetectedNatures(natures);\r
+               },\r
+               detectNaturesInData : function(userNaturesList){\r
+                       var detected = this.getDetectedNatures();\r
+                       var userDetected = [];\r
+                       for(var i = 0;i<userNaturesList.length;i++){\r
+                               var type = userNaturesList[i].type;\r
+                               if(detected[type]){\r
+                                       userDetected.push({\r
+                                               NATURE_CLASS : detected[type],\r
+                                               NATURE_DATA  : userNaturesList[i]\r
+                                       });\r
+                               }\r
+                       }\r
+                       return userDetected;\r
+               }\r
+       }\r
+});
\ No newline at end of file