this.rowTemplate = this.tbody.removeChild(dojo.byId('acq-lit-row'));
this.copyTbody = dojo.byId('acq-lit-li-details-tbody');
this.copyRow = this.copyTbody.removeChild(dojo.byId('acq-lit-li-details-row'));
+ this.copyBatchRow = dojo.byId('acq-lit-li-details-batch-row');
dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()};
dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')};
this.drawCopies = function(liId) {
this.show('copies');
+ var self = this;
this.copyCache = {};
+ this.copyWidgetCache = {};
+ this.copyBatchWidgets = {};
acqLitSaveCopies.onClick = function() { self.saveCopyChanges(liId) };
+ acqLitBatchUpdateCopies.onClick = function() { self.batchCopyUpdate() };
+
while(this.copyTbody.childNodes[0])
this.copyTbody.removeChild(this.copyTbody.childNodes[0]);
+
+ var row = this.copyBatchRow;
+ if(!this.copyBatchRowDrawn) {
+ dojo.forEach(['fund', 'owning_lib', 'location'],
+ function(field) {
+ var widget = new openils.widget.AutoFieldWidget({
+ fmField : field,
+ fmClass : 'acqlid',
+ parentNode : dojo.query('[name='+field+']', row)[0],
+ orgLimitPerms : ['CREATE_PICKLIST'],
+ });
+ widget.build();
+ self.copyBatchWidgets[field] = widget.widget;
+ }
+ );
+ this.copyBatchRowDrawn = true;
+ };
+
+
openils.acq.Lineitem.fetchAttrDefs(
function() {
self._fetchLineitem(liId, function(li){self._drawCopies(li);});
);
};
+ this.batchCopyUpdate = function() {
+ var self = this;
+ var fields = ['fund', 'owning_lib', 'location'];
+ for(var k in this.copyWidgetCache) {
+ var cache = this.copyWidgetCache[k];
+ dojo.forEach(fields, function(f) {
+ var newval = self.copyBatchWidgets[f].attr('value');
+ if(newval) cache[f].attr('value', newval);
+ });
+ }
+ };
this._drawCopies = function(li) {
acqLitAddCopyCount.onClick = function() {
this.addCopy = function(li, copy) {
var row = this.copyRow.cloneNode(true);
this.copyTbody.appendChild(row);
+ var self = this;
if(!copy) {
copy = new fieldmapper.acqlid();
this.copyCache[copy.id()] = copy;
row.setAttribute('copy_id', copy.id());
+ self.copyWidgetCache[copy.id()] = {};
dojo.forEach(['fund', 'owning_lib', 'location', 'barcode', 'cn_label'],
function(field) {
}
}
);
+ self.copyWidgetCache[copy.id()][field] = widget.widget;
}
);
- var self = this;
dojo.query('[name=delete]', row)[0].onclick =
function() { self.deleteCopy(row) };
};
<!-- Copies table -->
<div id='acq-lit-li-details' class='hidden'>
<h2>Copies</h2>
+
<div class='acq-lit-li-menu-bar'>
<table style='width:100%'>
<tr>
</div>
<table id='acq-lit-li-details-table'>
- <thead>
+ <tbody style='background-color:#ddd;'>
+ <tr id='acq-lit-li-details-batch-row'>
+ <td><div name='owning_lib'/></td>
+ <td><div name='location'/></td>
+ <td><div name='fund'/></td>
+ <td colspan='3' style='text-align:left;'>
+ <div dojoType='dijit.form.Button' jsId='acqLitBatchUpdateCopies'>Batch Update</div>
+ </td>
+ </tr>
+ </tbody>
+ <tbody><tr><td colspan='0' style='height:20px;'/></tr></tbody>
+ <tbody style='font-weight:bold;'>
<tr>
- <th>Owning Branch</th>
- <th>Shelving Location</th>
- <th>Fund</th>
- <th>Barcode</th>
- <th>Callnumber</th>
- <th/>
+ <td style='margin-top:30px;'>Owning Branch</td>
+ <td>Shelving Location</td>
+ <td>Fund</td>
+ <td>Barcode</td>
+ <td>Callnumber</td>
+ <td/>
</tr>
- </thead>
+ </tbody>
<tbody id='acq-lit-li-details-tbody'>
<tr id='acq-lit-li-details-row'>
<td><div name='owning_lib'/></td>