lp1533326 webstaff: Actions for Item Status Detail View
authorJason Etheridge <jason@equinoxinitiative.org>
Fri, 9 Jun 2017 13:38:02 +0000 (09:38 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 9 Jun 2017 19:30:21 +0000 (15:30 -0400)
This patch makes the actions available to the item status
grid view also available in the detail view.  It also adds an
indicator to the Detail View for when an item is deleted.

Signed-off-by: Jason Etheridge <jason@equinoxinitiative.org>
Signed-off-by: Andrea Neiman <abneiman@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/cat/item/index.tt2
Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js

index a88b85f..af02c13 100644 (file)
       </div>
     </div>
     <div class="flex-cell"></div><!-- force the final divs to the right -->
       </div>
     </div>
     <div class="flex-cell"></div><!-- force the final divs to the right -->
+    <div ng-show="context.page == 'detail'" uib-dropdown>
+      <button type="button" class="btn btn-default" uib-dropdown-toggle>
+        <span>[% l('Actions') %]</span><span class="caret"></span>
+      </button>
+      <ul uib-dropdown-menu>
+        <li><a href ng-click="add_copies_to_bucket()">[% l('Add Items to Bucket') %]</a></li>
+        <li><a href ng-click="make_copies_bookable()">[% l('Make Items Bookable') %]</a></li>
+        <li><a href ng-click="book_copies_now()">[% l('Book Item Now') %]</a></li>
+        <li><a href ng-click="requestItems()">[% l('Request Items') %]</a></li>
+        <li><a href ng-click="attach_to_peer_bib()">[% l('Link as Conjoined to Previously Marked Bib Record') %]</a></li>
+        <li><a href ng-click="selectedHoldingsCopyDelete()">[% l('Delete Items') %]</a></li>
+        <li><a href ng-click="checkin()">[% l('Check In Items') %]</a></li>
+        <li><a href ng-click="renew()">[% l('Renew Items') %]</a></li>
+        <li><a href ng-click="cancel_transit()">[% l('Cancel Transit') %]</a></li>
+
+        <p><b>[% l('Mark') %]</b></p>    
+        <li><a href ng-click="selectedHoldingsDamaged()">[% l('Item as Damaged') %]</a></li>
+        <li><a href ng-click="selectedHoldingsMissing()">[% l('Item as Missing') %]</a></li>
+    
+        <p><b>[% l('Add') %]</b></p>    
+        <li><a href ng-click="selectedHoldingsCopyAdd()">[% l('Items') %]</a></li>
+        <li><a href ng-click="selectedHoldingsVolCopyAdd()">[% l('Volumes and Items') %]</a></li>
+
+        <p><b>[% l('Edit') %]</b></p>    
+        <li><a href ng-click="selectedHoldingsVolEdit()">[% l('Volumes') %]</a></li>
+        <li><a href ng-click="selectedHoldingsCopyEdit()">[% l('Items') %]</a></li>
+        <li><a href ng-click="selectedHoldingsVolCopyEdit()">[% l('Volumes and Items') %]</a></li>
+        <li><a href ng-click="replaceBarcodes()">[% l('Replace Barcodes') %]</a></li>
+
+        <p><b>[% l('Transfer') %]</b></p>    
+        <li><a href ng-click="changeItemOwningLib()">[% l('Items to Previously Marked Library') %]</a></li>
+        <li><a href ng-click="transferItems()">[% l('Items to Previously Marked Volume') %]</a></li>
+      </ul>
+    </div>
     <div>
       <button class="btn btn-default" ng-click="toggleView($event)">
         <span ng-show="context.page == 'list'">[% l('Detail View') %]</span>
         <span ng-show="context.page == 'detail'">[% l('List View') %]</span>
       </button>
     </div>
     <div>
       <button class="btn btn-default" ng-click="toggleView($event)">
         <span ng-show="context.page == 'list'">[% l('Detail View') %]</span>
         <span ng-show="context.page == 'detail'">[% l('List View') %]</span>
       </button>
     </div>
-    <!--
-    <div class="btn-group btn-pad" uib-dropdown>
-      <button type="button" class="btn btn-default" uib-dropdown-toggle>
-        [% l('Actions for Catalogers') %]<span class="caret"></span>
-      </button>
-      <ul uib-dropdown-menu role="menu">
-      </ul>
-    </div>
-    -->
   </div><!-- flex row -->
 </form>
 
   </div><!-- flex row -->
 </form>
 
index 345eb23..2b5d135 100644 (file)
@@ -1,5 +1,9 @@
 <div class="">
 
 <div class="">
 
+  <div class="label label-danger" ng-show="copy.deleted() == 't'">
+    [% l('This item has been marked as Deleted.') %]
+  </div>
+
   <div class="flex-row">
     <div class="flex-cell">[% l('Barcode') %]</div>
     <div class="flex-cell well">{{copy.barcode()}}</div>
   <div class="flex-row">
     <div class="flex-cell">[% l('Barcode') %]</div>
     <div class="flex-cell well">{{copy.barcode()}}</div>
index dba013c..bada28c 100644 (file)
@@ -48,8 +48,8 @@ angular.module('egItemStatus',
 })
 
 .factory('itemSvc', 
 })
 
 .factory('itemSvc', 
-       ['egCore',
-function(egCore) {
+       ['egCore','egCirc','$uibModal','$q','$timeout','$window','egConfirmDialog',
+function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog ) {
 
     var service = {
         copies : [], // copy barcode search results
 
     var service = {
         copies : [], // copy barcode search results
@@ -201,163 +201,7 @@ function(egCore) {
 
     }
 
 
     }
 
-    return service;
-}])
-
-/**
- * Search bar along the top of the page.
- * Parent scope for list and detail views
- */
-.controller('SearchCtrl', 
-       ['$scope','$location','egCore','egGridDataProvider','itemSvc',
-function($scope , $location , egCore , egGridDataProvider , itemSvc) {
-    $scope.args = {}; // search args
-
-    // sub-scopes (search / detail-view) apply their version 
-    // of retrieval function to $scope.context.search
-    // and display toggling via $scope.context.toggleDisplay
-    $scope.context = {
-        selectBarcode : true
-    };
-
-    $scope.toggleView = function($event) {
-        $scope.context.toggleDisplay();
-        $event.preventDefault(); // avoid form submission
-    }
-}])
-
-/**
- * List view - grid stuff
- */
-.controller('ListCtrl', 
-       ['$scope','$q','$routeParams','$location','$timeout','$window','egCore','egGridDataProvider','itemSvc','egUser','$uibModal','egCirc','egConfirmDialog',
-function($scope , $q , $routeParams , $location , $timeout , $window , egCore , egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog) {
-    var copyId = [];
-    var cp_list = $routeParams.idList;
-    if (cp_list) {
-        copyId = cp_list.split(',');
-    }
-
-    $scope.context.page = 'list';
-
-    /*
-    var provider = egGridDataProvider.instance();
-    provider.get = function(offset, count) {
-    }
-    */
-
-    $scope.gridDataProvider = egGridDataProvider.instance({
-        get : function(offset, count) {
-            //return provider.arrayNotifier(itemSvc.copies, offset, count);
-            return this.arrayNotifier(itemSvc.copies, offset, count);
-        }
-    });
-
-    // If a copy was just displayed in the detail view, ensure it's
-    // focused in the list view.
-    var selected = false;
-    var copyGrid = $scope.gridControls = {
-        itemRetrieved : function(item) {
-            if (selected || !itemSvc.copy) return;
-            if (itemSvc.copy.id() == item.id) {
-                copyGrid.selectItems([item.index]);
-                selected = true;
-            }
-        }
-    };
-
-    $scope.$watch('barcodesFromFile', function(newVal, oldVal) {
-        if (newVal && newVal != oldVal) {
-            $scope.args.barcode = '';
-            var barcodes = [];
-
-            angular.forEach(newVal.split(/\n/), function(line) {
-                if (!line) return;
-                // scrub any trailing spaces or commas from the barcode
-                line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');
-                barcodes.push(line);
-            });
-
-            itemSvc.fetch(barcodes).then(
-                function() {
-                    copyGrid.refresh();
-                    copyGrid.selectItems([itemSvc.copies[0].index]);
-                }
-            );
-        }
-    });
-
-    $scope.context.search = function(args) {
-        if (!args.barcode) return;
-        $scope.context.itemNotFound = false;
-        itemSvc.fetch(args.barcode).then(function(res) {
-            if (res) {
-                copyGrid.refresh();
-                copyGrid.selectItems([res.index]);
-                $scope.args.barcode = '';
-            } else {
-                $scope.context.itemNotFound = true;
-                egCore.audio.play('warning.item_status.itemNotFound');
-            }
-            $scope.context.selectBarcode = true;
-        })
-    }
-
-    var add_barcode_to_list = function (b) {
-        $scope.context.search({barcode:b});
-    }
-
-    $scope.context.toggleDisplay = function() {
-        var item = copyGrid.selectedItems()[0];
-        if (item) 
-            $location.path('/cat/item/' + item.id);
-    }
-
-    $scope.context.show_triggered_events = function() {
-        var item = copyGrid.selectedItems()[0];
-        if (item) 
-            $location.path('/cat/item/' + item.id + '/triggered_events');
-    }
-
-    function gatherSelectedRecordIds () {
-        var rid_list = [];
-        angular.forEach(
-            copyGrid.selectedItems(),
-            function (item) {
-                if (rid_list.indexOf(item['call_number.record.id']) == -1)
-                    rid_list.push(item['call_number.record.id'])
-            }
-        );
-        return rid_list;
-    }
-
-    function gatherSelectedVolumeIds (rid) {
-        var cn_id_list = [];
-        angular.forEach(
-            copyGrid.selectedItems(),
-            function (item) {
-                if (rid && item['call_number.record.id'] != rid) return;
-                if (cn_id_list.indexOf(item['call_number.id']) == -1)
-                    cn_id_list.push(item['call_number.id'])
-            }
-        );
-        return cn_id_list;
-    }
-
-    function gatherSelectedHoldingsIds (rid) {
-        var cp_id_list = [];
-        angular.forEach(
-            copyGrid.selectedItems(),
-            function (item) {
-                if (rid && item['call_number.record.id'] != rid) return;
-                cp_id_list.push(item.id)
-            }
-        );
-        return cp_id_list;
-    }
-
-    $scope.add_copies_to_bucket = function() {
-        var copy_list = gatherSelectedHoldingsIds();
+    service.add_copies_to_bucket = function(copy_list) {
         if (copy_list.length == 0) return;
 
         return $uibModal.open({
         if (copy_list.length == 0) return;
 
         return $uibModal.open({
@@ -423,18 +267,12 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
         });
     }
 
         });
     }
 
-    $scope.need_one_selected = function() {
-        var items = $scope.gridControls.selectedItems();
-        if (items.length == 1) return false;
-        return true;
-    };
-
-    $scope.make_copies_bookable = function() {
+    service.make_copies_bookable = function(items) {
 
         var copies_by_record = {};
         var record_list = [];
         angular.forEach(
 
         var copies_by_record = {};
         var record_list = [];
         angular.forEach(
-            copyGrid.selectedItems(),
+            items,
             function (item) {
                 var record_id = item['call_number.record.id'];
                 if (typeof copies_by_record[ record_id ] == 'undefined') {
             function (item) {
                 var record_id = item['call_number.record.id'];
                 if (typeof copies_by_record[ record_id ] == 'undefined') {
@@ -487,11 +325,11 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
         });
     }
 
         });
     }
 
-    $scope.book_copies_now = function() {
+    service.book_copies_now = function(items) {
         var copies_by_record = {};
         var record_list = [];
         angular.forEach(
         var copies_by_record = {};
         var record_list = [];
         angular.forEach(
-            copyGrid.selectedItems(),
+            items,
             function (item) {
                 var record_id = item['call_number.record.id'];
                 if (typeof copies_by_record[ record_id ] == 'undefined') {
             function (item) {
                 var record_id = item['call_number.record.id'];
                 if (typeof copies_by_record[ record_id ] == 'undefined') {
@@ -554,8 +392,7 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
         });
     }
 
         });
     }
 
-    $scope.requestItems = function() {
-        var copy_list = gatherSelectedHoldingsIds();
+    service.requestItems = function(copy_list) {
         if (copy_list.length == 0) return;
 
         return $uibModal.open({
         if (copy_list.length == 0) return;
 
         return $uibModal.open({
@@ -623,58 +460,8 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
         });
     }
 
         });
     }
 
-    $scope.replaceBarcodes = function() {
-        angular.forEach(copyGrid.selectedItems(), function (cp) {
-            $uibModal.open({
-                templateUrl: './cat/share/t_replace_barcode',
-                animation: true,
-                controller:
-                           ['$scope','$uibModalInstance',
-                    function($scope , $uibModalInstance) {
-                        $scope.isModal = true;
-                        $scope.focusBarcode = false;
-                        $scope.focusBarcode2 = true;
-                        $scope.barcode1 = cp.barcode;
-
-                        $scope.updateBarcode = function() {
-                            $scope.copyNotFound = false;
-                            $scope.updateOK = false;
-
-                            egCore.pcrud.search('acp',
-                                {deleted : 'f', barcode : $scope.barcode1})
-                            .then(function(copy) {
-
-                                if (!copy) {
-                                    $scope.focusBarcode = true;
-                                    $scope.copyNotFound = true;
-                                    return;
-                                }
-
-                                $scope.copyId = copy.id();
-                                copy.barcode($scope.barcode2);
-
-                                egCore.pcrud.update(copy).then(function(stat) {
-                                    $scope.updateOK = stat;
-                                    $scope.focusBarcode = true;
-                                    if (stat) add_barcode_to_list(copy.barcode());
-                                });
-
-                            });
-                            $uibModalInstance.close();
-                        }
-
-                        $scope.cancel = function($event) {
-                            $uibModalInstance.dismiss();
-                            $event.preventDefault();
-                        }
-                    }
-                ]
-            });
-        });
-    }
-
-    $scope.attach_to_peer_bib = function() {
-        if (copyGrid.selectedItems().length == 0) return;
+    service.attach_to_peer_bib = function(items) {
+        if (items.length == 0) return;
 
         egCore.hatch.getItem('eg.cat.marked_conjoined_record').then(function(target_record) {
             if (!target_record) return;
 
         egCore.hatch.getItem('eg.cat.marked_conjoined_record').then(function(target_record) {
             if (!target_record) return;
@@ -708,13 +495,13 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
                     $scope.ok = function(type) {
                         var promises = [];
 
                     $scope.ok = function(type) {
                         var promises = [];
 
-                        angular.forEach(copyGrid.selectedItems(), function (cp) {
+                        angular.forEach(items, function (cp) {
                             var n = new egCore.idl.bpbcm();
                             n.isnew(true);
                             n.peer_record(target_record);
                             n.target_copy(cp.id);
                             n.peer_type(type);
                             var n = new egCore.idl.bpbcm();
                             n.isnew(true);
                             n.peer_record(target_record);
                             n.target_copy(cp.id);
                             n.peer_type(type);
-                            promises.push(egCore.pcrud.create(n).then(function(){add_barcode_to_list(cp.barcode)}));
+                            promises.push(egCore.pcrud.create(n).then(function(){service.add_barcode_to_list(cp.barcode)}));
                         });
 
                         return $q.all(promises).then(function(){$uibModalInstance.close()});
                         });
 
                         return $q.all(promises).then(function(){$uibModalInstance.close()});
@@ -729,13 +516,12 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
         });
     }
 
         });
     }
 
-    $scope.selectedHoldingsCopyDelete = function () {
-        var copy_list = gatherSelectedHoldingsIds();
-        if (copy_list.length == 0) return;
+    service.selectedHoldingsCopyDelete = function (items) {
+        if (items.length == 0) return;
 
         var copy_objects = [];
         egCore.pcrud.search('acp',
 
         var copy_objects = [];
         egCore.pcrud.search('acp',
-            {deleted : 'f', id : copy_list},
+            {deleted : 'f', id : items.map(function(el){return el.id;}) },
             { flesh : 1, flesh_fields : { acp : ['call_number'] } }
         ).then(function(copy) {
             copy_objects.push(copy);
             { flesh : 1, flesh_fields : { acp : ['call_number'] } }
         ).then(function(copy) {
             copy_objects.push(copy);
@@ -786,76 +572,97 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
                     'open-ils.cat.asset.volume.fleshed.batch.update.override',
                     egCore.auth.token(), cnList, 1, flags
                 ).then(function(){
                     'open-ils.cat.asset.volume.fleshed.batch.update.override',
                     egCore.auth.token(), cnList, 1, flags
                 ).then(function(){
-                    angular.forEach(copyGrid.selectedItems(), function(cp){add_barcode_to_list(cp.barcode)});
+                    angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
                 });
             });
         });
     }
 
                 });
             });
         });
     }
 
-    $scope.selectedHoldingsItemStatusTgrEvt= function() {
-        var item = copyGrid.selectedItems()[0];
-        if (item)
-            $location.path('/cat/item/' + item.id + '/triggered_events');
+    service.checkin = function (items) {
+        angular.forEach(items, function (cp) {
+            egCirc.checkin({copy_barcode:cp.barcode}).then(
+                function() { service.add_barcode_to_list(cp.barcode) }
+            );
+        });
     }
 
     }
 
-    $scope.selectedHoldingsItemStatusHolds= function() {
-        var item = copyGrid.selectedItems()[0];
-        if (item)
-            $location.path('/cat/item/' + item.id + '/holds');
+    service.renew = function (items) {
+        angular.forEach(items, function (cp) {
+            egCirc.renew({copy_barcode:cp.barcode}).then(
+                function() { service.add_barcode_to_list(cp.barcode) }
+            );
+        });
     }
 
     }
 
-    $scope.cancel_transit = function () {
-        var initial_list = copyGrid.selectedItems();
-        angular.forEach(copyGrid.selectedItems(), function(cp) {
+    service.cancel_transit = function (items) {
+        angular.forEach(items, function(cp) {
             egCirc.find_copy_transit(null, {copy_barcode:cp.barcode})
                 .then(function(t) { return egCirc.abort_transit(t.id())    })
             egCirc.find_copy_transit(null, {copy_barcode:cp.barcode})
                 .then(function(t) { return egCirc.abort_transit(t.id())    })
-                .then(function()  { return add_barcode_to_list(cp.barcode) });
-        });
-    }
-
-    $scope.selectedHoldingsDamaged = function () {
-        var initial_list = copyGrid.selectedItems();
-        egCirc.mark_damaged(gatherSelectedHoldingsIds()).then(function(){
-            angular.forEach(initial_list, function(cp){add_barcode_to_list(cp.barcode)});
+                .then(function()  { return service.add_barcode_to_list(cp.barcode) });
         });
     }
 
         });
     }
 
-    $scope.selectedHoldingsMissing = function () {
-        var initial_list = copyGrid.selectedItems();
-        egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function(){
-            angular.forEach(initial_list, function(cp){add_barcode_to_list(cp.barcode)});
+    service.selectedHoldingsDamaged = function (items) {
+        egCirc.mark_damaged(items.map(function(el){return el.id;})).then(function(){
+            angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
         });
     }
 
         });
     }
 
-    $scope.checkin = function () {
-        angular.forEach(copyGrid.selectedItems(), function (cp) {
-            egCirc.checkin({copy_barcode:cp.barcode}).then(
-                function() { add_barcode_to_list(cp.barcode) }
-            );
+    service.selectedHoldingsMissing = function (items) {
+        egCirc.mark_missing(items.map(function(el){return el.id;})).then(function(){
+            angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
         });
     }
 
         });
     }
 
-    $scope.renew = function () {
-        angular.forEach(copyGrid.selectedItems(), function (cp) {
-            egCirc.renew({copy_barcode:cp.barcode}).then(
-                function() { add_barcode_to_list(cp.barcode) }
-            );
-        });
+    service.gatherSelectedRecordIds = function (items) {
+        var rid_list = [];
+        angular.forEach(
+            items,
+            function (item) {
+                if (rid_list.indexOf(item['call_number.record.id']) == -1)
+                    rid_list.push(item['call_number.record.id'])
+            }
+        );
+        return rid_list;
     }
 
     }
 
-
-    var spawnHoldingsAdd = function (vols,copies){
-        angular.forEach(gatherSelectedRecordIds(), function (r) {
+    service.gatherSelectedVolumeIds = function (items,rid) {
+        var cn_id_list = [];
+        angular.forEach(
+            items,
+            function (item) {
+                if (rid && item['call_number.record.id'] != rid) return;
+                if (cn_id_list.indexOf(item['call_number.id']) == -1)
+                    cn_id_list.push(item['call_number.id'])
+            }
+        );
+        return cn_id_list;
+    }
+
+    service.gatherSelectedHoldingsIds = function (items,rid) {
+        var cp_id_list = [];
+        angular.forEach(
+            items,
+            function (item) {
+                if (rid && item['call_number.record.id'] != rid) return;
+                cp_id_list.push(item.id)
+            }
+        );
+        return cp_id_list;
+    }
+
+    service.spawnHoldingsAdd = function (items,use_vols,use_copies){
+        angular.forEach(service.gatherSelectedRecordIds(items), function (r) {
             var raw = [];
             var raw = [];
-            if (copies) { // just a copy on existing volumes
-                angular.forEach(gatherSelectedVolumeIds(r), function (v) {
+            if (use_copies) { // just a copy on existing volumes
+                angular.forEach(service.gatherSelectedVolumeIds(items,r), function (v) {
                     raw.push( {callnumber : v} );
                 });
                     raw.push( {callnumber : v} );
                 });
-            } else if (vols) {
+            } else if (use_vols) {
                 angular.forEach(
                 angular.forEach(
-                    gatherSelectedHoldingsIds(r),
+                    service.gatherSelectedHoldingsIds(items,r),
                     function (i) {
                     function (i) {
-                        angular.forEach(copyGrid.selectedItems(), function(item) {
+                        angular.forEach(items, function(item) {
                             if (i == item.id) raw.push({owner : item['call_number.owning_lib']});
                         });
                     }
                             if (i == item.id) raw.push({owner : item['call_number.owning_lib']});
                         });
                     }
@@ -883,24 +690,15 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
             });
         });
     }
             });
         });
     }
-    $scope.selectedHoldingsVolCopyAdd = function () { spawnHoldingsAdd(true,false) }
-    $scope.selectedHoldingsCopyAdd = function () { spawnHoldingsAdd(false,true) }
-
-    $scope.showBibHolds = function () {
-        angular.forEach(gatherSelectedRecordIds(), function (r) {
-            var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds';
-            $timeout(function() { $window.open(url, '_blank') });
-        });
-    }
 
 
-    var spawnHoldingsEdit = function (hide_vols,hide_copies){
-        angular.forEach(gatherSelectedRecordIds(), function (r) {
+    service.spawnHoldingsEdit = function (items,hide_vols,hide_copies){
+        angular.forEach(service.gatherSelectedRecordIds(items), function (r) {
             egCore.net.request(
                 'open-ils.actor',
                 'open-ils.actor.anon_cache.set_value',
                 null, 'edit-these-copies', {
                     record_id: r,
             egCore.net.request(
                 'open-ils.actor',
                 'open-ils.actor.anon_cache.set_value',
                 null, 'edit-these-copies', {
                     record_id: r,
-                    copies: gatherSelectedHoldingsIds(r),
+                    copies: service.gatherSelectedHoldingsIds(items,r),
                     raw: {},
                     hide_vols : hide_vols,
                     hide_copies : hide_copies
                     raw: {},
                     hide_vols : hide_vols,
                     hide_copies : hide_copies
@@ -915,15 +713,61 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
             });
         });
     }
             });
         });
     }
-    $scope.selectedHoldingsVolCopyEdit = function () { spawnHoldingsEdit(false,false) }
-    $scope.selectedHoldingsVolEdit = function () { spawnHoldingsEdit(false,true) }
-    $scope.selectedHoldingsCopyEdit = function () { spawnHoldingsEdit(true,false) }
+
+    service.replaceBarcodes = function(items) {
+        angular.forEach(items, function (cp) {
+            $uibModal.open({
+                templateUrl: './cat/share/t_replace_barcode',
+                animation: true,
+                controller:
+                           ['$scope','$uibModalInstance',
+                    function($scope , $uibModalInstance) {
+                        $scope.isModal = true;
+                        $scope.focusBarcode = false;
+                        $scope.focusBarcode2 = true;
+                        $scope.barcode1 = cp.barcode;
+
+                        $scope.updateBarcode = function() {
+                            $scope.copyNotFound = false;
+                            $scope.updateOK = false;
+
+                            egCore.pcrud.search('acp',
+                                {deleted : 'f', barcode : $scope.barcode1})
+                            .then(function(copy) {
+
+                                if (!copy) {
+                                    $scope.focusBarcode = true;
+                                    $scope.copyNotFound = true;
+                                    return;
+                                }
+
+                                $scope.copyId = copy.id();
+                                copy.barcode($scope.barcode2);
+
+                                egCore.pcrud.update(copy).then(function(stat) {
+                                    $scope.updateOK = stat;
+                                    $scope.focusBarcode = true;
+                                    if (stat) service.add_barcode_to_list(copy.barcode());
+                                });
+
+                            });
+                            $uibModalInstance.close();
+                        }
+
+                        $scope.cancel = function($event) {
+                            $uibModalInstance.dismiss();
+                            $event.preventDefault();
+                        }
+                    }
+                ]
+            });
+        });
+    }
 
     // this "transfers" selected copies to a new owning library,
     // auto-creating volumes and deleting unused volumes as required.
 
     // this "transfers" selected copies to a new owning library,
     // auto-creating volumes and deleting unused volumes as required.
-    $scope.changeItemOwningLib = function() {
+    service.changeItemOwningLib = function(items) {
         var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
         var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
-        var items = copyGrid.selectedItems();
         if (!xfer_target || !items.length) {
             return;
         }
         if (!xfer_target || !items.length) {
             return;
         }
@@ -973,19 +817,19 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
         });
 
         angular.forEach(
         });
 
         angular.forEach(
-            copyGrid.selectedItems(),
+            items,
             function(cp){
                 promises.push(
             function(cp){
                 promises.push(
-                    function(){ add_barcode_to_list(cp.barcode) }
+                    function(){ service.add_barcode_to_list(cp.barcode) }
                 )
             }
         );
         $q.all(promises);
     }
 
                 )
             }
         );
         $q.all(promises);
     }
 
-    $scope.transferItems = function (){
+    service.transferItems = function (items){
         var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target');
         var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target');
-        var copy_ids = gatherSelectedHoldingsIds();
+        var copy_ids = service.gatherSelectedHoldingsIds(items);
         if (xfer_target && copy_ids.length > 0) {
             egCore.net.request(
                 'open-ils.cat',
         if (xfer_target && copy_ids.length > 0) {
             egCore.net.request(
                 'open-ils.cat',
@@ -999,7 +843,7 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
                     egConfirmDialog.open(
                         egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE,
                         egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY,
                     egConfirmDialog.open(
                         egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE,
                         egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY,
-                        {'evt_desc': evt.desc}
+                        {'evt_desc': evt}
                     ).result.then(function() {
                         egCore.net.request(
                             'open-ils.cat',
                     ).result.then(function() {
                         egCore.net.request(
                             'open-ils.cat',
@@ -1014,11 +858,428 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
                 null, // onerror
                 null // onprogress
             ).then(function() {
                 null, // onerror
                 null // onprogress
             ).then(function() {
-                    angular.forEach(copyGrid.selectedItems(), function(cp){add_barcode_to_list(cp.barcode)});
+                    angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
             });
         }
     }
 
             });
         }
     }
 
+    return service;
+}])
+
+/**
+ * Search bar along the top of the page.
+ * Parent scope for list and detail views
+ */
+.controller('SearchCtrl', 
+       ['$scope','$location','$timeout','egCore','egGridDataProvider','itemSvc',
+function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) {
+    $scope.args = {}; // search args
+
+    // sub-scopes (search / detail-view) apply their version 
+    // of retrieval function to $scope.context.search
+    // and display toggling via $scope.context.toggleDisplay
+    $scope.context = {
+        selectBarcode : true
+    };
+
+    $scope.toggleView = function($event) {
+        $scope.context.toggleDisplay();
+        $event.preventDefault(); // avoid form submission
+    }
+
+    // The functions that follow in this controller are never called
+    // when the List View is active, only the Detail View.
+    
+    // In this context, we're only ever dealing with 1 item, so
+    // we can simply refresh the page.  These various itemSvc
+    // functions used to live in the ListCtrl, but they're now
+    // shared between SearchCtrl (for Actions for the Detail View)
+    // and ListCtrl (Actions in the egGrid)
+    itemSvc.add_barcode_to_list = function(b) {
+        //console.log('SearchCtrl: add_barcode_to_list',b);
+        // timeout so audible can happen upon checkin
+        $timeout(function() { location.href = location.href; }, 1000);
+    }
+
+    $scope.add_copies_to_bucket = function() {
+        itemSvc.add_copies_to_bucket([$scope.args.copyId]);
+    }
+
+    $scope.make_copies_bookable = function() {
+        itemSvc.make_copies_bookable([{
+            id : $scope.args.copyId,
+            'call_number.record.id' : $scope.args.recordId
+        }]);
+    }
+
+    $scope.book_copies_now = function() {
+        itemSvc.book_copies_now([{
+            id : $scope.args.copyId,
+            'call_number.record.id' : $scope.args.recordId
+        }]);
+    }
+
+    $scope.requestItems = function() {
+        itemSvc.requestItems([$scope.args.copyId]);
+    }
+
+    $scope.attach_to_peer_bib = function() {
+        itemSvc.attach_to_peer_bib([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.selectedHoldingsCopyDelete = function () {
+        itemSvc.selectedHoldingsCopyDelete([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.checkin = function () {
+        itemSvc.checkin([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.renew = function () {
+        itemSvc.renew([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.cancel_transit = function () {
+        itemSvc.cancel_transit([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.selectedHoldingsDamaged = function () {
+        itemSvc.selectedHoldingsDamaged([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.selectedHoldingsMissing = function () {
+        itemSvc.selectedHoldingsMissing([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.selectedHoldingsVolCopyAdd = function () {
+        itemSvc.spawnHoldingsAdd([{
+            id : $scope.args.copyId,
+            'call_number.owning_lib' : $scope.args.cnOwningLib,
+            'call_number.record.id' : $scope.args.recordId,
+            barcode : $scope.args.copyBarcode
+        }],true,false);
+    }
+    $scope.selectedHoldingsCopyAdd = function () {
+        itemSvc.spawnHoldingsAdd([{
+            id : $scope.args.copyId,
+            'call_number.id' : $scope.args.cnId,
+            'call_number.owning_lib' : $scope.args.cnOwningLib,
+            'call_number.record.id' : $scope.args.recordId,
+            barcode : $scope.args.copyBarcode
+        }],false,true);
+    }
+
+    $scope.selectedHoldingsVolCopyEdit = function () {
+        itemSvc.spawnHoldingsEdit([{
+            id : $scope.args.copyId,
+            'call_number.id' : $scope.args.cnId,
+            'call_number.owning_lib' : $scope.args.cnOwningLib,
+            'call_number.record.id' : $scope.args.recordId,
+            barcode : $scope.args.copyBarcode
+        }],false,false);
+    }
+    $scope.selectedHoldingsVolEdit = function () {
+        itemSvc.spawnHoldingsEdit([{
+            id : $scope.args.copyId,
+            'call_number.id' : $scope.args.cnId,
+            'call_number.owning_lib' : $scope.args.cnOwningLib,
+            'call_number.record.id' : $scope.args.recordId,
+            barcode : $scope.args.copyBarcode
+        }],false,true);
+    }
+    $scope.selectedHoldingsCopyEdit = function () {
+        itemSvc.spawnHoldingsEdit([{
+            id : $scope.args.copyId,
+            'call_number.id' : $scope.args.cnId,
+            'call_number.owning_lib' : $scope.args.cnOwningLib,
+            'call_number.record.id' : $scope.args.recordId,
+            barcode : $scope.args.copyBarcode
+        }],true,false);
+    }
+
+    $scope.replaceBarcodes = function() {
+        itemSvc.replaceBarcodes([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.changeItemOwningLib = function() {
+        itemSvc.changeItemOwningLib([{
+            id : $scope.args.copyId,
+            'call_number.id' : $scope.args.cnId,
+            'call_number.owning_lib' : $scope.args.cnOwningLib,
+            'call_number.record.id' : $scope.args.recordId,
+            'call_number.label' : $scope.args.cnLabel,
+            'call_number.label_class' : $scope.args.cnLabelClass,
+            'call_number.prefix.id' : $scope.args.cnPrefixId,
+            'call_number.suffix.id' : $scope.args.cnSuffixId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+    $scope.transferItems = function (){
+        itemSvc.transferItems([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode
+        }]);
+    }
+
+}])
+
+/**
+ * List view - grid stuff
+ */
+.controller('ListCtrl', 
+       ['$scope','$q','$routeParams','$location','$timeout','$window','egCore','egGridDataProvider','itemSvc','egUser','$uibModal','egCirc','egConfirmDialog',
+function($scope , $q , $routeParams , $location , $timeout , $window , egCore , egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog) {
+    var copyId = [];
+    var cp_list = $routeParams.idList;
+    if (cp_list) {
+        copyId = cp_list.split(',');
+    }
+
+    $scope.context.page = 'list';
+
+    /*
+    var provider = egGridDataProvider.instance();
+    provider.get = function(offset, count) {
+    }
+    */
+
+    $scope.gridDataProvider = egGridDataProvider.instance({
+        get : function(offset, count) {
+            //return provider.arrayNotifier(itemSvc.copies, offset, count);
+            return this.arrayNotifier(itemSvc.copies, offset, count);
+        }
+    });
+
+    // If a copy was just displayed in the detail view, ensure it's
+    // focused in the list view.
+    var selected = false;
+    var copyGrid = $scope.gridControls = {
+        itemRetrieved : function(item) {
+            if (selected || !itemSvc.copy) return;
+            if (itemSvc.copy.id() == item.id) {
+                copyGrid.selectItems([item.index]);
+                selected = true;
+            }
+        }
+    };
+
+    $scope.$watch('barcodesFromFile', function(newVal, oldVal) {
+        if (newVal && newVal != oldVal) {
+            $scope.args.barcode = '';
+            var barcodes = [];
+
+            angular.forEach(newVal.split(/\n/), function(line) {
+                if (!line) return;
+                // scrub any trailing spaces or commas from the barcode
+                line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');
+                barcodes.push(line);
+            });
+
+            itemSvc.fetch(barcodes).then(
+                function() {
+                    copyGrid.refresh();
+                    copyGrid.selectItems([itemSvc.copies[0].index]);
+                }
+            );
+        }
+    });
+
+    $scope.context.search = function(args) {
+        if (!args.barcode) return;
+        $scope.context.itemNotFound = false;
+        itemSvc.fetch(args.barcode).then(function(res) {
+            if (res) {
+                copyGrid.refresh();
+                copyGrid.selectItems([res.index]);
+                $scope.args.barcode = '';
+            } else {
+                $scope.context.itemNotFound = true;
+                egCore.audio.play('warning.item_status.itemNotFound');
+            }
+            $scope.context.selectBarcode = true;
+        })
+    }
+
+    var add_barcode_to_list = function (b) {
+        //console.log('listCtrl: add_barcode_to_list',b);
+        $scope.context.search({barcode:b});
+    }
+    itemSvc.add_barcode_to_list = add_barcode_to_list;
+
+    $scope.context.toggleDisplay = function() {
+        var item = copyGrid.selectedItems()[0];
+        if (item) 
+            $location.path('/cat/item/' + item.id);
+    }
+
+    $scope.context.show_triggered_events = function() {
+        var item = copyGrid.selectedItems()[0];
+        if (item) 
+            $location.path('/cat/item/' + item.id + '/triggered_events');
+    }
+
+    function gatherSelectedRecordIds () {
+        var rid_list = [];
+        angular.forEach(
+            copyGrid.selectedItems(),
+            function (item) {
+                if (rid_list.indexOf(item['call_number.record.id']) == -1)
+                    rid_list.push(item['call_number.record.id'])
+            }
+        );
+        return rid_list;
+    }
+
+    function gatherSelectedVolumeIds (rid) {
+        var cn_id_list = [];
+        angular.forEach(
+            copyGrid.selectedItems(),
+            function (item) {
+                if (rid && item['call_number.record.id'] != rid) return;
+                if (cn_id_list.indexOf(item['call_number.id']) == -1)
+                    cn_id_list.push(item['call_number.id'])
+            }
+        );
+        return cn_id_list;
+    }
+
+    function gatherSelectedHoldingsIds (rid) {
+        var cp_id_list = [];
+        angular.forEach(
+            copyGrid.selectedItems(),
+            function (item) {
+                if (rid && item['call_number.record.id'] != rid) return;
+                cp_id_list.push(item.id)
+            }
+        );
+        return cp_id_list;
+    }
+
+    $scope.add_copies_to_bucket = function() {
+        var copy_list = gatherSelectedHoldingsIds();
+        itemSvc.add_copies_to_bucket(copy_list);
+    }
+
+    $scope.need_one_selected = function() {
+        var items = $scope.gridControls.selectedItems();
+        if (items.length == 1) return false;
+        return true;
+    };
+
+    $scope.make_copies_bookable = function() {
+        itemSvc.make_copies_bookable(copyGrid.selectedItems());
+    }
+
+    $scope.book_copies_now = function() {
+        itemSvc.book_copies_now(copyGrid.selectedItems());
+    }
+
+    $scope.requestItems = function() {
+        var copy_list = gatherSelectedHoldingsIds();
+        itemSvc.requestItems(copy_list);
+    }
+
+    $scope.replaceBarcodes = function() {
+        itemSvc.replaceBarcodes(copyGrid.selectedItems());
+    }
+
+    $scope.attach_to_peer_bib = function() {
+        itemSvc.attach_to_peer_bib(copyGrid.selectedItems());
+    }
+
+    $scope.selectedHoldingsCopyDelete = function () {
+        itemSvc.selectedHoldingsCopyDelete(copyGrid.selectedItems());
+    }
+
+    $scope.selectedHoldingsItemStatusTgrEvt= function() {
+        var item = copyGrid.selectedItems()[0];
+        if (item)
+            $location.path('/cat/item/' + item.id + '/triggered_events');
+    }
+
+    $scope.selectedHoldingsItemStatusHolds= function() {
+        var item = copyGrid.selectedItems()[0];
+        if (item)
+            $location.path('/cat/item/' + item.id + '/holds');
+    }
+
+    $scope.cancel_transit = function () {
+        itemSvc.cancel_transit(copyGrid.selectedItems());
+    }
+
+    $scope.selectedHoldingsDamaged = function () {
+        itemSvc.selectedHoldingsDamaged(copyGrid.selectedItems());
+    }
+
+    $scope.selectedHoldingsMissing = function () {
+        itemSvc.selectedHoldingsMissing(copyGrid.selectedItems());
+    }
+
+    $scope.checkin = function () {
+        itemSvc.checkin(copyGrid.selectedItems());
+    }
+
+    $scope.renew = function () {
+        itemSvc.renew(copyGrid.selectedItems());
+    }
+
+    $scope.selectedHoldingsVolCopyAdd = function () {
+        itemSvc.spawnHoldingsAdd(copyGrid.selectedItems(),true,false);
+    }
+    $scope.selectedHoldingsCopyAdd = function () {
+        itemSvc.spawnHoldingsAdd(copyGrid.selectedItems(),false,true);
+    }
+
+    $scope.showBibHolds = function () {
+        angular.forEach(gatherSelectedRecordIds(), function (r) {
+            var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds';
+            $timeout(function() { $window.open(url, '_blank') });
+        });
+    }
+
+    $scope.selectedHoldingsVolCopyEdit = function () {
+        itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),false,false);
+    }
+    $scope.selectedHoldingsVolEdit = function () {
+        itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),false,true);
+    }
+    $scope.selectedHoldingsCopyEdit = function () {
+        itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),true,false);
+    }
+
+    $scope.changeItemOwningLib = function() {
+        itemSvc.changeItemOwningLib(copyGrid.selectedItems());
+    }
+
+    $scope.transferItems = function (){
+        itemSvc.transferItems(copyGrid.selectedItems());
+    }
+
     $scope.print_list = function() {
         var print_data = { copies : copyGrid.allItems() };
 
     $scope.print_list = function() {
         var print_data = { copies : copyGrid.allItems() };
 
@@ -1047,6 +1308,7 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
        ['$scope','$q','$location','$routeParams','$timeout','$window','egCore','itemSvc','egBilling',
 function($scope , $q , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling) {
     var copyId = $routeParams.id;
        ['$scope','$q','$location','$routeParams','$timeout','$window','egCore','itemSvc','egBilling',
 function($scope , $q , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling) {
     var copyId = $routeParams.id;
+    $scope.args.copyId = copyId;
     $scope.tab = $routeParams.tab || 'summary';
     $scope.context.page = 'detail';
     $scope.summaryRecord = null;
     $scope.tab = $routeParams.tab || 'summary';
     $scope.context.page = 'detail';
     $scope.summaryRecord = null;
@@ -1059,8 +1321,17 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
 
 
     // use the cached record info
 
 
     // use the cached record info
-    if (itemSvc.copy)
+    if (itemSvc.copy) {
         $scope.recordId = itemSvc.copy.call_number().record().id();
         $scope.recordId = itemSvc.copy.call_number().record().id();
+        $scope.args.recordId = $scope.recordId;
+        $scope.args.cnId = itemSvc.copy.call_number().id();
+        $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
+        $scope.args.cnLabel = itemSvc.copy.call_number().label();
+        $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
+        $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
+        $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
+        $scope.args.copyBarcode = itemSvc.copy.barcode();
+    }
 
     function loadCopy(barcode) {
         $scope.context.itemNotFound = false;
 
     function loadCopy(barcode) {
         $scope.context.itemNotFound = false;
@@ -1074,6 +1345,14 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
         if (!barcode && itemSvc.copy && itemSvc.copy.id() == copyId) {
             $scope.copy = itemSvc.copy;
             $scope.recordId = itemSvc.copy.call_number().record().id();
         if (!barcode && itemSvc.copy && itemSvc.copy.id() == copyId) {
             $scope.copy = itemSvc.copy;
             $scope.recordId = itemSvc.copy.call_number().record().id();
+            $scope.args.recordId = $scope.recordId;
+            $scope.args.cnId = itemSvc.copy.call_number().id();
+            $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
+            $scope.args.cnLabel = itemSvc.copy.call_number().label();
+            $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
+            $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
+            $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
+            $scope.args.copyBarcode = itemSvc.copy.barcode();
             return $q.when();
         }
 
             return $q.when();
         }
 
@@ -1098,6 +1377,14 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
 
             $scope.copy = copy;
             $scope.recordId = copy.call_number().record().id();
 
             $scope.copy = copy;
             $scope.recordId = copy.call_number().record().id();
+            $scope.args.recordId = $scope.recordId;
+            $scope.args.cnId = itemSvc.copy.call_number().id();
+            $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
+            $scope.args.cnLabel = itemSvc.copy.call_number().label();
+            $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
+            $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
+            $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
+            $scope.args.copyBarcode = copy.barcode();
             $scope.args.barcode = '';
 
             // locally flesh org units
             $scope.args.barcode = '';
 
             // locally flesh org units