[open-ils-commits] r17368 - in branches/rel_1_6/Open-ILS: examples src/sql/Pg xul/staff_client/server/admin xul/staff_client/server/cat (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Aug 30 10:14:14 EDT 2010
Author: dbs
Date: 2010-08-30 10:14:12 -0400 (Mon, 30 Aug 2010)
New Revision: 17368
Added:
branches/rel_1_6/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql
Modified:
branches/rel_1_6/Open-ILS/examples/fm_IDL.xml
branches/rel_1_6/Open-ILS/src/sql/Pg/040.schema.asset.sql
branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/copy_locations.js
branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml
branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/spine_labels.js
Log:
Backport spine label prefix/suffix and printing fixes for XUL 1.9.0 from trunk
Modified: branches/rel_1_6/Open-ILS/examples/fm_IDL.xml
===================================================================
--- branches/rel_1_6/Open-ILS/examples/fm_IDL.xml 2010-08-30 14:13:00 UTC (rev 17367)
+++ branches/rel_1_6/Open-ILS/examples/fm_IDL.xml 2010-08-30 14:14:12 UTC (rev 17368)
@@ -2523,6 +2523,8 @@
<field reporter:label="Name" name="name" reporter:datatype="text" oils_persist:i18n="true"/>
<field reporter:label="Is OPAC Visible?" name="opac_visible" reporter:datatype="bool"/>
<field reporter:label="Owning Org Unit" name="owning_lib" reporter:datatype="org_unit"/>
+ <field reporter:label="Label Prefix" name="label_prefix" reporter:datatype="text" oils_persist:i18n="true"/>
+ <field reporter:label="Label Suffix" name="label_suffix" reporter:datatype="text" oils_persist:i18n="true"/>
</fields>
<links>
<link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
Modified: branches/rel_1_6/Open-ILS/src/sql/Pg/040.schema.asset.sql
===================================================================
--- branches/rel_1_6/Open-ILS/src/sql/Pg/040.schema.asset.sql 2010-08-30 14:13:00 UTC (rev 17367)
+++ branches/rel_1_6/Open-ILS/src/sql/Pg/040.schema.asset.sql 2010-08-30 14:14:12 UTC (rev 17368)
@@ -29,6 +29,8 @@
hold_verify BOOL NOT NULL DEFAULT FALSE,
opac_visible BOOL NOT NULL DEFAULT TRUE,
circulate BOOL NOT NULL DEFAULT TRUE,
+ label_prefix TEXT,
+ label_suffix TEXT,
CONSTRAINT acl_name_once_per_lib UNIQUE (name, owning_lib)
);
Added: branches/rel_1_6/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql
===================================================================
--- branches/rel_1_6/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql (rev 0)
+++ branches/rel_1_6/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql 2010-08-30 14:14:12 UTC (rev 17368)
@@ -0,0 +1,8 @@
+BEGIN;
+
+-- Start picking up call number label prefixes and suffixes
+-- from asset.copy_location
+ALTER TABLE asset.copy_location ADD COLUMN label_prefix TEXT;
+ALTER TABLE asset.copy_location ADD COLUMN label_suffix TEXT;
+
+COMMIT;
Modified: branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/copy_locations.js
===================================================================
--- branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/copy_locations.js 2010-08-30 14:13:00 UTC (rev 17367)
+++ branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/copy_locations.js 2010-08-30 14:14:12 UTC (rev 17368)
@@ -160,6 +160,8 @@
appendClear($n( row, 'cl_hold_verify'), (isTrue(cl.hold_verify())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
appendClear($n( row, 'cl_visible'), (isTrue(cl.opac_visible())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
appendClear($n( row, 'cl_circulate'), (isTrue(cl.circulate())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
+ $n( row, 'cl_label_prefix').appendChild(text(cl.label_prefix()));
+ $n( row, 'cl_label_suffix').appendChild(text(cl.label_suffix()));
var edit = $n( row, 'cl_edit');
edit.onclick = function() { clEdit( cl, tbody, row ); };
@@ -192,6 +194,22 @@
if(isTrue(cl.hold_verify())) arr[6].checked = true;
else arr[7].checked = true;
+ var label_prefix = $n(r, 'cl_edit_label_prefix');
+ if (cl.label_prefix()) {
+ label_prefix.setAttribute('size', cl.label_prefix().length + 3);
+ } else {
+ label_prefix.setAttribute('size', 3);
+ }
+ label_prefix.value = cl.label_prefix();
+
+ var label_suffix = $n(r, 'cl_edit_label_suffix');
+ if (cl.label_suffix()) {
+ label_suffix.setAttribute('size', cl.label_suffix().length + 3);
+ } else {
+ label_suffix.setAttribute('size', 3);
+ }
+ label_suffix.value = cl.label_suffix();
+
$n(r, 'cl_edit_cancel').onclick = function(){cleanTbody(tbody,'edit');}
$n(r, 'cl_edit_commit').onclick = function(){clEditCommit( tbody, r, cl ); }
@@ -225,6 +243,8 @@
if(arr[6].checked) cl.hold_verify(1);
else cl.hold_verify(0);
cl.name($n(r, 'cl_edit_name').value);
+ cl.label_prefix($n(r, 'cl_edit_label_prefix').value);
+ cl.label_suffix($n(r, 'cl_edit_label_suffix').value);
var req = new Request( UPDATE_CL, SESSION, cl );
req.send(true);
Modified: branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml
===================================================================
--- branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml 2010-08-30 14:13:00 UTC (rev 17367)
+++ branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml 2010-08-30 14:14:12 UTC (rev 17368)
@@ -112,6 +112,8 @@
<td width=''>&staff.server.admin.copy_locations.editor.hold_verify;</td>
<td width=''>&staff.server.admin.copy_locations.editor.opac_visible;</td>
<td width=''>&staff.server.admin.copy_locations.editor.circulate;</td>
+ <td width=''>Label prefix</td>
+ <td width=''>Label suffix</td>
<td width=''>&staff.server.admin.copy_locations.editor.edit;</td>
<td width=''>&staff.server.admin.copy_locations.editor.delete;</td>
</tr>
@@ -124,6 +126,8 @@
<td name='cl_hold_verify'> </td>
<td name='cl_visible'> </td>
<td name='cl_circulate'> </td>
+ <td name='cl_label_prefix'> </td>
+ <td name='cl_label_suffix'> </td>
<td><input type='submit' value='Edit' name='cl_edit' disabled='disabled'> </input></td>
<td><input type='submit' value='Delete' name='cl_delete' disabled='disabled'> </input></td>
</tr>
@@ -187,6 +191,8 @@
<input type='radio' name='cl_edit_circulate'/>
</span>
</td>
+ <td><input name='cl_edit_label_prefix' type='text'> </input></td>
+ <td><input name='cl_edit_label_suffix' type='text'> </input></td>
<td><input type='submit' name='cl_edit_commit' value='&staff.server.admin.copy_locations.submit;'/></td>
<td><input type='submit' name='cl_edit_cancel' value='&staff.server.admin.copy_locations.cancel;'/></td>
</tr>
Modified: branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/spine_labels.js
===================================================================
--- branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/spine_labels.js 2010-08-30 14:13:00 UTC (rev 17367)
+++ branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/spine_labels.js 2010-08-30 14:14:12 UTC (rev 17368)
@@ -33,11 +33,18 @@
for (var i = 0; i < g.barcodes.length; i++) {
var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] );
if (typeof copy.ilsevent != 'undefined') throw(copy);
+ var label_prefix = copy.location().label_prefix() || '';
+ var label_suffix = copy.location().label_suffix() || '';
if (!g.volumes[ copy.call_number() ]) {
var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] );
if (typeof volume.ilsevent != 'undefined') throw(volume);
var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]);
volume.record( record );
+
+ /* Jam the prefixes and suffixes into the volume object */
+ volume.prefix = label_prefix;
+ volume.suffix = label_suffix;
+
g.volumes[ volume.id() ] = volume;
}
if (g.volumes[ copy.call_number() ].copies()) {
@@ -144,14 +151,44 @@
function generate_labels(volume, label_node, label_cfg, override) {
var names;
+ var callnum;
if (override && volume.id() == override.acn) {
/* If we're calling ourself, we'll have an altered label */
- names = String(override.label).split(/\s+/);
+ callnum = String(override.label);
} else {
/* take the call number and split it on whitespace */
- names = String(volume.label()).split(/\s+/);
+ callnum = String(volume.label());
}
+
+ /* for LC, split between classification subclass letters and numbers */
+ var lc_class_re = /^([A-Z]{1,3})([0-9]+.*?)$/i;
+ var lc_class_match = lc_class_re.exec(callnum);
+ if (lc_class_match && lc_class_match.length > 1) {
+ callnum = lc_class_match[1] + ' ' + lc_class_match[2];
+ }
+
+ /* for LC, split between Cutter numbers */
+ var lc_cutter_re = /^(.*)(\.[A-Z]{1}[0-9]+.*?)$/ig;
+ var lc_cutter_match = lc_cutter_re.exec(callnum);
+ if (lc_cutter_match && lc_cutter_match.length > 1) {
+ callnum = '';
+ for (var i = 1; i < lc_cutter_match.length; i++) {
+ callnum += lc_cutter_match[i] + ' ';
+ }
+ }
+
+ /* Only add the prefixes and suffixes once */
+ if (!override || volume.id() != override.acn) {
+ if (volume.prefix) {
+ callnum = volume.prefix + ' ' + callnum;
+ }
+ if (volume.suffix) {
+ callnum += ' ' + volume.suffix;
+ }
+ }
+
+ names = callnum.split(/\s+/);
var j = 0;
while (j < label_cfg.spine_length || j < label_cfg.pocket_length) {
var hb2 = document.createElement('hbox'); label_node.appendChild(hb2);
@@ -171,9 +208,11 @@
tb.setAttribute('name','spine');
var spine_row_id = 'acn_' + volume.id() + '_spine_' + j;
tb.setAttribute('id',spine_row_id);
+
var name = names.shift();
if (name) {
name = String( name );
+
/* if the name is greater than the label width... */
if (name.length > label_cfg.spine_width) {
/* then try to split it on periods */
@@ -341,7 +380,7 @@
case dojo.keys.BACKSPACE : {
/* Delete line if at the start of an input box */
- if (sel_start == 0) {
+ if (sel_start == 0 && sel_end == sel_start) {
var new_label = '';
var chunk;
var x = 0;
@@ -366,6 +405,13 @@
generate({"acn": row_id.acn, "label": new_label});
$(row_id.prefix + row_id.spine).focus();
}
+ if (sel_start == 0) {
+ /* Move to the previous row */
+ var prev_row = $(row_id.prefix + (parseInt(row_id.spine) - 1));
+ if (prev_row) {
+ prev_row.focus();
+ }
+ }
break;
}
@@ -505,22 +551,65 @@
}
}
html += '</body></html>';
- var loc = ( urls.XUL_BROWSER );
- xulG.new_tab(
- loc,
- {
- 'tab_name' : $("catStrings").getString('staff.cat.spine_labels.preview.title')
- },
- {
- 'url' : 'data:text/html;charset=utf-8,'+window.escape(html),
- 'html_source' : html,
- 'show_print_button' : 1,
- 'no_xulG' : 1
- }
- );
+
+ /* From https://developer.mozilla.org/en/Using_nsIXULAppInfo */
+ var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULAppInfo);
+ var platformVer = appInfo.platformVersion;
+
+ /* We need to use different print strategies for different
+ * XUL versions, apparently
+ */
+ if (platformVer.substr(0, 5) == '1.9.0') {
+ preview_xul_190(html);
+ } else {
+ preview_xul_192(html);
+ }
+
+
} catch(E) {
g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E);
}
}
+ function preview_xul_190(html) {
+ JSAN.use('util.window'); var win = new util.window();
+ var loc = ( urls.XUL_REMOTE_BROWSER );
+ //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels');
+ var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550');
+ w.xulG = {
+ 'url' : 'about:blank',
+ 'show_print_button' : 1,
+ 'alternate_print' : 1,
+ 'no_xulG' : 1,
+ 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'),
+ 'on_url_load' : function(b) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ if (typeof w.xulG.written == 'undefined') {
+ w.xulG.written = true;
+ w.g.browser.get_content().document.write(html);
+ w.g.browser.get_content().document.close();
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+ };
+ }
+ function preview_xul_192(html) {
+ var loc = ( urls.XUL_BROWSER );
+ xulG.new_tab(
+ loc,
+ {
+ 'tab_name' : $("catStrings").getString('staff.cat.spine_labels.preview.title')
+ },
+ {
+ 'url' : 'data:text/html;charset=utf-8,'+window.escape(html),
+ 'html_source' : html,
+ 'show_print_button' : 1,
+ 'no_xulG' : 1
+ }
+ );
+ }
More information about the open-ils-commits
mailing list