From: Bill Erickson Date: Wed, 20 Aug 2014 20:45:47 +0000 (-0400) Subject: LP#1653001 webstaff: Holds pull list sortable columns X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e59ffd6c0500f21858d701c584eaa3d2f568c21b;p=working%2FEvergreen.git LP#1653001 webstaff: Holds pull list sortable columns Retrieve holds for the pull list via the canned "ahopl" pull list IDL class. This lets the grid fetch the data via canned flattener query, supporting server-side sort/limit/offset options. To retain all previous UI behavior, primarily editing hold attributes (e.g. notification prefs), hold details for each hold have to be fetched (and cached) in addition to the main grid data. The grid renders and sorts the flattener data, then grid actions act upon the fleshed hold details data. Commit also includes: 1. Added some missing IDL links for the "ahopl" class. 2. Micro-optimization to egGrid to exit early when an invalid IDL path is provided. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 6f722e00c6..561fbd1952 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5648,7 +5648,7 @@ SELECT usr, - + @@ -5796,7 +5796,7 @@ SELECT usr, - + @@ -5881,7 +5881,7 @@ SELECT usr, - + @@ -5963,7 +5963,7 @@ SELECT usr, - + @@ -6022,7 +6022,7 @@ SELECT usr, - + diff --git a/Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2 b/Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2 index 4f4502f88a..91b8571acd 100644 --- a/Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2 +++ b/Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2 @@ -4,8 +4,8 @@ - - - - {{item.hold.current_copy().barcode()}} - + + + {{item.shelving_loc}} + + - - - - - - - - - - {{item.mvr.title()}} - + + + {{item.cn_prefix}} {{item.call_number_label}} {{item.cn_suffix}} + + + - - - - - - - - - - - - + + + + {{item.title}} + + + + + + + {{item.barcode}} + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/web/js/ui/default/staff/circ/holds/app.js b/Open-ILS/web/js/ui/default/staff/circ/holds/app.js index 83bb529d54..0dccd947e4 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/holds/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/holds/app.js @@ -35,11 +35,6 @@ angular.module('egHoldsApp', $routeProvider.otherwise({redirectTo : '/circ/holds/shelf'}); }) -.factory('holdUiSvc', function() { - return { - holds : [] // cache - } -}) .controller('HoldsShelfCtrl', ['$scope','$q','$routeParams','$window','$location','egCore','egHolds','egHoldGridActions','egCirc','egGridDataProvider', @@ -249,43 +244,77 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e }]) .controller('HoldsPullListCtrl', - ['$scope','$q','$routeParams','$window','$location','egCore','egHolds','egCirc','egGridDataProvider','egHoldGridActions','holdUiSvc', -function($scope , $q , $routeParams , $window , $location , egCore , egHolds , egCirc , egGridDataProvider , egHoldGridActions , holdUiSvc) { - $scope.detail_hold_id = $routeParams.hold_id; + ['$scope','$q','$routeParams','$window','$location','egCore', + 'egHolds','egCirc','egHoldGridActions', +function($scope , $q , $routeParams , $window , $location , egCore , + egHolds , egCirc , egHoldGridActions) { - var provider = egGridDataProvider.instance({}); - $scope.gridDataProvider = provider; + $scope.detail_hold_id = $routeParams.hold_id; - $scope.grid_actions = egHoldGridActions; - $scope.grid_actions.refresh = function() { - holdUiSvc.holds = []; - provider.refresh(); + var cached_details = {}; + var details_needed = {}; + + $scope.gridControls = { + setQuery : function() { + return {'copy_circ_lib_id' : egCore.auth.user().ws_ou()} + }, + setSort : function() { + return ['copy_location_order_position','call_number_sort_key'] + }, + itemRetrieved : function(item) { + if (!cached_details[item.id]) { + details_needed[item.id] = item; + } + }, + allItemsRetrieved : flesh_holds } - provider.get = function(offset, count) { - if (holdUiSvc.holds[offset]) { - return provider.arrayNotifier(holdUiSvc.holds, offset, count); - } + // Fetches hold detail data for each hold in the grid and links + // the detail data to the related grid item so egHoldGridActions + // and friends have access to holds data they understand. + // Only fetch not-yet-cached data. + function flesh_holds() { - var deferred = $q.defer(); - var recv_index = 0; + // Start by fleshing hold details from our cached data. + var items = $scope.gridControls.allItems(); + angular.forEach(items, function(item) { + if (!cached_details[item.id]) return; + angular.forEach(cached_details[item.id], + function(val, key) { item[key] = val }) + }); + + // Exit if all needed details were already cached + if (Object.keys(details_needed).length == 0) return; + + $scope.print_list_loading = true; + $scope.print_list_progress = 0; - // fetch the IDs egCore.net.request( 'open-ils.circ', - 'open-ils.circ.hold_pull_list.fleshed.stream', - egCore.auth.token(), count, offset + 'open-ils.circ.hold.details.batch.retrieve.authoritative', + egCore.auth.token(), Object.keys(details_needed) ).then( - deferred.resolve, null, - function(hold_data) { - egHolds.local_flesh(hold_data); - holdUiSvc.holds[offset + recv_index++] = hold_data; - deferred.notify(hold_data); + function() { + $scope.print_list_loading = false; + $scope.print_list_progress = null; + }, null, + function(hold_info) { + var hold_id = hold_info.hold.id(); + cached_details[hold_id] = hold_info; + var item = details_needed[hold_id]; + delete details_needed[hold_id]; + angular.forEach(hold_info, + function(val, key) { item[key] = val }); + $scope.print_list_progress++; } ); + } - return deferred.promise; + $scope.grid_actions = egHoldGridActions; + $scope.grid_actions.refresh = function() { + cached_details = {}; // un-cache details after edit actions. + $scope.gridControls.refresh(); } $scope.detail_view = function(action, user_data, items) { diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index 8828456f03..ff438f875c 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -1420,16 +1420,17 @@ angular.module('egGridMod', idl_parent = idl_field; idl_field = class_obj.field_map[part]; - if (idl_field && idl_field['class'] && ( - idl_field.datatype == 'link' || - idl_field.datatype == 'org_unit')) { - class_obj = egCore.idl.classes[idl_field['class']]; + if (idl_field) { + if (idl_field['class'] && ( + idl_field.datatype == 'link' || + idl_field.datatype == 'org_unit')) { + class_obj = egCore.idl.classes[idl_field['class']]; + } + } else { + return null; } - // else, path is not in the IDL, which is fine } - if (!idl_field) return null; - return { idl_parent: idl_parent, idl_field : idl_field,