From a50e864b221c3c00cc653bf5a9bd56a7a9e32dc1 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 8 Nov 2019 10:06:04 -0500 Subject: [PATCH] stub picklist actions with UI perm checks Signed-off-by: Jason Etheridge --- .../acq/search/picklist-results.component.html | 5 +++++ .../staff/acq/search/picklist-results.component.ts | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) 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 ddf5be5d03..b512266e51 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 @@ -10,5 +10,10 @@ [stickyHeader]="true" idlClass="acqpl" [dataSource]="gridSource"> + + + + + 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 092a668679..215f4a3ffe 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 @@ -6,6 +6,7 @@ import {Pager} from '@eg/share/util/pager'; import {IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; +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'; @@ -20,16 +21,35 @@ export class PicklistResultsComponent implements OnInit { gridSource: GridDataSource; @ViewChild('acqSearchPicklistsGrid', { static: true }) picklistResultsGrid: GridComponent; + permissions: {[name: string]: boolean}; + noSelectedRows: (rows: IdlObject[]) => boolean; + createNotAppropriate: (rows: IdlObject[]) => boolean; + cloneNotAppropriate: (rows: IdlObject[]) => boolean; + mergeNotAppropriate: (rows: IdlObject[]) => boolean; + deleteNotAppropriate: (rows: IdlObject[]) => boolean; + constructor( private router: Router, private route: ActivatedRoute, private net: NetService, private auth: AuthService, - private acqSearch: AcqSearchService) { + private acqSearch: AcqSearchService, + private perm: PermService + ) { + this.permissions = {}; } ngOnInit() { this.gridSource = this.acqSearch.getAcqSearchDataSource('picklist'); + + this.perm.hasWorkPermHere(['CREATE_PICKLIST','UPDATE_PICKLIST','VIEW_PICKLIST']). + then(perms => this.permissions = perms); + + this.noSelectedRows = (rows: IdlObject[]) => (rows.length === 0); + this.createNotAppropriate = function() { return !this.hasCreatePerm; } + 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)); } } -- 2.11.0