added widget directory and new org unit filtering select widget
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 21 Apr 2008 16:51:44 +0000 (16:51 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 21 Apr 2008 16:51:44 +0000 (16:51 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9396 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/widget/OrgUnitFilteringSelect.js [new file with mode: 0644]

diff --git a/Open-ILS/web/js/dojo/openils/widget/OrgUnitFilteringSelect.js b/Open-ILS/web/js/dojo/openils/widget/OrgUnitFilteringSelect.js
new file mode 100644 (file)
index 0000000..a875264
--- /dev/null
@@ -0,0 +1,33 @@
+if(!dojo._hasResource["openils.widget.OrgUnitFilteringSelect"]){
+dojo._hasResource["openils.widget.OrgUnitFilteringSelect"] = true;
+dojo.require("dijit.form.FilteringSelect");
+dojo.require("fieldmapper.OrgUtils");
+dojo.provide("openils.widget.OrgUnitFilteringSelect");
+
+/**
+ * This widget provides a FilteringSelect for Org Units.  In particular,
+ * it indents displayed name ('shortname', by default) based on the orgs depth 
+ * to imitate a tree.  
+ */
+
+/* TODO add org sorting to ensure proper render order */
+
+dojo.declare(
+    "openils.widget.OrgUnitFilteringSelect", [dijit.form.FilteringSelect], 
+    {
+        _getMenuLabelFromItem : function(item) {
+            var type = this.store.getValue(item, 'ou_type');
+            var depth = fieldmapper.aout.findOrgType(type).depth();
+            var lpad = depth*6; /* CSS instead? */
+
+            return {
+                html: true,
+                label: '<div style="padding-left:'+lpad+'px;">' +
+                    this.store.getValue(item, this.labelAttr || 'shortname') +
+                    '</div>'
+            }
+        }
+    }
+);
+
+}