acq invoice search; actual searching; showing results
authorBill Erickson <berick@esilibrary.com>
Wed, 11 Jul 2012 15:29:55 +0000 (11:29 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 11 Jul 2012 15:29:55 +0000 (11:29 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/acq/invoice/view.tt2
Open-ILS/web/js/ui/default/acq/invoice/view.js
Open-ILS/web/js/ui/default/acq/search/unified.js

index 50c5e94..f22941a 100644 (file)
                 </button>
             </div>
         </div> <!-- end search form -->
-        <div id='acq-invoice-search-results-div'>
+        <div id='acq-unified-results-lineitem'>
             <button dojoType='dijit.form.Button'>Add Selected Items</button><br/>
+            <style>
+                #acq-invoice-search-results-tbody  { width: 100%; }
+                #acq-invoice-search-results-tbody td { 
+                    padding: 5px; 
+                    border-bottom: 1px solid #888;
+                }
+                .search-resutls-select-td {
+                    padding-right: 8px; border-right: 2px solid #888;
+                }
+                .search-results-content-td {
+                    padding-left: 8px; border-left: 2px solid #888; 
+                }
+            </style>
+            <table>
+                <tbody id='acq-invoice-search-results-tbody'>
+                    <tr id='acq-invoice-search-results-tr'>
+                        <td class='search-resutls-select-td'>
+                            <input type='checkbox' name='search-results-checkbox'/>
+                        </td>
+                        <td class='search-results-content-td'>
+                            <div name='search-results-content-div'>
+                                <img src='[% ctx.media_prefix %]/opac/images/progressbar_green.gif'/>
+                            </div>
+                        </td>
+                    </tr>
+                </tbody>
+            </table>
         </div>
     </div>
 </div>
index c4b3e14..a83241a 100644 (file)
@@ -221,10 +221,8 @@ function renderUnifiedSearch() {
         // define custom lineitem result handler
         resultManager.result_types = {
             "lineitem": {
-                "search_options": {
-                },
-                "revealer": function() {
-                },
+                "search_options": { "id_list": true },
+                "revealer": function() { },
                 "finisher": function() {
                     resultsLoader.batch_length = resultManager.count_results;
                 },
@@ -234,23 +232,32 @@ function renderUnifiedSearch() {
                 "interface": resultsLoader
             }
         };
-
     }
 
     dojo.addClass(dojo.byId('oils-acq-invoice-table'), 'hidden');
     dojo.removeClass(dojo.byId('oils-acq-invoice-search'), 'hidden');
 }
 
+var resultsTbody, resultsRow;
 function searchResultsLoader() {
-    console.log('creating searchResultsLoader...');
-
     this.displayOffset = 0;
     this.displayLimit = 10;
 
-    this.addLineitem = function(li) {
-        console.log('adding lineitem ' + li);
-        dojo.byId('acq-invoice-search-results-div').appendChild(
-            dojo.create('div', {innerHTML : '<input type="checkbox"/>  Some Book About Stuff ' + li}));
+    if (!resultsTbody) {
+        resultsTbody = dojo.byId('acq-invoice-search-results-tbody');
+        resultsRow = resultsTbody.removeChild(dojo.byId('acq-invoice-search-results-tr'));
+    }
+
+    this.addLineitem = function(li_id) {
+        console.log('Adding search result lineitem ' + li_id);
+        var row = resultsRow.cloneNode(true);
+        resultsTbody.appendChild(row);
+        openils.acq.Lineitem.fetchAndRender(
+            li_id, {}, 
+            function(li, html) { 
+                dojo.query('[name=search-results-content-div]', row)[0].innerHTML = html;
+            }
+        );
     }
 }
 
index 48ffffd..f023dd4 100644 (file)
@@ -255,7 +255,7 @@ function TermManager() {
     };
 
     this.terms = {};
-    ["jub", "acqpl", "acqpo", "acqinv"].forEach(
+    ["jub", "acqpl", "acqpo", "acqinv", "acqlid"].forEach(
         function(hint) {
             var o = {};
             o.__label = fieldmapper.IDL.fmclasses[hint].label;
@@ -791,10 +791,15 @@ function ResultManager(liPager, poGrid, plGrid, invGrid) {
 
     this.go = function(search_object) {
 
-        if (unifiedSearchMode == 'invoice') {
-            var self = this;
-            dojo.forEach([1,2,3,4,5], function(idx) {self.add('lineitem', 'foo ' + idx)});
+        if (unifiedSearchMode == 'invoice') { // TODO: s/invoice/inline/ or some such
+            uriManager = new URIManager();
+            uriManager.search_object = search_object;
+            uriManager.result_type = dojo.byId("acq-unified-result-type").getValue();
+            uriManager.conjunction = dojo.byId("acq-unified-conjunction").getValue();
+            this.search(uriManager, termManager);
+
         } else {
+
         location.href = oilsBasePath + "/acq/search/unified?" +
             "so=" + base64Encode(search_object) +
             "&rt=" + dojo.byId("acq-unified-result-type").getValue() +