From 4f0d5806652c4c2163da2f8a4b908649ec493e40 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Sun, 10 Nov 2019 20:48:22 -0500 Subject: [PATCH] picklist clone dialog Signed-off-by: Jason Etheridge --- .../src/app/staff/acq/search/acq-search.module.ts | 4 +- .../search/picklist-clone-dialog.component.html | 23 +++++++++ .../acq/search/picklist-clone-dialog.component.ts | 56 ++++++++++++++++++++++ .../acq/search/picklist-results.component.html | 11 +++-- .../staff/acq/search/picklist-results.component.ts | 16 ++++++- 5 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-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 6fa5ffef4a..3eaee44e9d 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 @@ -7,6 +7,7 @@ import {PurchaseOrderResultsComponent} from './purchase-order-results.component' 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'; @NgModule({ declarations: [ @@ -15,7 +16,8 @@ import {PicklistCreateDialogComponent} from './picklist-create-dialog.component' PurchaseOrderResultsComponent, InvoiceResultsComponent, PicklistResultsComponent, - PicklistCreateDialogComponent + PicklistCreateDialogComponent, + PicklistCloneDialogComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.html new file mode 100644 index 0000000000..460e0c0061 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.html @@ -0,0 +1,23 @@ + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts new file mode 100644 index 0000000000..dd9317a735 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts @@ -0,0 +1,56 @@ +import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; +import {Observable, 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-clone-dialog', + templateUrl: './picklist-clone-dialog.component.html' +}) + +export class PicklistCloneDialogComponent + extends DialogComponent implements OnInit { + + @Input() grid: any; + selectionListName: String; + leadListName: String; + selections: IdlObject[]; + + constructor( + private idl: IdlService, + private net: NetService, + private auth: AuthService, + private modal: NgbModal + ) { + super(modal); + } + + ngOnInit() { + } + + update() { + this.leadListName = this.grid.context.getSelectedRows()[0].name(); + } + + cloneList() { + const picklist = this.idl.create('acqpl'); + picklist.owner(this.auth.user().id()) + picklist.name(this.selectionListName) + this.net.request( + 'open-ils.acq', + 'open-ils.acq.picklist.clone', + this.auth.token(), + this.grid.context.getSelectedRows()[0].id(), + this.selectionListName + ).subscribe( + new_id => this.close(new_id), + 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 342312c61d..12edb90171 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 @@ -1,5 +1,7 @@ + + + + + + (onClick)="openCloneDialog($event)" [disableOnRows]="cloneNotAppropriate"> + (onClick)="openMergeDialog($event)" [disableOnRows]="mergeNotAppropriate"> + (onClick)="openDeleteConfirmation($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 009362fa7c..e310af8c72 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 @@ -13,6 +13,7 @@ import {GridComponent} from '@eg/share/grid/grid.component'; 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'; @Component({ selector: 'eg-picklist-results', @@ -24,10 +25,13 @@ export class PicklistResultsComponent implements OnInit { gridSource: GridDataSource; @ViewChild('acqSearchPicklistsGrid', { static: true }) picklistResultsGrid: GridComponent; @ViewChild('picklistCreateDialog', { static: true }) picklistCreateDialog: PicklistCreateDialogComponent; + @ViewChild('picklistCloneDialog', { static: true }) picklistCloneDialog: PicklistCloneDialogComponent; @ViewChild('createSelectionListString', { static: true }) createSelectionListString: StringComponent; + @ViewChild('cloneSelectionListString', { static: true }) cloneSelectionListString: StringComponent; permissions: {[name: string]: boolean}; noSelectedRows: (rows: IdlObject[]) => boolean; + oneSelectedRows: (rows: IdlObject[]) => boolean; createNotAppropriate: (rows: IdlObject[]) => boolean; cloneNotAppropriate: (rows: IdlObject[]) => boolean; mergeNotAppropriate: (rows: IdlObject[]) => boolean; @@ -52,8 +56,9 @@ export class PicklistResultsComponent implements OnInit { then(perms => this.permissions = perms); this.noSelectedRows = (rows: IdlObject[]) => (rows.length === 0); + this.oneSelectedRows = (rows: IdlObject[]) => (rows.length === 1); this.createNotAppropriate = (rows: IdlObject[]) => (!this.permissions.CREATE_PICKLIST); - this.cloneNotAppropriate = (rows: IdlObject[]) => (!this.permissions.CREATE_PICKLIST || this.noSelectedRows(rows)); + this.cloneNotAppropriate = (rows: IdlObject[]) => (!this.permissions.CREATE_PICKLIST || !this.oneSelectedRows(rows)); this.mergeNotAppropriate = (rows: IdlObject[]) => (!this.permissions.UPDATE_PICKLIST || this.noSelectedRows(rows)); this.deleteNotAppropriate = (rows: IdlObject[]) => (!this.permissions.UPDATE_PICKLIST || this.noSelectedRows(rows)); } @@ -67,4 +72,13 @@ export class PicklistResultsComponent implements OnInit { ); } + openCloneDialog(rows: IdlObject[]) { + this.picklistCloneDialog.open().subscribe( + modified => { + this.cloneSelectionListString.current().then(msg => this.toast.success(msg)); + this.picklistResultsGrid.reload(); // FIXME - spec calls for inserted grid row and not refresh + } + ); + this.picklistCloneDialog.update(); // set the dialog title + } } -- 2.11.0