From 48a6b1d297f160c87596982a97f268010fdc3846 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 11 Nov 2019 07:36:26 -0500 Subject: [PATCH] picklist delete dialog Signed-off-by: Jason Etheridge --- .../src/app/staff/acq/search/acq-search.module.ts | 4 +- .../search/picklist-delete-dialog.component.html | 24 +++++++++ .../acq/search/picklist-delete-dialog.component.ts | 59 ++++++++++++++++++++++ .../acq/search/picklist-results.component.html | 7 ++- .../staff/acq/search/picklist-results.component.ts | 15 +++++- 5 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts index 3eaee44e9d..7a76f6ee76 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts @@ -8,6 +8,7 @@ import {InvoiceResultsComponent} from './invoice-results.component'; import {PicklistResultsComponent} from './picklist-results.component'; import {PicklistCreateDialogComponent} from './picklist-create-dialog.component'; import {PicklistCloneDialogComponent} from './picklist-clone-dialog.component'; +import {PicklistDeleteDialogComponent} from './picklist-delete-dialog.component'; @NgModule({ declarations: [ @@ -17,7 +18,8 @@ import {PicklistCloneDialogComponent} from './picklist-clone-dialog.component'; InvoiceResultsComponent, PicklistResultsComponent, PicklistCreateDialogComponent, - PicklistCloneDialogComponent + PicklistCloneDialogComponent, + PicklistDeleteDialogComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.html new file mode 100644 index 0000000000..bd30a9d383 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.html @@ -0,0 +1,24 @@ + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts new file mode 100644 index 0000000000..cb6f658004 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts @@ -0,0 +1,59 @@ +import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; +import {Observable, forkJoin, from, empty, throwError} from 'rxjs'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; + +@Component({ + selector: 'eg-picklist-delete-dialog', + templateUrl: './picklist-delete-dialog.component.html' +}) + +export class PicklistDeleteDialogComponent + extends DialogComponent implements OnInit { + + @Input() grid: any; + listNames: string[]; + + constructor( + private idl: IdlService, + private net: NetService, + private auth: AuthService, + private modal: NgbModal + ) { + super(modal); + } + + ngOnInit() { + } + + update() { + this.listNames = this.grid.context.getSelectedRows().map( r => r.name() ); + } + + deleteList(list) { + return this.net.request( + 'open-ils.acq', + 'open-ils.acq.picklist.delete', + this.auth.token(), + list.id() + ); + } + + deleteLists() { + var that = this; + var observables = []; + this.grid.context.getSelectedRows().forEach(function(r) { + observables.push( that.deleteList(r) ); + }); + forkJoin(observables).subscribe( + results => this.close(results), + err => throwError(err) + ); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html index 12edb90171..d3690bee21 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html @@ -2,6 +2,8 @@ + + + + + + (onClick)="openDeleteDialog($event)" [disableOnRows]="deleteNotAppropriate"> diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts index e310af8c72..f2c4ff8d34 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts @@ -14,6 +14,7 @@ import {GridDataSource} from '@eg/share/grid/grid'; import {AcqSearchService} from './acq-search.service'; import {PicklistCreateDialogComponent} from './picklist-create-dialog.component'; import {PicklistCloneDialogComponent} from './picklist-clone-dialog.component'; +import {PicklistDeleteDialogComponent} from './picklist-delete-dialog.component'; @Component({ selector: 'eg-picklist-results', @@ -26,8 +27,10 @@ export class PicklistResultsComponent implements OnInit { @ViewChild('acqSearchPicklistsGrid', { static: true }) picklistResultsGrid: GridComponent; @ViewChild('picklistCreateDialog', { static: true }) picklistCreateDialog: PicklistCreateDialogComponent; @ViewChild('picklistCloneDialog', { static: true }) picklistCloneDialog: PicklistCloneDialogComponent; + @ViewChild('picklistDeleteDialog', { static: true }) picklistDeleteDialog: PicklistDeleteDialogComponent; @ViewChild('createSelectionListString', { static: true }) createSelectionListString: StringComponent; @ViewChild('cloneSelectionListString', { static: true }) cloneSelectionListString: StringComponent; + @ViewChild('deleteSelectionListString', { static: true }) deleteSelectionListString: StringComponent; permissions: {[name: string]: boolean}; noSelectedRows: (rows: IdlObject[]) => boolean; @@ -79,6 +82,16 @@ export class PicklistResultsComponent implements OnInit { this.picklistResultsGrid.reload(); // FIXME - spec calls for inserted grid row and not refresh } ); - this.picklistCloneDialog.update(); // set the dialog title + this.picklistCloneDialog.update(); // update the dialog UI with selections + } + + openDeleteDialog(rows: IdlObject[]) { + this.picklistDeleteDialog.open().subscribe( + modified => { + this.deleteSelectionListString.current().then(msg => this.toast.success(msg)); + this.picklistResultsGrid.reload(); // FIXME - spec calls for removed grid rows and not refresh + } + ); + this.picklistDeleteDialog.update(); // update the dialog UI with selections } } -- 2.11.0