From b959115fab86a03f38e5a6bd417b57db1d14796c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 15 Nov 2016 14:27:20 -0500 Subject: [PATCH] webstaff transit list: switch to egGridFlatDataProvider This gets us sorting "for free", or at least more easily than with a custom-written data provider. The following fields are marked sortable for now: - barcode - title - source library - destination library - send date/time Because egGridFlatDataProvider gives us flattened hashes, not fieldmapper objects, various tweaks were required to compensate. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../templates/staff/circ/transits/t_list.tt2 | 22 ++++--- .../default/staff/circ/services/transits.js | 4 +- .../js/ui/default/staff/circ/transits/list.js | 65 +++++-------------- 3 files changed, 30 insertions(+), 61 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/transits/t_list.tt2 b/Open-ILS/src/templates/staff/circ/transits/t_list.tt2 index 5c240db2c4..6d598f08f3 100644 --- a/Open-ILS/src/templates/staff/circ/transits/t_list.tt2 +++ b/Open-ILS/src/templates/staff/circ/transits/t_list.tt2 @@ -29,7 +29,6 @@ id-field="id" idl-class="atc" features="-sort,-multisort" - items-provider="grid_data_provider" grid-controls="grid_controls" persist-key="circ.transits.list" > @@ -42,21 +41,24 @@ - - - {{item.target_copy().barcode()}} + + + + + + {{item['target_copy.barcode']}} - - - {{item.target_copy().call_number().record().simple_record().title()}} + + + {{item['target_copy.call_number.record.simple_record.title']}} - - - + + + diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/transits.js b/Open-ILS/web/js/ui/default/staff/circ/services/transits.js index ec2499e1fc..001de632ad 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/transits.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/transits.js @@ -22,7 +22,7 @@ function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog) { $scope.num_transits = transits.length; $scope.num_hold_transits = 0; angular.forEach(transits, function(t) { - if (t.hold_transit_copy()) { + if (t['hold_transit_copy.hold.id']) { $scope.num_hold_transits++; } }); @@ -42,7 +42,7 @@ function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog) { } egCore.net.request( 'open-ils.circ', 'open-ils.circ.transit.abort', - egCore.auth.token(), { 'transitid' : transit.id() } + egCore.auth.token(), { 'transitid' : transit['id'] } ).then(function(resp) { if (evt = egCore.evt.parse(resp)) { egCore.audio.play('warning.transit.abort_failed'); diff --git a/Open-ILS/web/js/ui/default/staff/circ/transits/list.js b/Open-ILS/web/js/ui/default/staff/circ/transits/list.js index e11a77adb0..5e6550ab35 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/transits/list.js +++ b/Open-ILS/web/js/ui/default/staff/circ/transits/list.js @@ -21,9 +21,6 @@ angular.module('egTransitListApp', ['$scope','$q','$routeParams','$window','egCore','egTransits','egGridDataProvider','$uibModal','$timeout', function($scope , $q , $routeParams , $window , egCore , egTransits , egGridDataProvider , $uibModal , $timeout) { - var transits = []; - var provider = egGridDataProvider.instance({}); - $scope.grid_data_provider = provider; $scope.transit_direction = 'to'; function init_dates() { @@ -90,10 +87,10 @@ function($scope , $q , $routeParams , $window , egCore , egTransits , egGridData abort_transit(transits); } - $scope.add_copies_to_bucket = function(transits) { + $scope.add_copies_to_bucket = function() { var copy_list = []; angular.forEach($scope.grid_controls.selectedItems(), function(transit) { - copy_list.push(transit.target_copy().id()); + copy_list.push(transit['target_copy.id']); }); if (copy_list.length == 0) return; @@ -167,8 +164,8 @@ function($scope , $q , $routeParams , $window , egCore , egTransits , egGridData angular.forEach( $scope.grid_controls.selectedItems(), function (item) { - if (rid_list.indexOf(item.target_copy().call_number().record().simple_record().id()) == -1) - rid_list.push(item.target_copy().call_number().record().simple_record().id()); + if (rid_list.indexOf(item['target_copy.call_number.record.simple_record.id']) == -1) + rid_list.push(item['target_copy.call_number.record.simple_record.id']); } ); return rid_list; @@ -178,8 +175,8 @@ function($scope , $q , $routeParams , $window , egCore , egTransits , egGridData angular.forEach( $scope.grid_controls.selectedItems(), function (item) { - if (rid && item.target_copy().call_number().record().simple_record().id() != rid) return; - cp_id_list.push(item.target_copy().id()); + if (rid && item['target_copy.call_number.record.simple_record.id'] != rid) return; + cp_id_list.push(item['target_copy.id']); } ); return cp_id_list; @@ -212,54 +209,24 @@ function($scope , $q , $routeParams , $window , egCore , egTransits , egGridData spawnHoldingsEdit(true, false); } - $scope.grid_controls = { - activateItem : load_item - } - - function refresh_page() { - transits = []; - provider.refresh(); - } - - provider.get = function(offset, count) { - var deferred = $q.defer(); - var recv_index = 0; - + function current_query() { var filter = { 'source_send_time' : { 'between' : date_range() }, 'dest_recv_time' : null }; if ($scope.transit_direction == 'to') { filter['dest'] = $scope.context_org.id(); } if ($scope.transit_direction == 'from') { filter['source'] = $scope.context_org.id(); } + return filter; + } - egCore.pcrud.search('atc', - filter, { - 'flesh' : 5, - // atc -> target_copy -> call_number -> record -> simple_record - // atc -> hold_transit_copy -> hold -> usr -> card - 'flesh_fields' : { - 'atc' : ['target_copy','dest','source','hold_transit_copy'], - 'acp' : ['call_number','location','circ_lib'], - 'acn' : ['record'], - 'bre' : ['simple_record'], - 'ahtc' : ['hold'], - 'ahr' : ['usr'], - 'au' : ['card'] - }, - 'select' : { 'bre' : ['id'] }, - order_by : { atc : 'source_send_time' }, - limit : count, - offset : offset, - } - ).then( - deferred.resolve, null, - function(transit) { - transits[offset + recv_index++] = transit; - deferred.notify(transit); - } - ); + $scope.grid_controls = { + activateItem : load_item, + setQuery : current_query + } - return deferred.promise; + function refresh_page() { + $scope.grid_controls.setQuery(current_query()); + $scope.grid_controls.refresh(); } $scope.context_org = egCore.org.get(egCore.auth.user().ws_ou()); -- 2.43.2