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: [
LineitemResultsComponent,
PurchaseOrderResultsComponent,
InvoiceResultsComponent,
- PicklistResultsComponent
+ PicklistResultsComponent,
+ PicklistCreateDialogComponent
],
imports: [
StaffCommonModule,
--- /dev/null
+<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">×</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>
--- /dev/null
+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)
+ );
+ }
+}
+
+
+<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">
</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>
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';
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',
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;
constructor(
private router: Router,
private route: ActivatedRoute,
+ private toast: ToastService,
private net: NetService,
private auth: AuthService,
private acqSearch: AcqSearchService,
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
+ }
+ );
+ }
+
}