From 015942383771a9f993253337d40276c3ccedcb95 Mon Sep 17 00:00:00 2001
From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Wed, 11 Aug 2010 02:18:47 +0000
Subject: [PATCH] added an UI for editing vandelay import item attribute
 definitions.  it's a basic autogrid version for now.  TODO: fix some grid
 height styling issues

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17165 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/examples/fm_IDL.xml                       |  8 ++---
 Open-ILS/web/js/ui/default/vandelay/vandelay.js    | 39 ++++++++++++++++++++--
 Open-ILS/web/opac/locale/en-US/vandelay.dtd        |  1 +
 .../templates/default/vandelay/inc/item_attrs.tt2  | 27 +++++++++++++++
 .../web/templates/default/vandelay/inc/toolbar.tt2 |  2 ++
 .../web/templates/default/vandelay/vandelay.tt2    |  3 ++
 6 files changed, 74 insertions(+), 6 deletions(-)
 create mode 100644 Open-ILS/web/templates/default/vandelay/inc/item_attrs.tt2

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index db066c78b0..dfa255818f 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -251,10 +251,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 		</links>
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
 			<actions>
-				<create permission="CREATE_IMPORT_ITEM_ATTR_DEF" context_field="owner"/>
-				<retrieve permission="CREATE_IMPORT_ITEM_ATTR_DEF UPDATE_IMPORT_ITEM_ATTR_DEF DELETE_IMPORT_ITEM_ATTR_DEF" context_field="owner"/>
-				<update permission="UPDATE_IMPORT_ITEM_ATTR_DEF" context_field="owner"/>
-				<delete permission="DELETE_IMPORT_ITEM_ATTR_DEF" context_field="owner"/>
+				<create permission="CREATE_IMPORT_ITEM_ATTR_DEF ADMIN_IMPORT_ITEM_ATTR_DEF" context_field="owner"/>
+				<retrieve permission="CREATE_IMPORT_ITEM_ATTR_DEF UPDATE_IMPORT_ITEM_ATTR_DEF DELETE_IMPORT_ITEM_ATTR_DEF ADMIN_IMPORT_ITEM_ATTR_DEF" context_field="owner"/>
+				<update permission="UPDATE_IMPORT_ITEM_ATTR_DEF ADMIN_IMPORT_ITEM_ATTR_DEF" context_field="owner"/>
+				<delete permission="DELETE_IMPORT_ITEM_ATTR_DEF ADMIN_IMPORT_ITEM_ATTR_DEF" context_field="owner"/>
 			</actions>
 		</permacrud>
 	</class>
diff --git a/Open-ILS/web/js/ui/default/vandelay/vandelay.js b/Open-ILS/web/js/ui/default/vandelay/vandelay.js
index 7346ef029b..61d0485024 100644
--- a/Open-ILS/web/js/ui/default/vandelay/vandelay.js
+++ b/Open-ILS/web/js/ui/default/vandelay/vandelay.js
@@ -56,7 +56,8 @@ var globalDivs = [
     'vl-marc-upload-status-div',
     'vl-attr-editor-div',
     'vl-marc-export-div',
-    'vl-profile-editor-div'
+    'vl-profile-editor-div',
+    'vl-item-attr-editor-div'
 ];
 
 var authtoken;
@@ -273,6 +274,9 @@ function displayGlobalDiv(id) {
         case 'vl-profile-editor-div':
             openils.Util.addCSSClass(dojo.byId('vl-menu-profile-editor'), 'toolbar_selected');
             break;
+        case 'vl-item-attr-editor-div':
+            openils.Util.addCSSClass(dojo.byId('vl-menu-import-item-attr-editor'), 'toolbar_selected');
+            break;
     }
 }
 
@@ -1322,7 +1326,7 @@ function vlShowProfileEditor() {
             function() {
                 profileContextOrg = this.attr('value');
                 pGrid.resetStore();
-                buildGrid();
+                buildProfileGrid();
             }
         );
     };
@@ -1342,5 +1346,36 @@ function buildProfileGrid() {
     );
 }
 
+/* --- Import Item Attr Grid --------------- */
+
+var itemAttrContextOrg;
+function vlShowImportItemAttrEditor() {
+    displayGlobalDiv('vl-item-attr-editor-div');
+    buildImportItemAttrGrid();
+
+    var connect = function() {
+        dojo.connect(itemAttrContextOrgSelector, 'onChange',
+            function() {
+                itemAttrContextOrg = this.attr('value');
+                itemAttrGrid.resetStore();
+                vlShowImportItemAttrEditor();
+            }
+        );
+    };
 
+    new openils.User().buildPermOrgSelector(
+        'ADMIN_IMPORT_ITEM_ATTR_DEF', 
+            itemAttrContextOrgSelector, null, connect);
+}
+
+function buildImportItemAttrGrid() {
+
+    if(itemAttrContextOrg == null)
+        itemAttrContextOrg = openils.User.user.ws_ou();
+
+    itemAttrGrid.loadAll( 
+        {order_by : {viiad : 'name'}}, 
+        {owner : fieldmapper.aou.fullPath(itemAttrContextOrg, true)}
+    );
+}
 
diff --git a/Open-ILS/web/opac/locale/en-US/vandelay.dtd b/Open-ILS/web/opac/locale/en-US/vandelay.dtd
index de3b233133..31fdc67e12 100644
--- a/Open-ILS/web/opac/locale/en-US/vandelay.dtd
+++ b/Open-ILS/web/opac/locale/en-US/vandelay.dtd
@@ -27,6 +27,7 @@
 <!ENTITY vandelay.edit.attributes "Edit Attributes">
 <!ENTITY vandelay.edit.attrs "Edit Attributes">
 <!ENTITY vandelay.edit.profiles "Edit Merge / Overlay Profiles">
+<!ENTITY vandelay.edit.import_item_attrs "Edit Import Item Attributes">
 <!ENTITY vandelay.false "False">
 <!ENTITY vandelay.file.to.upload "File to Upload:">
 <!ENTITY vandelay.for.example "Example">
diff --git a/Open-ILS/web/templates/default/vandelay/inc/item_attrs.tt2 b/Open-ILS/web/templates/default/vandelay/inc/item_attrs.tt2
new file mode 100644
index 0000000000..ad9878d2e8
--- /dev/null
+++ b/Open-ILS/web/templates/default/vandelay/inc/item_attrs.tt2
@@ -0,0 +1,27 @@
+<!--
+    Grid for configuring vandelay.import_item_attr_definition
+-->
+
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+    <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+        <div>Import Item Attrbute Definitions</div>
+        <div>
+            <button dojoType='dijit.form.Button' onClick='itemAttrGrid.showCreateDialog()'>New Definition</button>
+            <button dojoType='dijit.form.Button' onClick='itemAttrGrid.deleteSelected()'>Delete Selected</button>
+        </div>
+    </div>
+    <div>
+        <span style='padding-right:10px;'>Context Org Unit</span>
+        <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='itemAttrContextOrgSelector'
+            searchAttr='shortname' labelAttr='shortname'> </select>
+    </div>
+    <table  jsId="itemAttrGrid"
+            dojoType="openils.widget.AutoGrid"
+            fieldOrder="[]"
+            query="{id: '*'}"
+            fmClass='viiad'
+            editStyle='pane'
+            showPaginator='true'
+            editOnEnter='true'>
+    </table>
+</div>
diff --git a/Open-ILS/web/templates/default/vandelay/inc/toolbar.tt2 b/Open-ILS/web/templates/default/vandelay/inc/toolbar.tt2
index d2aca97297..69c2190a56 100644
--- a/Open-ILS/web/templates/default/vandelay/inc/toolbar.tt2
+++ b/Open-ILS/web/templates/default/vandelay/inc/toolbar.tt2
@@ -9,4 +9,6 @@
         onclick="vlShowAttrEditor();" showLabel="true">&vandelay.edit.attributes;</div>
     <div dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconCopy"  id='vl-menu-profile-editor'
         onclick="vlShowProfileEditor();" showLabel="true">&vandelay.edit.profiles;</div>
+    <div dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconCopy"  id='vl-menu-import-item-attr-editor'
+        onclick="vlShowImportItemAttrEditor();" showLabel="true">&vandelay.edit.import_item_attrs;</div>
 </div>
diff --git a/Open-ILS/web/templates/default/vandelay/vandelay.tt2 b/Open-ILS/web/templates/default/vandelay/vandelay.tt2
index 019245f8c4..2e2a2e0ab5 100644
--- a/Open-ILS/web/templates/default/vandelay/vandelay.tt2
+++ b/Open-ILS/web/templates/default/vandelay/vandelay.tt2
@@ -37,6 +37,9 @@
 <div dojoType="dijit.layout.ContentPane" layoutAlign='client' id='vl-profile-editor-div' class='hidden content'>
     [% INCLUDE 'default/vandelay/inc/profiles.tt2' %]
 </div>
+<div dojoType="dijit.layout.ContentPane" layoutAlign='client' id='vl-item-attr-editor-div' class='hidden content'>
+    [% INCLUDE 'default/vandelay/inc/item_attrs.tt2' %]
+</div>
 
 
 [% END %]
-- 
2.11.0