From 5ef3fd0c7a93ea5ca972ff8eddf8b37268f90877 Mon Sep 17 00:00:00 2001 From: senator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Thu, 13 May 2010 21:07:16 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16432 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js | 7 ++++--- Open-ILS/web/js/ui/default/acq/common/li_table.js | 13 +++++++++---- Open-ILS/web/js/ui/default/acq/common/li_table_pager.js | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js b/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js index 50f2d27352..3bb1dcd509 100644 --- a/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js +++ b/Open-ILS/web/js/dojo/openils/widget/XULTermLoader.js @@ -85,9 +85,10 @@ if (!dojo._hasResource["openils.widget.XULTermLoader"]) { }, "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; }); } } ); diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index 19a8754a13..b881630450 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -110,12 +110,14 @@ function AcqLiTable() { 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 @@ function AcqLiTable() { /** @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) { diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js b/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js index d352e5258a..ba92d94d2b 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js @@ -21,7 +21,7 @@ function LiTablePager() { [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); }); } -- 2.11.0