LP#1346421 TPAC copy view / edit links
authorBill Erickson <berick@esilibrary.com>
Mon, 21 Jul 2014 18:44:34 +0000 (14:44 -0400)
committerBen Shum <bshum@biblio.org>
Fri, 8 Aug 2014 00:12:57 +0000 (20:12 -0400)
Adds "view" and "edit" links next to each copy in the TPAC copy grid
when in embedded mode.  The "edit" link only appears when the user has
permission to edit the specified copy.

Via the XUL volume_item_creator, the ui.unified_volume_copy_editor org
unit setting is inspected to determine which UI to load.  Also, the data
needed to load the subsequent UI is fetched within the
volume_item_creator, so the catalog doesn't have to.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
Open-ILS/src/templates/opac/parts/record/copy_table.tt2
Open-ILS/xul/staff_client/chrome/content/main/menu.js

index d6f616e..1dc306e 100644 (file)
@@ -1976,7 +1976,8 @@ sub basic_opac_copy_query {
             ],
             acn => [
                 {column => 'label', alias => 'call_number_label'},
-                {column => 'id', alias => 'call_number'}
+                {column => 'id', alias => 'call_number'},
+                {column => 'owning_lib', alias => 'call_number_owning_lib'}
             ],
             circ => ['due_date'],
             acnp => [
index 3ae8504..814c4f9 100644 (file)
@@ -103,10 +103,20 @@ END; # FOREACH bib
             <td headers='copy_header_part'>[% copy_info.part_label | html %]</td>
             [%- END %]
             <td headers='copy_header_barcode' property="serialNumber">
-                [%- IF ctx.is_staff -%]
-                    <a href="javascript:void(0)" onclick="xulG.new_tab(xulG.urls.XUL_COPY_STATUS, {}, {'from_item_details_new': true, 'barcodes': ['[%- copy_info.barcode | html | replace('\'', '\\\'') -%]']})">[% copy_info.barcode | html %]</a>
-                [%- ELSE -%][% copy_info.barcode | html %]
-                [%- END -%]
+                [% copy_info.barcode | html -%]
+                [% IF ctx.is_staff %]
+                    <a onclick="xulG.new_tab(xulG.urls.XUL_COPY_STATUS, {}, {'from_item_details_new': true, 'barcodes': ['[%- copy_info.barcode | html | replace('\'', '\\\'') -%]']})"
+                        href="javascript:;">[% l('view') %]</a>
+                    [%# if the user can edit copies, show the copy edit link %]
+                    [% IF ctx.has_perm('UPDATE_COPY', copy_info.circ_lib) 
+                        OR ctx.has_perm('UPDATE_COPY', copy_info.call_number_owning_lib) %]
+                        <span> | </span>
+                        <a href="javascript:;" 
+                            onclick="xulG.volume_item_creator({copy_id : [% copy_info.id %]})">
+                            [% l(' edit') %]
+                        </a>
+                    [% END %]
+                [% END %]
                 [%- IF attrs.gtin13;
                     '<meta property="gtin13" content="' _ attrs.gtin13 _ '" />';
                 END; -%]
index 3addc9c..f10ba71 100644 (file)
@@ -2335,7 +2335,28 @@ commands:
         } else {
             url = obj.url_prefix('XUL_VOLUME_COPY_CREATOR_ORIGINAL');
         }
-        var w = obj.new_tab(
+
+
+        if (params && params.copy_id) {
+            // if accessing directly from the embedded catalog,
+            // load the copy/volume data here so the catalog
+            // doesn't have to.
+            try {
+                JSAN.use('util.network'); 
+                var net = new util.network();
+                var copies = net.simple_request(
+                    'FM_ACP_FLESHED_BATCH_RETRIEVE', [[params.copy_id]]);
+                var copy = copies[0];
+                var volume = net.simple_request(
+                    'FM_ACN_RETRIEVE.authoritative', [copy.call_number()]);
+                copy.call_number(volume);
+                params.existing_copies = [copy];
+            } catch (E) {
+                alert('cannot fetch copy ' + E);
+            }
+        }
+
+         var w = obj.new_tab(
             url,
             { 'tab_name' : document.getElementById('offlineStrings').getString('staff.cat.create_or_rebarcode_items') },
             params