Add an autogrid-based interface for CRUD ops on vms objects, with links to the tree...
authorsenator <lebbeous@esilibrary.com>
Wed, 13 Apr 2011 22:04:10 +0000 (18:04 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 6 Jul 2011 18:50:48 +0000 (14:50 -0400)
Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
Open-ILS/web/templates/default/vandelay/match_set.tt2
Open-ILS/web/templates/default/vandelay/match_set_tree.tt2 [new file with mode: 0644]

index ecbdf95..9e5be71 100644 (file)
@@ -640,6 +640,13 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
         */
 
         return autoWidget.getDisplayString();
-    }
+    };
+
+    openils.widget.AutoGrid.orgUnitGetter = function(rowIndex, item) {
+        if (!item) return "";
+        return fieldmapper.aou.findOrgUnit(
+            this.grid.store.getValue(item, this.field)
+        ).shortname();
+    };
 }
 
index fe5def0..0d59f54 100644 (file)
@@ -1,59 +1,94 @@
-[% WRAPPER 'default/base.tt2' %]
-[% ctx.page_title = 'Vandelay Match Set' %]
-<style type="text/css">
-    h1 { margin: 0.5em 0; }
-    .outer { clear: both; }
-    #vmsp-buttons button { padding: 0 1.5em; }
-    .node-editor { margin-bottom: 2em; }
-    .node-editor td { padding: 0.5ex; }
-    li { background-color: #ddd; }
-</style>
-<h1>[% ctx.page_title %]</h1>
-<table class="hidden">
-    <tr consistent-controls="1">
-        <td>
-            <label for="quality-input"
-                title="A relative number representing the impact of this expression on the quality of the overall record match"><!-- XXX tooltipize -->
-                Quality:
-            </label>
-        </td>
-        <td>
-            <input id="quality-input" type="text" value="1"
-                size="4" maxlength="3" fmfield="quality" />
-        </td>
-    </tr>
-    <tr consistent-controls="1">
-        <td>
-            <label for="negate-input">Negate?</label>
-        </td>
-        <td>
-            <input id="negate-input" type="checkbox" fmfield="negate" />
-        </td>
-    </tr>
-</table>
-<div class="outer">
-    <div><!-- XXX TODO: consider a read-only display here of the query as built
-        so far from the treet --></div>
-    <div id="vmsp-buttons">
-        <button onclick="node_editor.add('svf');">New Single-Value-Field</button>
-        <button onclick="node_editor.add('tag');">New MARC Tag and Subfield</button>
-        <button onclick="node_editor.add('bool_op');">New Boolean Operator</button>
-    </div>
-</div>
-<div class="outer" style="margin-top: 2ex;">
-    <div style="float: left; width: 49%">
+[% WRAPPER default/base.tt2 %]
+[% ctx.page_title = 'Vandelay Match Sets' %]
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+    <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class="oils-header-panel">
+        <div>[% ctx.page_title %]</div>
         <div>
-            <form id="node-editor-container" onsubmit="return false;"></form>
+            <button dojoType="dijit.form.Button"
+                onClick="vms_grid.showCreateDialog()">New Match Set</button>
+            <button dojoType="dijit.form.Button"
+                onClick="vms_grid.deleteSelected()">Delete Selected</button>
         </div>
-        <ul id="src_here"></ul>
     </div>
-
-    <div style="float: right; width: 50%">
-        <div><big>Your Expression</big></div>
-        <div id="tree_here"></div>
+    <div>
+        Show sets owned at or below:
+        <select dojoType="openils.widget.OrgUnitFilteringSelect"
+            jsId="context_org_selector"></select>
     </div>
+    <table jsId="vms_grid"
+        dojoType="openils.widget.AutoGrid"
+        query="{id: '*'}"
+        defaultCellWidth="'16em'"
+        fmClass="vms"
+        fieldorder="['name', 'owner']"
+        suppressEditFields="['id']"
+        showPaginator="true"
+        editOnEnter="true">
+        <thead>
+            <tr>
+                <th field="name" get="field_plus_id" formatter="tree_editor_link"></th>
+                <th field="owner" get="openils.widget.AutoGrid.orgUnitGetter">
+                </th>
+            </tr>
+        </thead>
+    </table>
 </div>
-<div jsId="progress_dialog" dojoType="openils.widget.ProgressDialog"></div>
-<script type="text/javascript"
-    src="[% ctx.media_prefix %]/js/ui/default/vandelay/match_set.js"></script>
+<div class="hidden">
+    <select dojoType="dijit.form.FilteringSelect" jsId="mtype_selector">
+        [%# for the origin of these hard coded options, see the definition
+        of vandelay.match_set.mtype in 012.schema.vandelay.sql %]
+        <option value="biblio">biblio</option>
+        <option value="authority">authority</option>
+        <!-- XXX: nah <option value="mfhd">mfhd</option> -->
+    </select>
+</div>
+
+<script type="text/javascript">
+    dojo.require("dijit.form.FilteringSelect");
+    dojo.require("openils.widget.AutoGrid");
+    dojo.require("openils.widget.OrgUnitFilteringSelect");
+
+    var context_org;
+
+    function load_grid(search) {
+        if (!search) search = {"id": {"!=": null}};
+
+        vms_grid.loadAll({"order_by": {"vms": "name"}}, search);
+    }
+
+    function field_plus_id(rowIndex, item) {
+        if (!item) return null;
+        var datum = {};
+        datum[this.field] = this.grid.store.getValue(item, this.field);
+        datum.id = this.grid.store.getValue(item, "id");
+        return datum;
+    }
+
+    function tree_editor_link(datum) {
+        if (!datum) return "";
+        return '<a href="[% ctx.base_path %]/vandelay/match_set_tree?match_set=' +
+            datum.id + '">' + datum.name + '</a>';
+    }
+
+    openils.Util.addOnLoad(
+        function() {
+            new openils.User().buildPermOrgSelector(
+                "ADMIN_IMPORT_MATCH_SET", context_org_selector,
+                null, function() {
+                    context_org_selector.onChange = function() {
+                        context_org = this.attr("value");
+                        vms_grid.resetStore();
+                        load_grid({
+                            "owner": aou.descendantNodeList(context_org, true)
+                        });
+                    };
+                }
+            );
+
+            vms_grid.overrideEditWidgets.mtype = mtype_selector;
+            vms_grid.overrideEditWidgets.mtype.shove = {"create": "biblio"};
+            load_grid();
+        }
+    );
+</script>
 [% END %]
diff --git a/Open-ILS/web/templates/default/vandelay/match_set_tree.tt2 b/Open-ILS/web/templates/default/vandelay/match_set_tree.tt2
new file mode 100644 (file)
index 0000000..0cec41c
--- /dev/null
@@ -0,0 +1,62 @@
+[% WRAPPER 'default/base.tt2' %]
+[% ctx.page_title = 'Vandelay Match Set Editor' %]
+<style type="text/css">
+    h1 { margin: 0.5em 0; }
+    .outer { clear: both; }
+    #vmsp-buttons button { padding: 0 1.5em; }
+    .node-editor { margin-bottom: 2em; }
+    .node-editor td { padding: 0.5ex; }
+    li { background-color: #ddd; }
+</style>
+<h1>[% ctx.page_title %]</h1>
+<!-- XXX TODO
+    give some indication of which match set we're editing the tree for
+    -->
+<table class="hidden">
+    <tr consistent-controls="1">
+        <td>
+            <label for="quality-input"
+                title="A relative number representing the impact of this expression on the quality of the overall record match"><!-- XXX tooltipize -->
+                Quality:
+            </label>
+        </td>
+        <td>
+            <input id="quality-input" type="text" value="1"
+                size="4" maxlength="3" fmfield="quality" />
+        </td>
+    </tr>
+    <tr consistent-controls="1">
+        <td>
+            <label for="negate-input">Negate?</label>
+        </td>
+        <td>
+            <input id="negate-input" type="checkbox" fmfield="negate" />
+        </td>
+    </tr>
+</table>
+<div class="outer">
+    <div><!-- XXX TODO: consider a read-only display here of the query as built
+        so far from the treet --></div>
+    <div id="vmsp-buttons">
+        <button onclick="node_editor.add('svf');">New Single-Value-Field</button>
+        <button onclick="node_editor.add('tag');">New MARC Tag and Subfield</button>
+        <button onclick="node_editor.add('bool_op');">New Boolean Operator</button>
+    </div>
+</div>
+<div class="outer" style="margin-top: 2ex;">
+    <div style="float: left; width: 49%">
+        <div>
+            <form id="node-editor-container" onsubmit="return false;"></form>
+        </div>
+        <ul id="src_here"></ul>
+    </div>
+
+    <div style="float: right; width: 50%">
+        <div><big>Your Expression</big></div>
+        <div id="tree_here"></div>
+    </div>
+</div>
+<div jsId="progress_dialog" dojoType="openils.widget.ProgressDialog"></div>
+<script type="text/javascript"
+    src="[% ctx.media_prefix %]/js/ui/default/vandelay/match_set.js"></script>
+[% END %]