dojo.require('dijit.form.ComboBox');
dojo.require('openils.CGI');
+// KCLS: used for tracking selected lineitems that are
+// not visibible in the current page of lineitems.
+// Stores a JSON hash of lineitem ID's
+var checkBoxStorage = openils.XUL.localStorage();
+
+if (window.location.toString().indexOf('picklist/view/') < 0) {
+ // only tracking selection of multiple pages of
+ // lineitems on the picklist page.
+ checkBoxStorage.removeItem('eg.acq.piclist.selected');
+}
+
if (!localeStrings) { /* we can do this because javascript doesn't have block scope */
dojo.requireLocalization('openils.acq', 'acq');
var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
}
this.toggleSelect = function() {
- if(self.toggleState)
- dojo.forEach(self.selectors, function(i){i.checked = false});
- else
- dojo.forEach(self.selectors, function(i){i.checked = true});
self.toggleState = !self.toggleState;
+ var fromStore = self.storedLiSelection();
+
+ dojo.forEach(self.selectors, function(i) {
+
+ i.checked = self.toggleState;
+ var id = i.parentNode.parentNode.getAttribute('li');
+
+ if (self.toggleState) {
+ fromStore[id] = true;
+ } else {
+ delete fromStore[id];
+ }
+ });
+
+ checkBoxStorage.setItem(
+ 'eg.acq.piclist.selected', js2JSON(fromStore));
};
}
);
+ var fromStore = self.storedLiSelection();
+ indices = dojo.mixin(indices, fromStore);
+
var result = openils.Util.objectProperties(indices);
// caller provided a lineitem state filter. remove IDs for lineitems
}
return li;
}
+
+ this.storedLiSelection = function() {
+ return JSON2js(checkBoxStorage.getItem(
+ 'eg.acq.piclist.selected') || "{}");
+ }
+
/**
* Inserts a single lineitem into the growing table of lineitems
}
}
- self.selectors.push(dojo.query('[name=selectbox]', row)[0]);
+ var liSelector = dojo.query('[name=selectbox]', row)[0];
+ self.selectors.push(liSelector);
+
+ // when selecting a lineitem, add it to the stored list
+ // of selected lineitems
+ liSelector.onclick = function() {
+ var fromStore = self.storedLiSelection();
+ if (this.checked) {
+ fromStore[li.id()] = true;
+ } else {
+ delete fromStore[li.id()];
+ }
+ checkBoxStorage.setItem(
+ 'eg.acq.piclist.selected', js2JSON(fromStore));
+ };
+
+ // if a lineitem is in the set of selected lineitems,
+ // set the selector input to checked on page load.
+ var fromStore = self.storedLiSelection();
+ if (fromStore[li.id()]) liSelector.checked = true;
// sort the lineitem notes on edit_time
if(!li.lineitem_notes()) li.lineitem_notes([]);