From: Bill Erickson Date: Wed, 1 Aug 2018 22:17:46 +0000 (-0400) Subject: LP#1775466 fm-editor and admin page org perm limits X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=acdc861e25068cb687aa907d533b03e1d812682f;p=working%2FEvergreen.git LP#1775466 fm-editor and admin page org perm limits Apply view org perm limits in the admin page org selector. Apply view/update/create org perm limits to org-selector's inside of fm-editor panes. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html index 800165e8cf..721423c05c 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html @@ -123,6 +123,7 @@ diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts index 8162775342..ebde00959f 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts @@ -45,6 +45,10 @@ export class FmRecordEditorComponent // TODO: allow this to be update in real time by the caller? record: IdlObject; + // Permissions extracted from the permacrud defs in the IDL + // for the current IDL class + modePerms: {[mode: string]: string}; + @Input() customFieldTemplates: {[fieldName: string]: CustomFieldTemplate} = {}; @@ -164,6 +168,13 @@ export class FmRecordEditorComponent }); } + const pc = this.idlDef.permacrud || {}; + this.modePerms = { + view: pc.retrieve ? pc.retrieve.perms : [], + create: pc.create ? pc.create.perms : [], + update: pc.update ? pc.update.perms : [], + }; + // create a new record from scratch this.pkeyIsEditable = !('pkey_sequence' in this.idlDef); this.record = this.idl.create(this.idlClass); diff --git a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts index bd63ed5b96..bc3bf85fe1 100644 --- a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts @@ -103,9 +103,7 @@ export class OrgSelectComponent implements OnInit { private store: StoreService, private org: OrgService, private perm: PermService - ) { - this.permLimitOrgs = []; - } + ) { } ngOnInit() { @@ -130,8 +128,14 @@ export class OrgSelectComponent implements OnInit { // applyPermLimitOrgs(perms: string[]) { - if (!perms || perms.length === 0) { - this.permLimitOrgs = []; + if (!perms) { + return; + } + + // handle lazy clients that pass null perm names + perms = perms.filter(p => p !== null && p !== undefined); + + if (perms.length === 0) { return; } @@ -181,7 +185,7 @@ export class OrgSelectComponent implements OnInit { this.hidden.filter(id => org.id() === id).length === 0 ); - if (this.permLimitOrgs && this.permLimitOrgs.length) { + if (this.permLimitOrgs) { // Avoid showing org units where the user does // not have the requested permission. orgs = orgs.filter(org => diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html index 600db00326..9435dc2a32 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html @@ -12,6 +12,7 @@ {{orgFieldLabel}} diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts index 2713c786d4..003a2daaff 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts @@ -64,6 +64,7 @@ export class AdminPageComponent implements OnInit { contextOrg: IdlObject; orgFieldLabel: string; + viewPerms: string; constructor( private idl: IdlService, @@ -101,6 +102,14 @@ export class AdminPageComponent implements OnInit { this.idlClassDef = this.idl.classes[this.idlClass]; this.pkeyField = this.idlClassDef.pkey || 'id'; this.persistKey = 'admin.' + this.idlClassDef.table; + + // Limit the view org selector to orgs where the user has + // permacrud-encoded view permissions. + const pc = this.idlClassDef.permacrud; + if (pc && pc.retrieve) { + this.viewPerms = pc.retrieve.perms; + } + this.applyOrgValues(); // If the caller provides not data source, create a generic one.