LP#1619703 Transfer ACQ lineitem browser staff/acq UI
authorBill Erickson <berickxx@gmail.com>
Fri, 17 Mar 2017 19:36:35 +0000 (15:36 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 17 Mar 2017 19:36:35 +0000 (15:36 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
Open-ILS/src/templates/acq/common/li_table.tt2
Open-ILS/src/templates/staff/cat/catalog/index.tt2
Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2
Open-ILS/web/js/dojo/openils/acq/nls/acq.js
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index facb334..b25ab58 100644 (file)
@@ -4218,12 +4218,10 @@ sub transfer_lineitem {
         where => {lineitem => $li_id}
     });
 
-    # TODO: Transfer monograph parts.
+    if (@$acp_ids) {
 
-    my $copies = $e->search_asset_copy(
-        {id => [map {$_->{eg_copy_id}} @$acp_ids]});
-
-    if (@$copies) {
+        my $copies = $e->search_asset_copy(
+            {id => [map {$_->{eg_copy_id}} @$acp_ids]});
 
         # Group copies into call number batches so each call number can
         # be assessed and processed once.
index 4d4773d..e3c551b 100644 (file)
                             <option name='action_holdings_maint' value='action_holdings_maint'>[% l('Holdings Maint.') %]</option>
                             <option name='action_manage_claims' value='action_manage_claims'>[% l('Claims') %]</option>
                             <option name='action_view_history' value='action_view_history'>[% l('View History') %]</option>
+                            <option name='action_transfer_to_bib' value='action_transfer_to_bib'>[% l('Transfer To Bib Record') %]</option>
                         </select>
                     </td>
                     <td>
index c2df10e..1398e5c 100644 (file)
@@ -44,6 +44,8 @@
       "[% l('Conjoined Item Target set') %]";                
     s.MARK_VOL_TARGET =                                                                                                            
       "[% l('Volume Transfer Target set') %]";                
+    s.MARK_LI_TARGET =                                                                                                            
+      "[% l('Lineitem Transfer Target set') %]";                
     s.MARK_ITEM_TARGET =                                                                                                            
       "[% l('Item Transfer Target set') %]";                
     s.MARK_OVERLAY_TARGET =                                                                                                            
index 0848890..8cb523d 100644 (file)
                 </a>
             </li>
             <li role="menuitem">
+              <a ng-click="markLiTransfer()">
+                [% l('Order Lineitem Transfer') %]
+                <span class="target-record-aside" ng-if="current_litransfer_target">
+                  [% l('(Currently [_1])', '{{current_litransfer_target}}') %]
+                </span>
+              </a>
+            </li>
+
+            <li role="menuitem">
                 <a ng-click="clearRecordMarks()">[% l('Reset Record Marks') %]</a>
             </li>
         </ul>
index 0947f21..ffb6084 100644 (file)
     "ACTIVATE_BIBS_PROCESSED"           : "Bib Records Merged/Imported: ${0}",
     "ACTIVATE_LID_PROCESSED"            : "ACQ Copies Processed: ${0}",
     "ACTIVATE_DEBITS_ACCRUED_PROCESSED" : "Debits Encumbered: ${0}",
-    "ACTIVATE_COPIES_PROCESSED"         : "Real Copies Processed: ${0}"
+    "ACTIVATE_COPIES_PROCESSED"         : "Real Copies Processed: ${0}",
+    "LI_TRANSFER_NO_TARGET"             : "No transfer destination selected",
+    "LI_TRANSFER_CONFIRM"               : "Transfer lineitem #${0} to bib record ID ${1}?\n\nTitle: ${2}"
 }
index 44e7b97..526a119 100644 (file)
@@ -661,6 +661,46 @@ function AcqLiTable() {
         );
     }
 
+    this.transferLiToBib = function(li_id) {
+        var self = this;
+        var target = openils.XUL.localStorage().getItem(
+            'eg.cat.marked_lineitem_transfer_record');
+
+        if (!target) {
+            alert(localeStrings.LI_TRANSFER_NO_TARGET);
+            return;
+        }
+
+        // Data stored by the browser client are JSON-encoded.
+        target = JSON2js(target);
+
+        self.pcrud.retrieve('rmsr', target, {   
+            async : true, 
+            oncomplete : function(r) {
+                var rec = openils.Util.readResponse(r);
+
+                if (!confirm(dojo.string.substitute(
+                        localeStrings.LI_TRANSFER_CONFIRM, 
+                        [li_id, target, rec.title()]))) return;
+
+                console.debug('Transfering lineitem ' + 
+                    li_id + ' to bib ' + target);
+
+                fieldmapper.standardRequest(
+                    ['open-ils.acq', 
+                        'open-ils.acq.lineitem.transfer_to_bib'],
+                    {   params : [self.authtoken, li_id, target],
+                        oncomplete : function(r) {
+                            var li = openils.Util.readResponse(r);
+                            // no events fired, reload the page.
+                            location.href = location.href;
+                        }
+                    }
+                );
+            }
+        });
+    }
+
     // fetch an updated copy of the lineitem 
     // and add it back to the lineitem table
     this.refreshLineitem = function(li, focus) {
@@ -1238,6 +1278,10 @@ function AcqLiTable() {
                 case 'action_view_history':
                     location.href = oilsBasePath + '/acq/lineitem/history/' + li.id();
                     break;
+                case 'action_transfer_to_bib':
+                    self.transferLiToBib(li.id());
+                    nodeByName("action_none", row).selected = true;
+                    break;
             }
         };
         var actUpdateBarcodes = nodeByName("action_update_barcodes", row);
index 1f1ac58..9dfce61 100644 (file)
@@ -364,6 +364,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
     $scope.current_overlay_target     = egCore.hatch.getLocalItem('eg.cat.marked_overlay_record');
     $scope.current_voltransfer_target = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
     $scope.current_conjoined_target   = egCore.hatch.getLocalItem('eg.cat.marked_conjoined_record');
+    $scope.current_litransfer_target  = egCore.hatch.getLocalItem('eg.cat.marked_lineitem_transfer_record');
 
     $scope.markConjoined = function () {
         $scope.current_conjoined_target = $scope.record_id;
@@ -377,6 +378,16 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         egCore.hatch.setLocalItem('eg.cat.marked_volume_transfer_record',$scope.record_id);
     };
 
+    $scope.markLiTransfer = function () {
+        ngToast.create(egCore.strings.MARK_LI_TARGET);
+        $scope.current_litransfer_target = $scope.record_id;
+        // Lineitem transfer requires target data to live in localStorage
+        // and not Hatch, hence setLocalItem().  The legacy ACQ interfaces
+        // don't have access to Hatch.
+        egCore.hatch.setLocalItem(
+            'eg.cat.marked_lineitem_transfer_record', $scope.record_id);
+    };
+
     $scope.markOverlay = function () {
         $scope.current_overlay_target = $scope.record_id;
         egCore.hatch.setLocalItem('eg.cat.marked_overlay_record',$scope.record_id);
@@ -388,10 +399,12 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         $scope.current_voltransfer_target = null;
         $scope.current_conjoined_target   = null;
         $scope.current_hold_transfer_dest = null;
+        $scope.current_litransfer_target  = null;
         egCore.hatch.removeLocalItem('eg.cat.marked_volume_transfer_record');
         egCore.hatch.removeLocalItem('eg.cat.marked_conjoined_record');
         egCore.hatch.removeLocalItem('eg.cat.marked_overlay_record');
         egCore.hatch.removeLocalItem('eg.circ.hold.title_transfer_target');
+        egCore.hatch.removeLocalItem('eg.cat.marked_lineitem_transfer_record');
     }
 
     $scope.stop_unload = false;