Vandelay: Rewrite Inspect Queues Interface
authorThomas Berezansky <tsbere@mvlc.org>
Wed, 14 Mar 2012 16:04:25 +0000 (12:04 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 12 Jun 2012 16:31:49 +0000 (12:31 -0400)
This accomplishes several things:
1 - Load the list of queues on page load
2 - Single-click access (rather than select and click) to queues
3 - Batch Deletion of Queues

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/templates/vandelay/inc/queueselect.tt2
Open-ILS/web/js/ui/default/vandelay/vandelay.js

index 91416c9..e6be903 100644 (file)
@@ -1,26 +1,27 @@
 <!-- Form for choosing which queue to view -->
 <h1>[% l('Select a Queue to Inspect') %]</h1><br/>
-<table class='form_table'>
-    <tr>
-        <td>[% l('Queue Type') %]</td>
-        <td>
-            <select jsId='vlQueueSelectType' dojoType='dijit.form.FilteringSelect' onchange='vlShowQueueSelect();'>
-                <option value='bib' selected='selected'>[% l('Bibliographic Records') %]</option>
-                <option value='bib-acq'>[% l('Acquisitions Records') %]</option>
-                <option value='auth'>[% l('Authority Records') %]</option>
-            </select>
-        </td>
-    </tr>
-    <tr>
-        <td>[% l('Queue') %]</td>
-        <td>
-            <select jsId='vlQueueSelectQueueList' dojoType='dijit.form.FilteringSelect'>
-            </select>
-        </td>
-    </tr>
-    <tr>
-        <td colspan='2'>
-            <button dojoType='dijit.form.Button' onclick='vlFetchQueueFromForm();'>[% l('Retrieve Queue') %]</button>
-        </td>
-    </tr>
+[% l('Queue Type') %]
+<select jsId='vlQueueSelectType' dojoType='dijit.form.FilteringSelect' onchange='vlShowQueueSelect();'>
+    <option value='bib' selected='selected'>[% l('Bibliographic Records') %]</option>
+    <option value='bib-acq'>[% l('Acquisitions Records') %]</option>
+    <option value='auth'>[% l('Authority Records') %]</option>
+</select>
+<table>
+    <thead>
+        <tr>
+            <td><input type="checkbox" disabled="true" /> &nbsp;</td>
+            <td>[% l('Queue') %]</td>
+        </tr>
+    </thead>
+    <tbody id="vlQueueSelectList">
+    </tbody>
+    <tfoot>
+        <tr>
+            <td>&nbsp;</td>
+            <td><input type="button" value="[% l('Delete Selected') %]" onclick='
+                if(confirm("[% l('Are you sure you want to delete the selected queues?') %]")) {
+                    vlDeleteSelectedQueues();
+                }' /></td>
+        </tr>
+    </tfoot>
 </table>
index 5d7d6a3..9988eb2 100644 (file)
@@ -344,10 +344,8 @@ function runStartupCommands() {
     dojo.style('vl-nav-bar', 'visibility', 'visible');
     if(currentQueueId)
         return retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
-    if (cgi.param('page', 'inspectq')) {
-        vlShowQueueSelect();
-        return displayGlobalDiv('vl-queue-select-div');
-    }
+    if (cgi.param('page', 'inspectq'))
+        return vlShowQueueSelect();
         
     vlShowUploadForm();
 }
@@ -1354,28 +1352,29 @@ function batchUpload() {
     }
 }
 
-
-function vlFleshQueueSelect(selector, type) {
-    var data;
-    if (type == 'bib') {
-        var bibList = allUserBibQueues.filter(
-            function(q) {
-                return (q.queue_type() == 'bib');
-            }
-        );
-        data = vbq.toStoreData(bibList);
-    } else if (type == 'bib-acq') {
-        // ACQ queues are a special type of bib queue
-        var acqList = allUserBibQueues.filter(
-            function(q) {
-                return (q.queue_type() == 'acq');
-            }
-        );
-        data = vbq.toStoreData(acqList);
-    } else {
-        data = vaq.toStoreData(allUserAuthQueues);
+// Inspect Queue no longer uses stores, so put type matching here instead
+function vlGetQueueData(type, asStore) {
+    var filter;
+    switch(type) {
+        case 'bib-acq':
+            filter = 'acq';
+        case 'bib':
+            if(!filter) filter = 'bib';
+            var bibList = allUserBibQueues.filter(
+                function(q) {
+                    return (q.queue_type() == filter);
+                }
+            );
+            if (!asStore) return bibList;
+            return vbq.toStoreData(bibList);
+        case 'auth':
+            if (!asStore) return allUserAuthQueues;
+            return vaq.toStoreData(allUserAuthQueues);
     }
+}
 
+function vlFleshQueueSelect(selector, type) {
+    var data = vlGetQueueData(type, true);
     selector.store = new dojo.data.ItemFileReadStore({data:data});
     selector.setValue(null);
     selector.setDisplayedValue('');
@@ -1459,9 +1458,48 @@ function vlShowUploadForm() {
 
 }
 
+function vlDeleteSelectedQueues() {
+    var checkboxes = document.getElementById('vlQueueSelectList').getElementsByTagName('input');
+    var type = vlQueueSelectType.attr('value').replace(/-.*/, '');
+    for(var i = 0; i < checkboxes.length; i++) {
+        if(checkboxes[i].getAttribute('name') == 'delete' && checkboxes[i].checked) {
+            vlDeleteQueue(type, checkboxes[i].getAttribute('value'), function () {});
+        }
+    }
+    window.location.reload();
+}
+
 function vlShowQueueSelect() {
     displayGlobalDiv('vl-queue-select-div');
-    vlFleshQueueSelect(vlQueueSelectQueueList, vlQueueSelectType.getValue());
+    var type = vlQueueSelectType.attr('value');
+    var data = vlGetQueueData(type, false);
+    type = type.replace(/-.*/, ''); // To remove any sub-typeish info.
+    var tbody = document.getElementById('vlQueueSelectList');
+    // Clear it out
+    while(tbody.firstChild) {
+        tbody.removeChild(tbody.firstChild);
+    }
+    // Add entries
+    for(var entry in data) {
+        var name = data[entry].name();
+        if(!name.match(/\S/))
+            name = '-';
+        var tr = document.createElement('tr');
+        var td = document.createElement('td');
+        var checkbox = document.createElement('input');
+        checkbox.setAttribute('type', 'checkbox');
+        checkbox.setAttribute('name', 'delete');
+        checkbox.setAttribute('value', data[entry].id());
+        td.appendChild(checkbox);
+        tr.appendChild(td);
+        td = document.createElement('td');
+        var a = document.createElement('a');
+        a.textContent = name;
+        a.setAttribute('href', "javascript:retrieveQueuedRecords('" + type + "', " + data[entry].id() + ");");
+        td.appendChild(a);
+        tr.appendChild(td);
+        tbody.appendChild(tr);
+    }
 }
 
 function vlShowMatchSetEditor() {
@@ -1475,12 +1513,6 @@ function vlShowMatchSetEditor() {
     );
 }
 
-function vlFetchQueueFromForm() {
-    currentType = vlQueueSelectType.attr('value').replace(/-.*/, ''); // trim bib-acq
-    currentQueueId = vlQueueSelectQueueList.getValue();
-    retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
-}
-
 function vlOpenMarcEditWindow(rec, postReloadHTMLHandler) {
     /*
         To run in Firefox directly, must set signed.applets.codebase_principal_support