@memberjunction/ng-entity-permissions 1.8.1 → 2.0.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/entity-selector-with-grid/entity-selector-with-grid.component.js +1 -1
- package/dist/lib/grid/entity-permissions-grid.component.d.ts +2 -1
- package/dist/lib/grid/entity-permissions-grid.component.d.ts.map +1 -1
- package/dist/lib/grid/entity-permissions-grid.component.js +15 -9
- package/package.json +6 -6
|
@@ -58,4 +58,4 @@ EntityPermissionsSelectorWithGridComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineCo
|
|
|
58
58
|
}], CurrentEntity: [{
|
|
59
59
|
type: Input
|
|
60
60
|
}] }); })();
|
|
61
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(EntityPermissionsSelectorWithGridComponent, { className: "EntityPermissionsSelectorWithGridComponent"
|
|
61
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(EntityPermissionsSelectorWithGridComponent, { className: "EntityPermissionsSelectorWithGridComponent" }); })();
|
|
@@ -3,7 +3,7 @@ import { EntityPermissionEntity } from '@memberjunction/core-entities';
|
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
export type EntityPermissionChangedEvent = {
|
|
5
5
|
EntityName: string;
|
|
6
|
-
|
|
6
|
+
RoleID: string;
|
|
7
7
|
PermissionTypeChanged: 'Read' | 'Create' | 'Update' | 'Delete';
|
|
8
8
|
Value: boolean;
|
|
9
9
|
Cancel: boolean;
|
|
@@ -22,6 +22,7 @@ export declare class EntityPermissionsGridComponent implements OnInit, OnChanges
|
|
|
22
22
|
ngOnChanges(changes: SimpleChanges): void;
|
|
23
23
|
ValidateInputs(): void;
|
|
24
24
|
Refresh(): Promise<void>;
|
|
25
|
+
getRoleName(roleID: string): string;
|
|
25
26
|
savePermissions(): Promise<void>;
|
|
26
27
|
cancelEdit(): Promise<void>;
|
|
27
28
|
get NumDirtyPermissions(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-permissions-grid.component.d.ts","sourceRoot":"","sources":["../../../src/lib/grid/entity-permissions-grid.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAE,MAAM,EAAS,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGzG,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;;AAGvE,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,
|
|
1
|
+
{"version":3,"file":"entity-permissions-grid.component.d.ts","sourceRoot":"","sources":["../../../src/lib/grid/entity-permissions-grid.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAE,MAAM,EAAS,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGzG,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;;AAGvE,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,qBAAqB,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAC9D,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,qBAKa,8BAA+B,YAAW,MAAM,EAAE,SAAS;IAC7D,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAY;IACnC,UAAU,EAAG,MAAM,CAAC;IACpB,QAAQ,EAAG,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAK;IAExB,iBAAiB,6CAAoD;IAExE,WAAW,EAAE,sBAAsB,EAAE,CAAM;IAC3C,UAAU,EAAE,MAAM,CAAO;IACzB,SAAS,EAAE,OAAO,CAAS;;IAKlC,QAAQ,IAAI,IAAI;IAIhB,WAAW,CAAC,OAAO,EAAE,aAAa;IAOlC,cAAc;IAMR,OAAO;IA0FN,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAM7B,eAAe;IAkBf,UAAU;IAWvB,IAAW,mBAAmB,IAAI,MAAM,CAEvC;IAED,SAAS,CAAC,uBAAuB,CAAC,CAAC,EAAE,sBAAsB,GAAG,OAAO;IAS9D,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ;IAoDhE,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,sBAAsB;IAO/D,OAAO,CAAC,UAAU,EAAE,sBAAsB;IA0B1C,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,EAAE,cAAc,EAAE,OAAO;yCA/PpJ,8BAA8B;2CAA9B,8BAA8B;CA6R1C"}
|
|
@@ -35,8 +35,9 @@ function EntityPermissionsGridComponent_table_6_tr_14_Conditional_2_Template(rf,
|
|
|
35
35
|
i0.ɵɵelementEnd();
|
|
36
36
|
} if (rf & 2) {
|
|
37
37
|
const permission_r4 = i0.ɵɵnextContext().$implicit;
|
|
38
|
+
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
38
39
|
i0.ɵɵadvance();
|
|
39
|
-
i0.ɵɵtextInterpolate1(" ", permission_r4.
|
|
40
|
+
i0.ɵɵtextInterpolate1(" ", ctx_r1.getRoleName(permission_r4.RoleID), " ");
|
|
40
41
|
} }
|
|
41
42
|
function EntityPermissionsGridComponent_table_6_tr_14_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
42
43
|
i0.ɵɵelementStart(0, "span");
|
|
@@ -169,7 +170,7 @@ export class EntityPermissionsGridComponent {
|
|
|
169
170
|
if (this.Mode === 'Role' && !r)
|
|
170
171
|
throw new Error("Role not found: " + this.RoleName);
|
|
171
172
|
const rv = new RunView();
|
|
172
|
-
const filter = this.Mode === 'Entity' ?
|
|
173
|
+
const filter = this.Mode === 'Entity' ? `EntityID='${entity.ID}'` : `RoleName='${r === null || r === void 0 ? void 0 : r.Name}'`;
|
|
173
174
|
const result = yield rv.RunView({
|
|
174
175
|
EntityName: 'Entity Permissions',
|
|
175
176
|
ExtraFilter: filter,
|
|
@@ -184,7 +185,7 @@ export class EntityPermissionsGridComponent {
|
|
|
184
185
|
const existingPermissions = result.Results;
|
|
185
186
|
const roles = md.Roles;
|
|
186
187
|
if (this.Mode === 'Entity') {
|
|
187
|
-
const rolesWithNoPermissions = roles.filter(r => !existingPermissions.some(p => p.
|
|
188
|
+
const rolesWithNoPermissions = roles.filter(r => !existingPermissions.some(p => p.RoleID === r.ID));
|
|
188
189
|
for (const r of rolesWithNoPermissions) {
|
|
189
190
|
const p = yield md.GetEntityObject('Entity Permissions');
|
|
190
191
|
// p.NewRecord();
|
|
@@ -198,7 +199,7 @@ export class EntityPermissionsGridComponent {
|
|
|
198
199
|
ID: null,
|
|
199
200
|
Entity: entity.Name,
|
|
200
201
|
EntityID: entity.ID,
|
|
201
|
-
|
|
202
|
+
RoleID: r.ID,
|
|
202
203
|
CanRead: false,
|
|
203
204
|
CanCreate: false,
|
|
204
205
|
CanUpdate: false,
|
|
@@ -206,7 +207,7 @@ export class EntityPermissionsGridComponent {
|
|
|
206
207
|
});
|
|
207
208
|
existingPermissions.push(p);
|
|
208
209
|
}
|
|
209
|
-
this.permissions = existingPermissions
|
|
210
|
+
this.permissions = existingPermissions;
|
|
210
211
|
}
|
|
211
212
|
else if (this.Mode === 'Role') {
|
|
212
213
|
// for the mode of Role, that means we want to show all entities and their permissions for the given role
|
|
@@ -242,6 +243,11 @@ export class EntityPermissionsGridComponent {
|
|
|
242
243
|
this.isLoading = false;
|
|
243
244
|
});
|
|
244
245
|
}
|
|
246
|
+
getRoleName(roleID) {
|
|
247
|
+
const md = new Metadata();
|
|
248
|
+
const r = md.Roles.find(r => r.ID === roleID);
|
|
249
|
+
return r ? r.Name : '';
|
|
250
|
+
}
|
|
245
251
|
savePermissions() {
|
|
246
252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
247
253
|
if (this.NumDirtyPermissions > 0) {
|
|
@@ -279,7 +285,7 @@ export class EntityPermissionsGridComponent {
|
|
|
279
285
|
IsPermissionReallyDirty(p) {
|
|
280
286
|
if (!p.Dirty)
|
|
281
287
|
return false;
|
|
282
|
-
else if (p.
|
|
288
|
+
else if (p.IsSaved)
|
|
283
289
|
return true;
|
|
284
290
|
else
|
|
285
291
|
return p.CanRead || p.CanCreate || p.CanUpdate || p.CanDelete; // if we have a new record, only consider it dirty if at least one permission is true
|
|
@@ -382,7 +388,7 @@ export class EntityPermissionsGridComponent {
|
|
|
382
388
|
const value = type === 'Read' ? permission.CanRead : type === 'Create' ? permission.CanCreate : type === 'Update' ? permission.CanUpdate : permission.CanDelete;
|
|
383
389
|
this.PermissionChanged.emit({
|
|
384
390
|
EntityName: this.EntityName,
|
|
385
|
-
|
|
391
|
+
RoleID: permission.RoleID,
|
|
386
392
|
PermissionTypeChanged: type,
|
|
387
393
|
Value: value,
|
|
388
394
|
Cancel: false
|
|
@@ -417,7 +423,7 @@ EntityPermissionsGridComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ ty
|
|
|
417
423
|
} }, dependencies: [i1.NgClass, i1.NgForOf, i1.NgIf, i2.CheckboxControlValueAccessor, i2.NgControlStatus, i2.NgModel, i3.ButtonComponent, i4.LoaderComponent], styles: ["\n\ntable[_ngcontent-%COMP%] {\n margin-left: 5px;\n margin-top: 5px;\n border-collapse: collapse; \n\n}\n\nbutton[_ngcontent-%COMP%] {\n margin-left: 5px;\n margin-top: 5px;\n width: 125px;\n}\n \ntable[_ngcontent-%COMP%] th[_ngcontent-%COMP%] {\n background-color: #f2f2f2; \n\n color: black; \n\n font-weight: bold; \n\n cursor: pointer;\n}\n\n.permission-left-col[_ngcontent-%COMP%] {\n cursor: pointer;\n}\n\n\n\ntable[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table[_ngcontent-%COMP%] td[_ngcontent-%COMP%] {\n border: 1px solid gray; \n\n height: 36px; \n\n text-align: center;\n padding: 0 8px; \n\n}\n\n\n\ntable[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:first-child, table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:first-child {\n min-width: 150px; \n\n text-align: left;\n}\n\n\n\ntable[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:not(:first-child), table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:not(:first-child) {\n width: 100px; \n\n}\n\n\n\ntable[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(odd) {\n background-color: white; \n\n}\n\ntable[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(even) {\n background-color: #e7f4ff; \n\n}\n\ntable[_ngcontent-%COMP%] tr.dirty-row[_ngcontent-%COMP%] {\n font-style: italic;\n background-color: #ffcccc;\n}"] });
|
|
418
424
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EntityPermissionsGridComponent, [{
|
|
419
425
|
type: Component,
|
|
420
|
-
args: [{ selector: 'mj-entity-permissions-grid', template: "<div>\n <div *ngIf=\"isLoading\"><kendo-loader></kendo-loader></div>\n <button [disabled]=\"NumDirtyPermissions === 0\" kendoButton (click)=\"savePermissions()\">Save</button>\n <button [disabled]=\"NumDirtyPermissions === 0\" kendoButton (click)=\"cancelEdit()\">Cancel</button>\n <table *ngIf=\"!isLoading\" class=\"grid\">\n <thead>\n <tr>\n <th *ngIf=\"this.Mode==='Entity'\">Role</th>\n <th *ngIf=\"this.Mode==='Role'\">Entity</th>\n <th (click)=\"flipAllPermissions('Read')\">Read</th>\n <th (click)=\"flipAllPermissions('Create')\">Create</th>\n <th (click)=\"flipAllPermissions('Update')\">Update</th>\n <th (click)=\"flipAllPermissions('Delete')\">Delete</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let permission of permissions\" [ngClass]=\"IsPermissionReallyDirty(permission) ? 'dirty-row' : ''\">\n <td class=\"permission-left-col\" (click)=\"flipRow(permission)\">\n @if(this.Mode === 'Entity') {\n <span>\n {{ permission.
|
|
426
|
+
args: [{ selector: 'mj-entity-permissions-grid', template: "<div>\n <div *ngIf=\"isLoading\"><kendo-loader></kendo-loader></div>\n <button [disabled]=\"NumDirtyPermissions === 0\" kendoButton (click)=\"savePermissions()\">Save</button>\n <button [disabled]=\"NumDirtyPermissions === 0\" kendoButton (click)=\"cancelEdit()\">Cancel</button>\n <table *ngIf=\"!isLoading\" class=\"grid\">\n <thead>\n <tr>\n <th *ngIf=\"this.Mode==='Entity'\">Role</th>\n <th *ngIf=\"this.Mode==='Role'\">Entity</th>\n <th (click)=\"flipAllPermissions('Read')\">Read</th>\n <th (click)=\"flipAllPermissions('Create')\">Create</th>\n <th (click)=\"flipAllPermissions('Update')\">Update</th>\n <th (click)=\"flipAllPermissions('Delete')\">Delete</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let permission of permissions\" [ngClass]=\"IsPermissionReallyDirty(permission) ? 'dirty-row' : ''\">\n <td class=\"permission-left-col\" (click)=\"flipRow(permission)\">\n @if(this.Mode === 'Entity') {\n <span>\n {{ getRoleName(permission.RoleID) }}\n </span> \n }\n @else if(this.Mode === 'Role') {\n <span>\n {{ permission.Entity }}\n </span>\n }\n\n @if(IsPermissionReallyDirty(permission)) {\n <span class=\"fa-solid fa-arrow-rotate-left\" (click)=\"revertRow($event, permission)\"></span>\n }\n </td>\n <td (click)=\"flipPermission($event, permission, 'Read', true)\">\n <input type=\"checkbox\" kendoCheckBox [(ngModel)]=\"permission.CanRead\" (click)=\"flipPermission($event, permission, 'Read', false)\">\n </td>\n <td (click)=\"flipPermission($event, permission, 'Create', true)\">\n <input type=\"checkbox\" kendoCheckBox [(ngModel)]=\"permission.CanCreate\" (click)=\"flipPermission($event, permission, 'Create', false)\">\n </td>\n <td (click)=\"flipPermission($event, permission, 'Update', true)\">\n <input type=\"checkbox\" kendoCheckBox [(ngModel)]=\"permission.CanUpdate\" (click)=\"flipPermission($event, permission, 'Update', false)\">\n </td>\n <td (click)=\"flipPermission($event, permission, 'Delete', true)\">\n <input type=\"checkbox\" kendoCheckBox [(ngModel)]=\"permission.CanDelete\" (click)=\"flipPermission($event, permission, 'Delete', false)\">\n </td>\n </tr>\n </tbody>\n </table>\n</div>\n ", styles: ["/* Style for the whole table */\ntable {\n margin-left: 5px;\n margin-top: 5px;\n border-collapse: collapse; /* Ensures border collapse for a cleaner look */\n}\n\nbutton {\n margin-left: 5px;\n margin-top: 5px;\n width: 125px;\n}\n \ntable th {\n background-color: #f2f2f2; /* Light gray background for headers */\n color: black; /* Black text color for headers */\n font-weight: bold; /* Bold font weight for headers */\n cursor: pointer;\n}\n\n.permission-left-col {\n cursor: pointer;\n}\n\n/* Style for all table cells */\ntable th, table td {\n border: 1px solid gray; /* Gray border for cells */\n height: 36px; /* Fixed height for all rows */\n text-align: center;\n padding: 0 8px; /* Add some padding inside cells */\n}\n\n/* Specific styles for the first column */\ntable th:first-child, table td:first-child {\n min-width: 150px; /* Set width for the first column */\n text-align: left;\n}\n\n/* Specific styles for the \"Can\" columns */\ntable th:not(:first-child), table td:not(:first-child) {\n width: 100px; /* Set width for \"Can\" columns */\n}\n\n/* Alternating row background colors */\ntable tr:nth-child(odd) {\n background-color: white; /* Light color for odd rows */\n}\n\ntable tr:nth-child(even) {\n background-color: #e7f4ff; /* Light blue for even rows */\n}\n\ntable tr.dirty-row {\n font-style: italic;\n background-color: #ffcccc;\n}\n\n"] }]
|
|
421
427
|
}], () => [], { Mode: [{
|
|
422
428
|
type: Input
|
|
423
429
|
}], EntityName: [{
|
|
@@ -429,4 +435,4 @@ EntityPermissionsGridComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ ty
|
|
|
429
435
|
}], PermissionChanged: [{
|
|
430
436
|
type: Output
|
|
431
437
|
}] }); })();
|
|
432
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(EntityPermissionsGridComponent, { className: "EntityPermissionsGridComponent"
|
|
438
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(EntityPermissionsGridComponent, { className: "EntityPermissionsGridComponent" }); })();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-entity-permissions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "MemberJunction: Angular components for displaying/editing permissions for an entity, and related components.",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"@angular/router": "18.0.2"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@memberjunction/core-entities": "
|
|
29
|
-
"@memberjunction/global": "
|
|
30
|
-
"@memberjunction/core": "
|
|
31
|
-
"@memberjunction/ng-container-directives": "
|
|
32
|
-
"@memberjunction/ng-shared": "
|
|
28
|
+
"@memberjunction/core-entities": "2.0.0",
|
|
29
|
+
"@memberjunction/global": "2.0.0",
|
|
30
|
+
"@memberjunction/core": "2.0.0",
|
|
31
|
+
"@memberjunction/ng-container-directives": "2.0.0",
|
|
32
|
+
"@memberjunction/ng-shared": "2.0.0",
|
|
33
33
|
"@progress/kendo-angular-dropdowns": "16.2.0",
|
|
34
34
|
"@progress/kendo-angular-grid": "16.2.0",
|
|
35
35
|
"@progress/kendo-angular-buttons": "16.2.0",
|