From: Jason Etheridge Date: Wed, 2 Nov 2022 07:01:23 +0000 (-0400) Subject: perm scoped org selector X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5218aaa0d774ab025270e6c1dbf75d87498041b0;p=working%2FEvergreen.git perm scoped org selector for stat cat entries fm editor. keep the template for the "sticky" org Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html index 431f8efa82..465b381c97 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html @@ -2,7 +2,7 @@ i18n-bannerText> - diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts index 19a0f15d51..a63d2b1d3e 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts @@ -21,7 +21,7 @@ export class StatCatEntriesComponent implements OnInit { statCatId: number; // parent stat cat id statCatOrgId: number; // parent stat cat org id statCatOrg: IdlObject; // parent stat cat org Idl - hiddenOrgs: any[]; // List of invalid orgs for a new entry + limitPerms: any[]; // For use with the org template for the FM editor statCatType: 'Copy' | 'Patron'; // parent type defaultNewRecord: IdlObject; copyDataSource: GridDataSource = new GridDataSource(); @@ -86,6 +86,7 @@ export class StatCatEntriesComponent implements OnInit { 'UPDATE_PATRON_STAT_CAT_ENTRY'], true) .then(userPerms => { this.userPerms = userPerms; + console.debug('checkPerms', userPerms); if (this.statCatType === 'Copy') { this.userPerms.canEdit = this.userPerms.UPDATE_COPY_STAT_CAT_ENTRY.indexOf(this.statCatOrg) !== -1; @@ -104,17 +105,29 @@ export class StatCatEntriesComponent implements OnInit { }); } + setLimitPerms(mode) { + if (this.statCatType === 'Copy') { + if (mode === 'create') { + this.limitPerms = ['CREATE_COPY_STAT_CAT_ENTRY']; + } else { + this.limitPerms = ['UPDATE_COPY_STAT_CAT_ENTRY']; + } + } else { + if (mode === 'create') { + this.limitPerms = ['CREATE_PATRON_STAT_CAT_ENTRY']; + } else { + this.limitPerms = ['UPDATE_PATRON_STAT_CAT_ENTRY']; + } + } + console.debug('setLimitPerms',this.limitPerms); + } + getParentData = (searchIdl) => { return this.pcrud.search(searchIdl, {id: this.statCatId}, {} ).subscribe(rec => { this.statCatOrg = rec.owner(); this.statCatOrgId = rec.owner(); this.checkPerms(); - const allOrgIds = this.org.list().map(x => x.id()); - const statCatDescendantIds = this.org.descendants(rec.owner(), true); - this.hiddenOrgs = allOrgIds.filter(org => { - return !statCatDescendantIds.includes(org); - }); return rec; }); } @@ -160,6 +173,7 @@ export class StatCatEntriesComponent implements OnInit { this.defaultNewRecord.owner(this.statCatOrg); this.defaultNewRecord.stat_cat(this.statCatId); currentDialog.mode = 'create'; + this.setLimitPerms('create'); currentDialog.recordId = null; currentDialog.record = this.defaultNewRecord; currentDialog.open({size: 'lg'}).subscribe( @@ -189,6 +203,7 @@ export class StatCatEntriesComponent implements OnInit { const currentDialog = lookupResponse.currentDialog; const currentGrid = lookupResponse.currentGrid; currentDialog.mode = 'update'; + this.setLimitPerms('update'); currentDialog.recordId = idlThing[0].id(); currentDialog.open({size: 'lg'}).subscribe( id => {