From c33d301ae9974b4e662eaf1c091aa5f11e755202 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 10 Jul 2018 11:00:05 -0400 Subject: [PATCH] LP#1779158 Ang vand add-to-bucket and delete-queue Signed-off-by: Bill Erickson --- .../app/staff/cat/vandelay/import.component.html | 4 +- .../src/app/staff/cat/vandelay/import.component.ts | 2 +- .../app/staff/cat/vandelay/queue.component.html | 23 ++++++-- .../src/app/staff/cat/vandelay/queue.component.ts | 67 ++++++++++++++++++++-- .../src/app/staff/cat/vandelay/vandelay.module.ts | 4 +- .../buckets/record-bucket-dialog.component.html | 3 +- .../buckets/record-bucket-dialog.component.ts | 51 +++++++++++++++- 7 files changed, 137 insertions(+), 17 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html index 68c0116c2f..8b8d6da806 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html @@ -1,6 +1,4 @@ - -

MARC File Upload

@@ -154,6 +152,8 @@ Importing {{importSelection().recordIds.length}} Record(s) Importing Queue {{importSelection().queue.name()}} +
+
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts index 69b32b775d..e7ed230129 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts @@ -331,7 +331,6 @@ export class ImportComponent implements OnInit, AfterViewInit { }, (err: HttpErrorResponse) => { - //this.progressDialog.close(); console.error(err); this.toast.danger(err.error.error); } @@ -386,6 +385,7 @@ export class ImportComponent implements OnInit, AfterViewInit { importRecordQueue(recIds?: number[]): Promise { const rtype = this.recordType === 'bib' ? 'bib' : 'auth'; + let method = `open-ils.vandelay.${rtype}_queue.import`; const options: ImportOptions = this.compileImportOptions(); diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html index 707ccd5fb7..ae489009d3 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html @@ -1,4 +1,15 @@ - + + + + + + + +

Queue {{queueSummary.queue.name()}}

@@ -43,7 +54,7 @@ i18n>Import Selected Records
@@ -59,11 +70,15 @@
  • diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts index 5758f58d63..600ef25a2a 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts @@ -2,11 +2,15 @@ import {Component, OnInit, AfterViewInit, ViewChild} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import 'rxjs/add/observable/of'; import {map} from 'rxjs/operators/map'; +import {filter} from 'rxjs/operators/filter'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {Pager} from '@eg/share/util/pager'; import {IdlObject} from '@eg/core/idl.service'; +import {EventService} from '@eg/core/event.service'; import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; +import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; +import {ProgressDialogComponent} from '@eg/share/dialog/progress.component'; import {GridComponent} from '@eg/share/grid/grid.component'; import {GridDataSource, GridColumn} from '@eg/share/grid/grid'; import {VandelayService, VandelayImportSelection} from './vandelay.service'; @@ -36,10 +40,13 @@ export class QueueComponent implements AfterViewInit { attrDefs: IdlObject[]; @ViewChild('queueGrid') queueGrid: GridComponent; + @ViewChild('confirmDelDlg') confirmDelDlg: ConfirmDialogComponent; + @ViewChild('progressDlg') progressDlg: ProgressDialogComponent; constructor( private router: Router, private route: ActivatedRoute, + private evt: EventService, private net: NetService, private auth: AuthService, private vandelay: VandelayService) { @@ -100,10 +107,13 @@ export class QueueComponent implements AfterViewInit { ); } + qtypeShort(): string { + return this.queueType === 'bib' ? 'bib' : 'auth'; + } + loadQueueSummary(): Promise { - const qtype = this.queueType === 'bib' ? 'bib' : 'auth'; const method = - `open-ils.vandelay.${qtype}_queue.summary.retrieve`; + `open-ils.vandelay.${this.qtypeShort()}_queue.summary.retrieve`; return this.net.request( 'open-ils.vandelay', method, this.auth.token(), this.queueId) @@ -122,9 +132,16 @@ export class QueueComponent implements AfterViewInit { } return this.vandelay.getQueuedRecords( - this.queueId, this.queueType, options, this.filters.matches) - .pipe(map(rec => { - + this.queueId, this.queueType, options, this.filters.matches).pipe( + filter(rec => { + // avoid sending mishapen data to the grid + // this happens (among other reasons) when the grid + // no longer exists + const e = this.evt.parse(rec); + if (e) { console.error(e); return false; } + return true; + }), + map(rec => { const recHash: any = { id: rec.id(), import_error: rec.import_error(), @@ -153,5 +170,45 @@ export class QueueComponent implements AfterViewInit { this.vandelay.importSelection = selection; this.router.navigate(['/staff/cat/vandelay/import']); } + + importAll() { + const selection = new VandelayImportSelection(); + selection.queue = this.queueSummary.queue; + selection.importQueue = true; + this.vandelay.importSelection = selection; + this.router.navigate(['/staff/cat/vandelay/import']); + } + + deleteQueue() { + this.confirmDelDlg.open().then( + yes => { + this.progressDlg.open(); + return this.net.request( + 'open-ils.vandelay', + `open-ils.vandelay.${this.qtypeShort()}_queue.delete`, + this.auth.token(), this.queueId + ).toPromise(); + }, + no => { + this.progressDlg.close(); + return Promise.reject('delete failed'); + } + ).then( + resp => { + this.progressDlg.close(); + const e = this.evt.parse(resp); + if (e) { + console.error(e); + alert(e); + } else { + // Jump back to the main queue page. + this.router.navigate(['/staff/cat/vandelay/queue']); + } + }, + err => { + this.progressDlg.close(); + } + ); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts index bd8fecc66a..aed9845883 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts @@ -9,6 +9,7 @@ import {QueueComponent} from './queue.component'; import {QueueListComponent} from './queue-list.component'; import {GridModule} from '@eg/share/grid/grid.module'; import {HttpClientModule} from '@angular/common/http'; +import {RecordBucketDialogComponent} from '@eg/staff/share/buckets/record-bucket-dialog.component'; @NgModule({ declarations: [ @@ -16,7 +17,8 @@ import {HttpClientModule} from '@angular/common/http'; ImportComponent, ExportComponent, QueueComponent, - QueueListComponent + QueueListComponent, + RecordBucketDialogComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html index f5e4c94652..4399111883 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html @@ -1,6 +1,7 @@