@memberjunction/ng-resource-permissions 5.4.1 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/available-resources.component.d.ts.map +1 -1
- package/dist/lib/available-resources.component.js +5 -4
- package/dist/lib/available-resources.component.js.map +1 -1
- package/dist/lib/resource-permissions.component.d.ts.map +1 -1
- package/dist/lib/resource-permissions.component.js +4 -3
- package/dist/lib/resource-permissions.component.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"available-resources.component.d.ts","sourceRoot":"","sources":["../../src/lib/available-resources.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,YAAY,EAA4B,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,eAAe,EAAW,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAA4B,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"available-resources.component.d.ts","sourceRoot":"","sources":["../../src/lib/available-resources.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,YAAY,EAA4B,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,eAAe,EAAW,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAA4B,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAErG,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;;AAE7D;;GAEG;AACH,qBAMa,2BAA6B,SAAQ,oBAAqB,YAAW,aAAa;IAClF,IAAI,EAAG,QAAQ,CAAC;IAChB,cAAc,EAAG,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,QAAQ,GAAG,UAAU,CAAY;IAEzD;;OAEG;IACM,YAAY,EAAE,MAAM,CAAM;IAE1B,iBAAiB,EAAE,YAAY,EAAE,CAAM;IACtC,gBAAgB,+BAAsC;IAEzD,mBAAmB,EAAE,MAAM,EAAE,CAAM;IACnC,gBAAgB,EAAE,eAAe,EAAE,CAAM;IAEpB,aAAa,EAAG,aAAa,CAAC;IACnD,iBAAiB,CAAC,CAAC,EAAE,cAAc;IAcnC,mBAAmB,EAAE,0BAA0B,EAAE,CAAM;IACvD,SAAS,EAAE,YAAY,EAAE,CAAM;IAChC,eAAe;IAIrB;;OAEG;IACU,OAAO;yCAzCX,2BAA2B;2CAA3B,2BAA2B;CA8FvC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
|
2
2
|
import { RunView } from '@memberjunction/core';
|
|
3
3
|
import { ResourcePermissionEngine } from '@memberjunction/core-entities';
|
|
4
|
+
import { UUIDsEqual } from '@memberjunction/global';
|
|
4
5
|
import { ResourceData } from '@memberjunction/core-entities';
|
|
5
6
|
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
|
|
6
7
|
import * as i0 from "@angular/core";
|
|
@@ -59,7 +60,7 @@ export class AvailableResourcesComponent extends BaseAngularComponent {
|
|
|
59
60
|
onSelectionChange(e) {
|
|
60
61
|
this.SelectedResources.splice(0, this.SelectedResources.length); // empty the array
|
|
61
62
|
this.gridRecordSelection.forEach((item) => {
|
|
62
|
-
const resourceMatch = this.resources.find((r) => r.ResourceRecordID
|
|
63
|
+
const resourceMatch = this.resources.find((r) => UUIDsEqual(r.ResourceRecordID, item));
|
|
63
64
|
if (resourceMatch) {
|
|
64
65
|
this.SelectedResources.push(resourceMatch);
|
|
65
66
|
}
|
|
@@ -85,11 +86,11 @@ export class AvailableResourcesComponent extends BaseAngularComponent {
|
|
|
85
86
|
this.resources = [];
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
88
|
-
const rt = ResourcePermissionEngine.Instance.ResourceTypes.find(rt => rt.ID
|
|
89
|
+
const rt = ResourcePermissionEngine.Instance.ResourceTypes.find(rt => UUIDsEqual(rt.ID, this.ResourceTypeID));
|
|
89
90
|
if (!rt || !rt.EntityID)
|
|
90
91
|
throw new Error(`Resource Type ${this.ResourceTypeID} not found`);
|
|
91
92
|
const p = this.ProviderToUse;
|
|
92
|
-
const entity = p.Entities.find(e => e.ID
|
|
93
|
+
const entity = p.Entities.find(e => UUIDsEqual(e.ID, rt.EntityID));
|
|
93
94
|
if (!entity || !entity.NameField)
|
|
94
95
|
throw new Error(`Entity ${rt.EntityID} not found, or no Name field defined`);
|
|
95
96
|
const rv = new RunView(this.RunViewToUse);
|
|
@@ -160,5 +161,5 @@ export class AvailableResourcesComponent extends BaseAngularComponent {
|
|
|
160
161
|
type: ViewChild,
|
|
161
162
|
args: ['resourcesGrid']
|
|
162
163
|
}] }); })();
|
|
163
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AvailableResourcesComponent, { className: "AvailableResourcesComponent", filePath: "src/lib/available-resources.component.ts", lineNumber:
|
|
164
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AvailableResourcesComponent, { className: "AvailableResourcesComponent", filePath: "src/lib/available-resources.component.ts", lineNumber: 19 }); })();
|
|
164
165
|
//# sourceMappingURL=available-resources.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"available-resources.component.js","sourceRoot":"","sources":["../../src/lib/available-resources.component.ts","../../src/lib/available-resources.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAmB,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,wBAAwB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AAE,SAAS,CAAC,IAAI;aAC1B,CAAC,CAAA;YACF,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO;gBAC1B,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YAEpE,4DAA4D;YAC5D,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACtC,OAAO,IAAI,YAAY,CAAC;oBACpB,gBAAgB,EAAE,CAAC,CAAC,EAAE;oBACtB,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC;oBACvB,cAAc,EAAE,IAAI,CAAC,cAAc;oBACnC,YAAY,EAAE,EAAE,CAAC,IAAI;oBACrB,aAAa,EAAE,CAAC,CAAC,mFAAmF;iBACvG,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;yRA7FQ,2BAA2B,yBAA3B,2BAA2B;6DAA3B,2BAA2B;;;;;;YCjBxC,8BAAuB;YACnB,oGAAY;YAsBd,iBAAM;;YAtBJ,cAqBC;YArBD,mCAqBC;;;iFDLQ,2BAA2B;cANvC,SAAS;6BACI,KAAK,YACP,wBAAwB;;kBAK/B,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBAKL,KAAK;;kBAEL,KAAK;;kBACL,MAAM;;kBAKN,SAAS;mBAAC,eAAe;;kFAjBjB,2BAA2B","sourcesContent":["import { AfterViewInit, Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';\nimport { EntityFieldInfo, RunView, UserInfo } from '@memberjunction/core';\nimport { ResourcePermissionEngine, MJResourcePermissionEntity } from '@memberjunction/core-entities';\nimport { ResourceData } from '@memberjunction/core-entities';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { SelectionEvent } from '@progress/kendo-angular-grid';\nimport { GridComponent } from '@progress/kendo-angular-grid';\n\n/**\n * This component displays a list of available resources for a user for a specific Resource Type.\n */\n@Component({\n standalone: false,\n selector: 'mj-available-resources',\n templateUrl: './available-resources.component.html',\n styleUrls: ['./available-resources.component.css']\n})\nexport class AvailableResourcesComponent extends BaseAngularComponent implements AfterViewInit {\n @Input() User!: UserInfo;\n @Input() ResourceTypeID!: string;\n @Input() ResourceExtraFilter?: string;\n @Input() SelectionMode: 'Single' | 'Multiple' = 'Single';\n\n /**\n * Optional, comma-delimited list of field names to provide extra columns here to display in the grid. These columns will be displayed after the Name of the resource\n */\n @Input() ExtraColumns: string = \"\";\n\n @Input() SelectedResources: ResourceData[] = [];\n @Output() SelectionChanged = new EventEmitter<ResourceData[]>();\n\n public gridRecordSelection: string[] = [];\n public gridExtraColumns: EntityFieldInfo[] = [];\n\n @ViewChild('resourcesGrid') resourcesGrid!: GridComponent;\n public onSelectionChange(e: SelectionEvent) {\n this.SelectedResources.splice(0, this.SelectedResources.length); // empty the array\n\n this.gridRecordSelection.forEach((item) => {\n const resourceMatch = this.resources.find((r) => r.ResourceRecordID === item);\n if (resourceMatch) {\n this.SelectedResources.push(resourceMatch);\n }\n });\n\n // now bubble up the event\n this.SelectionChanged.emit(this.SelectedResources);\n }\n\n public resourcePermissions: MJResourcePermissionEntity[] = [];\n public resources: ResourceData[] = [];\n async ngAfterViewInit() {\n await this.Refresh();\n }\n\n /**\n * This method will refresh the contents of the component based on the current state of the component. \n */\n public async Refresh() {\n if (!this.User) {\n throw new Error('User is a required property for the AvailableResourcesDialogComponent');\n }\n\n // now we can get the permissions for the specified resource\n this.resourcePermissions = ResourcePermissionEngine.Instance.GetUserAvailableResources(this.User, this.ResourceTypeID);\n if (this.resourcePermissions.length === 0) {\n this.resources = [];\n }\n else {\n const rt = ResourcePermissionEngine.Instance.ResourceTypes.find(rt => rt.ID === this.ResourceTypeID); \n if (!rt || !rt.EntityID)\n throw new Error(`Resource Type ${this.ResourceTypeID} not found`);\n\n const p = this.ProviderToUse;\n const entity = p.Entities.find(e => e.ID === rt.EntityID);\n if (!entity || !entity.NameField)\n throw new Error(`Entity ${rt.EntityID} not found, or no Name field defined`);\n const rv = new RunView(this.RunViewToUse);\n const nameField = entity.NameField;\n if (this.ExtraColumns && this.ExtraColumns.length > 0) {\n /// split the comma delim string and for each item find it in the EntityFields collection\n const extraColumns = this.ExtraColumns.split(',');\n this.gridExtraColumns = [];\n extraColumns.forEach((ec) => {\n const field = entity.Fields.find((f) => f.Name.trim().toLowerCase() === ec.trim().toLowerCase());\n if (field) \n this.gridExtraColumns.push(field);\n });\n }\n\n const extraFilter = this.ResourceExtraFilter ? ` AND (${this.ResourceExtraFilter})` : '';\n const result = await rv.RunView({\n EntityName: entity.Name,\n ExtraFilter: `(ID in (${this.resourcePermissions.map((r) => `'${r.ResourceRecordID}'`).join(',')})${extraFilter})`,\n OrderBy: nameField.Name\n })\n if (!result || !result.Success)\n throw new Error(`Error running view for entity ${entity.Name}`);\n\n // only return rows where we have a record in result.Results\n this.resources = result.Results.map((r) => {\n return new ResourceData({\n ResourceRecordID: r.ID,\n Name: r[nameField.Name],\n ResourceTypeID: this.ResourceTypeID,\n ResourceType: rt.Name,\n Configuration: r // pass the whole resource record into configuration so it is accessible as desired\n });\n });\n }\n }\n}\n","<div class=\"container\">\n @if (User) {\n <kendo-grid\n #resourcesGrid\n [data]=\"resources\"\n [selectable]=\"{ mode: SelectionMode.toLowerCase() === 'Single' ? 'single' : 'multiple' }\"\n (selectionChange)=\"onSelectionChange($event)\"\n style=\"width: 100%; max-height: 400px;\"\n kendoGridSelectBy=\"ResourceRecordID\"\n [(selectedKeys)]=\"gridRecordSelection\"\n >\n <kendo-grid-column field=\"Name\" title=\"Name\" [width]=\"225\">\n </kendo-grid-column>\n\n @for (col of gridExtraColumns; track col) {\n <kendo-grid-column [title]=\"col.DisplayNameOrName\">\n <ng-template kendoGridCellTemplate let-dataItem>\n {{ dataItem.Configuration[col.Name] }} \n </ng-template>\n </kendo-grid-column>\n }\n </kendo-grid> \n }\n </div>\n "]}
|
|
1
|
+
{"version":3,"file":"available-resources.component.js","sourceRoot":"","sources":["../../src/lib/available-resources.component.ts","../../src/lib/available-resources.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAmB,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAA8B,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;;;;;;ICY7C,YACJ;;;;IADI,uEACJ;;;IAHJ,4CAAmD;IAC/C,gHAAgD;IAGpD,iBAAoB;;;IAJD,gDAA+B;;;;IAb1D,wCAQG;IAJC,6NAAmB,gCAAyB,KAAC;IAG7C,wVAAsC;IAEtC,uCACoB;IAEpB,4IAMC;IACL,iBAAa;;;IAhBT,AADA,uCAAkB,mHACuE;IAIzF,+DAAsC;IAEO,eAAa;IAAb,2BAAa;IAG1D,cAMC;IAND,sCAMC;;ADXb;;GAEG;AAOH,MAAM,OAAO,2BAA6B,SAAQ,oBAAoB;IACzD,IAAI,CAAY;IAChB,cAAc,CAAU;IACxB,mBAAmB,CAAU;IAC7B,aAAa,GAA0B,QAAQ,CAAC;IAEzD;;OAEG;IACM,YAAY,GAAW,EAAE,CAAC;IAE1B,iBAAiB,GAAmB,EAAE,CAAC;IACtC,gBAAgB,GAAG,IAAI,YAAY,EAAkB,CAAC;IAEzD,mBAAmB,GAAa,EAAE,CAAC;IACnC,gBAAgB,GAAsB,EAAE,CAAC;IAEpB,aAAa,CAAiB;IACnD,iBAAiB,CAAC,CAAiB;QACtC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC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L,MAAM;;kBAKN,SAAS;mBAAC,eAAe;;kFAjBjB,2BAA2B","sourcesContent":["import { AfterViewInit, Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';\nimport { EntityFieldInfo, RunView, UserInfo } from '@memberjunction/core';\nimport { ResourcePermissionEngine, MJResourcePermissionEntity } from '@memberjunction/core-entities';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { ResourceData } from '@memberjunction/core-entities';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { SelectionEvent } from '@progress/kendo-angular-grid';\nimport { GridComponent } from '@progress/kendo-angular-grid';\n\n/**\n * This component displays a list of available resources for a user for a specific Resource Type.\n */\n@Component({\n standalone: false,\n selector: 'mj-available-resources',\n templateUrl: './available-resources.component.html',\n styleUrls: ['./available-resources.component.css']\n})\nexport class AvailableResourcesComponent extends BaseAngularComponent implements AfterViewInit {\n @Input() User!: UserInfo;\n @Input() ResourceTypeID!: string;\n @Input() ResourceExtraFilter?: string;\n @Input() SelectionMode: 'Single' | 'Multiple' = 'Single';\n\n /**\n * Optional, comma-delimited list of field names to provide extra columns here to display in the grid. These columns will be displayed after the Name of the resource\n */\n @Input() ExtraColumns: string = \"\";\n\n @Input() SelectedResources: ResourceData[] = [];\n @Output() SelectionChanged = new EventEmitter<ResourceData[]>();\n\n public gridRecordSelection: string[] = [];\n public gridExtraColumns: EntityFieldInfo[] = [];\n\n @ViewChild('resourcesGrid') resourcesGrid!: GridComponent;\n public onSelectionChange(e: SelectionEvent) {\n this.SelectedResources.splice(0, this.SelectedResources.length); // empty the array\n\n this.gridRecordSelection.forEach((item) => {\n const resourceMatch = this.resources.find((r) => UUIDsEqual(r.ResourceRecordID, item));\n if (resourceMatch) {\n this.SelectedResources.push(resourceMatch);\n }\n });\n\n // now bubble up the event\n this.SelectionChanged.emit(this.SelectedResources);\n }\n\n public resourcePermissions: MJResourcePermissionEntity[] = [];\n public resources: ResourceData[] = [];\n async ngAfterViewInit() {\n await this.Refresh();\n }\n\n /**\n * This method will refresh the contents of the component based on the current state of the component. \n */\n public async Refresh() {\n if (!this.User) {\n throw new Error('User is a required property for the AvailableResourcesDialogComponent');\n }\n\n // now we can get the permissions for the specified resource\n this.resourcePermissions = ResourcePermissionEngine.Instance.GetUserAvailableResources(this.User, this.ResourceTypeID);\n if (this.resourcePermissions.length === 0) {\n this.resources = [];\n }\n else {\n const rt = ResourcePermissionEngine.Instance.ResourceTypes.find(rt => UUIDsEqual(rt.ID, this.ResourceTypeID));\n if (!rt || !rt.EntityID)\n throw new Error(`Resource Type ${this.ResourceTypeID} not found`);\n\n const p = this.ProviderToUse;\n const entity = p.Entities.find(e => UUIDsEqual(e.ID, rt.EntityID));\n if (!entity || !entity.NameField)\n throw new Error(`Entity ${rt.EntityID} not found, or no Name field defined`);\n const rv = new RunView(this.RunViewToUse);\n const nameField = entity.NameField;\n if (this.ExtraColumns && this.ExtraColumns.length > 0) {\n /// split the comma delim string and for each item find it in the EntityFields collection\n const extraColumns = this.ExtraColumns.split(',');\n this.gridExtraColumns = [];\n extraColumns.forEach((ec) => {\n const field = entity.Fields.find((f) => f.Name.trim().toLowerCase() === ec.trim().toLowerCase());\n if (field) \n this.gridExtraColumns.push(field);\n });\n }\n\n const extraFilter = this.ResourceExtraFilter ? ` AND (${this.ResourceExtraFilter})` : '';\n const result = await rv.RunView({\n EntityName: entity.Name,\n ExtraFilter: `(ID in (${this.resourcePermissions.map((r) => `'${r.ResourceRecordID}'`).join(',')})${extraFilter})`,\n OrderBy: nameField.Name\n })\n if (!result || !result.Success)\n throw new Error(`Error running view for entity ${entity.Name}`);\n\n // only return rows where we have a record in result.Results\n this.resources = result.Results.map((r) => {\n return new ResourceData({\n ResourceRecordID: r.ID,\n Name: r[nameField.Name],\n ResourceTypeID: this.ResourceTypeID,\n ResourceType: rt.Name,\n Configuration: r // pass the whole resource record into configuration so it is accessible as desired\n });\n });\n }\n }\n}\n","<div class=\"container\">\n @if (User) {\n <kendo-grid\n #resourcesGrid\n [data]=\"resources\"\n [selectable]=\"{ mode: SelectionMode.toLowerCase() === 'Single' ? 'single' : 'multiple' }\"\n (selectionChange)=\"onSelectionChange($event)\"\n style=\"width: 100%; max-height: 400px;\"\n kendoGridSelectBy=\"ResourceRecordID\"\n [(selectedKeys)]=\"gridRecordSelection\"\n >\n <kendo-grid-column field=\"Name\" title=\"Name\" [width]=\"225\">\n </kendo-grid-column>\n\n @for (col of gridExtraColumns; track col) {\n <kendo-grid-column [title]=\"col.DisplayNameOrName\">\n <ng-template kendoGridCellTemplate let-dataItem>\n {{ dataItem.Configuration[col.Name] }} \n </ng-template>\n </kendo-grid-column>\n }\n </kendo-grid> \n }\n </div>\n "]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-permissions.component.d.ts","sourceRoot":"","sources":["../../src/lib/resource-permissions.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,eAAe,CAAC;AAChE,OAAO,EAA2D,QAAQ,EAAW,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-permissions.component.d.ts","sourceRoot":"","sources":["../../src/lib/resource-permissions.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,eAAe,CAAC;AAChE,OAAO,EAA2D,QAAQ,EAAW,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEnH,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;;AAGrE;;;GAGG;AACH,qBAMa,4BAA6B,SAAQ,oBAAqB,YAAW,aAAa;IAC7F;;OAEG;IACM,cAAc,EAAG,MAAM,CAAC;IACjC;;OAEG;IACM,gBAAgB,EAAG,MAAM,CAAC;IACnC;;;;OAIG;IACM,cAAc,EAAE,OAAO,CAAS;IACzC;;;OAGG;IACM,oBAAoB,EAAE,OAAO,CAAQ;IAC9C;;;OAGG;IACM,qBAAqB,EAAE,OAAO,CAAS;IAChD;;OAEG;IACM,mBAAmB,EAAE,OAAO,CAAQ;IAC7C;;OAEG;IACM,oBAAoB,EAAE,OAAO,CAAQ;IAC9C;;OAEG;IACM,sBAAsB,EAAE,OAAO,CAAQ;IAEhD;;OAEG;IACM,gBAAgB,WAA6B;IAEtD;;OAEG;IACM,eAAe,WAAoB;IAE5C;;;OAGG;IACM,iBAAiB,EAAE,MAAM,EAAE,CAAM;IAE1C;;;OAGG;IACM,kBAAkB,EAAE,MAAM,EAAE,CAAM;IAEpC,QAAQ,EAAE,YAAY,EAAE,CAAM;IAC9B,QAAQ,EAAE,QAAQ,EAAE,CAAM;IAE1B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAQ;IACzC,YAAY,EAAE,QAAQ,GAAG,IAAI,CAAQ;IACrC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAU;IACvC,uBAAuB,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAU;IAE5D,QAAQ,EAAE,OAAO,CAAS;IAEpB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM;IAQrD,mBAAmB,EAAE,0BAA0B,EAAE,CAAM;IACxD,eAAe;IAkCrB,OAAO,CAAC,eAAe,CAAoC;IACpD,gBAAgB,CAAC,UAAU,EAAE,0BAA0B;IAK9D,OAAO,CAAC,YAAY,CAAoC;IAC3C,aAAa;IAuBnB,uBAAuB,IAAI,OAAO;IAkB5B,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAwEhD,SAAS,CAAC,SAAS,IAAI,wBAAwB;yCAzOpC,4BAA4B;2CAA5B,4BAA4B;CA4OxC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component, Input } from '@angular/core';
|
|
2
2
|
import { LogError, RunView } from '@memberjunction/core';
|
|
3
3
|
import { ResourcePermissionEngine } from '@memberjunction/core-entities';
|
|
4
|
+
import { UUIDsEqual } from '@memberjunction/global';
|
|
4
5
|
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
|
|
5
6
|
import { MJNotificationService } from '@memberjunction/ng-notifications';
|
|
6
7
|
import * as i0 from "@angular/core";
|
|
@@ -283,10 +284,10 @@ export class ResourcePermissionsComponent extends BaseAngularComponent {
|
|
|
283
284
|
// in our list of permissions
|
|
284
285
|
for (const permission of this.resourcePermissions) {
|
|
285
286
|
if (permission.Type === this.SelectedType) {
|
|
286
|
-
if (this.SelectedType === 'User' && permission.UserID
|
|
287
|
+
if (this.SelectedType === 'User' && UUIDsEqual(permission.UserID, this.SelectedUser?.ID)) {
|
|
287
288
|
return true;
|
|
288
289
|
}
|
|
289
|
-
else if (this.SelectedType === 'Role' && permission.RoleID
|
|
290
|
+
else if (this.SelectedType === 'Role' && UUIDsEqual(permission.RoleID, this.SelectedRole?.ID)) {
|
|
290
291
|
return true;
|
|
291
292
|
}
|
|
292
293
|
}
|
|
@@ -423,5 +424,5 @@ export class ResourcePermissionsComponent extends BaseAngularComponent {
|
|
|
423
424
|
}], ExcludedUserEmails: [{
|
|
424
425
|
type: Input
|
|
425
426
|
}] }); })();
|
|
426
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ResourcePermissionsComponent, { className: "ResourcePermissionsComponent", filePath: "src/lib/resource-permissions.component.ts", lineNumber:
|
|
427
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ResourcePermissionsComponent, { className: "ResourcePermissionsComponent", filePath: "src/lib/resource-permissions.component.ts", lineNumber: 18 }); })();
|
|
427
428
|
//# sourceMappingURL=resource-permissions.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-permissions.component.js","sourceRoot":"","sources":["../../src/lib/resource-permissions.component.ts","../../src/lib/resource-permissions.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAA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AQ,GAAG,KAAK,CAAC;YACtB,IAAI,IAAI,CAAC,qBAAqB;gBAC5B,qBAAqB,CAAC,QAAQ,CAAC,wBAAwB,CAAC,0BAA0B,EAAE,OAAO,CAAG,CAAC;YAEjG,QAAQ,CAAC,mDAAmD,CAAC,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAES,SAAS;QACjB,OAAiC,wBAAwB,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,EAAE,wBAAwB,CAAC,CAAC;IAC9H,CAAC;6RA3OU,4BAA4B,yBAA5B,4BAA4B;6DAA5B,4BAA4B;YChBzC,8BAAuB;YACrB,qGAAe;YAGf,iGAAqB;YAGrB,8BAA6B;YAC3B,+FAA0B;YA0CpB,AADF,AADF,AADF,gCAA8B,YACrB,SACD,SACE;YAAA,oBAAI;YAAA,iBAAK;YACb,2BAAI;YAAA,qBAAI;YAAA,iBAAK;YACb,4FAA4B;YAG5B,4FAA6B;YAIjC,AADE,iBAAK,EACC;YACR,8BAAO;YACL,qHAwBC;YAIT,AADE,AADE,AADE,iBAAQ,EACF,EACJ,EACF;;YAxFJ,cAEC;YAFD,uCAEC;YACD,cAEC;YAFD,6CAEC;YAEC,eAsCC;YAtCD,kDAsCC;YAMK,eAEC;YAFD,oDAEC;YACD,cAEC;YAFD,sDAEC;YAIH,eAwBC;YAxBD,sCAwBC;;;iFDrEI,4BAA4B;cANxC,SAAS;6BACI,KAAK,YACP,yBAAyB;;kBAQlC,KAAK;;kBAIL,KAAK;;kBAML,KAAK;;kBAKL,KAAK;;kBAKL,KAAK;;kBAIL,KAAK;;kBAIL,KAAK;;kBAIL,KAAK;;kBAKL,KAAK;;kBAKL,KAAK;;kBAML,KAAK;;kBAML,KAAK;;kFA1DK,4BAA4B","sourcesContent":["import { AfterViewInit, Component, Input } from '@angular/core';\nimport { IMetadataProvider, IRunViewProvider, LogError, Metadata, RoleInfo, RunView } from '@memberjunction/core';\nimport { ResourcePermissionEngine, MJResourcePermissionEntity, MJUserEntity } from '@memberjunction/core-entities';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { MJNotificationService } from '@memberjunction/ng-notifications';\n\n/**\n * Visual component used to display and manage permissions for a resource. You can wrap this in a dialog or display anywhere else within\n * an Angular application or component.\n */\n@Component({\n standalone: false,\n selector: 'mj-resource-permissions',\n templateUrl: './resource-permissions.component.html',\n styleUrls: ['./resource-permissions.component.css']\n})\nexport class ResourcePermissionsComponent extends BaseAngularComponent implements AfterViewInit {\n /**\n * Required: the ID of the resource type record for the specified resource that the permissions are being set for.\n */\n @Input() ResourceTypeID!: string;\n /**\n * Required: the record ID of the resource that the permissions are being set for.\n */ \n @Input() ResourceRecordID!: string;\n /**\n * If set to true, the component will show a Save button to the user and persist the changes to the \n * database when the user clicks the Save button. By default this is off to allow users of the component\n * to wrap the component as desired, and handle the save themselves.\n */\n @Input() ShowSaveButton: boolean = false;\n /**\n * If set to true, the component will show the permission levels to the user. By default this is on. If you have \n * a Resource Type or run-time use case where levels are not relevant, you can turn this off.\n */\n @Input() ShowPermissionLevels: boolean = true;\n /**\n * By default, this component will not show any error messages to the user. \n * If you want to show error messages to the user, set this to true. The component will always throw exceptions when error occur internally.\n */\n @Input() ShowUserErrorMessages: boolean = false;\n /**\n * Allows you to determine if the user is able to add new permissions for the resource.\n */\n @Input() AllowAddPermissions: boolean = true;\n /**\n * Allows you to determine if the user is able to edit existing permissions for the resource.\n */\n @Input() AllowEditPermissions: boolean = true;\n /**\n * Allows you to determine if the user is able to delete existing permissions for the resource.\n */\n @Input() AllowDeletePermissions: boolean = true;\n\n /**\n * List of possible permission levels that can be set for the resource. An array of strings, defaults to ['View', 'Edit', 'Owner']\n */\n @Input() PermissionLevels = ['View', 'Edit', 'Owner']; // these are the possible permission levels\n\n /**\n * Specifies the types of permissions the UI will allow settings for. An array of strings, defaults to ['User', 'Role']\n */\n @Input() PermissionTypes = ['User', 'Role'];\n\n /**\n * This optional input allows you to exclude certain roles from the list of roles that can be selected for permissions. If existing permissions have been created with roles that are in this list they will still be displayed, \n * but the user will not be able to add new permissions with these roles. This is an array of strings with the NAMES of the roles.\n */\n @Input() ExcludedRoleNames: string[] = [];\n\n /**\n * This optional input allows you to exclude certain users from the list of users that can be selected for permissions. If existing permissions have been created with users that are in this list they will still be displayed, \n * but the user will not be able to add new permissions with these users. This is an array of strings with EMAILS.\n */\n @Input() ExcludedUserEmails: string[] = [];\n\n public AllUsers: MJUserEntity[] = [];\n public AllRoles: RoleInfo[] = [];\n\n public SelectedUser: MJUserEntity | null = null;\n public SelectedRole: RoleInfo | null = null;\n public SelectedType: 'User' | 'Role' = 'Role';\n public SelectedPermissionLevel: 'View' | 'Edit' | 'Owner' = 'View';\n\n public _Loading: boolean = false;\n\n public async UpdateResourceRecordID(ResourceRecordID: string) {\n this.ResourceRecordID = ResourceRecordID;\n // now go through all of our permissions and update the ResourceRecordID\n for (const permission of this.resourcePermissions) {\n permission.ResourceRecordID = ResourceRecordID\n }\n }\n\n public resourcePermissions: MJResourcePermissionEntity[] = [];\n async ngAfterViewInit() {\n if (!this.ResourceTypeID || !this.ResourceRecordID) {\n throw new Error('ResourceTypeID and ResourceRecordID must be set');\n }\n\n this._Loading = true;\n // load up the current permissions for the specified ResourceTypeID and ResourceRecordID\n const engine = this.GetEngine();\n await engine.Config(false, this.ProviderToUse.CurrentUser, this.ProviderToUse);\n // now we can get the permissions for the specified resource\n const allResourcePermissions = engine.GetResourcePermissions(this.ResourceTypeID, this.ResourceRecordID);\n this.resourcePermissions = allResourcePermissions.filter((p) => p.Status === 'Approved'); // only include approved permissions in the UI, we don't show requested, rejected, revoked permissions here, just suppress them.\n \n const p = this.ProviderToUse;\n const rv = new RunView(<IRunViewProvider><any>p)\n const result = await rv.RunView<MJUserEntity>({\n EntityName: \"MJ: Users\",\n ResultType: \"entity_object\",\n OrderBy: \"Name\",\n ExtraFilter: \"IsActive=1\"\n });\n // filter out any users that are in the ExcludedUserEmails list\n this.AllUsers = result.Results.filter((u) => !this.ExcludedUserEmails.includes(u.Email));\n // filter out any roles that are in the ExcludedRoleNames list\n this.AllRoles = p.Roles.filter((r) => !this.ExcludedRoleNames.includes(r.Name));\n\n if (this.AllUsers.length > 0)\n this.SelectedUser = this.AllUsers[0];\n if (this.AllRoles.length > 0)\n this.SelectedRole = this.AllRoles[0];\n\n this._Loading = false;\n }\n\n private _pendingDeletes: MJResourcePermissionEntity[] = [];\n public deletePermission(permission: MJResourcePermissionEntity) {\n this._pendingDeletes.push(permission);\n this.resourcePermissions = this.resourcePermissions.filter((p) => p !== permission);\n }\n\n private _pendingAdds: MJResourcePermissionEntity[] = [];\n public async addPermission() {\n const p = this.ProviderToUse;\n const permission = await p.GetEntityObject<MJResourcePermissionEntity>(\"MJ: Resource Permissions\", p.CurrentUser);\n permission.ResourceTypeID = this.ResourceTypeID;\n permission.ResourceRecordID = this.ResourceRecordID;\n permission.Type = this.SelectedType;\n permission.Status = 'Approved';\n permission.PermissionLevel = this.SelectedPermissionLevel;\n if (this.SelectedType === 'User' && this.SelectedUser) {\n permission.UserID = this.SelectedUser.ID;\n permission.Set(\"User\", this.SelectedUser.Name);// set the virtual field for display purposes\n }\n else if (this.SelectedType === 'Role' && this.SelectedRole) { \n permission.RoleID = this.SelectedRole.ID;\n permission.Set(\"Role\", this.SelectedRole.Name); // set the virtual field for display purposes\n }\n else {\n LogError('Invalid permission type or missing user/role');\n return;\n }\n this.resourcePermissions.push(permission);\n }\n\n public permissionAlreadyExists(): boolean {\n // check to see if the selection that the user currently has in place for the combination of TYPE + either USER or ROLE already exists\n // in our list of permissions\n for (const permission of this.resourcePermissions) {\n if (permission.Type === this.SelectedType) {\n if (this.SelectedType === 'User' && permission.UserID === this.SelectedUser?.ID) {\n return true;\n }\n else if (this.SelectedType === 'Role' && permission.RoleID === this.SelectedRole?.ID) {\n return true;\n }\n }\n }\n\n // if we get here, then the permission does not already exist\n return false;\n }\n\n public async SavePermissions(): Promise<boolean> {\n // first delete any permissions that were marked for deletion\n this._Loading = true;\n const p = this.ProviderToUse;\n const tg = await p.CreateTransactionGroup();\n for (const permission of this._pendingDeletes) {\n if (permission.IsSaved) {\n // only delete records previously saved, sometimes a user adds a new permission and deletes it before saving it\n permission.TransactionGroup = tg;\n if (!await permission.Delete()) { // we use await here because the promise will resolve before the actual save occurs --- the internals will not call the network until tg.Submit() below\n // validation errors come back here\n if (this.ShowUserErrorMessages)\n MJNotificationService.Instance.CreateSimpleNotification('Error saving permissions', 'error', 2500);\n\n LogError('Error deleting permission record in the transaction group: ' + permission.LatestResult.CompleteMessage);\n return false;\n } \n } \n }\n\n // next add new permissions by saving them in the transaction group\n for (const permission of this._pendingAdds) {\n if (this._pendingDeletes.includes(permission)) {\n // don't save a permission record that is new, if it was also marked for deletion\n permission.TransactionGroup = tg;\n if (!await permission.Save()) { \n // validation errors come back here\n if (this.ShowUserErrorMessages)\n MJNotificationService.Instance.CreateSimpleNotification('Error saving permissions', 'error', 2500);\n\n LogError('Error saving permission record in the transaction group: ' + permission.LatestResult.CompleteMessage); \n return false;\n }\n }\n }\n\n // now save the existing permissions\n for (const permission of this.resourcePermissions) {\n // make sure not in the delete array\n if (!this._pendingDeletes.includes(permission)) {\n permission.TransactionGroup = tg;\n if (!await permission.Save()) { \n // validation errors come back here\n if (this.ShowUserErrorMessages)\n MJNotificationService.Instance.CreateSimpleNotification('Error saving permissions', 'error', 2500);\n\n LogError('Error saving permission record in the transaction group: ' + permission.LatestResult.CompleteMessage);\n return false;\n }\n }\n }\n\n // now save the changes\n if (await tg.Submit()) {\n this._Loading = false;\n this._pendingDeletes = [];\n this._pendingAdds = [];\n const engine = this.GetEngine();\n await engine.RefreshAllItems(); // refresh the permissions cache\n return true;\n }\n else {\n // we had an error, show the user via SharedService\n this._Loading = false;\n if (this.ShowUserErrorMessages)\n MJNotificationService.Instance.CreateSimpleNotification('Error saving permissions', 'error', );\n \n LogError('Error saving permissions in the transaction group');\n return false;\n }\n }\n\n protected GetEngine(): ResourcePermissionEngine {\n return <ResourcePermissionEngine>ResourcePermissionEngine.GetProviderInstance(this.ProviderToUse, ResourcePermissionEngine);\n }\n}\n","<div class=\"container\">\n @if(_Loading) {\n <mj-loading [showText]=\"false\" size=\"medium\"></mj-loading>\n }\n @if(ShowSaveButton) {\n <button kendoButton (click)=\"SavePermissions()\">Save</button>\n }\n <div class=\"table-container\">\n @if(AllowAddPermissions) {\n <div class=\"add-permission-section\">\n <span class=\"add-permission-label\">Add Permission</span>\n <kendo-dropdownlist \n [data]=\"PermissionTypes\"\n [(ngModel)]=\"SelectedType\"\n style=\"width: 100px;\">\n </kendo-dropdownlist>\n @if (SelectedType === 'User') {\n <kendo-dropdownlist \n [data]=\"AllUsers\"\n [(ngModel)]=\"SelectedUser\"\n textField=\"Name\"\n valueField=\"ID\"\n style=\"width: 225px;\">\n </kendo-dropdownlist>\n }\n @else if (SelectedType === 'Role') {\n <kendo-dropdownlist \n [data]=\"AllRoles\"\n [(ngModel)]=\"SelectedRole\"\n textField=\"Name\"\n valueField=\"ID\"\n style=\"width: 150px;\">\n </kendo-dropdownlist>\n }\n @else {\n SelectedType: {{ SelectedType }}\n }\n @if (ShowPermissionLevels) {\n <kendo-dropdownlist \n [data]=\"PermissionLevels\"\n [(ngModel)]=\"SelectedPermissionLevel\"\n style=\"width: 100px;\">\n </kendo-dropdownlist>\n }\n <button kendoButton (click)=\"addPermission()\" [disabled]=\"permissionAlreadyExists()\" [title]=\"permissionAlreadyExists() ? 'This combination of Type/User/Role already exists below' : ''\" >Add</button>\n </div>\n }\n <table class=\"resource-table\">\n <thead>\n <tr>\n <th>Type</th>\n <th>Name</th>\n @if (ShowPermissionLevels) {\n <th>Level</th>\n }\n @if(AllowDeletePermissions) {\n <th>Actions</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (p of resourcePermissions; track p) {\n <tr>\n <td>{{ p.Type }}</td>\n <td>{{ p.Type === 'User' ? p.User : p.Role }}</td>\n @if (ShowPermissionLevels) {\n <td>\n @if (AllowEditPermissions) {\n <kendo-dropdownlist \n [(ngModel)]=\"p.PermissionLevel\"\n [data]=\"PermissionLevels\"\n style=\"width: 100px;\">\n </kendo-dropdownlist>\n }\n @else {\n {{ p.PermissionLevel }}\n }\n </td>\n }\n @if(AllowDeletePermissions) {\n <td>\n <button kendoButton (click)=\"deletePermission(p)\"><span class=\"fa-solid fa-trash-can\"></span></button>\n </td>\n }\n </tr> \n }\n </tbody>\n </table>\n </div>\n</div>\n"]}
|
|
1
|
+
{"version":3,"file":"resource-permissions.component.js","sourceRoot":"","sources":["../../src/lib/resource-permissions.component.ts","../../src/lib/resource-permissions.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAuC,QAAQ,EAAsB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,wBAAwB,EAA4C,MAAM,+BAA+B,CAAC;AACnH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;;;;;;;ICHrE,gCAA0D;;IAA9C,gCAAkB;;;;IAG9B,iCAAgD;IAA5B,gMAAS,wBAAiB,KAAC;IAAC,oBAAI;IAAA,iBAAS;;;;IAYvD,8CAKwB;IAHtB,wVAA0B;IAI5B,iBAAqB;;;IALnB,sCAAiB;IACjB,mDAA0B;;;;IAO5B,8CAKwB;IAHtB,wVAA0B;IAI5B,iBAAqB;;;IALnB,sCAAiB;IACjB,mDAA0B;;;IAO5B,YACF;;;IADE,kEACF;;;;IAEE,6CAGwB;IADtB,8WAAqC;IAEvC,iBAAqB;;;IAHnB,8CAAyB;IACzB,8DAAqC;;;;IA9BzC,AADF,8BAAoC,cACC;IAAA,8BAAc;IAAA,iBAAO;IACxD,6CAGwB;IADtB,yUAA0B;IAE5B,iBAAqB;IAmBrB,AATA,A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EC;YACD,cAEC;YAFD,6CAEC;YAEC,eAsCC;YAtCD,kDAsCC;YAMK,eAEC;YAFD,oDAEC;YACD,cAEC;YAFD,sDAEC;YAIH,eAwBC;YAxBD,sCAwBC;;;iFDpEI,4BAA4B;cANxC,SAAS;6BACI,KAAK,YACP,yBAAyB;;kBAQlC,KAAK;;kBAIL,KAAK;;kBAML,KAAK;;kBAKL,KAAK;;kBAKL,KAAK;;kBAIL,KAAK;;kBAIL,KAAK;;kBAIL,KAAK;;kBAKL,KAAK;;kBAKL,KAAK;;kBAML,KAAK;;kBAML,KAAK;;kFA1DK,4BAA4B","sourcesContent":["import { AfterViewInit, Component, Input } from '@angular/core';\nimport { IMetadataProvider, IRunViewProvider, LogError, Metadata, RoleInfo, RunView } from '@memberjunction/core';\nimport { ResourcePermissionEngine, MJResourcePermissionEntity, MJUserEntity } from '@memberjunction/core-entities';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { MJNotificationService } from '@memberjunction/ng-notifications';\n\n/**\n * Visual component used to display and manage permissions for a resource. You can wrap this in a dialog or display anywhere else within\n * an Angular application or component.\n */\n@Component({\n standalone: false,\n selector: 'mj-resource-permissions',\n templateUrl: './resource-permissions.component.html',\n styleUrls: ['./resource-permissions.component.css']\n})\nexport class ResourcePermissionsComponent extends BaseAngularComponent implements AfterViewInit {\n /**\n * Required: the ID of the resource type record for the specified resource that the permissions are being set for.\n */\n @Input() ResourceTypeID!: string;\n /**\n * Required: the record ID of the resource that the permissions are being set for.\n */ \n @Input() ResourceRecordID!: string;\n /**\n * If set to true, the component will show a Save button to the user and persist the changes to the \n * database when the user clicks the Save button. By default this is off to allow users of the component\n * to wrap the component as desired, and handle the save themselves.\n */\n @Input() ShowSaveButton: boolean = false;\n /**\n * If set to true, the component will show the permission levels to the user. By default this is on. If you have \n * a Resource Type or run-time use case where levels are not relevant, you can turn this off.\n */\n @Input() ShowPermissionLevels: boolean = true;\n /**\n * By default, this component will not show any error messages to the user. \n * If you want to show error messages to the user, set this to true. The component will always throw exceptions when error occur internally.\n */\n @Input() ShowUserErrorMessages: boolean = false;\n /**\n * Allows you to determine if the user is able to add new permissions for the resource.\n */\n @Input() AllowAddPermissions: boolean = true;\n /**\n * Allows you to determine if the user is able to edit existing permissions for the resource.\n */\n @Input() AllowEditPermissions: boolean = true;\n /**\n * Allows you to determine if the user is able to delete existing permissions for the resource.\n */\n @Input() AllowDeletePermissions: boolean = true;\n\n /**\n * List of possible permission levels that can be set for the resource. An array of strings, defaults to ['View', 'Edit', 'Owner']\n */\n @Input() PermissionLevels = ['View', 'Edit', 'Owner']; // these are the possible permission levels\n\n /**\n * Specifies the types of permissions the UI will allow settings for. An array of strings, defaults to ['User', 'Role']\n */\n @Input() PermissionTypes = ['User', 'Role'];\n\n /**\n * This optional input allows you to exclude certain roles from the list of roles that can be selected for permissions. If existing permissions have been created with roles that are in this list they will still be displayed, \n * but the user will not be able to add new permissions with these roles. This is an array of strings with the NAMES of the roles.\n */\n @Input() ExcludedRoleNames: string[] = [];\n\n /**\n * This optional input allows you to exclude certain users from the list of users that can be selected for permissions. If existing permissions have been created with users that are in this list they will still be displayed, \n * but the user will not be able to add new permissions with these users. This is an array of strings with EMAILS.\n */\n @Input() ExcludedUserEmails: string[] = [];\n\n public AllUsers: MJUserEntity[] = [];\n public AllRoles: RoleInfo[] = [];\n\n public SelectedUser: MJUserEntity | null = null;\n public SelectedRole: RoleInfo | null = null;\n public SelectedType: 'User' | 'Role' = 'Role';\n public SelectedPermissionLevel: 'View' | 'Edit' | 'Owner' = 'View';\n\n public _Loading: boolean = false;\n\n public async UpdateResourceRecordID(ResourceRecordID: string) {\n this.ResourceRecordID = ResourceRecordID;\n // now go through all of our permissions and update the ResourceRecordID\n for (const permission of this.resourcePermissions) {\n permission.ResourceRecordID = ResourceRecordID\n }\n }\n\n public resourcePermissions: MJResourcePermissionEntity[] = [];\n async ngAfterViewInit() {\n if (!this.ResourceTypeID || !this.ResourceRecordID) {\n throw new Error('ResourceTypeID and ResourceRecordID must be set');\n }\n\n this._Loading = true;\n // load up the current permissions for the specified ResourceTypeID and ResourceRecordID\n const engine = this.GetEngine();\n await engine.Config(false, this.ProviderToUse.CurrentUser, this.ProviderToUse);\n // now we can get the permissions for the specified resource\n const allResourcePermissions = engine.GetResourcePermissions(this.ResourceTypeID, this.ResourceRecordID);\n this.resourcePermissions = allResourcePermissions.filter((p) => p.Status === 'Approved'); // only include approved permissions in the UI, we don't show requested, rejected, revoked permissions here, just suppress them.\n \n const p = this.ProviderToUse;\n const rv = new RunView(<IRunViewProvider><any>p)\n const result = await rv.RunView<MJUserEntity>({\n EntityName: \"MJ: Users\",\n ResultType: \"entity_object\",\n OrderBy: \"Name\",\n ExtraFilter: \"IsActive=1\"\n });\n // filter out any users that are in the ExcludedUserEmails list\n this.AllUsers = result.Results.filter((u) => !this.ExcludedUserEmails.includes(u.Email));\n // filter out any roles that are in the ExcludedRoleNames list\n this.AllRoles = p.Roles.filter((r) => !this.ExcludedRoleNames.includes(r.Name));\n\n if (this.AllUsers.length > 0)\n this.SelectedUser = this.AllUsers[0];\n if (this.AllRoles.length > 0)\n this.SelectedRole = this.AllRoles[0];\n\n this._Loading = false;\n }\n\n private _pendingDeletes: MJResourcePermissionEntity[] = [];\n public deletePermission(permission: MJResourcePermissionEntity) {\n this._pendingDeletes.push(permission);\n this.resourcePermissions = this.resourcePermissions.filter((p) => p !== permission);\n }\n\n private _pendingAdds: MJResourcePermissionEntity[] = [];\n public async addPermission() {\n const p = this.ProviderToUse;\n const permission = await p.GetEntityObject<MJResourcePermissionEntity>(\"MJ: Resource Permissions\", p.CurrentUser);\n permission.ResourceTypeID = this.ResourceTypeID;\n permission.ResourceRecordID = this.ResourceRecordID;\n permission.Type = this.SelectedType;\n permission.Status = 'Approved';\n permission.PermissionLevel = this.SelectedPermissionLevel;\n if (this.SelectedType === 'User' && this.SelectedUser) {\n permission.UserID = this.SelectedUser.ID;\n permission.Set(\"User\", this.SelectedUser.Name);// set the virtual field for display purposes\n }\n else if (this.SelectedType === 'Role' && this.SelectedRole) { \n permission.RoleID = this.SelectedRole.ID;\n permission.Set(\"Role\", this.SelectedRole.Name); // set the virtual field for display purposes\n }\n else {\n LogError('Invalid permission type or missing user/role');\n return;\n }\n this.resourcePermissions.push(permission);\n }\n\n public permissionAlreadyExists(): boolean {\n // check to see if the selection that the user currently has in place for the combination of TYPE + either USER or ROLE already exists\n // in our list of permissions\n for (const permission of this.resourcePermissions) {\n if (permission.Type === this.SelectedType) {\n if (this.SelectedType === 'User' && UUIDsEqual(permission.UserID, this.SelectedUser?.ID)) {\n return true;\n }\n else if (this.SelectedType === 'Role' && UUIDsEqual(permission.RoleID, this.SelectedRole?.ID)) {\n return true;\n }\n }\n }\n\n // if we get here, then the permission does not already exist\n return false;\n }\n\n public async SavePermissions(): Promise<boolean> {\n // first delete any permissions that were marked for deletion\n this._Loading = true;\n const p = this.ProviderToUse;\n const tg = await p.CreateTransactionGroup();\n for (const permission of this._pendingDeletes) {\n if (permission.IsSaved) {\n // only delete records previously saved, sometimes a user adds a new permission and deletes it before saving it\n permission.TransactionGroup = tg;\n if (!await permission.Delete()) { // we use await here because the promise will resolve before the actual save occurs --- the internals will not call the network until tg.Submit() below\n // validation errors come back here\n if (this.ShowUserErrorMessages)\n MJNotificationService.Instance.CreateSimpleNotification('Error saving permissions', 'error', 2500);\n\n LogError('Error deleting permission record in the transaction group: ' + permission.LatestResult.CompleteMessage);\n return false;\n } \n } \n }\n\n // next add new permissions by saving them in the transaction group\n for (const permission of this._pendingAdds) {\n if (this._pendingDeletes.includes(permission)) {\n // don't save a permission record that is new, if it was also marked for deletion\n permission.TransactionGroup = tg;\n if (!await permission.Save()) { \n // validation errors come back here\n if (this.ShowUserErrorMessages)\n MJNotificationService.Instance.CreateSimpleNotification('Error saving permissions', 'error', 2500);\n\n LogError('Error saving permission record in the transaction group: ' + permission.LatestResult.CompleteMessage); \n return false;\n }\n }\n }\n\n // now save the existing permissions\n for (const permission of this.resourcePermissions) {\n // make sure not in the delete array\n if (!this._pendingDeletes.includes(permission)) {\n permission.TransactionGroup = tg;\n if (!await permission.Save()) { \n // validation errors come back here\n if (this.ShowUserErrorMessages)\n MJNotificationService.Instance.CreateSimpleNotification('Error saving permissions', 'error', 2500);\n\n LogError('Error saving permission record in the transaction group: ' + permission.LatestResult.CompleteMessage);\n return false;\n }\n }\n }\n\n // now save the changes\n if (await tg.Submit()) {\n this._Loading = false;\n this._pendingDeletes = [];\n this._pendingAdds = [];\n const engine = this.GetEngine();\n await engine.RefreshAllItems(); // refresh the permissions cache\n return true;\n }\n else {\n // we had an error, show the user via SharedService\n this._Loading = false;\n if (this.ShowUserErrorMessages)\n MJNotificationService.Instance.CreateSimpleNotification('Error saving permissions', 'error', );\n \n LogError('Error saving permissions in the transaction group');\n return false;\n }\n }\n\n protected GetEngine(): ResourcePermissionEngine {\n return <ResourcePermissionEngine>ResourcePermissionEngine.GetProviderInstance(this.ProviderToUse, ResourcePermissionEngine);\n }\n}\n","<div class=\"container\">\n @if(_Loading) {\n <mj-loading [showText]=\"false\" size=\"medium\"></mj-loading>\n }\n @if(ShowSaveButton) {\n <button kendoButton (click)=\"SavePermissions()\">Save</button>\n }\n <div class=\"table-container\">\n @if(AllowAddPermissions) {\n <div class=\"add-permission-section\">\n <span class=\"add-permission-label\">Add Permission</span>\n <kendo-dropdownlist \n [data]=\"PermissionTypes\"\n [(ngModel)]=\"SelectedType\"\n style=\"width: 100px;\">\n </kendo-dropdownlist>\n @if (SelectedType === 'User') {\n <kendo-dropdownlist \n [data]=\"AllUsers\"\n [(ngModel)]=\"SelectedUser\"\n textField=\"Name\"\n valueField=\"ID\"\n style=\"width: 225px;\">\n </kendo-dropdownlist>\n }\n @else if (SelectedType === 'Role') {\n <kendo-dropdownlist \n [data]=\"AllRoles\"\n [(ngModel)]=\"SelectedRole\"\n textField=\"Name\"\n valueField=\"ID\"\n style=\"width: 150px;\">\n </kendo-dropdownlist>\n }\n @else {\n SelectedType: {{ SelectedType }}\n }\n @if (ShowPermissionLevels) {\n <kendo-dropdownlist \n [data]=\"PermissionLevels\"\n [(ngModel)]=\"SelectedPermissionLevel\"\n style=\"width: 100px;\">\n </kendo-dropdownlist>\n }\n <button kendoButton (click)=\"addPermission()\" [disabled]=\"permissionAlreadyExists()\" [title]=\"permissionAlreadyExists() ? 'This combination of Type/User/Role already exists below' : ''\" >Add</button>\n </div>\n }\n <table class=\"resource-table\">\n <thead>\n <tr>\n <th>Type</th>\n <th>Name</th>\n @if (ShowPermissionLevels) {\n <th>Level</th>\n }\n @if(AllowDeletePermissions) {\n <th>Actions</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (p of resourcePermissions; track p) {\n <tr>\n <td>{{ p.Type }}</td>\n <td>{{ p.Type === 'User' ? p.User : p.Role }}</td>\n @if (ShowPermissionLevels) {\n <td>\n @if (AllowEditPermissions) {\n <kendo-dropdownlist \n [(ngModel)]=\"p.PermissionLevel\"\n [data]=\"PermissionLevels\"\n style=\"width: 100px;\">\n </kendo-dropdownlist>\n }\n @else {\n {{ p.PermissionLevel }}\n }\n </td>\n }\n @if(AllowDeletePermissions) {\n <td>\n <button kendoButton (click)=\"deletePermission(p)\"><span class=\"fa-solid fa-trash-can\"></span></button>\n </td>\n }\n </tr> \n }\n </tbody>\n </table>\n </div>\n</div>\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-resource-permissions",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "MemberJunction: Generic Angular components for displaying/editing permissions for a resource",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"@angular/router": "21.1.3"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@memberjunction/core": "5.
|
|
31
|
-
"@memberjunction/core-entities": "5.
|
|
32
|
-
"@memberjunction/global": "5.
|
|
33
|
-
"@memberjunction/ng-base-types": "5.
|
|
34
|
-
"@memberjunction/ng-container-directives": "5.
|
|
35
|
-
"@memberjunction/ng-generic-dialog": "5.
|
|
36
|
-
"@memberjunction/ng-notifications": "5.
|
|
37
|
-
"@memberjunction/ng-shared-generic": "5.
|
|
30
|
+
"@memberjunction/core": "5.6.0",
|
|
31
|
+
"@memberjunction/core-entities": "5.6.0",
|
|
32
|
+
"@memberjunction/global": "5.6.0",
|
|
33
|
+
"@memberjunction/ng-base-types": "5.6.0",
|
|
34
|
+
"@memberjunction/ng-container-directives": "5.6.0",
|
|
35
|
+
"@memberjunction/ng-generic-dialog": "5.6.0",
|
|
36
|
+
"@memberjunction/ng-notifications": "5.6.0",
|
|
37
|
+
"@memberjunction/ng-shared-generic": "5.6.0",
|
|
38
38
|
"@progress/kendo-angular-buttons": "22.0.1",
|
|
39
39
|
"@progress/kendo-angular-dialog": "22.0.1",
|
|
40
40
|
"@progress/kendo-angular-dropdowns": "22.0.1",
|