[open-ils-commits] r16432 - in trunk/Open-ILS/web/js: dojo/openils/widget ui/default/acq/common (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu May 13 17:07:22 EDT 2010


Author: senator
Date: 2010-05-13 17:07:16 -0400 (Thu, 13 May 2010)
New Revision: 16432

Modified:
   trunk/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js
Log:
Acq: the XULTermLoader dijit now returns the first columns of CSV rows

Could be improved later to allow more control over what data you get back,
but it works fine for the current uses (reading a file of one-term-per-line
for unified search and reading a CSV file where the first column is of
interest in the Bib record->lineitem interface).

Also added a little support to the LI table/pager for remember what lineitems
are selected even after you move on to the next page.  Nothing really takes
full advantage of this yet, though.


Modified: trunk/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js	2010-05-13 20:19:02 UTC (rev 16431)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js	2010-05-13 21:07:16 UTC (rev 16432)
@@ -85,9 +85,10 @@
             },
             "parseUnimaginatively": function(data) {
                 if (!data) return [];
-                else return data.split(/[\n, ]/).filter(
-                    function(o) { return o.length > 0; }
-                );
+                else return data.split("\n").
+                    filter(function(o) { return o.length > 0; }).
+                    map(function(o) { return o.split(",")[0] }).
+                    filter(function(o) { return o.length > 0; });
             }
         }
     );

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-05-13 20:19:02 UTC (rev 16431)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-05-13 21:07:16 UTC (rev 16432)
@@ -110,12 +110,14 @@
     dojo.byId('acq-lit-notes-back-button').onclick = function(){self.show('list')};
     dojo.byId('acq-lit-real-copies-back-button').onclick = function(){self.show('list')};
 
-    this.reset = function() {
+    this.reset = function(keep_selectors) {
         while(self.tbody.childNodes[0])
             self.tbody.removeChild(self.tbody.childNodes[0]);
-        self.selectors = [];
         self.noteAcks = {};
         self.relCache = {};
+
+        if (!keep_selectors)
+            self.selectors = [];
     };
     
     this.setNext = function(handler) {
@@ -182,13 +184,16 @@
     /** @param all If true, assume all are selected */
     this.getSelected = function(all) {
         var selected = [];
+        var indices = {};   /* use to uniqify. needed in paging situations. */
         dojo.forEach(self.selectors, 
             function(i) { 
                 if(i.checked || all)
-                    selected.push(self.liCache[i.parentNode.parentNode.getAttribute('li')]);
+                    indices[i.parentNode.parentNode.getAttribute('li')] = true;
             }
         );
-        return selected;
+        return openils.Util.objectProperties(indices).map(
+            function(liId) { return self.liCache[liId]; }
+        );
     };
 
     this.setRowAttr = function(td, liWrapper, field, type) {

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js	2010-05-13 20:19:02 UTC (rev 16431)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js	2010-05-13 21:07:16 UTC (rev 16432)
@@ -21,7 +21,7 @@
         [this.batch, this.total] = this.fetcher(this.offset, this.limit);
 
         if (this.batch.length) {
-            this.liTable.reset();
+            this.liTable.reset(/* keep_selectors */ true);
             this.liTable.show("list");
             this.batch.forEach(function(li) { self.liTable.addLineitem(li); });
         }



More information about the open-ils-commits mailing list