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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jun 16 13:41:28 EDT 2010


Author: senator
Date: 2010-06-16 13:41:25 -0400 (Wed, 16 Jun 2010)
New Revision: 16729

Modified:
   trunk/Open-ILS/web/js/dojo/openils/Util.js
   trunk/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js
   trunk/Open-ILS/web/js/ui/default/acq/picklist/from_bib.js
Log:
Acq: bugfixes for "Import Catalog Records by ID"

Previously, this interface did not correctly interpret realistic CSV data as
produced by the Reporter module, as it was intended to do.


Modified: trunk/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/Util.js	2010-06-16 17:32:08 UTC (rev 16728)
+++ trunk/Open-ILS/web/js/dojo/openils/Util.js	2010-06-16 17:41:25 UTC (rev 16729)
@@ -282,5 +282,11 @@
         return K;
     }
 
+    openils.Util.uniqueElements = function(L) {
+        var o = {};
+        for (var k in L) o[L[k]] = true;
+        return openils.Util.objectProperties(o);
+    }
+
 }
 

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js	2010-06-16 17:32:08 UTC (rev 16728)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js	2010-06-16 17:41:25 UTC (rev 16729)
@@ -63,11 +63,14 @@
                         alert(this._.TERM_LIMIT);
                         return;
                     }
-                    var data = this.parseUnimaginatively(
+                    var data = this[
+                        this.parseCSV ? "parseAsCSV" : "parseUnimaginatively"
+                    ](
                         openils.XUL.contentFromFileOpenDialog(
                             this._.CHOOSE_FILE, this.args.fileSizeLimit
                         )
                     );
+
                     if (data.length + this.terms.length >=
                         this.args.termLimit) {
                         alert(this._.TERM_LIMIT_SOME);
@@ -83,6 +86,17 @@
                     alert(E);
                 }
             },
+            "parseAsCSV": function(data) {
+                return this.parseUnimaginatively(data).
+                    map(
+                        function(o) {
+                            return o.match(/^".+"$/) ? o.slice(1,-1) : o;
+                        }
+                    ).
+                    filter(
+                        function(o) { return Boolean(o.match(/^\d+$/)); }
+                    );
+            },
             "parseUnimaginatively": function(data) {
                 if (!data) return [];
                 else return data.split("\n").

Modified: trunk/Open-ILS/web/js/ui/default/acq/picklist/from_bib.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/picklist/from_bib.js	2010-06-16 17:32:08 UTC (rev 16728)
+++ trunk/Open-ILS/web/js/ui/default/acq/picklist/from_bib.js	2010-06-16 17:41:25 UTC (rev 16729)
@@ -7,10 +7,15 @@
 var usingPl = null;
 
 function fetchRecords() {
-    var data = termLoader.attr("value");
+    var data = openils.Util.uniqueElements(termLoader.attr("value"));
     var result_count = 0;
-    pager.total = data.length;
+    // Don't show a total for now... This total is the total number of
+    // search terms, but a user would take it to mean the total number of
+    // results, which we don't have a straightfoward way of getting without
+    // doing the search more that once.
 
+    // pager.total = data.length;
+
     progressDialog.show(true);
     fieldmapper.standardRequest(
         ["open-ils.acq", "open-ils.acq.biblio.create_by_id"], {
@@ -60,7 +65,7 @@
 
 function init() {
     new openils.widget.XULTermLoader(
-        {"parentNode": "acq-frombib-upload"}
+        {"parentNode": "acq-frombib-upload", "parseCSV": true}
     ).build(function(w) { termLoader = w; });
     liTable = new AcqLiTable();
     pager = new LiTablePager(fetchRecords, liTable);



More information about the open-ils-commits mailing list