create selection list action
authorJason Etheridge <jason@EquinoxInitiative.org>
Fri, 8 Nov 2019 22:41:02 +0000 (17:41 -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-create-dialog.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-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 85515ba..6fa5ffe 100644 (file)
@@ -6,6 +6,7 @@ import {LineitemResultsComponent} from './lineitem-results.component';
 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';
 
 @NgModule({
   declarations: [
@@ -13,7 +14,8 @@ import {PicklistResultsComponent} from './picklist-results.component';
     LineitemResultsComponent,
     PurchaseOrderResultsComponent,
     InvoiceResultsComponent,
-    PicklistResultsComponent
+    PicklistResultsComponent,
+    PicklistCreateDialogComponent
   ],
   imports: [
     StaffCommonModule,
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.html
new file mode 100644 (file)
index 0000000..5a13089
--- /dev/null
@@ -0,0 +1,23 @@
+<ng-template #dialogContent>
+  <div class="modal-header bg-info">
+    <h3 class="modal-title" i18n>Create New Selection List</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>Selection list name:</h4>
+    <input type="text" id="create-picklist-name"
+      class="form-control col-lg-7" [(ngModel)]="selectionListName">
+  </div>
+  <div class="modal-footer">
+    <button type="button" class="btn btn-success"
+      (click)="createList()" i18n>Create</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 create this selection list.">
+</eg-alert-dialog>
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts
new file mode 100644 (file)
index 0000000..380b9fc
--- /dev/null
@@ -0,0 +1,48 @@
+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-create-dialog',
+  templateUrl: './picklist-create-dialog.component.html'
+})
+
+export class PicklistCreateDialogComponent
+  extends DialogComponent implements OnInit {
+
+  selectionListName: String;
+
+  constructor(
+    private idl: IdlService,
+    private net: NetService,
+    private auth: AuthService,
+    private modal: NgbModal
+  ) {
+    super(modal);
+  }
+
+  ngOnInit() {
+    this.selectionListName = '';
+  }
+
+  createList() {
+    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.create',
+      this.auth.token(), picklist
+    ).subscribe(
+      new_id => this.close(new_id),
+      err => throwError(err)
+    );
+  }
+}
+
+
index b512266..342312c 100644 (file)
@@ -1,3 +1,6 @@
+<eg-string #createSelectionListString i18n-text text="Selection List Created">
+</eg-string>
+
 <ng-template #nameTmpl let-selectionlist="row">
   <a href="/eg/acq/picklist/view/{{selectionlist.id()}}"
      target="_blank">
@@ -5,15 +8,32 @@
   </a>
 </ng-template>
 
+<eg-confirm-dialog #delConfirm
+  i18n-dialogTitle i18n-dialogBody
+  dialogTitle="Confirm Delete"
+  dialogBody="Delete Selection List {{selected ? selected.label : ''}}?">
+</eg-confirm-dialog>
+
+<eg-picklist-create-dialog #picklistCreateDialog>
+</eg-picklist-create-dialog>
+
 <eg-grid #acqSearchPicklistsGrid
   persistKey="acq.search.selectionlists"
   [stickyHeader]="true"
   idlClass="acqpl" [dataSource]="gridSource">
 
-  <eg-grid-toolbar-action label="New Selection List" i18n-label (onClick)="new_picklist" [disableOnRows]="createNotAppropriate"></eg-grid-toolbar-action>
-  <eg-grid-toolbar-action label="Clone Selected" i18n-label (onClick)="cloneSelected($event)" [disableOnRows]="cloneNotAppropriate"></eg-grid-toolbar-action>
-  <eg-grid-toolbar-action label="Merge Selected" i18n-label (onClick)="mergeSelected($event)" [disableOnRows]="mergeNotAppropriate"></eg-grid-toolbar-action>
-  <eg-grid-toolbar-action label="Delete Selected" i18n-label (onClick)="deleteSelected($event)" [disableOnRows]="deleteNotAppropriate"></eg-grid-toolbar-action>
+  <eg-grid-toolbar-action label="New Selection List" i18n-label
+    (onClick)="openCreateDialog()" [disableOnRows]="createNotAppropriate">
+  </eg-grid-toolbar-action>
+  <eg-grid-toolbar-action label="Clone Selected" i18n-label
+    (onClick)="cloneSelected($event)" [disableOnRows]="cloneNotAppropriate">
+  </eg-grid-toolbar-action>
+  <eg-grid-toolbar-action label="Merge Selected" i18n-label
+    (onClick)="mergeSelected($event)" [disableOnRows]="mergeNotAppropriate">
+  </eg-grid-toolbar-action>
+  <eg-grid-toolbar-action label="Delete Selected" i18n-label
+    (onClick)="deleteSelected($event)" [disableOnRows]="deleteNotAppropriate">
+  </eg-grid-toolbar-action>
 
   <eg-grid-column path="name" [cellTemplate]="nameTmpl"></eg-grid-column>
 </eg-grid>
index 215f4a3..009362f 100644 (file)
@@ -3,6 +3,8 @@ import {Observable} from 'rxjs';
 import {map} from 'rxjs/operators';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
 import {Pager} from '@eg/share/util/pager';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {StringComponent} from '@eg/share/string/string.component';
 import {IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
 import {AuthService} from '@eg/core/auth.service';
@@ -10,6 +12,7 @@ import {PermService} from '@eg/core/perm.service';
 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';
 
 @Component({
   selector: 'eg-picklist-results',
@@ -20,6 +23,8 @@ export class PicklistResultsComponent implements OnInit {
 
     gridSource: GridDataSource;
     @ViewChild('acqSearchPicklistsGrid', { static: true }) picklistResultsGrid: GridComponent;
+    @ViewChild('picklistCreateDialog', { static: true }) picklistCreateDialog: PicklistCreateDialogComponent;
+    @ViewChild('createSelectionListString', { static: true }) createSelectionListString: StringComponent;
 
     permissions: {[name: string]: boolean};
     noSelectedRows: (rows: IdlObject[]) => boolean;
@@ -31,6 +36,7 @@ export class PicklistResultsComponent implements OnInit {
     constructor(
         private router: Router,
         private route: ActivatedRoute,
+        private toast: ToastService,
         private net: NetService,
         private auth: AuthService,
         private acqSearch: AcqSearchService,
@@ -46,10 +52,19 @@ export class PicklistResultsComponent implements OnInit {
           then(perms => this.permissions = perms);
 
         this.noSelectedRows = (rows: IdlObject[]) => (rows.length === 0);
-        this.createNotAppropriate = function() { return !this.hasCreatePerm; }
+        this.createNotAppropriate = (rows: IdlObject[]) => (!this.permissions.CREATE_PICKLIST);
         this.cloneNotAppropriate = (rows: IdlObject[]) => (!this.permissions.CREATE_PICKLIST || this.noSelectedRows(rows));
         this.mergeNotAppropriate = (rows: IdlObject[]) => (!this.permissions.UPDATE_PICKLIST || this.noSelectedRows(rows));
         this.deleteNotAppropriate = (rows: IdlObject[]) => (!this.permissions.UPDATE_PICKLIST || this.noSelectedRows(rows));
     }
 
+    openCreateDialog() {
+        this.picklistCreateDialog.open().subscribe(
+            modified => {
+                this.createSelectionListString.current().then(msg => this.toast.success(msg));
+                this.picklistResultsGrid.reload(); // FIXME - spec calls for inserted grid row and not refresh
+            }
+        );
+    }
+
 }