[open-ils-commits] r10018 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
public/oils/media/ui_js/oils/default/acq/picklist
templates/oils/default/acq/picklist
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jul 11 18:53:32 EDT 2008
Author: erickson
Date: 2008-07-11 18:53:32 -0400 (Fri, 11 Jul 2008)
New Revision: 10018
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/bib_search.js
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/bib_search.html
Log:
added the ability to save selected search results and save results to an existing picklist
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/bib_search.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/bib_search.js 2008-07-11 18:40:48 UTC (rev 10017)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/bib_search.js 2008-07-11 22:53:32 UTC (rev 10018)
@@ -6,10 +6,13 @@
dojo.require('dijit.form.NumberSpinner');
dojo.require('openils.Event');
dojo.require('openils.acq.Picklist');
+dojo.require('openils.acq.Lineitems');
dojo.require('openils.User');
var searchFields = [];
var resultPicklist;
+var resultLIs;
+var selectedLIs;
var recvCount = 0;
var sourceCount = 0; // how many sources are we searching
var user = new openils.User();
@@ -112,6 +115,7 @@
function viewResults(plId) {
var plist = new openils.acq.Picklist(plId,
function(model) {
+ resultLIs = plist._items;
dojo.style('oils-acq-pl-search-results', 'visibility', 'visible');
JUBGrid.populate(plResultGrid, model, plist._items);
},
@@ -120,13 +124,74 @@
resultPicklist = plist._plist;
}
+function loadPLSelect() {
+ var plList = [];
+ function handleResponse(r) {
+ plList.push(r.recv().content());
+ }
+ var method = 'open-ils.acq.picklist.user.retrieve';
+ fieldmapper.standardRequest(
+ ['open-ils.acq', method],
+ { async: true,
+ params: [openils.User.authtoken],
+ onresponse: handleResponse,
+ oncomplete: function() {
+ plAddExistingSelect.store =
+ new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)});
+ plAddExistingSelect.setValue();
+ }
+ }
+ );
+}
+
+
function saveResults(values) {
- if(!values.name) return;
- resultPicklist.name(values.name);
- openils.acq.Picklist.update(resultPicklist,
- function(stat) {
- location.href = 'view/' + resultPicklist.id();
+ selectedLIs = resultLIs;
+
+ if(values.which == 'selected') {
+ selectedLIs = [];
+ var selected = plResultGrid.selection.getSelected();
+ for(var idx = 0; idx < selected.length; idx++) {
+ var rowIdx = selected[idx];
+ var id = plResultGrid.model.getRow(rowIdx).id;
+ for(var i = 0; i < resultLIs.length; i++) {
+ var pl = resultLIs[i];
+ if(pl.id() == id) {
+ selectedLIs.push(pl);
+ }
+ }
}
+ }
+
+ if(values.new_name && values.new_name != '') {
+ // XXX create a new PL and copy LIs over
+ /*
+ if(values.which = 'selected') {
+ resultPicklist = new acqpl();
+ resultPicklist.owner(user.user.id())
+ }
+ */
+ resultPicklist.name(values.new_name);
+ openils.acq.Picklist.update(resultPicklist,
+ function(stat) {
+ location.href = 'view/' + resultPicklist.id();
+ }
+ );
+ } else if(values.existing_pl) {
+ updateLiList(values.existing_pl, selectedLIs, 0,
+ function(){location.href = 'view/' + values.existing_pl});
+ }
+}
+
+function updateLiList(pl, list, idx, oncomplete) {
+ if(idx >= list.length)
+ return oncomplete();
+ var li = selectedLIs[idx];
+ li.picklist(pl);
+ new openils.acq.Lineitems({lineitem:li}).update(
+ function(r) {
+ updateLiList(pl, list, ++idx, oncomplete);
+ }
);
}
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/bib_search.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/bib_search.html 2008-07-11 18:40:48 UTC (rev 10017)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/bib_search.html 2008-07-11 22:53:32 UTC (rev 10018)
@@ -66,13 +66,30 @@
<span>${('Save Results')}</span>
<div dojoType="dijit.TooltipDialog" execute="saveResults(arguments[0]);">
<script type='dojo/connect' event='onOpen'>
+ loadPLSelect();
</script>
<table class='dijitTooltipTable'>
<tr>
- <td><label for="name">${_('Save as picklist:')} </label></td>
- <td><input dojoType="dijit.form.TextBox" name="name"></td>
+ <td colspan='2'>
+ <input dojoType="dijit.form.RadioButton" name="which" type='radio' checked='checked' value='selected'/>
+ <label for="name">${_('Save selected')}</label>
+ <input dojoType="dijit.form.RadioButton" name="which" type='radio' value='all'/>
+ <label for="name">${_('Save all')}</label>
+ </td>
</tr>
+ <tr><td colspan='2'><hr/></td></tr>
<tr>
+ <td><label for="new_name">${_('Save as picklist:')} </label></td>
+ <td><input dojoType="dijit.form.TextBox" name="new_name"/></td>
+ </tr>
+ <tr>
+ <td><label for="existing_pl">${_('Add to picklist:')} </label></td>
+ <td>
+ <input jsId='plAddExistingSelect' dojoType="dijit.form.FilteringSelect"
+ name="existing_pl" searchAttr='name' displayAttr='name'/>
+ </td>
+ </tr>
+ <tr>
<td colspan='2' align='center'>
<button dojoType=dijit.form.Button type="submit">${_('Save')}</button>
</td>
More information about the open-ils-commits
mailing list