dojo.require('openils.Util');
dojo.require('openils.acq.Lineitem');
dojo.require('openils.widget.AutoFieldWidget');
+dojo.require('dojo.data.ItemFileReadStore');
function AcqLiTable() {
this.copyRow = this.copyTbody.removeChild(dojo.byId('acq-lit-li-details-row'));
this.copyBatchRow = dojo.byId('acq-lit-li-details-batch-row');
this.copyBatchWidgets = {};
+ dojo.connect(acqLitLiActionsSelector, 'onChange',
+ function() {
+ self.applySelectedLiAction(this.attr('value'))
+ acqLitLiActionsSelector.attr('value', '_');
+ });
dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()};
dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')};
self.toggleState = !self.toggleState;
};
+
/** @param all If true, assume all are selected */
this.getSelected = function(all) {
var selected = [];
// XXX media prefix for added content
dojo.query('[name=jacket]', row)[0].setAttribute('src', '/opac/extras/ac/jacket/small/' + isbn);
}
- dojo.query('[name=infolink]', row)[0].onclick = function() {self.drawInfo(li.id())};
+ //dojo.query('[name=infolink]', row)[0].onclick = function() {self.drawInfo(li.id())};
+ dojo.query('[attr=title]', row)[0].onclick = function() {self.drawInfo(li.id())};
dojo.query('[name=copieslink]', row)[0].onclick = function() {self.drawCopies(li.id())};
dojo.query('[name=count]', row)[0].appendChild(document.createTextNode(li.item_count()));
self.tbody.appendChild(row);
self.selectors.push(dojo.query('[name=selectbox]', row)[0]);
};
+ this.removeLineitem = function(liId) {
+ console.log(liId);
+ console.log('[li='+liId+']');
+ console.log(dojo.query('[li='+liId+']', this.tbody)[0]);
+ this.tbody.removeChild(dojo.query('[li='+liId+']', this.tbody)[0]);
+ delete this.liCache[liId];
+ }
+
this.drawInfo = function(liId) {
this.show('info');
openils.acq.Lineitem.fetchAttrDefs(
while(this.copyTbody.childNodes[0])
this.copyTbody.removeChild(this.copyTbody.childNodes[0]);
+ this._drawBatchCopyWidgets();
+
+ this._fetchDistribFormulas(
+ function() {
+ openils.acq.Lineitem.fetchAttrDefs(
+ function() {
+ self._fetchLineitem(liId, function(li){self._drawCopies(li);});
+ }
+ );
+ }
+ );
+ };
+
+ this._fetchDistribFormulas = function(onload) {
+ if(this.distribForms) {
+ onload();
+ } else {
+ var self = this;
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.distribution_formula.ranged.retrieve.atomic'],
+ { async: true,
+ params: [openils.User.authtoken],
+ oncomplete: function(r) {
+ self.distribForms = openils.Util.readResponse(r);
+ self.distribFormulaStore =
+ new dojo.data.ItemFileReadStore(
+ {data:acqdf.toStoreData(self.distribForms)});
+ onload();
+ }
+ }
+ );
+ }
+ }
+
+ this._drawBatchCopyWidgets = function() {
var row = this.copyBatchRow;
dojo.forEach(['fund', 'owning_lib', 'location'],
function(field) {
}
);
this.copyBatchRowDrawn = true;
-
-
- openils.acq.Lineitem.fetchAttrDefs(
- function() {
- self._fetchLineitem(liId, function(li){self._drawCopies(li);});
- }
- );
};
this.batchCopyUpdate = function() {
}
);
}
+
+ this.applySelectedLiAction = function(action) {
+ switch(action) {
+ case 'delete_selected':
+ self._deleteLiList(self.getSelected());
+ break;
+ }
+ }
+
+ this._deleteLiList = function(list, idx) {
+ if(idx == null) idx = 0;
+ if(idx >= list.length) return;
+ var liId = list[idx].id();
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.lineitem.delete'],
+ { async: true,
+ params: [openils.User.authtoken, liId],
+ oncomplete: function(r) {
+ self.removeLineitem(liId);
+ self._deleteLiList(list, ++idx);
+ }
+ }
+ );
+ }
}
<td>
<div style='width:100%;text-align:right;'>
<span>
- <select dojoType='dijit.form.FilteringSelect' value='_'>
+ <select dojoType='dijit.form.FilteringSelect' value='_' jsId='acqLitLiActionsSelector'>
<option value='_'>--Actions--</option>
+ <option value='delete_selected'>Delete Selected Items</option>
<option value='selector_ready'>Mark Ready for Selector</option>
<option value='order_ready'>Mark Ready for Order</option>
<option value='create_order'>Create Purchase Order</option>
<table style='width:100%;'>
<tbody>
<tr>
- <td rowspan='2'><img style='width:40px;height:65px;' name='jacket'/></td>
- <td attr='title' style='width:70%;font-weight:bold;'/>
+ <td rowspan='2' style='width:43px;'><img style='width:40px;height:65px;' name='jacket'></img></td>
+ <td style='width:70%;font-weight:bold;'><a attr='title' href='javascript:void(0);'></a></td>
<td rowspan='2' style='text-align:right'>
+ <!--
<a name='infolink' href='javascript:void(0);' style='margin-right:10px;'>Details</a>
+ -->
<a name='copieslink' href='javascript:void(0);'
style='margin-right:20px;'>Copies(<span name='count'></span>)</a>
</td>
</td>
</tr>
</tbody>
+ <!--
+ <tbody><tr>
+ <td colspan='0'>
+ <a href='javascript:void(0);'
+ onclick='openils.Util.toggle("acq-lit-distrib-formula-tbody");'>Distribution Formulas</a>
+ </td>
+ </tr></tbody>
+ -->
+ <tbody id='acq-lit-distrib-formula-tbody' class='hidden'>
+ <tr id='acq-lit-distrib-form-row'>
+ <td name='selector'/>
+ <td name='setbutton'/>
+ </tr>
+ </tbody>
<tbody><tr><td class='acq-lit-table-spacer' colspan='0'/></tr></tbody>
<tbody style='font-weight:bold;'>
<tr>