LP1904036 Checkin actions continued
authorBill Erickson <berickxx@gmail.com>
Tue, 20 Apr 2021 19:49:57 +0000 (15:49 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:32 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.html
Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.ts
Open-ILS/src/eg2/src/app/staff/share/circ/cancel-transit-dialog.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/share/circ/cancel-transit-dialog.component.ts [new file with mode: 0644]

index 7c6870f..480ae7c 100644 (file)
         (onClick)="markMissingPieces($event)"></eg-grid-toolbar-action>
 
       <eg-grid-toolbar-action
-        i18n-group group="Manage" i18n-label label="Manage Item Alerts"
+        i18n-group group="Edit" i18n-label label="Manage Item Alerts"
         [disabled]="grid.context.rowSelector.selected().length !== 1"
         (onClick)="manageItemAlerts($event)">
       </eg-grid-toolbar-action>
 
       <eg-grid-toolbar-action
+        i18n-group group="Edit" i18n-label label="Edit Holdings"
+        (onClick)="editHoldings($event)">
+      </eg-grid-toolbar-action>
+
+      <eg-grid-toolbar-action
+        i18n-group group="Print" i18n-label label="Print Labels"
+        (onClick)="openItemPrintLabels($event)">
+      </eg-grid-toolbar-action>
+
+      <eg-grid-toolbar-action
         i18n-group group="Add" i18n-label label="Add Item Alerts"
         (onClick)="addItemAlerts($event)">
       </eg-grid-toolbar-action>
       </eg-grid-toolbar-action>
 
       <eg-grid-toolbar-action
-        i18n-group group="Retrieve" i18n-label 
+        i18n-group group="Show" i18n-label 
         label="Retrieve Last Patron Who Circulated Item"
         [disabled]="grid.context.rowSelector.selected().length !== 1"
         (onClick)="retrieveLastPatron($event)">
       </eg-grid-toolbar-action>
 
+      <eg-grid-toolbar-action
+        i18n-group group="Show" i18n-label 
+        label="Show Record Holds"
+        [disabled]="grid.context.rowSelector.selected().length !== 1"
+        (onClick)="showRecordHolds($event)">
+      </eg-grid-toolbar-action>
+
+      <eg-grid-toolbar-action
+        i18n-group group="Show" i18n-label 
+        label="Show Last Few Circs"
+        [disabled]="grid.context.rowSelector.selected().length !== 1"
+        (onClick)="showRecentCircs($event)">
+      </eg-grid-toolbar-action>
+
       <!-- COLUMNS -->
 
       <eg-grid-column path="index" [index]="true" 
index e627385..5991c33 100644 (file)
@@ -28,6 +28,8 @@ import {StringComponent} from '@eg/share/string/string.component';
 import {BackdateDialogComponent} from '@eg/staff/share/circ/backdate-dialog.component';
 import {CancelTransitDialogComponent
     } from '@eg/staff/share/circ/cancel-transit-dialog.component';
+import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
+import {AnonCacheService} from '@eg/share/util/anon-cache.service';
 
 
 interface CheckinGridEntry extends CheckinResult {
@@ -95,6 +97,8 @@ export class CheckinComponent implements OnInit, AfterViewInit {
         private circ: CircService,
         private toast: ToastService,
         private printer: PrintService,
+        private holdings: HoldingsService,
+        private anonCache: AnonCacheService,
         public patronService: PatronService
     ) {}
 
@@ -345,5 +349,44 @@ export class CheckinComponent implements OnInit, AfterViewInit {
             this.cancelTransitDialog.open().subscribe();
         }
     }
+
+    showRecordHolds(rows: CheckinGridEntry[]) {
+
+        const row = rows[0];
+        if (row.record) {
+            const id = row.record.doc_id()
+
+            const url = this.ngLocation.prepareExternalUrl(
+                `/staff/catalog/record/${id}/holds`);
+
+            window.open(url);
+        }
+    }
+
+    showRecentCircs(rows: CheckinGridEntry[]) {
+        const copyId = this.getCopyIds(rows)[0];
+        if (copyId) {
+            const url = `/eg/staff/cat/item/${copyId}/circs`;
+            window.open(url);
+        }
+    }
+
+    editHoldings(rows: CheckinGridEntry[]) {
+        const ids = this.getCopyIds(rows);
+        if (ids.length === 0) { return; }
+
+        this.holdings.spawnAddHoldingsUi(null, null, null, ids);
+    }
+
+    openItemPrintLabels(rows: CheckinGridEntry[]) {
+        const ids = this.getCopyIds(rows);
+        if (ids.length === 0) { return; }
+
+        this.anonCache.setItem(null, 'print-labels-these-copies', {copies: ids})
+        .then(key => {
+            const url = `/eg/staff/cat/printlabels/${key}`;
+            window.open(url);
+        });
+    }
 }
 
diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/cancel-transit-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/circ/cancel-transit-dialog.component.html
new file mode 100644 (file)
index 0000000..7519b5c
--- /dev/null
@@ -0,0 +1,27 @@
+<eg-string #success i18n-text text="Transit(s) Successfully Canceled">
+</eg-string>
+<eg-string #failure i18n-text text="Some Transits Failed to Cancel">
+</eg-string>
+
+<ng-template #dialogContent>
+  <div class="modal-header bg-info">
+    <h4 i18n>Cancel Transits</h4>
+    <button type="button" class="close"
+      i18n-aria-label aria-label="Close" (click)="close()">
+      <span aria-hidden="true">&times;</span>
+    </button>
+  </div>
+  <div class="modal-body">
+    <strong i18n>Cancel {{numTransits}} transits?</strong>
+  </div>
+  <div class="modal-footer">
+    <button type="button" class="btn btn-success" (click)="proceed()" i18n>
+      Cancel Transits
+    </button>
+    <button type="button" class="btn btn-warning" (click)="close()" i18n>
+      Close Dialog
+    </button>
+  </div>
+</ng-template>
+
+
diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/cancel-transit-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/cancel-transit-dialog.component.ts
new file mode 100644 (file)
index 0000000..07698d2
--- /dev/null
@@ -0,0 +1,77 @@
+import {Component, OnInit, Output, Input, ViewChild, EventEmitter} from '@angular/core';
+import {empty, of, from, Observable} from 'rxjs';
+import {concatMap, tap} from 'rxjs/operators';
+import {IdlService, IdlObject} from '@eg/core/idl.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {OrgService} from '@eg/core/org.service';
+import {AuthService} from '@eg/core/auth.service';
+import {NetService} from '@eg/core/net.service';
+import {EventService} from '@eg/core/event.service';
+import {StringComponent} from '@eg/share/string/string.component';
+import {AlertDialogComponent} from '@eg/share/dialog/alert.component';
+import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
+import {DialogComponent} from '@eg/share/dialog/dialog.component';
+import {CircService, CheckinResult} from './circ.service';
+import {ServerStoreService} from '@eg/core/server-store.service';
+import {AudioService} from '@eg/share/util/audio.service';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {PrintService} from '@eg/share/print/print.service';
+
+/** Route Item Dialog */
+
+@Component({
+  templateUrl: 'cancel-transit-dialog.component.html',
+  selector: 'eg-cancel-transit-dialog'
+})
+export class CancelTransitDialogComponent extends DialogComponent implements OnInit {
+
+    @Input() transitIds: number[];
+    numTransits: number;
+
+    @ViewChild('success') success: StringComponent;
+    @ViewChild('failure') failure: StringComponent;
+
+    constructor(
+        private modal: NgbModal,
+        private auth: AuthService,
+        private net: NetService,
+        private evt: EventService,
+        private toast: ToastService
+    ) { super(modal); }
+
+    ngOnInit() {
+        this.onOpen$.subscribe(_ => {
+            this.numTransits = this.transitIds.length;
+        });
+    }
+
+    proceed() {
+
+        let changesMade = false;
+        let error = false;
+
+        from(this.transitIds).pipe(concatMap(id => {
+            return this.net.request(
+                'open-ils.circ',
+                'open-ils.circ.transit.abort',
+                this.auth.token(), {transitid: id}
+            ).pipe(tap(resp => {
+                const evt = this.evt.parse(resp);
+                if (evt) {
+                    error = true;
+                    this.toast.danger(this.failure.text);
+                    console.error(evt);
+                } else {
+                    changesMade = true;
+                }
+            }));
+        })).subscribe(null, null, () => {
+            if (changesMade && !error) {
+                this.toast.success(this.success.text);
+            }
+            this.close(changesMade);
+        });
+    }
+}
+
+