[open-ils-commits] r12573 - in trunk/Open-ILS/web: js/ui/default/acq/common templates/default/acq/common (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Mar 18 10:44:16 EDT 2009
Author: erickson
Date: 2009-03-18 10:44:14 -0400 (Wed, 18 Mar 2009)
New Revision: 12573
Modified:
trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Log:
added a copy (li_details) pane for creating a managing copies
Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-03-18 14:43:30 UTC (rev 12572)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-03-18 14:44:14 UTC (rev 12573)
@@ -1,5 +1,6 @@
dojo.require('dijit.form.Button');
dojo.require('dijit.form.TextBox');
+dojo.require('dijit.ProgressBar');
dojo.require('openils.User');
dojo.require('openils.Util');
dojo.require('openils.acq.Lineitem');
@@ -183,6 +184,10 @@
this.drawCopies = function(liId) {
this.show('copies');
+ this.copyCache = {};
+ acqLitSaveCopies.onClick = function() { self.saveCopyChanges(liId) };
+ while(this.copyTbody.childNodes[0])
+ this.copyTbody.removeChild(this.copyTbody.childNodes[0]);
openils.acq.Lineitem.fetchAttrDefs(
function() {
self._fetchLineitem(liId, function(li){self._drawCopies(li);});
@@ -197,17 +202,32 @@
for(var i = 0; i < count; i++)
self.addCopy(li);
}
- dojo.forEach(li.lineitem_details(),
- function(copy) {
- self.addCopy(copy);
- }
- );
+ if(li.lineitem_details().length > 0) {
+ dojo.forEach(li.lineitem_details(),
+ function(copy) {
+ self.addCopy(li, copy);
+ }
+ );
+ } else {
+ self.addCopy(li);
+ }
};
+ this.virtCopyId = -1;
this.addCopy = function(li, copy) {
var row = this.copyRow.cloneNode(true);
this.copyTbody.appendChild(row);
+ if(!copy) {
+ copy = new fieldmapper.acqlid();
+ copy.isnew(true);
+ copy.id(this.virtCopyId--);
+ copy.lineitem(li.id());
+ }
+
+ this.copyCache[copy.id()] = copy;
+ row.setAttribute('copy_id', copy.id());
+
dojo.forEach(['fund', 'owning_lib', 'location'],
function(field) {
var widget = new openils.widget.AutoFieldWidget({
@@ -218,14 +238,61 @@
orgLimitPerms : ['CREATE_PICKLIST'],
});
widget.build();
+ dojo.connect(widget.widget, 'onChange',
+ function() { copy[field](widget.getFormattedValue()) });
}
);
- if(copy) {
+ if(!copy.isnew()) {
dojo.query('[name=barcode]', row)[0].value = copy.barcode();
dojo.query('[name=cn_label]', row)[0].value = copy.cn_label();
}
+
+ var self = this;
+ dojo.query('[name=delete]', row)[0].onclick =
+ function() { self.deleteCopy(row) };
+ };
+
+ this.deleteCopy = function(row) {
+ var copy = this.copyCache[row.getAttribute('copy_id')];
+ copy.isdeleted(true);
+ if(copy.isnew())
+ delete this.copyCache[copy.id()];
+ this.copyTbody.removeChild(row);
}
+
+ this.saveCopyChanges = function(liId) {
+ var self = this;
+ var copies = [];
+
+ openils.Util.show('acq-lit-update-copies-progress');
+
+ for(var id in this.copyCache) {
+ var c = this.copyCache[id];
+ if(c.isnew() || c.ischanged() || c.isdeleted()) {
+ if(c.id() < 0) c.id(null);
+ copies.push(c);
+ }
+ }
+
+ if(copies.length == 0)
+ return;
+
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.lineitem_detail.cud.batch'],
+ { async: true,
+ params: [openils.User.authtoken, copies],
+ onresponse: function(r) {
+ var res = openils.Util.readResponse(r);
+ litUpdateCopiesProgress.update(res);
+ },
+ oncomplete: function() {
+ openils.Util.hide('acq-lit-update-copies-progress');
+ self.drawCopies(liId);
+ }
+ }
+ );
+ }
}
Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-03-18 14:43:30 UTC (rev 12572)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-03-18 14:44:14 UTC (rev 12573)
@@ -1,6 +1,8 @@
<script src='[% ctx.media_prefix %]/js/ui/default/acq/common/li_table.js'> </script>
<div id='acq-lit-table-container'>
<div id='acq-lit-table-div' class='hidden'>
+
+ <!-- Lineitem (bib record) list -->
<table id='acq-lit-table'>
<thead>
<tr>
@@ -50,6 +52,7 @@
</table>
</div>
+ <!-- Bib record / Lineitem details table -->
<div id='acq-lit-info-div' class='hidden'>
<div dojoType='dijit.form.Button' id='acq-lit-info-back-button'>↖ Return</div>
<table>
@@ -63,33 +66,51 @@
</div>
</div>
+ <!-- Copies table -->
<div id='acq-lit-li-details' class='hidden'>
<h2>Copies</h2>
- <table id='acq-lit-li-details-table'>
- <thead>
+ <table style='width:100%;'>
+ <tbody>
<tr>
- <th>Owning Branch</th>
- <th>Shelving Location</th>
- <th>Fund</th>
- <th>Barcode</th>
- <th>Callnumber</th>
- <th style='text-align:right;width:30%'>
- Add items to order:
- <input dojoType='dijit.form.NumberTextBox' jsId='acqLitCopyCountInput'
- constraints="{min:1,max:1000,places:0}" style='width:40px' value='1'></input>
- <div dojoType='dijit.form.Button' jsId='acqLitAddCopyCount'>Go</div>
- </th>
+ <td style='width:75%'>
+ <table id='acq-lit-li-details-table'>
+ <thead>
+ <tr>
+ <th>Owning Branch</th>
+ <th>Shelving Location</th>
+ <th>Fund</th>
+ <th>Barcode</th>
+ <th>Callnumber</th>
+ <th/>
+ </tr>
+ </thead>
+ <tbody id='acq-lit-li-details-tbody'>
+ <tr id='acq-lit-li-details-row'>
+ <td><div name='owning_lib'/></td>
+ <td><div name='location'/></td>
+ <td><div name='fund'/></td>
+ <td><input type='text' name='barcode'/></td>
+ <td><input type='text' name='cn_label'/></td>
+ <td><div name='delete' dojoType='dijit.form.Button' style='color:red;'>X</div></td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td style='vertical-align:top;text-align:center;'>
+ <div style='border:1px solid #999;'>
+ Add items to order:
+ <input dojoType='dijit.form.NumberTextBox' jsId='acqLitCopyCountInput'
+ constraints="{min:1,max:1000,places:0}" style='width:40px' value='1'></input>
+ <div dojoType='dijit.form.Button' jsId='acqLitAddCopyCount'>Go</div>
+ </div>
+ <div style='border:1px solid #999;margin-top:20px;'>
+ <div dojoType='dijit.form.Button' jsId='acqLitSaveCopies'>Save Changes</div>
+ </div>
+ <div id='acq-lit-update-copies-progress' class='hidden'>
+ <div dojoType="dijit.ProgressBar" style="width:300px" jsId="litUpdateCopiesProgress"></div>
+ </div>
+ </td>
</tr>
- </thead>
- <tbody id='acq-lit-li-details-tbody'>
- <tr id='acq-lit-li-details-row'>
- <td><div name='owning_lib'/></td>
- <td><div name='location'/></td>
- <td><div name='fund'/></td>
- <td><input type='text' name='barcode'/></td>
- <td><input type='text' name='cn_label'/></td>
- <td/>
- </tr>
</tbody>
</table>
</div>
More information about the open-ils-commits
mailing list