<div>
+ <div ng-style="{visibility : refreshNeeded ? 'visible' : 'hidden'}" class="alert alert-warning">
+ [% l('Updates to the curbside appointment list are available. Please refresh.') %]
+ </div>
<eg-grid
id-field="slot_id"
features="-sort,-multisort,-picker,-multiselect"
dateformat="{{$root.egDateAndTimeFormat}}">
<eg-grid-menu-item handler="refresh_staging" standalone="true"
- label="[% l('Refresh List') %]"></eg-grid-menu-item>
+ label="[% l('Refresh List')%]"></eg-grid-menu-item>
<eg-grid-field label="[% l('Pickup Date/Time') %]" path="slot.slot" datatype="timestamp"></eg-grid-field>
<eg-grid-field label="[% l('Patron') %]" path="slot.patron">
<eg-grid-field label="[% l('Items for Pickup') %]" path="holds" compiled>
<eg-curbside-holds-list holds="item.holds" bib-data="item.bib_data_by_hold"></eg-curbside-holds-list>
</eg-grid-field>
- <eg-grid-field label="[% l('Action') %]">
- <button class="btn btn-sm btn-primary">[% l('Mark As Staged And Ready') %]</button>
+ <eg-grid-field label="[% l('Action') %]" handlers="gridCellHandlers" compiled>
+ <button class="btn btn-sm btn-primary"
+ ng-disabled="col.handlers.wasHandled(item['slot_id'])"
+ ng-click="col.handlers.mark_staged(item['slot_id'])">
+ [% l('Mark As Staged And Ready') %]
+ </button>
</eg-grid-field>
</eg-grid>
</div>
templateUrl: './circ/curbside/t_to_be_staged_manager',
controller:
['$scope','$q','egCurbsideCoreSvc','egCore','egGridDataProvider',
- '$uibModal','$timeout','$location','egConfirmDialog','ngToast',
+ '$uibModal','$timeout','$location','egConfirmDialog','ngToast','$interval',
function($scope , $q , egCurbsideCoreSvc , egCore , egGridDataProvider ,
- $uibModal , $timeout , $location , egConfirmDialog , ngToast) {
+ $uibModal , $timeout , $location , egConfirmDialog , ngToast , $interval) {
- $scope.gridControls = {
- activateItem : function (item) { console.debug('gmc') } // TODO
- };
+ $scope.gridControls = {};
+
+ $scope.wasHandled = {};
+ $scope.refreshNeeded = false;
+ latestTime = undefined;
+ var checkRefresh;
+ checkRefresh = $interval(function() {
+ egCurbsideCoreSvc.get_latest_to_be_staged().then(function(latest) {
+ if (angular.isDefined(latest)) {
+ if (angular.isDefined(latestTime) && latestTime != latest) {
+ $scope.refreshNeeded = true;
+ }
+ latestTime = latest;
+ }
+ });
+ }, 10000);
+ $scope.$on('$destroy', function() {
+ if (angular.isDefined(checkRefresh)) {
+ $interval.cancel(checkRefresh);
+ checkRefresh = undefined;
+ };
+ });
$scope.gridDataProvider = egGridDataProvider.instance({
get : function(offset, count) {
+ $scope.wasHandled = {};
+ $scope.refreshNeeded = false;
return egCurbsideCoreSvc.get_to_be_staged(offset, count);
}
});
+ $scope.refresh_staging = function() {
+ $scope.gridControls.refresh();
+ }
+
+ $scope.gridCellHandlers = { };
+ $scope.gridCellHandlers.mark_staged = function(id) {
+ egCurbsideCoreSvc.mark_staged(id).then(function(resp) {
+ if (evt = egCore.evt.parse(resp)) {
+ ngToast.danger(egCore.strings.$replace(
+ egCore.strings.FAILED_CURBSIDE_MARK_STAGED,
+ { slot_id : id, evt_code : evt.code }
+ ));
+ return;
+ }
+ if (typeof resp == 'undefined') {
+ ngToast.warning(egCore.strings.$replace(
+ egCore.strings.NOTFOUND_CURBSIDE_MARK_STAGED,
+ { slot_id : id }
+ ));
+ return;
+ }
+ ngToast.success(egCore.strings.$replace(
+ egCore.strings.SUCCESS_CURBSIDE_MARK_STAGED,
+ { slot_id : id }
+ ));
+ $scope.wasHandled[id] = true;
+ $timeout(function() { $scope.refresh_staging() }, 500);
+ });
+ }
+ $scope.gridCellHandlers.wasHandled = function(id) {
+ return $scope.wasHandled[id];
+ }
+
}]}});