From: Galen Charlton Date: Tue, 18 Aug 2020 18:03:18 +0000 (-0400) Subject: account for staff users who do not have the ADMIN_PROVIDER permission X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=990ae8c0044e4ffb548a6cbefd0c51f0a193220c;p=working%2FEvergreen.git account for staff users who do not have the ADMIN_PROVIDER permission TODO: make the Delete Provider and New Provider buttons be deactivated or not appear as relevant. Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider.component.html b/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider.component.html index a1167b4ebd..3453163f43 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider.component.html @@ -51,7 +51,7 @@ - +
@@ -62,7 +62,7 @@ - +
@@ -73,7 +73,7 @@ - +
@@ -84,7 +84,7 @@ - +
@@ -95,7 +95,7 @@ - +
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html index f548c5e143..189e57cb56 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html @@ -5,7 +5,7 @@ (); providerUpdated$ = this.providerUpdatedSource.asObservable(); + private permissions: any; + constructor( private idl: IdlService, private net: NetService, - private pcrud: PcrudService + private pcrud: PcrudService, + private perm: PermService ) { this.currentProvider = null; + this.loadPerms(); + } + + loadPerms() { + this.perm.hasWorkPermAt(['ADMIN_PROVIDER','MANAGE_PROVIDER'], true).then(permMap => { + this.permissions = permMap; + }); } getProviderRecord(id: number): Observable { @@ -77,6 +90,7 @@ export class ProviderRecordService { }); this.currentProvider = provider; this.checkIfCanDelete(provider); + this.checkIfCanManage(provider); return provider; })); } @@ -98,6 +112,13 @@ export class ProviderRecordService { }); } + checkIfCanManage(prov: ProviderRecord) { + if (Object.keys(this.permissions).length > 0 && + this.permissions['ADMIN_PROVIDER'].includes(prov.record.owner())) { + prov.canAdmin = true; + } + } + current(): IdlObject { return this.currentProvider ? this.currentProvider.record : null; } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.ts index 64d0f6a000..929c3891e2 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.ts @@ -146,7 +146,13 @@ export class AcqProviderSummaryPaneComponent implements OnInit, AfterViewInit { this.provider_holding_tag = provider.holding_tag(); this.provider_addresses = provider.addresses(); this.provider_san = provider.san(); - this.provider_edi_default = provider.edi_default() ? provider.edi_default().label() : ''; + if (typeof provider.edi_default() === 'object') { + this.provider_edi_default = provider.edi_default() ? provider.edi_default().label() : ''; + } else { + // not fleshed, presumably because user doesn't have + // permission to retrieve EDI accounts + this.provider_edi_default = ''; + } this.provider_active = provider.active(); this.provider_prepayment_required = provider.prepayment_required(); this.provider_url = provider.url();