added a toolbar for choosing interfaces. added a queue picker interface to pick...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 5 Sep 2008 17:39:45 +0000 (17:39 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 5 Sep 2008 17:39:45 +0000 (17:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10548 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/vandelay/vandelay.html
Open-ILS/web/vandelay/vandelay.js

index 8ed65eb..bf0b5bb 100644 (file)
             }
             .tall { height:100%; }
             .hidden { display: none; }
+            #toolbar { margin-top: 0px; }
+            body { width:100%; height:100%; border:0; margin:0; padding:0; }
+            .progress { 
+                width:100%;
+                text-align:center;
+                margin: 20px;
+            }
         </style>
         <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:true" src="/js/dojo/dojo/dojo.js"></script>
         <script type="text/javascript" src='vandelay.js'></script>
     </head>
-    <body class="tundra" class='tall'>
-        <div id="vl-generic-progress" style='width:100%;text-align:center'>
+    <body class="tundra tall">
+
+        <div dojoType="dijit.Toolbar" id='toolbar'>
+            <div dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconCopy" 
+                onclick='displayGlobalDiv("vl-marc-upload-div");' showLabel="true">Import Records</div>
+            <div dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconCopy" 
+                onclick='vlShowQueueSelect();' showLabel="true">Inspect Queue</div>
+        </div>
+
+        <div id="vl-generic-progress" class='progress'>
             <div dojoType="dijit.ProgressBar" style="width:200px" indeterminate="true"></div>
         </div>
-        <div id="vl-generic-progress-with-total" class='hidden' style='width:100%;text-align:center;'>
+        <div id="vl-generic-progress-with-total" class='hidden progress'>
             <div dojoType="dijit.ProgressBar" jsId='vlControlledProgressBar' style="width:200px"></div>
         </div>
 
@@ -51,7 +66,7 @@
             <h1>Evergreen MARC File Upload</h1><br/>
             <form id="vl-marc-upload-form" enctype="multipart/form-data">
                 <input type='hidden' name='ses' id='vl-ses-input'/>
-                <br>
+                <br/>
                 <table>
                     <tr>
                         <td>Queue Name</td>
                     </tr>
                     <tr>
                         <td>
-                            <span id="vl-file-label">File to Upload:</span><br>
-                            <span id="vl-file-uploading" class='hidden'>Uploading...</span><br>
+                            <span id="vl-file-label">File to Upload:</span>
+                            <span id="vl-file-uploading" class='hidden'>Uploading...</span>
                         </td>
                         <td id='vl-input-td'>
-                            <input size='48' type="file" name="marc_upload">
+                            <input size='48' type="file" name="marc_upload"/>
                         </td>
                     </tr>
                     <tr>
         <!-- record queue grid -->
         <div id='vl-queue-div' class='tall hidden'>
             <h1>Record Queue</h1><br/>
+            <div id='vl-queue-no-records' class='hidden'><h2>There are no records in the selected queue</h2></div>
             <script>
                 var vlQueueGridLayout;
                 function resetVlQueueGridLayout() {
                     }];
                 }
             </script>
-            <button dojoType='dijit.form.Button' onclick='vlSelectAllGridRecords();'>Select All</button>
-            <button dojoType='dijit.form.Button' onclick='vlSelectNoGridRecords();'>Select None</button>
-            <button dojoType='dijit.form.Button' onclick='vlImportSelectedRecords();'>Import Selected</button>
-            <div class='tall'>
-                <div dojoType='dojox.Grid' jsId='vlQueueGrid'> </div>
+            <div id='vl-queue-div-grid' class='tall'>
+                <button dojoType='dijit.form.Button' onclick='vlSelectAllGridRecords();'>Select All</button>
+                <button dojoType='dijit.form.Button' onclick='vlSelectNoGridRecords();'>Select None</button>
+                <button dojoType='dijit.form.Button' onclick='vlImportSelectedRecords();'>Import Selected</button>
+                <div class='tall'>
+                    <div dojoType='dojox.Grid' jsId='vlQueueGrid' class='tall'> </div>
+                </div>
             </div>
         </div>
 
                     }];
                 }
             </script>
-            <h1>Import Matches</h1></br>
+            <h1>Import Matches</h1><br/>
             <div>
                 <button dojoType='dijit.form.Button' 
                     onclick='displayGlobalDiv("vl-queue-div");'>Back To Import Queue...</button>
             </div>
         </div>
 
-
         <!-- MARC as HTML for matched records -->
         <div id='vl-match-html-div' class='tall hidden'>
             <h1>MARC Record</h1><br/>
             </div>
             <div>
                 <style>#vl-match-record-html td {padding:0px;}</style>
-                <div id='vl-match-record-html'/>
+                <div id='vl-match-record-html'> </div>
             </div>
         </div>
 
+        <!-- Form for choosing which queue to view -->
+        <div id='vl-queue-select-div' class='tall hidden'>
+            <h1>Select a Queue to Inspect</h1><br/>
+            <table>
+                <tr>
+                    <td>Queue Type</td>
+                    <td>
+                        <select jsId='vlQueueSelectType' dojoType='dijit.form.FilteringSelect' onchange='alert(1);'>
+                            <option value='bib' selected='selected'>Bibliographic Records</option>
+                            <option value='auth'>Authority Records</option>
+                        </select>
+                    </td>
+                </tr>
+                <tr>
+                    <td>Queue</td>
+                    <td>
+                        <select jsId='vlQueueSelectQueueList' dojoType='dijit.form.FilteringSelect'>
+                        </select>
+                    </td>
+                </tr>
+                <tr>
+                    <td colspan='2'>
+                        <button dojoType='dijit.form.Button' onclick='vlFetchQueueFromForm();'>Retrieve Queue</button>
+                    </td>
+                </tr>
+            </table>
+        </div>
     </body>
 </html>
index 5c6334d..265304a 100644 (file)
@@ -36,7 +36,8 @@ var globalDivs = [
     'vl-marc-upload-div',
     'vl-queue-div',
     'vl-match-div',
-    'vl-match-html-div'
+    'vl-match-html-div',
+    'vl-queue-select-div'
 ];
 
 var authtoken;
@@ -55,14 +56,23 @@ var userCache = {};
 var currentMatchedRecords; // set of loaded matched bib records
 var currentOverlayRecordsMap; // map of import record to overlay record
 var currentImportRecId; // when analyzing matches, this is the current import record
+var userBibQueues;
+var userAuthQueues;
+var selectableGridRecords;
 
 /**
   * Grab initial data
   */
 function vlInit() {
     authtoken = dojo.cookie('ses') || cgi.param('ses');
-    bibAttrsFetched = false;
-    authAttrsFetched = false;
+    var initNeeded = 4; // how many async responses do we need before we're init'd 
+    var initCount = 0; // how many async reponses we've received
+
+    function checkInitDone() {
+        initCount++;
+        if(initCount == initNeeded)
+            runStartupCommands();
+    }
 
     // Fetch the bib and authority attribute definitions
     fieldmapper.standardRequest(
@@ -76,7 +86,6 @@ function vlInit() {
                 bibAttrDefs.push(def);
             },
             oncomplete: function() {
-                bibAttrsFetched = true;
                 bibAttrDefs = bibAttrDefs.sort(
                     function(a, b) {
                         if(a.id() > b.id()) return 1;
@@ -84,8 +93,7 @@ function vlInit() {
                         return 0;
                     }
                 );
-                if(authAttrsFetched) 
-                    runStartupCommands();
+                checkInitDone();
             }
         }
     );
@@ -101,7 +109,6 @@ function vlInit() {
                 authAttrDefs.push(def);
             },
             oncomplete: function() {
-                authAttrsFetched = true;
                 authAttrDefs = authAttrDefs.sort(
                     function(a, b) {
                         if(a.id() > b.id()) return 1;
@@ -109,16 +116,48 @@ function vlInit() {
                         return 0;
                     }
                 );
-                if(bibAttrsFetched) 
-                    runStartupCommands();
+                checkInitDone();
+            }
+        }
+    );
+
+    fieldmapper.standardRequest(
+        ['open-ils.vandelay', 'open-ils.vandelay.bib_queue.owner.retrieve.atomic'],
+        {   async: true,
+            params: [authtoken],
+            oncomplete: function(r) {
+                var list = r.recv().content();
+                if(e = openils.Event.parse(list[0]))
+                    return alert(e);
+                userBibQueues = list;
+                checkInitDone();
+            }
+        }
+    );
+
+    fieldmapper.standardRequest(
+        ['open-ils.vandelay', 'open-ils.vandelay.authority_queue.owner.retrieve.atomic'],
+        {   async: true,
+            params: [authtoken],
+            oncomplete: function(r) {
+                var list = r.recv().content();
+                if(e = openils.Event.parse(list[0]))
+                    return alert(e);
+                userAuthQueues = list;
+                checkInitDone();
             }
         }
     );
 }
 
 function displayGlobalDiv(id) {
-    for(var i = 0; i < globalDivs.length; i++) 
-        dojo.style(dojo.byId(globalDivs[i]), 'display', 'none');
+    for(var i = 0; i < globalDivs.length; i++) {
+        try {
+            dojo.style(dojo.byId(globalDivs[i]), 'display', 'none');
+        } catch(e) {
+            alert('please define ' + globalDivs[i]);
+        }
+    }
     dojo.style(dojo.byId(id),'display','block');
 }
 
@@ -126,7 +165,7 @@ function runStartupCommands() {
     currentQueueId = cgi.param('qid');
     currentType = cgi.param('qtype');
     if(currentQueueId)
-        return retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
+        return retrievenueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
     displayGlobalDiv('vl-marc-upload-div');
 }
 
@@ -198,6 +237,7 @@ function retrieveQueuedRecords(type, queueId, onload) {
     queuedRecords = [];
     queuedRecordsMap = {};
     currentOverlayRecordsMap = {};
+    selectableGridRecords = {};
     resetVlQueueGridLayout();
 
     fieldmapper.standardRequest(
@@ -326,6 +366,7 @@ function getAttrValue(rowIdx) {
     var data = this.grid.model.getRow(rowIdx);
     if(!data) return '';
     var attrCode = this.field.split('.')[1];
+    console.log(attrCode + " : " + data.id + ' : ' + queuedRecordsMap[data.id] + " : count = " + queuedRecords.length);
     var rec = queuedRecordsMap[data.id];
     var attr = getRecAttrFromCode(rec, attrCode);
     if(attr)
@@ -397,6 +438,15 @@ function buildRecordGrid(type) {
 
     currentOverlayRecordsMap = {};
 
+    if(queuedRecords.length == 0) {
+        dojo.style(dojo.byId('vl-queue-no-records'), 'display', 'block');
+        dojo.style(dojo.byId('vl-queue-div-grid'), 'display', 'none');
+        return;
+    } else {
+        dojo.style(dojo.byId('vl-queue-no-records'), 'display', 'none');
+        dojo.style(dojo.byId('vl-queue-div-grid'), 'display', 'block');
+    }
+
     var defs = (type == 'bib') ? bibAttrDefs : authAttrDefs;
     for(var i = 0; i < defs.length; i++) {
         var def = defs[i]
@@ -410,8 +460,6 @@ function buildRecordGrid(type) {
         vlQueueGridLayout[0].cells[0].push(col);
     }
 
-    vlQueueGrid.setStructure(vlQueueGridLayout);
-
     var storeData;
     if(type == 'bib')
         storeData = vqbr.toStoreData(queuedRecords);
@@ -423,6 +471,7 @@ function buildRecordGrid(type) {
         null, store, {rowsPerPage: 100, clientSort: true, query:{id:'*'}});
 
     vlQueueGrid.setModel(model);
+    vlQueueGrid.setStructure(vlQueueGridLayout);
     vlQueueGrid.update();
 }
 
@@ -440,7 +489,6 @@ function test() {
 }
 */
 
-var selectableGridRecords = {};
 function vlQueueGridDrawSelectBox(rowIdx) {
     var data = this.grid.model.getRow(rowIdx);
     if(!data) return '';
@@ -519,4 +567,24 @@ function batchUpload() {
     createQueue(queueName, currentType, handleCreateQueue);
 }
 
+
+function vlFleshQueueSelect(selector, type) {
+    var data = (type == 'bib') ? vbq.toStoreData(userBibQueues) : vaq.toStoreData(userAuthQueues);
+    selector.store = new dojo.data.ItemFileReadStore({data:data});
+    if(data[0])
+        selector.setValue(data[0].id());
+}
+
+function vlShowQueueSelect() {
+    displayGlobalDiv('vl-queue-select-div');
+    vlFleshQueueSelect(vlQueueSelectQueueList, 'bib');
+}
+
+function vlFetchQueueFromForm() {
+    currentType = vlQueueSelectType.getValue();
+    currentQueueId = vlQueueSelectQueueList.getValue();
+    retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
+}
+    
+
 dojo.addOnLoad(vlInit);