From: Jason Etheridge Date: Fri, 8 Nov 2019 22:41:02 +0000 (-0500) Subject: create selection list action X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0347fd894493a41938ddd51a7d1a1e769a4931c8;p=working%2FEvergreen.git create selection list action Signed-off-by: Jason Etheridge --- 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 85515babe3..6fa5ffef4a 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 @@ -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 index 0000000000..5a130891b0 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.html @@ -0,0 +1,23 @@ + + + + + + + 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 index 0000000000..380b9fcb10 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts @@ -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) + ); + } +} + + 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 b512266e51..342312c61d 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,3 +1,6 @@ + + + @@ -5,15 +8,32 @@ + + + + + + - - - - + + + + + + + + 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 215f4a3ffe..009362fa7c 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 @@ -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 + } + ); + } + }