From 95918a92259658ea0ac93663766001bbaffcd291 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 1 Mar 2021 11:19:07 -0500 Subject: [PATCH] LP1904036 Renew with due date Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../share/circ/due-date-dialog.component.html | 16 +---- .../staff/share/circ/due-date-dialog.component.ts | 39 ----------- .../src/app/staff/share/circ/grid.component.html | 5 ++ .../eg2/src/app/staff/share/circ/grid.component.ts | 75 ++++++++++++++++------ 4 files changed, 62 insertions(+), 73 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/due-date-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/circ/due-date-dialog.component.html index b991ef76bb..04b87096e3 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/due-date-dialog.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/due-date-dialog.component.html @@ -21,29 +21,15 @@ -
Selected due date is not valid.
- -
-
- {{numSucceeded}} Due Date(s) Successfully Modified -
-
-
-
-
- {{numFailed}} Due Date(s) Failed to Modify -
-
-
diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/due-date-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/due-date-dialog.component.ts index 60ced722fc..7ce8b91840 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/due-date-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/due-date-dialog.component.ts @@ -27,8 +27,6 @@ export class DueDateDialogComponent dueDateIsValid = false; dueDateIso: string; - numSucceeded: number; - numFailed: number; nowTime: number; constructor( @@ -43,8 +41,6 @@ export class DueDateDialogComponent ngOnInit() { this.onOpen$.subscribe(_ => { - this.numSucceeded = 0; - this.numFailed = 0; this.dueDateIso = new Date().toISOString(); this.nowTime = new Date().getTime(); }); @@ -57,39 +53,4 @@ export class DueDateDialogComponent this.dueDateIso = null; } } - - modifyBatch() { - if (!this.dueDateIso) { return; } - - let promise = Promise.resolve(); - - this.circs.forEach(circ => { - promise = promise.then(_ => this.modifyOne(circ)); - }); - - promise.then(_ => { - this.close(); - this.circs = []; - }); - } - - modifyOne(circ: IdlObject): Promise { - return this.net.request( - 'open-ils.circ', - 'open-ils.circ.circulation.due_date.update', - this.auth.token(), circ.id(), this.dueDateIso - - ).toPromise().then(modCirc => { - - const evt = this.evt.parse(modCirc); - - if (evt) { - this.numFailed++; - console.error(evt); - } else { - this.numSucceeded++; - this.respond(modCirc); - } - }); - } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html b/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html index ea9561830e..b89311a4b2 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html @@ -87,6 +87,11 @@ i18n-label label="Renew All" (onClick)="renewAll()"> + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts index dba0088c58..81e327e53f 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts @@ -317,26 +317,35 @@ export class CircGridComponent implements OnInit { } editDueDate(rows: any) { - const circs = this.getCircs(rows); - if (circs.length === 0) { return; } - - let refreshNeeded = false; - this.dueDateDialog.circs = circs; - this.dueDateDialog.open().subscribe( - circ => { - refreshNeeded = true; - const row = rows.filter(r => r.circ.id() === circ.id())[0]; - row.circ.due_date(circ.due_date()); - row.dueDate = circ.due_date(); - delete row.overdue; // it will recalculate - }, - err => console.error(err), - () => { - if (refreshNeeded) { - this.reloadGrid(); + const ids = this.getCircIds(rows); + if (ids.length === 0) { return; } + + this.dueDateDialog.open().subscribe(isoDate => { + if (!isoDate) { return; } // canceled + + const dialog = this.openProgressDialog(rows); + + from(ids).pipe(concatMap(id => { + return this.net.request( + 'open-ils.circ', + 'open-ils.circ.circulation.due_date.update', + this.auth.token(), id, isoDate + ); + })).subscribe( + circ => { + const row = rows.filter(r => r.circ.id() === circ.id())[0]; + row.circ.due_date(circ.due_date()); + row.dueDate = circ.due_date(); + delete row.overdue; // it will recalculate + dialog.increment(); + }, + err => console.log(err), + () => { + dialog.close(); + this.emitReloadRequest(); } - } - ); + ); + }); } circIsOverdue(row: CircGridEntry): boolean { @@ -431,6 +440,34 @@ export class CircGridComponent implements OnInit { ); } + renewWithDate(rows: any) { + const ids = this.getCopyIds(rows); + if (ids.length === 0) { return; } + + this.dueDateDialog.open().subscribe(isoDate => { + if (!isoDate) { return; } // canceled + + const dialog = this.openProgressDialog(rows); + const params: CheckoutParams = {due_date: isoDate}; + + let refreshNeeded = false; + this.circ.renewBatch(ids).subscribe( + resp => { + if (resp.success) { refreshNeeded = true; } + dialog.increment(); + }, + err => console.error(err), + () => { + dialog.close(); + if (refreshNeeded) { + this.emitReloadRequest(); + } + } + ); + }); + } + + // Same params will be used for each copy checkin(rows: CircGridEntry[], params?: CheckinParams, noReload?: boolean): Observable { -- 2.11.0