picklist delete dialog
authorJason Etheridge <jason@EquinoxInitiative.org>
Mon, 11 Nov 2019 12:36:26 +0000 (07:36 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 16 Jan 2020 21:38:28 +0000 (16:38 -0500)
Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts
Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html
Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts

index 3eaee44..7a76f6e 100644 (file)
@@ -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 (file)
index 0000000..bd30a9d
--- /dev/null
@@ -0,0 +1,24 @@
+<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">&times;</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>
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 (file)
index 0000000..cb6f658
--- /dev/null
@@ -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)
+    );
+  }
+}
+
+
index 12edb90..d3690be 100644 (file)
@@ -2,6 +2,8 @@
 </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()}}"
@@ -22,6 +24,9 @@
 <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"
@@ -37,7 +42,7 @@
     (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>
index e310af8..f2c4ff8 100644 (file)
@@ -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
     }
 }