add ability to unstage an appointment in the staff interface
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 3 Jun 2020 19:01:34 +0000 (15:01 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 3 Jun 2020 19:01:46 +0000 (15:01 -0400)
* add open-ils.curbside.mark_unstaged method
* add button in 'staged and ready' tab

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Curbside.pm
Open-ILS/src/templates/staff/circ/curbside/index.tt2
Open-ILS/src/templates/staff/circ/curbside/t_staged_manager.tt2
Open-ILS/web/js/ui/default/staff/circ/curbside/directives/staged_manager.js
Open-ILS/web/js/ui/default/staff/circ/curbside/services/core.js

index caa415a..717008a 100644 (file)
@@ -802,6 +802,35 @@ __PACKAGE__->register_method(
     }
 );
 
+sub mark_unstaged {
+    my ($self, $conn, $authtoken, $appointment) = @_;
+    my $e = new_editor(xact => 1, authtoken => $authtoken);
+    return $e->die_event unless $e->checkauth;
+    return $e->die_event unless $e->allowed("STAFF_LOGIN");
+
+    my $slot = $e->retrieve_action_curbside($appointment);
+    return undef unless ($slot);
+
+    $slot->clear_staged();
+    $slot->clear_stage_staff();
+    $e->update_action_curbside($slot) or return $e->die_event;
+    $e->commit;
+
+    return $e->retrieve_action_curbside($slot->id);
+}
+__PACKAGE__->register_method(
+    method   => "mark_unstaged",
+    api_name => "open-ils.curbside.mark_unstaged",
+    signature => {
+        params => [
+            {type => 'string', desc => 'Authentication token'},
+            {type => 'number', desc => 'Appointment ID'},
+        ],
+        return => { desc => 'Appointment on success, nothing when no appointment found, '.
+                            'an ILS Event on permission error'}
+    }
+);
+
 sub mark_arrived {
     my ($self, $conn, $authtoken, $appointment) = @_;
     my $e = new_editor(xact => 1, authtoken => $authtoken);
index efbf980..822a73b 100644 (file)
@@ -23,6 +23,9 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
     s.SUCCESS_CURBSIDE_MARK_ARRIVED = "[% l('Marked curbside appointment {{slot_id}} as patron arrived') %]";
     s.NOTFOUND_CURBSIDE_MARK_ARRIVED = "[% l('Could not find curbside appointment {{slot_id}} to mark as patron arrived') %]";
     s.FAILED_CURBSIDE_MARK_ARRIVED = "[% l('Failed to mark curbside appointment {{slot_id}} as patron arrived: {{evt_code}}') %]";
+    s.SUCCESS_CURBSIDE_MARK_UNSTAGED = "[% l('Marked curbside appointment {{slot_id}} back to to-be-staged') %]";
+    s.NOTFOUND_CURBSIDE_MARK_UNSTAGED = "[% l('Could not find curbside appointment {{slot_id}} to mark as to-be-staged') %]";
+    s.FAILED_CURBSIDE_MARK_UNSTAGED = "[% l('Failed to mark curbside appointment {{slot_id}} as to-be-staged: {{evt_code}}') %]";
     s.SUCCESS_CURBSIDE_MARK_DELIVERED = "[% l('Marked curbside appointment {{slot_id}} as delivered') %]";
     s.NOTFOUND_CURBSIDE_MARK_DELIVERED = "[% l('Could not find curbside appointment {{slot_id}} to mark as delivered') %]";
     s.FAILED_CURBSIDE_MARK_DELIVERED = "[% l('Failed to mark curbside appointment {{slot_id}} as delivered: {{evt_code}}') %]";
index 66b5b29..c2a6023 100644 (file)
           </button>
         </div>
       </div>
+      <div class="row">
+        <div class="col-xs-12">
+          <button class="btn btn-sm btn-warning"
+            ng-disabled="col.handlers.wasHandled(item['slot_id'])"
+            ng-click="col.handlers.mark_unstaged(item['slot_id'])">
+            [% l('Set Back to To Be Staged') %]
+          </button>
+        </div>
+      </div>
     </eg-grid-field>
   </eg-grid>
 </div>
index ac6fa90..915582d 100644 (file)
@@ -85,6 +85,30 @@ function($scope , $q , egCurbsideCoreSvc , egCore , egGridDataProvider , egProgr
             $timeout(function() { $scope.refresh_staged() }, 500);
         });
     }
+    $scope.gridCellHandlers.mark_unstaged = function(id) {
+        egCurbsideCoreSvc.mark_unstaged(id).then(function(resp) {
+            if (evt = egCore.evt.parse(resp)) {
+                ngToast.danger(egCore.strings.$replace(
+                    egCore.strings.FAILED_CURBSIDE_MARK_UNSTAGED,
+                    { slot_id : id, evt_code : evt.code }
+                ));
+                return;
+            } 
+            if (!angular.isDefined(resp)) {
+                ngToast.warning(egCore.strings.$replace(
+                    egCore.strings.NOTFOUND_CURBSIDE_MARK_UNSTAGED,
+                    { slot_id : id }
+                ));
+                return;
+            }
+            ngToast.success(egCore.strings.$replace(
+                egCore.strings.SUCCESS_CURBSIDE_MARK_UNSTAGED,
+                { slot_id : id }
+            ));
+            $scope.wasHandled[id] = true;
+            $timeout(function() { $scope.refresh_staged() }, 500);
+        });
+    }
     $scope.gridCellHandlers.mark_delivered = function(id) {
         egProgressDialog.open();
         egCurbsideCoreSvc.mark_delivered(id).then(function(resp) {
index d52b7a3..dc5faa1 100644 (file)
@@ -108,6 +108,14 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
             slot_id
         );
     }
+    service.mark_unstaged = function(slot_id) {
+        return egCore.net.request(
+            'open-ils.curbside',
+            'open-ils.curbside.mark_unstaged',
+            egCore.auth.token(),
+            slot_id
+        );
+    }
     service.mark_arrived = function(slot_id) {
         return egCore.net.request(
             'open-ils.curbside',