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();
'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;
});
}
+ 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;
});
}
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(
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 => {