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: [
InvoiceResultsComponent,
PicklistResultsComponent,
PicklistCreateDialogComponent,
- PicklistCloneDialogComponent
+ PicklistCloneDialogComponent,
+ PicklistDeleteDialogComponent
],
imports: [
StaffCommonModule,
--- /dev/null
+<ng-template #dialogContent>
+ <div class="modal-header bg-info">
+ <h3 class="modal-title" i18n>Confirm Delete</h3>
+ <button type="button" class="close"
+ i18n-aria-label aria-label="Close" (click)="close()">
+ <span aria-hidden="true">×</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <h4 i18n>Delete the following selection lists?</h4>
+ <ul>
+ <li *ngFor="let listName of listNames">{{listName}}</li>
+ </ul>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-success"
+ (click)="deleteLists()" i18n>Delete</button>
+ <button type="button" class="btn btn-warning"
+ (click)="close()" i18n>Cancel</button>
+ </div>
+</ng-template>
+<eg-alert-dialog #fail i18n-dialogBody
+ dialogBody="Could not delete the selection list(s).">
+</eg-alert-dialog>
--- /dev/null
+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)
+ );
+ }
+}
+
+
</eg-string>
<eg-string #cloneSelectionListString i18n-text text="Selection List Cloned">
</eg-string>
+<eg-string #deleteSelectionListString i18n-text text="Selection List(s) Deleted">
+</eg-string>
<ng-template #nameTmpl let-selectionlist="row">
<a href="/eg/acq/picklist/view/{{selectionlist.id()}}"
<eg-picklist-clone-dialog #picklistCloneDialog [grid]="picklistResultsGrid">
</eg-picklist-clone-dialog>
+<eg-picklist-delete-dialog #picklistDeleteDialog [grid]="picklistResultsGrid">
+</eg-picklist-delete-dialog>
+
<eg-grid #acqSearchPicklistsGrid
persistKey="acq.search.selectionlists"
[stickyHeader]="true"
(onClick)="openMergeDialog($event)" [disableOnRows]="mergeNotAppropriate">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Delete Selected" i18n-label
- (onClick)="openDeleteConfirmation($event)" [disableOnRows]="deleteNotAppropriate">
+ (onClick)="openDeleteDialog($event)" [disableOnRows]="deleteNotAppropriate">
</eg-grid-toolbar-action>
<eg-grid-column path="name" [cellTemplate]="nameTmpl"></eg-grid-column>
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',
@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;
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
}
}