@memberjunction/ng-resource-permissions 5.22.0 → 5.24.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 +11 -5
- package/dist/lib/available-resources.component.d.ts.map +1 -1
- package/dist/lib/available-resources.component.js +73 -52
- package/dist/lib/available-resources.component.js.map +1 -1
- package/dist/lib/request-access.component.js +4 -4
- package/dist/lib/request-access.component.js.map +1 -1
- package/dist/lib/resource-permissions.component.js +23 -24
- package/dist/lib/resource-permissions.component.js.map +1 -1
- package/dist/module.d.ts +6 -12
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +13 -36
- package/dist/module.js.map +1 -1
- package/package.json +12 -17
|
@@ -3,8 +3,7 @@ import { EntityFieldInfo, UserInfo } from '@memberjunction/core';
|
|
|
3
3
|
import { MJResourcePermissionEntity } from '@memberjunction/core-entities';
|
|
4
4
|
import { ResourceData } from '@memberjunction/core-entities';
|
|
5
5
|
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
|
|
6
|
-
import {
|
|
7
|
-
import { GridComponent } from '@progress/kendo-angular-grid';
|
|
6
|
+
import { ColDef, GridReadyEvent, GetRowIdParams, RowSelectionOptions, SelectionChangedEvent, type Theme } from 'ag-grid-community';
|
|
8
7
|
import * as i0 from "@angular/core";
|
|
9
8
|
/**
|
|
10
9
|
* This component displays a list of available resources for a user for a specific Resource Type.
|
|
@@ -20,10 +19,15 @@ export declare class AvailableResourcesComponent extends BaseAngularComponent im
|
|
|
20
19
|
ExtraColumns: string;
|
|
21
20
|
SelectedResources: ResourceData[];
|
|
22
21
|
SelectionChanged: EventEmitter<ResourceData[]>;
|
|
23
|
-
gridRecordSelection: string[];
|
|
24
22
|
gridExtraColumns: EntityFieldInfo[];
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
ColumnDefs: ColDef[];
|
|
24
|
+
DefaultColDef: ColDef;
|
|
25
|
+
RowSelectionConfig: RowSelectionOptions;
|
|
26
|
+
GridTheme: Theme;
|
|
27
|
+
private gridApi;
|
|
28
|
+
getRowId: (params: GetRowIdParams<ResourceData>) => string;
|
|
29
|
+
onGridReady(event: GridReadyEvent): void;
|
|
30
|
+
onSelectionChange(event: SelectionChangedEvent): void;
|
|
27
31
|
resourcePermissions: MJResourcePermissionEntity[];
|
|
28
32
|
resources: ResourceData[];
|
|
29
33
|
ngAfterViewInit(): Promise<void>;
|
|
@@ -31,6 +35,8 @@ export declare class AvailableResourcesComponent extends BaseAngularComponent im
|
|
|
31
35
|
* This method will refresh the contents of the component based on the current state of the component.
|
|
32
36
|
*/
|
|
33
37
|
Refresh(): Promise<void>;
|
|
38
|
+
private buildColumnDefs;
|
|
39
|
+
private applyPreselection;
|
|
34
40
|
static ɵfac: i0.ɵɵFactoryDeclaration<AvailableResourcesComponent, never>;
|
|
35
41
|
static ɵcmp: i0.ɵɵComponentDeclaration<AvailableResourcesComponent, "mj-available-resources", never, { "User": { "alias": "User"; "required": false; }; "ResourceTypeID": { "alias": "ResourceTypeID"; "required": false; }; "ResourceExtraFilter": { "alias": "ResourceExtraFilter"; "required": false; }; "SelectionMode": { "alias": "SelectionMode"; "required": false; }; "ExtraColumns": { "alias": "ExtraColumns"; "required": false; }; "SelectedResources": { "alias": "SelectedResources"; "required": false; }; }, { "SelectionChanged": "SelectionChanged"; }, never, never, false, never>;
|
|
36
42
|
}
|
|
@@ -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,
|
|
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,EAAiB,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,eAAe,EAAW,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1E,O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, Input, Output
|
|
1
|
+
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
2
|
import { RunView } from '@memberjunction/core';
|
|
3
3
|
import { ResourcePermissionEngine } from '@memberjunction/core-entities';
|
|
4
4
|
import { UUIDsEqual } from '@memberjunction/global';
|
|
5
5
|
import { ResourceData } from '@memberjunction/core-entities';
|
|
6
6
|
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
|
|
7
|
+
import { ModuleRegistry, AllCommunityModule, themeAlpine, colorSchemeVariable } from 'ag-grid-community';
|
|
7
8
|
import * as i0 from "@angular/core";
|
|
8
|
-
import * as i1 from "
|
|
9
|
-
const _c0 = ["resourcesGrid"];
|
|
10
|
-
const _c1 = a0 => ({ mode: a0 });
|
|
11
|
-
function AvailableResourcesComponent_Conditional_1_For_4_ng_template_1_Template(rf, ctx) { if (rf & 1) {
|
|
12
|
-
i0.ɵɵtext(0);
|
|
13
|
-
} if (rf & 2) {
|
|
14
|
-
const dataItem_r3 = ctx.$implicit;
|
|
15
|
-
const col_r4 = i0.ɵɵnextContext().$implicit;
|
|
16
|
-
i0.ɵɵtextInterpolate1(" ", dataItem_r3.Configuration[col_r4.Name], " ");
|
|
17
|
-
} }
|
|
18
|
-
function AvailableResourcesComponent_Conditional_1_For_4_Template(rf, ctx) { if (rf & 1) {
|
|
19
|
-
i0.ɵɵelementStart(0, "kendo-grid-column", 5);
|
|
20
|
-
i0.ɵɵtemplate(1, AvailableResourcesComponent_Conditional_1_For_4_ng_template_1_Template, 1, 1, "ng-template", 6);
|
|
21
|
-
i0.ɵɵelementEnd();
|
|
22
|
-
} if (rf & 2) {
|
|
23
|
-
const col_r4 = ctx.$implicit;
|
|
24
|
-
i0.ɵɵproperty("title", col_r4.DisplayNameOrName);
|
|
25
|
-
} }
|
|
9
|
+
import * as i1 from "ag-grid-angular";
|
|
26
10
|
function AvailableResourcesComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
27
11
|
const _r1 = i0.ɵɵgetCurrentView();
|
|
28
|
-
i0.ɵɵelementStart(0, "
|
|
29
|
-
i0.ɵɵlistener("
|
|
30
|
-
i0.ɵɵtwoWayListener("selectedKeysChange", function AvailableResourcesComponent_Conditional_1_Template_kendo_grid_selectedKeysChange_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵtwoWayBindingSet(ctx_r1.gridRecordSelection, $event) || (ctx_r1.gridRecordSelection = $event); return i0.ɵɵresetView($event); });
|
|
31
|
-
i0.ɵɵelement(2, "kendo-grid-column", 4);
|
|
32
|
-
i0.ɵɵrepeaterCreate(3, AvailableResourcesComponent_Conditional_1_For_4_Template, 2, 1, "kendo-grid-column", 5, i0.ɵɵrepeaterTrackByIdentity);
|
|
12
|
+
i0.ɵɵelementStart(0, "ag-grid-angular", 2);
|
|
13
|
+
i0.ɵɵlistener("selectionChanged", function AvailableResourcesComponent_Conditional_1_Template_ag_grid_angular_selectionChanged_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onSelectionChange($event)); })("gridReady", function AvailableResourcesComponent_Conditional_1_Template_ag_grid_angular_gridReady_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onGridReady($event)); });
|
|
33
14
|
i0.ɵɵelementEnd();
|
|
34
15
|
} if (rf & 2) {
|
|
35
16
|
const ctx_r1 = i0.ɵɵnextContext();
|
|
36
|
-
i0.ɵɵproperty("
|
|
37
|
-
i0.ɵɵtwoWayProperty("selectedKeys", ctx_r1.gridRecordSelection);
|
|
38
|
-
i0.ɵɵadvance(2);
|
|
39
|
-
i0.ɵɵproperty("width", 225);
|
|
40
|
-
i0.ɵɵadvance();
|
|
41
|
-
i0.ɵɵrepeater(ctx_r1.gridExtraColumns);
|
|
17
|
+
i0.ɵɵproperty("theme", ctx_r1.GridTheme)("rowData", ctx_r1.resources)("columnDefs", ctx_r1.ColumnDefs)("defaultColDef", ctx_r1.DefaultColDef)("rowSelection", ctx_r1.RowSelectionConfig)("getRowId", ctx_r1.getRowId);
|
|
42
18
|
} }
|
|
19
|
+
// Register AG Grid modules
|
|
20
|
+
ModuleRegistry.registerModules([AllCommunityModule]);
|
|
43
21
|
/**
|
|
44
22
|
* This component displays a list of available resources for a user for a specific Resource Type.
|
|
45
23
|
*/
|
|
@@ -54,16 +32,33 @@ export class AvailableResourcesComponent extends BaseAngularComponent {
|
|
|
54
32
|
ExtraColumns = "";
|
|
55
33
|
SelectedResources = [];
|
|
56
34
|
SelectionChanged = new EventEmitter();
|
|
57
|
-
gridRecordSelection = [];
|
|
58
35
|
gridExtraColumns = [];
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
// AG Grid configuration
|
|
37
|
+
ColumnDefs = [];
|
|
38
|
+
DefaultColDef = {
|
|
39
|
+
sortable: true,
|
|
40
|
+
resizable: true,
|
|
41
|
+
filter: false
|
|
42
|
+
};
|
|
43
|
+
RowSelectionConfig = {
|
|
44
|
+
mode: 'singleRow',
|
|
45
|
+
checkboxes: false,
|
|
46
|
+
enableClickSelection: true
|
|
47
|
+
};
|
|
48
|
+
GridTheme = themeAlpine.withPart(colorSchemeVariable);
|
|
49
|
+
gridApi = null;
|
|
50
|
+
getRowId = (params) => {
|
|
51
|
+
return params.data.ResourceRecordID;
|
|
52
|
+
};
|
|
53
|
+
onGridReady(event) {
|
|
54
|
+
this.gridApi = event.api;
|
|
55
|
+
this.applyPreselection();
|
|
56
|
+
}
|
|
57
|
+
onSelectionChange(event) {
|
|
58
|
+
const selectedRows = event.api.getSelectedRows();
|
|
61
59
|
this.SelectedResources.splice(0, this.SelectedResources.length); // empty the array
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (resourceMatch) {
|
|
65
|
-
this.SelectedResources.push(resourceMatch);
|
|
66
|
-
}
|
|
60
|
+
selectedRows.forEach((item) => {
|
|
61
|
+
this.SelectedResources.push(item);
|
|
67
62
|
});
|
|
68
63
|
// now bubble up the event
|
|
69
64
|
this.SelectionChanged.emit(this.SelectedResources);
|
|
@@ -105,6 +100,8 @@ export class AvailableResourcesComponent extends BaseAngularComponent {
|
|
|
105
100
|
this.gridExtraColumns.push(field);
|
|
106
101
|
});
|
|
107
102
|
}
|
|
103
|
+
// Build column definitions after we know the extra columns
|
|
104
|
+
this.buildColumnDefs();
|
|
108
105
|
const extraFilter = this.ResourceExtraFilter ? ` AND (${this.ResourceExtraFilter})` : '';
|
|
109
106
|
const result = await rv.RunView({
|
|
110
107
|
EntityName: entity.Name,
|
|
@@ -123,26 +120,53 @@ export class AvailableResourcesComponent extends BaseAngularComponent {
|
|
|
123
120
|
Configuration: r // pass the whole resource record into configuration so it is accessible as desired
|
|
124
121
|
});
|
|
125
122
|
});
|
|
123
|
+
// Update selection mode based on input
|
|
124
|
+
this.RowSelectionConfig = {
|
|
125
|
+
mode: this.SelectionMode.toLowerCase() === 'single' ? 'singleRow' : 'multiRow',
|
|
126
|
+
checkboxes: false,
|
|
127
|
+
enableClickSelection: true
|
|
128
|
+
};
|
|
129
|
+
// Re-apply preselection after data loads
|
|
130
|
+
this.applyPreselection();
|
|
126
131
|
}
|
|
127
132
|
}
|
|
133
|
+
buildColumnDefs() {
|
|
134
|
+
const cols = [
|
|
135
|
+
{ field: 'Name', headerName: 'Name', width: 225 }
|
|
136
|
+
];
|
|
137
|
+
for (const col of this.gridExtraColumns) {
|
|
138
|
+
cols.push({
|
|
139
|
+
headerName: col.DisplayNameOrName,
|
|
140
|
+
valueGetter: (params) => {
|
|
141
|
+
return params.data?.Configuration?.[col.Name] ?? '';
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
this.ColumnDefs = cols;
|
|
146
|
+
}
|
|
147
|
+
applyPreselection() {
|
|
148
|
+
if (!this.gridApi || this.SelectedResources.length === 0)
|
|
149
|
+
return;
|
|
150
|
+
this.gridApi.forEachNode((node) => {
|
|
151
|
+
const isSelected = this.SelectedResources.some((r) => UUIDsEqual(r.ResourceRecordID, node.data?.ResourceRecordID));
|
|
152
|
+
if (isSelected) {
|
|
153
|
+
node.setSelected(true);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
128
157
|
static ɵfac = /*@__PURE__*/ (() => { let ɵAvailableResourcesComponent_BaseFactory; return function AvailableResourcesComponent_Factory(__ngFactoryType__) { return (ɵAvailableResourcesComponent_BaseFactory || (ɵAvailableResourcesComponent_BaseFactory = i0.ɵɵgetInheritedFactory(AvailableResourcesComponent)))(__ngFactoryType__ || AvailableResourcesComponent); }; })();
|
|
129
|
-
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AvailableResourcesComponent, selectors: [["mj-available-resources"]],
|
|
130
|
-
i0.ɵɵ
|
|
131
|
-
|
|
132
|
-
let _t;
|
|
133
|
-
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.resourcesGrid = _t.first);
|
|
134
|
-
} }, inputs: { User: "User", ResourceTypeID: "ResourceTypeID", ResourceExtraFilter: "ResourceExtraFilter", SelectionMode: "SelectionMode", ExtraColumns: "ExtraColumns", SelectedResources: "SelectedResources" }, outputs: { SelectionChanged: "SelectionChanged" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 1, consts: [["resourcesGrid", ""], [1, "container"], ["kendoGridSelectBy", "ResourceRecordID", 2, "width", "100%", "max-height", "400px", 3, "data", "selectable", "selectedKeys"], ["kendoGridSelectBy", "ResourceRecordID", 2, "width", "100%", "max-height", "400px", 3, "selectionChange", "selectedKeysChange", "data", "selectable", "selectedKeys"], ["field", "Name", "title", "Name", 3, "width"], [3, "title"], ["kendoGridCellTemplate", ""]], template: function AvailableResourcesComponent_Template(rf, ctx) { if (rf & 1) {
|
|
135
|
-
i0.ɵɵelementStart(0, "div", 1);
|
|
136
|
-
i0.ɵɵconditionalCreate(1, AvailableResourcesComponent_Conditional_1_Template, 5, 6, "kendo-grid", 2);
|
|
158
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AvailableResourcesComponent, selectors: [["mj-available-resources"]], inputs: { User: "User", ResourceTypeID: "ResourceTypeID", ResourceExtraFilter: "ResourceExtraFilter", SelectionMode: "SelectionMode", ExtraColumns: "ExtraColumns", SelectedResources: "SelectedResources" }, outputs: { SelectionChanged: "SelectionChanged" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 1, consts: [[1, "container"], [1, "resources-grid", 2, "width", "100%", "height", "400px", 3, "theme", "rowData", "columnDefs", "defaultColDef", "rowSelection", "getRowId"], [1, "resources-grid", 2, "width", "100%", "height", "400px", 3, "selectionChanged", "gridReady", "theme", "rowData", "columnDefs", "defaultColDef", "rowSelection", "getRowId"]], template: function AvailableResourcesComponent_Template(rf, ctx) { if (rf & 1) {
|
|
159
|
+
i0.ɵɵelementStart(0, "div", 0);
|
|
160
|
+
i0.ɵɵconditionalCreate(1, AvailableResourcesComponent_Conditional_1_Template, 1, 6, "ag-grid-angular", 1);
|
|
137
161
|
i0.ɵɵelementEnd();
|
|
138
162
|
} if (rf & 2) {
|
|
139
163
|
i0.ɵɵadvance();
|
|
140
164
|
i0.ɵɵconditional(ctx.User ? 1 : -1);
|
|
141
|
-
} }, dependencies: [i1.
|
|
165
|
+
} }, dependencies: [i1.AgGridAngular], styles: ["\n\n.container[_ngcontent-%COMP%] {\n max-width: 100%;\n background: var(--mj-bg-surface);\n color: var(--mj-text-primary);\n}\n\nh3[_ngcontent-%COMP%] {\n margin-bottom: var(--mj-space-4);\n font-size: var(--mj-text-2xl);\n color: var(--mj-text-primary);\n}\n\n\n\n.resources-grid[_ngcontent-%COMP%] {\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n box-shadow: var(--mj-shadow-sm);\n}"] });
|
|
142
166
|
}
|
|
143
167
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AvailableResourcesComponent, [{
|
|
144
168
|
type: Component,
|
|
145
|
-
args: [{ standalone: false, selector: 'mj-available-resources', template: "<div class=\"container\">\n @if (User) {\n <
|
|
169
|
+
args: [{ standalone: false, selector: 'mj-available-resources', template: "<div class=\"container\">\n @if (User) {\n <ag-grid-angular\n class=\"resources-grid\"\n [theme]=\"GridTheme\"\n [rowData]=\"resources\"\n [columnDefs]=\"ColumnDefs\"\n [defaultColDef]=\"DefaultColDef\"\n [rowSelection]=\"RowSelectionConfig\"\n [getRowId]=\"getRowId\"\n (selectionChanged)=\"onSelectionChange($event)\"\n (gridReady)=\"onGridReady($event)\"\n style=\"width: 100%; height: 400px;\">\n </ag-grid-angular>\n }\n </div>\n", styles: ["/* Container styling */\n.container {\n max-width: 100%;\n background: var(--mj-bg-surface);\n color: var(--mj-text-primary);\n}\n\nh3 {\n margin-bottom: var(--mj-space-4);\n font-size: var(--mj-text-2xl);\n color: var(--mj-text-primary);\n}\n\n/* AG Grid wrapper */\n.resources-grid {\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n box-shadow: var(--mj-shadow-sm);\n}\n"] }]
|
|
146
170
|
}], null, { User: [{
|
|
147
171
|
type: Input
|
|
148
172
|
}], ResourceTypeID: [{
|
|
@@ -157,9 +181,6 @@ export class AvailableResourcesComponent extends BaseAngularComponent {
|
|
|
157
181
|
type: Input
|
|
158
182
|
}], SelectionChanged: [{
|
|
159
183
|
type: Output
|
|
160
|
-
}], resourcesGrid: [{
|
|
161
|
-
type: ViewChild,
|
|
162
|
-
args: ['resourcesGrid']
|
|
163
184
|
}] }); })();
|
|
164
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AvailableResourcesComponent, { className: "AvailableResourcesComponent", filePath: "src/lib/available-resources.component.ts", lineNumber:
|
|
185
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AvailableResourcesComponent, { className: "AvailableResourcesComponent", filePath: "src/lib/available-resources.component.ts", lineNumber: 33 }); })();
|
|
165
186
|
//# 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,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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AAwB;;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 { 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
|
+
{"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,MAAM,eAAe,CAAC;AACtF,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;AACrE,OAAO,EAKL,cAAc,EACd,kBAAkB,EAGlB,WAAW,EACX,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;;;;;IChBnB,0CAUwC;IADpC,AADA,oOAAoB,gCAAyB,KAAC,yMACjC,0BAAmB,KAAC;IAErC,iBAAkB;;;IAJd,AADA,AADA,AADA,AADA,AADA,wCAAmB,6BACE,iCACI,uCACM,2CACI,6BACd;;ADWjC,2BAA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AAC;gBACN,UAAU,EAAE,GAAG,CAAC,iBAAiB;gBACjC,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE;oBACpB,OAAO,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACxD,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC3B,CAAC;IAEO,iBAAiB;QACrB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,iBAAiB,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACjE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAC1C,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,CACrE,CAAC;YACF,IAAI,UAAU,EAAE,CAAC;gBACb,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;yRA1JQ,2BAA2B,yBAA3B,2BAA2B;6DAA3B,2BAA2B;YChCxC,8BAAuB;YACnB,yGAAY;YAcd,iBAAM;;YAdJ,cAaC;YAbD,mCAaC;;;iFDkBQ,2BAA2B;cANvC,SAAS;6BACI,KAAK,YACP,wBAAwB;;kBAK/B,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBAKL,KAAK;;kBAEL,KAAK;;kBACL,MAAM;;kFAZE,2BAA2B","sourcesContent":["import { AfterViewInit, Component, EventEmitter, Input, Output } 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 {\n ColDef,\n GridReadyEvent,\n GridApi,\n GetRowIdParams,\n ModuleRegistry,\n AllCommunityModule,\n RowSelectionOptions,\n SelectionChangedEvent,\n themeAlpine,\n colorSchemeVariable,\n type Theme\n} from 'ag-grid-community';\n\n// Register AG Grid modules\nModuleRegistry.registerModules([AllCommunityModule]);\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 gridExtraColumns: EntityFieldInfo[] = [];\n\n // AG Grid configuration\n public ColumnDefs: ColDef[] = [];\n public DefaultColDef: ColDef = {\n sortable: true,\n resizable: true,\n filter: false\n };\n public RowSelectionConfig: RowSelectionOptions = {\n mode: 'singleRow',\n checkboxes: false,\n enableClickSelection: true\n };\n public GridTheme: Theme = themeAlpine.withPart(colorSchemeVariable);\n private gridApi: GridApi | null = null;\n\n public getRowId = (params: GetRowIdParams<ResourceData>): string => {\n return params.data.ResourceRecordID;\n };\n\n public onGridReady(event: GridReadyEvent): void {\n this.gridApi = event.api;\n this.applyPreselection();\n }\n\n public onSelectionChange(event: SelectionChangedEvent): void {\n const selectedRows = event.api.getSelectedRows() as ResourceData[];\n this.SelectedResources.splice(0, this.SelectedResources.length); // empty the array\n selectedRows.forEach((item) => {\n this.SelectedResources.push(item);\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 // Build column definitions after we know the extra columns\n this.buildColumnDefs();\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 // Update selection mode based on input\n this.RowSelectionConfig = {\n mode: this.SelectionMode.toLowerCase() === 'single' ? 'singleRow' : 'multiRow',\n checkboxes: false,\n enableClickSelection: true\n };\n\n // Re-apply preselection after data loads\n this.applyPreselection();\n }\n }\n\n private buildColumnDefs(): void {\n const cols: ColDef[] = [\n { field: 'Name', headerName: 'Name', width: 225 }\n ];\n\n for (const col of this.gridExtraColumns) {\n cols.push({\n headerName: col.DisplayNameOrName,\n valueGetter: (params) => {\n return params.data?.Configuration?.[col.Name] ?? '';\n }\n });\n }\n\n this.ColumnDefs = cols;\n }\n\n private applyPreselection(): void {\n if (!this.gridApi || this.SelectedResources.length === 0) return;\n this.gridApi.forEachNode((node) => {\n const isSelected = this.SelectedResources.some(\n (r) => UUIDsEqual(r.ResourceRecordID, node.data?.ResourceRecordID)\n );\n if (isSelected) {\n node.setSelected(true);\n }\n });\n }\n}\n","<div class=\"container\">\n @if (User) {\n <ag-grid-angular\n class=\"resources-grid\"\n [theme]=\"GridTheme\"\n [rowData]=\"resources\"\n [columnDefs]=\"ColumnDefs\"\n [defaultColDef]=\"DefaultColDef\"\n [rowSelection]=\"RowSelectionConfig\"\n [getRowId]=\"getRowId\"\n (selectionChanged)=\"onSelectionChange($event)\"\n (gridReady)=\"onGridReady($event)\"\n style=\"width: 100%; height: 400px;\">\n </ag-grid-angular>\n }\n </div>\n"]}
|
|
@@ -5,7 +5,7 @@ import { BaseAngularComponent } from '@memberjunction/ng-base-types';
|
|
|
5
5
|
import { MJNotificationService } from '@memberjunction/ng-notifications';
|
|
6
6
|
import * as i0 from "@angular/core";
|
|
7
7
|
import * as i1 from "@angular/forms";
|
|
8
|
-
import * as i2 from "@
|
|
8
|
+
import * as i2 from "@memberjunction/ng-ui-components";
|
|
9
9
|
function RequestResourceAccessComponent_Conditional_8_Template(rf, ctx) { if (rf & 1) {
|
|
10
10
|
i0.ɵɵelementStart(0, "p");
|
|
11
11
|
i0.ɵɵtext(1, " You do not have access to this resource. Click the button below to request access.");
|
|
@@ -107,7 +107,7 @@ export class RequestResourceAccessComponent extends BaseAngularComponent {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
static ɵfac = /*@__PURE__*/ (() => { let ɵRequestResourceAccessComponent_BaseFactory; return function RequestResourceAccessComponent_Factory(__ngFactoryType__) { return (ɵRequestResourceAccessComponent_BaseFactory || (ɵRequestResourceAccessComponent_BaseFactory = i0.ɵɵgetInheritedFactory(RequestResourceAccessComponent)))(__ngFactoryType__ || RequestResourceAccessComponent); }; })();
|
|
110
|
-
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RequestResourceAccessComponent, selectors: [["mj-request-resource-access"]], inputs: { ResourceType: "ResourceType", ResourceName: "ResourceName", ResourceRecordID: "ResourceRecordID", PermissionLevel: "PermissionLevel", ShowPermissionLevelDropdown: "ShowPermissionLevelDropdown" }, outputs: { AccessRequested: "AccessRequested" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 12, vars: 5, consts: [[1, "request-access-container"], [1, "request-icon"], [1, "fas", "fa-lock"], [1, "request-info"], [1, "request-actions"], ["for", "permissionLevel"], [3, "ngModelChange", "ngModel"], ["value", "View"], ["value", "Edit"], ["value", "Owner"], ["
|
|
110
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RequestResourceAccessComponent, selectors: [["mj-request-resource-access"]], inputs: { ResourceType: "ResourceType", ResourceName: "ResourceName", ResourceRecordID: "ResourceRecordID", PermissionLevel: "PermissionLevel", ShowPermissionLevelDropdown: "ShowPermissionLevelDropdown" }, outputs: { AccessRequested: "AccessRequested" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 12, vars: 5, consts: [[1, "request-access-container"], [1, "request-icon"], [1, "fas", "fa-lock"], [1, "request-info"], [1, "request-actions"], ["for", "permissionLevel"], [3, "ngModelChange", "ngModel"], ["value", "View"], ["value", "Edit"], ["value", "Owner"], ["mjButton", "", 1, "request-button", 3, "click"], [1, "fas", "fa-paper-plane"]], template: function RequestResourceAccessComponent_Template(rf, ctx) { if (rf & 1) {
|
|
111
111
|
i0.ɵɵelementStart(0, "div", 0)(1, "div", 1);
|
|
112
112
|
i0.ɵɵelement(2, "i", 2);
|
|
113
113
|
i0.ɵɵelementEnd();
|
|
@@ -131,11 +131,11 @@ export class RequestResourceAccessComponent extends BaseAngularComponent {
|
|
|
131
131
|
i0.ɵɵconditional(ctx.ShowPermissionLevelDropdown && !ctx.AfterRequest ? 10 : -1);
|
|
132
132
|
i0.ɵɵadvance();
|
|
133
133
|
i0.ɵɵconditional(!ctx.AfterRequest ? 11 : -1);
|
|
134
|
-
} }, dependencies: [i1.NgSelectOption, i1.ɵNgSelectMultipleOption, i1.SelectControlValueAccessor, i1.NgControlStatus, i1.NgModel, i2.
|
|
134
|
+
} }, dependencies: [i1.NgSelectOption, i1.ɵNgSelectMultipleOption, i1.SelectControlValueAccessor, i1.NgControlStatus, i1.NgModel, i2.MJButtonDirective], styles: [".request-access-container[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: var(--mj-space-5);\n background-color: var(--mj-bg-surface);\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n max-width: 400px;\n margin: var(--mj-space-2-5);\n box-shadow: var(--mj-shadow-sm);\n}\n\n.request-icon[_ngcontent-%COMP%] {\n font-size: 48px;\n \n\n color: var(--mj-status-warning);\n margin-bottom: var(--mj-space-2-5);\n}\n\n.request-info[_ngcontent-%COMP%] {\n text-align: center;\n margin-bottom: var(--mj-space-5);\n}\n\n.request-info[_ngcontent-%COMP%] h3[_ngcontent-%COMP%] {\n font-size: var(--mj-text-2xl);\n margin: 0;\n color: var(--mj-text-primary);\n}\n\n.request-info[_ngcontent-%COMP%] p[_ngcontent-%COMP%] {\n font-size: var(--mj-text-base);\n color: var(--mj-text-secondary);\n margin-top: var(--mj-space-2);\n}\n\n.request-actions[_ngcontent-%COMP%] {\n display: flex;\n justify-content: center;\n}\n\n.request-button[_ngcontent-%COMP%] {\n display: flex;\n align-items: center;\n background-color: var(--mj-status-success);\n color: var(--mj-text-inverse);\n padding: var(--mj-space-2-5) var(--mj-space-5);\n border: none;\n border-radius: var(--mj-radius-sm);\n font-size: var(--mj-text-base);\n cursor: pointer;\n transition: var(--mj-transition-base);\n font-family: var(--mj-font-family);\n}\n\n.request-button[_ngcontent-%COMP%]:hover {\n background-color: var(--mj-status-success-text);\n}\n\n.request-button[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n margin-right: var(--mj-space-2);\n}\n\n@media (max-width: 600px) {\n .request-access-container[_ngcontent-%COMP%] {\n padding: var(--mj-space-4);\n max-width: 90%;\n }\n\n .request-info[_ngcontent-%COMP%] h3[_ngcontent-%COMP%] {\n font-size: var(--mj-text-xl);\n }\n\n .request-info[_ngcontent-%COMP%] p[_ngcontent-%COMP%] {\n font-size: var(--mj-text-sm);\n }\n\n .request-button[_ngcontent-%COMP%] {\n font-size: var(--mj-text-sm);\n padding: var(--mj-space-2) var(--mj-space-4);\n }\n}"] });
|
|
135
135
|
}
|
|
136
136
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RequestResourceAccessComponent, [{
|
|
137
137
|
type: Component,
|
|
138
|
-
args: [{ standalone: false, selector: 'mj-request-resource-access', template: "<div class=\"request-access-container\">\n <div class=\"request-icon\">\n <i class=\"fas fa-lock\"></i>\n </div>\n <div class=\"request-info\">\n <h3>Request Access</h3>\n <h5>{{ResourceType ? ResourceType : 'Resource'}}{{ResourceName ? ': ' + ResourceName : ''}}</h5>\n @if (!AfterRequest){\n <p> You do not have access to this resource. Click the button below to request access.</p>\n }\n @else {\n <h3>Your request has been submitted</h3>\n <p> You will be notified when your request has been processed.</p>\n }\n @if(ShowPermissionLevelDropdown && !AfterRequest) {\n <span>\n <label for=\"permissionLevel\">Permission Level:</label>\n <select [(ngModel)] = \"PermissionLevel\">\n <option value=\"View\">View</option>\n <option value=\"Edit\">Edit</option>\n <option value=\"Owner\">Owner</option> \n </select>\n </span> \n }\n </div>\n @if (!AfterRequest) {\n <div class=\"request-actions\">\n <button
|
|
138
|
+
args: [{ standalone: false, selector: 'mj-request-resource-access', template: "<div class=\"request-access-container\">\n <div class=\"request-icon\">\n <i class=\"fas fa-lock\"></i>\n </div>\n <div class=\"request-info\">\n <h3>Request Access</h3>\n <h5>{{ResourceType ? ResourceType : 'Resource'}}{{ResourceName ? ': ' + ResourceName : ''}}</h5>\n @if (!AfterRequest){\n <p> You do not have access to this resource. Click the button below to request access.</p>\n }\n @else {\n <h3>Your request has been submitted</h3>\n <p> You will be notified when your request has been processed.</p>\n }\n @if(ShowPermissionLevelDropdown && !AfterRequest) {\n <span>\n <label for=\"permissionLevel\">Permission Level:</label>\n <select [(ngModel)] = \"PermissionLevel\">\n <option value=\"View\">View</option>\n <option value=\"Edit\">Edit</option>\n <option value=\"Owner\">Owner</option> \n </select>\n </span> \n }\n </div>\n @if (!AfterRequest) {\n <div class=\"request-actions\">\n <button mjButton class=\"request-button\" (click)=\"requestAccess()\">\n <i class=\"fas fa-paper-plane\"></i> Request Access\n </button>\n </div> \n }\n</div>\n", styles: [".request-access-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: var(--mj-space-5);\n background-color: var(--mj-bg-surface);\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n max-width: 400px;\n margin: var(--mj-space-2-5);\n box-shadow: var(--mj-shadow-sm);\n}\n\n.request-icon {\n font-size: 48px;\n /* Consider a token for icon size if available, or keep generic */\n color: var(--mj-status-warning);\n margin-bottom: var(--mj-space-2-5);\n}\n\n.request-info {\n text-align: center;\n margin-bottom: var(--mj-space-5);\n}\n\n.request-info h3 {\n font-size: var(--mj-text-2xl);\n margin: 0;\n color: var(--mj-text-primary);\n}\n\n.request-info p {\n font-size: var(--mj-text-base);\n color: var(--mj-text-secondary);\n margin-top: var(--mj-space-2);\n}\n\n.request-actions {\n display: flex;\n justify-content: center;\n}\n\n.request-button {\n display: flex;\n align-items: center;\n background-color: var(--mj-status-success);\n color: var(--mj-text-inverse);\n padding: var(--mj-space-2-5) var(--mj-space-5);\n border: none;\n border-radius: var(--mj-radius-sm);\n font-size: var(--mj-text-base);\n cursor: pointer;\n transition: var(--mj-transition-base);\n font-family: var(--mj-font-family);\n}\n\n.request-button:hover {\n background-color: var(--mj-status-success-text);\n}\n\n.request-button i {\n margin-right: var(--mj-space-2);\n}\n\n@media (max-width: 600px) {\n .request-access-container {\n padding: var(--mj-space-4);\n max-width: 90%;\n }\n\n .request-info h3 {\n font-size: var(--mj-text-xl);\n }\n\n .request-info p {\n font-size: var(--mj-text-sm);\n }\n\n .request-button {\n font-size: var(--mj-text-sm);\n padding: var(--mj-space-2) var(--mj-space-4);\n }\n}"] }]
|
|
139
139
|
}], null, { ResourceType: [{
|
|
140
140
|
type: Input
|
|
141
141
|
}], ResourceName: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-access.component.js","sourceRoot":"","sources":["../../src/lib/request-access.component.ts","../../src/lib/request-access.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAU,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAoD,MAAM,+BAA+B,CAAC;AAC3H,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;;;;;ICIjE,yBAAG;IAAC,mGAAkF;IAAA,iBAAI;;;IAG1F,0BAAI;IAAA,+CAA+B;IAAA,iBAAK;IACxC,yBAAG;IAAC,2EAA0D;IAAA,iBAAI;;;;IAI9D,AADJ,4BAAM,eAC2B;IAAA,iCAAiB;IAAA,iBAAQ;IACtD,iCAAwC;IAAhC,sUAA+B;IACnC,iCAAqB;IAAA,oBAAI;IAAA,iBAAS;IAClC,iCAAqB;IAAA,oBAAI;IAAA,iBAAS;IAClC,iCAAsB;IAAA,qBAAK;IAEnC,AADI,AAD+B,iBAAS,EAC/B,EACN;;;IALK,eAA+B;IAA/B,sDAA+B;;;;IAUvC,AADJ,8BAA6B,
|
|
1
|
+
{"version":3,"file":"request-access.component.js","sourceRoot":"","sources":["../../src/lib/request-access.component.ts","../../src/lib/request-access.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAU,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAoD,MAAM,+BAA+B,CAAC;AAC3H,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;;;;;ICIjE,yBAAG;IAAC,mGAAkF;IAAA,iBAAI;;;IAG1F,0BAAI;IAAA,+CAA+B;IAAA,iBAAK;IACxC,yBAAG;IAAC,2EAA0D;IAAA,iBAAI;;;;IAI9D,AADJ,4BAAM,eAC2B;IAAA,iCAAiB;IAAA,iBAAQ;IACtD,iCAAwC;IAAhC,sUAA+B;IACnC,iCAAqB;IAAA,oBAAI;IAAA,iBAAS;IAClC,iCAAqB;IAAA,oBAAI;IAAA,iBAAS;IAClC,iCAAsB;IAAA,qBAAK;IAEnC,AADI,AAD+B,iBAAS,EAC/B,EACN;;;IALK,eAA+B;IAA/B,sDAA+B;;;;IAUvC,AADJ,8BAA6B,iBACyC;IAA1B,mMAAS,sBAAe,KAAC;IAC/D,wBAAkC;IAAC,gCACrC;IACJ,AADI,iBAAS,EACP;;ADx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AAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAClD,IAAI,MAAM,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1B,2BAA2B;YAC3B,qIAAqI;YACrI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACtC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC7B,CAAC;aACI,CAAC;YACF,QAAQ;YACR,QAAQ,CAAC,+BAA+B,IAAI,CAAC,YAAY,WAAW,IAAI,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;YACjI,qBAAqB,CAAC,QAAQ,CAAC,wBAAwB,CAAC,+BAA+B,IAAI,CAAC,YAAY,WAAW,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,gBAAgB,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACtL,CAAC;IACL,CAAC;qSA7DQ,8BAA8B,yBAA9B,8BAA8B;6DAA9B,8BAA8B;YCdvC,AADJ,8BAAsC,aACR;YACxB,uBAA2B;YAC7B,iBAAM;YAEJ,AADF,8BAA0B,SACpB;YAAA,8BAAc;YAAA,iBAAK;YACvB,0BAAI;YAAA,YAAuF;YAAA,iBAAK;YAIhG,AAHA,2FAAoB,gEAGb;YAIP,iGAAmD;YAUrD,iBAAM;YACN,kGAAqB;YAOzB,iBAAM;;YA1BI,eAAuF;YAAvF,gIAAuF;YAC3F,cAMC;YAND,2CAMC;YACD,eASC;YATD,gFASC;YAEH,cAMC;YAND,6CAMC;;;iFDhBQ,8BAA8B;cAN1C,SAAS;6BACI,KAAK,YACP,4BAA4B;;kBAQnC,KAAK;;kBAKL,KAAK;;kBAIL,KAAK;;kBAKL,KAAK;;kBAKL,KAAK;;kBAEL,MAAM;;kFAzBE,8BAA8B","sourcesContent":["import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';\nimport { LogError, Metadata } from '@memberjunction/core';\nimport { ResourcePermissionEngine, MJResourcePermissionEntity, MJResourceTypeEntity } from '@memberjunction/core-entities';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { MJNotificationService } from '@memberjunction/ng-notifications';\n\n/**\n * Use this component to display to the user the ability to request access to a resource they do not own and do not currently have permission to access\n */\n@Component({\n standalone: false,\n selector: 'mj-request-resource-access',\n templateUrl: './request-access.component.html',\n styleUrls: ['./request-access.component.css']\n})\nexport class RequestResourceAccessComponent extends BaseAngularComponent implements OnInit {\n /**\n * The name of the resource type that the user is requesting access to\n */\n @Input() ResourceType!: string;\n\n /**\n * Optional, the name of the resource that the user is requesting access to that will be displayed to the user\n */\n @Input() ResourceName: string=\"\";\n /**\n * The resource record ID that the user is requesting access to\n */\n @Input() ResourceRecordID!: string;\n\n /** \n * The default value for the permission level\n */\n @Input() PermissionLevel: 'View' | 'Edit' | 'Owner' = 'View';\n\n /**\n * Turn this off to not show the user the permission level drop down which would result in the default value for the PermissionLevel being requested.\n */\n @Input() ShowPermissionLevelDropdown: boolean = true;\n\n @Output() AccessRequested = new EventEmitter<MJResourcePermissionEntity>();\n\n /**\n * The resource type object that the user is requesting access to for all info on the resource type\n */\n public ResourceTypeObject!: MJResourceTypeEntity;\n public AfterRequest: boolean = false;\n\n async ngOnInit() {\n const rt = ResourcePermissionEngine.Instance.ResourceTypes.find(x => x.Name.trim().toLowerCase() === this.ResourceType.trim().toLowerCase()); \n if (rt) \n this.ResourceTypeObject = rt;\n else\n throw new Error(`Resource Type ${this.ResourceType} not found`);\n }\n\n public async requestAccess() {\n const p = this.ProviderToUse;\n const permission = await p.GetEntityObject<MJResourcePermissionEntity>(\"MJ: Resource Permissions\", p.CurrentUser);\n permission.ResourceTypeID = this.ResourceTypeObject.ID;\n permission.ResourceRecordID = this.ResourceRecordID;\n permission.Status = 'Requested';\n permission.Type = 'User';\n permission.UserID = p.CurrentUser.ID; \n permission.PermissionLevel = this.PermissionLevel;\n if (await permission.Save()) {\n // worked, fire the event. \n // NOTE - the notification creatd to notify the resource owner happens in the MJResourcePermissionEntity sub-class not here in the UI\n this.AccessRequested.emit(permission);\n this.AfterRequest = true;\n }\n else {\n //failed\n LogError(`Failed to request access to ${this.ResourceType} record ${this.ResourceRecordID}`, undefined, permission.LatestResult);\n MJNotificationService.Instance.CreateSimpleNotification(`Failed to request access to ${this.ResourceType} record ${this.ResourceName} (${this.ResourceRecordID})`, 'error', 5000);\n }\n }\n}","<div class=\"request-access-container\">\n <div class=\"request-icon\">\n <i class=\"fas fa-lock\"></i>\n </div>\n <div class=\"request-info\">\n <h3>Request Access</h3>\n <h5>{{ResourceType ? ResourceType : 'Resource'}}{{ResourceName ? ': ' + ResourceName : ''}}</h5>\n @if (!AfterRequest){\n <p> You do not have access to this resource. Click the button below to request access.</p>\n }\n @else {\n <h3>Your request has been submitted</h3>\n <p> You will be notified when your request has been processed.</p>\n }\n @if(ShowPermissionLevelDropdown && !AfterRequest) {\n <span>\n <label for=\"permissionLevel\">Permission Level:</label>\n <select [(ngModel)] = \"PermissionLevel\">\n <option value=\"View\">View</option>\n <option value=\"Edit\">Edit</option>\n <option value=\"Owner\">Owner</option> \n </select>\n </span> \n }\n </div>\n @if (!AfterRequest) {\n <div class=\"request-actions\">\n <button mjButton class=\"request-button\" (click)=\"requestAccess()\">\n <i class=\"fas fa-paper-plane\"></i> Request Access\n </button>\n </div> \n }\n</div>\n"]}
|
|
@@ -6,9 +6,8 @@ import { BaseAngularComponent } from '@memberjunction/ng-base-types';
|
|
|
6
6
|
import { MJNotificationService } from '@memberjunction/ng-notifications';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
import * as i1 from "@angular/forms";
|
|
9
|
-
import * as i2 from "@
|
|
10
|
-
import * as i3 from "@
|
|
11
|
-
import * as i4 from "@memberjunction/ng-shared-generic";
|
|
9
|
+
import * as i2 from "@memberjunction/ng-shared-generic";
|
|
10
|
+
import * as i3 from "@memberjunction/ng-ui-components";
|
|
12
11
|
function ResourcePermissionsComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
13
12
|
i0.ɵɵelement(0, "mj-loading", 1);
|
|
14
13
|
} if (rf & 2) {
|
|
@@ -23,22 +22,22 @@ function ResourcePermissionsComponent_Conditional_2_Template(rf, ctx) { if (rf &
|
|
|
23
22
|
} }
|
|
24
23
|
function ResourcePermissionsComponent_Conditional_4_Conditional_4_Template(rf, ctx) { if (rf & 1) {
|
|
25
24
|
const _r4 = i0.ɵɵgetCurrentView();
|
|
26
|
-
i0.ɵɵelementStart(0, "
|
|
27
|
-
i0.ɵɵtwoWayListener("ngModelChange", function
|
|
25
|
+
i0.ɵɵelementStart(0, "mj-dropdown", 13);
|
|
26
|
+
i0.ɵɵtwoWayListener("ngModelChange", function ResourcePermissionsComponent_Conditional_4_Conditional_4_Template_mj_dropdown_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); i0.ɵɵtwoWayBindingSet(ctx_r1.SelectedUser, $event) || (ctx_r1.SelectedUser = $event); return i0.ɵɵresetView($event); });
|
|
28
27
|
i0.ɵɵelementEnd();
|
|
29
28
|
} if (rf & 2) {
|
|
30
29
|
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
31
|
-
i0.ɵɵproperty("
|
|
30
|
+
i0.ɵɵproperty("Data", ctx_r1.AllUsers);
|
|
32
31
|
i0.ɵɵtwoWayProperty("ngModel", ctx_r1.SelectedUser);
|
|
33
32
|
} }
|
|
34
33
|
function ResourcePermissionsComponent_Conditional_4_Conditional_5_Template(rf, ctx) { if (rf & 1) {
|
|
35
34
|
const _r5 = i0.ɵɵgetCurrentView();
|
|
36
|
-
i0.ɵɵelementStart(0, "
|
|
37
|
-
i0.ɵɵtwoWayListener("ngModelChange", function
|
|
35
|
+
i0.ɵɵelementStart(0, "mj-dropdown", 14);
|
|
36
|
+
i0.ɵɵtwoWayListener("ngModelChange", function ResourcePermissionsComponent_Conditional_4_Conditional_5_Template_mj_dropdown_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(2); i0.ɵɵtwoWayBindingSet(ctx_r1.SelectedRole, $event) || (ctx_r1.SelectedRole = $event); return i0.ɵɵresetView($event); });
|
|
38
37
|
i0.ɵɵelementEnd();
|
|
39
38
|
} if (rf & 2) {
|
|
40
39
|
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
41
|
-
i0.ɵɵproperty("
|
|
40
|
+
i0.ɵɵproperty("Data", ctx_r1.AllRoles);
|
|
42
41
|
i0.ɵɵtwoWayProperty("ngModel", ctx_r1.SelectedRole);
|
|
43
42
|
} }
|
|
44
43
|
function ResourcePermissionsComponent_Conditional_4_Conditional_6_Template(rf, ctx) { if (rf & 1) {
|
|
@@ -49,12 +48,12 @@ function ResourcePermissionsComponent_Conditional_4_Conditional_6_Template(rf, c
|
|
|
49
48
|
} }
|
|
50
49
|
function ResourcePermissionsComponent_Conditional_4_Conditional_7_Template(rf, ctx) { if (rf & 1) {
|
|
51
50
|
const _r6 = i0.ɵɵgetCurrentView();
|
|
52
|
-
i0.ɵɵelementStart(0, "
|
|
53
|
-
i0.ɵɵtwoWayListener("ngModelChange", function
|
|
51
|
+
i0.ɵɵelementStart(0, "mj-dropdown", 8);
|
|
52
|
+
i0.ɵɵtwoWayListener("ngModelChange", function ResourcePermissionsComponent_Conditional_4_Conditional_7_Template_mj_dropdown_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(2); i0.ɵɵtwoWayBindingSet(ctx_r1.SelectedPermissionLevel, $event) || (ctx_r1.SelectedPermissionLevel = $event); return i0.ɵɵresetView($event); });
|
|
54
53
|
i0.ɵɵelementEnd();
|
|
55
54
|
} if (rf & 2) {
|
|
56
55
|
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
57
|
-
i0.ɵɵproperty("
|
|
56
|
+
i0.ɵɵproperty("Data", ctx_r1.PermissionLevels);
|
|
58
57
|
i0.ɵɵtwoWayProperty("ngModel", ctx_r1.SelectedPermissionLevel);
|
|
59
58
|
} }
|
|
60
59
|
function ResourcePermissionsComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
|
|
@@ -62,11 +61,11 @@ function ResourcePermissionsComponent_Conditional_4_Template(rf, ctx) { if (rf &
|
|
|
62
61
|
i0.ɵɵelementStart(0, "div", 4)(1, "span", 7);
|
|
63
62
|
i0.ɵɵtext(2, "Add Permission");
|
|
64
63
|
i0.ɵɵelementEnd();
|
|
65
|
-
i0.ɵɵelementStart(3, "
|
|
66
|
-
i0.ɵɵtwoWayListener("ngModelChange", function
|
|
64
|
+
i0.ɵɵelementStart(3, "mj-dropdown", 8);
|
|
65
|
+
i0.ɵɵtwoWayListener("ngModelChange", function ResourcePermissionsComponent_Conditional_4_Template_mj_dropdown_ngModelChange_3_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵtwoWayBindingSet(ctx_r1.SelectedType, $event) || (ctx_r1.SelectedType = $event); return i0.ɵɵresetView($event); });
|
|
67
66
|
i0.ɵɵelementEnd();
|
|
68
|
-
i0.ɵɵconditionalCreate(4, ResourcePermissionsComponent_Conditional_4_Conditional_4_Template, 1, 2, "
|
|
69
|
-
i0.ɵɵconditionalCreate(7, ResourcePermissionsComponent_Conditional_4_Conditional_7_Template, 1, 2, "
|
|
67
|
+
i0.ɵɵconditionalCreate(4, ResourcePermissionsComponent_Conditional_4_Conditional_4_Template, 1, 2, "mj-dropdown", 9)(5, ResourcePermissionsComponent_Conditional_4_Conditional_5_Template, 1, 2, "mj-dropdown", 10)(6, ResourcePermissionsComponent_Conditional_4_Conditional_6_Template, 1, 1);
|
|
68
|
+
i0.ɵɵconditionalCreate(7, ResourcePermissionsComponent_Conditional_4_Conditional_7_Template, 1, 2, "mj-dropdown", 11);
|
|
70
69
|
i0.ɵɵelementStart(8, "button", 12);
|
|
71
70
|
i0.ɵɵlistener("click", function ResourcePermissionsComponent_Conditional_4_Template_button_click_8_listener() { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.addPermission()); });
|
|
72
71
|
i0.ɵɵtext(9, "Add");
|
|
@@ -74,7 +73,7 @@ function ResourcePermissionsComponent_Conditional_4_Template(rf, ctx) { if (rf &
|
|
|
74
73
|
} if (rf & 2) {
|
|
75
74
|
const ctx_r1 = i0.ɵɵnextContext();
|
|
76
75
|
i0.ɵɵadvance(3);
|
|
77
|
-
i0.ɵɵproperty("
|
|
76
|
+
i0.ɵɵproperty("Data", ctx_r1.PermissionTypes);
|
|
78
77
|
i0.ɵɵtwoWayProperty("ngModel", ctx_r1.SelectedType);
|
|
79
78
|
i0.ɵɵadvance();
|
|
80
79
|
i0.ɵɵconditional(ctx_r1.SelectedType === "User" ? 4 : ctx_r1.SelectedType === "Role" ? 5 : 6);
|
|
@@ -95,14 +94,14 @@ function ResourcePermissionsComponent_Conditional_13_Template(rf, ctx) { if (rf
|
|
|
95
94
|
} }
|
|
96
95
|
function ResourcePermissionsComponent_For_16_Conditional_5_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
97
96
|
const _r7 = i0.ɵɵgetCurrentView();
|
|
98
|
-
i0.ɵɵelementStart(0, "
|
|
99
|
-
i0.ɵɵtwoWayListener("ngModelChange", function
|
|
97
|
+
i0.ɵɵelementStart(0, "mj-dropdown", 16);
|
|
98
|
+
i0.ɵɵtwoWayListener("ngModelChange", function ResourcePermissionsComponent_For_16_Conditional_5_Conditional_1_Template_mj_dropdown_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r7); const p_r8 = i0.ɵɵnextContext(2).$implicit; i0.ɵɵtwoWayBindingSet(p_r8.PermissionLevel, $event) || (p_r8.PermissionLevel = $event); return i0.ɵɵresetView($event); });
|
|
100
99
|
i0.ɵɵelementEnd();
|
|
101
100
|
} if (rf & 2) {
|
|
102
101
|
const p_r8 = i0.ɵɵnextContext(2).$implicit;
|
|
103
102
|
const ctx_r1 = i0.ɵɵnextContext();
|
|
104
103
|
i0.ɵɵtwoWayProperty("ngModel", p_r8.PermissionLevel);
|
|
105
|
-
i0.ɵɵproperty("
|
|
104
|
+
i0.ɵɵproperty("Data", ctx_r1.PermissionLevels);
|
|
106
105
|
} }
|
|
107
106
|
function ResourcePermissionsComponent_For_16_Conditional_5_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
108
107
|
i0.ɵɵtext(0);
|
|
@@ -112,7 +111,7 @@ function ResourcePermissionsComponent_For_16_Conditional_5_Conditional_2_Templat
|
|
|
112
111
|
} }
|
|
113
112
|
function ResourcePermissionsComponent_For_16_Conditional_5_Template(rf, ctx) { if (rf & 1) {
|
|
114
113
|
i0.ɵɵelementStart(0, "td");
|
|
115
|
-
i0.ɵɵconditionalCreate(1, ResourcePermissionsComponent_For_16_Conditional_5_Conditional_1_Template, 1, 2, "
|
|
114
|
+
i0.ɵɵconditionalCreate(1, ResourcePermissionsComponent_For_16_Conditional_5_Conditional_1_Template, 1, 2, "mj-dropdown", 15)(2, ResourcePermissionsComponent_For_16_Conditional_5_Conditional_2_Template, 1, 1);
|
|
116
115
|
i0.ɵɵelementEnd();
|
|
117
116
|
} if (rf & 2) {
|
|
118
117
|
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
@@ -363,7 +362,7 @@ export class ResourcePermissionsComponent extends BaseAngularComponent {
|
|
|
363
362
|
return ResourcePermissionEngine.GetProviderInstance(this.ProviderToUse, ResourcePermissionEngine);
|
|
364
363
|
}
|
|
365
364
|
static ɵfac = /*@__PURE__*/ (() => { let ɵResourcePermissionsComponent_BaseFactory; return function ResourcePermissionsComponent_Factory(__ngFactoryType__) { return (ɵResourcePermissionsComponent_BaseFactory || (ɵResourcePermissionsComponent_BaseFactory = i0.ɵɵgetInheritedFactory(ResourcePermissionsComponent)))(__ngFactoryType__ || ResourcePermissionsComponent); }; })();
|
|
366
|
-
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ResourcePermissionsComponent, selectors: [["mj-resource-permissions"]], inputs: { ResourceTypeID: "ResourceTypeID", ResourceRecordID: "ResourceRecordID", ShowSaveButton: "ShowSaveButton", ShowPermissionLevels: "ShowPermissionLevels", ShowUserErrorMessages: "ShowUserErrorMessages", AllowAddPermissions: "AllowAddPermissions", AllowEditPermissions: "AllowEditPermissions", AllowDeletePermissions: "AllowDeletePermissions", PermissionLevels: "PermissionLevels", PermissionTypes: "PermissionTypes", ExcludedRoleNames: "ExcludedRoleNames", ExcludedUserEmails: "ExcludedUserEmails" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 17, vars: 5, consts: [[1, "container"], ["size", "medium", 3, "showText"], ["
|
|
365
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ResourcePermissionsComponent, selectors: [["mj-resource-permissions"]], inputs: { ResourceTypeID: "ResourceTypeID", ResourceRecordID: "ResourceRecordID", ShowSaveButton: "ShowSaveButton", ShowPermissionLevels: "ShowPermissionLevels", ShowUserErrorMessages: "ShowUserErrorMessages", AllowAddPermissions: "AllowAddPermissions", AllowEditPermissions: "AllowEditPermissions", AllowDeletePermissions: "AllowDeletePermissions", PermissionLevels: "PermissionLevels", PermissionTypes: "PermissionTypes", ExcludedRoleNames: "ExcludedRoleNames", ExcludedUserEmails: "ExcludedUserEmails" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 17, vars: 5, consts: [[1, "container"], ["size", "medium", 3, "showText"], ["mjButton", ""], [1, "table-container"], [1, "add-permission-section"], [1, "resource-table"], ["mjButton", "", 3, "click"], [1, "add-permission-label"], [2, "width", "100px", 3, "ngModelChange", "Data", "ngModel"], ["TextField", "Name", "ValueField", "ID", 2, "width", "225px", 3, "Data", "ngModel"], ["TextField", "Name", "ValueField", "ID", 2, "width", "150px", 3, "Data", "ngModel"], [2, "width", "100px", 3, "Data", "ngModel"], ["mjButton", "", 3, "click", "disabled", "title"], ["TextField", "Name", "ValueField", "ID", 2, "width", "225px", 3, "ngModelChange", "Data", "ngModel"], ["TextField", "Name", "ValueField", "ID", 2, "width", "150px", 3, "ngModelChange", "Data", "ngModel"], [2, "width", "100px", 3, "ngModel", "Data"], [2, "width", "100px", 3, "ngModelChange", "ngModel", "Data"], [1, "fa-solid", "fa-trash-can"]], template: function ResourcePermissionsComponent_Template(rf, ctx) { if (rf & 1) {
|
|
367
366
|
i0.ɵɵelementStart(0, "div", 0);
|
|
368
367
|
i0.ɵɵconditionalCreate(1, ResourcePermissionsComponent_Conditional_1_Template, 1, 1, "mj-loading", 1);
|
|
369
368
|
i0.ɵɵconditionalCreate(2, ResourcePermissionsComponent_Conditional_2_Template, 2, 0, "button", 2);
|
|
@@ -394,11 +393,11 @@ export class ResourcePermissionsComponent extends BaseAngularComponent {
|
|
|
394
393
|
i0.ɵɵconditional(ctx.AllowDeletePermissions ? 13 : -1);
|
|
395
394
|
i0.ɵɵadvance(2);
|
|
396
395
|
i0.ɵɵrepeater(ctx.resourcePermissions);
|
|
397
|
-
} }, dependencies: [i1.NgControlStatus, i1.NgModel, i2.
|
|
396
|
+
} }, dependencies: [i1.NgControlStatus, i1.NgModel, i2.LoadingComponent, i3.MJButtonDirective, i3.MJDropdownComponent], styles: ["\n\n.container[_ngcontent-%COMP%] {\n max-width: 100%;\n background: var(--mj-bg-surface);\n color: var(--mj-text-primary);\n}\n\n\n\n.table-container[_ngcontent-%COMP%] {\n max-height: 400px;\n \n\n overflow-y: auto;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n box-shadow: var(--mj-shadow-sm);\n}\n\n\n\n.resource-table[_ngcontent-%COMP%] {\n width: 100%;\n border-collapse: collapse;\n}\n\n.resource-table[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] {\n background-color: var(--mj-bg-surface-elevated);\n font-weight: var(--mj-font-bold);\n position: sticky;\n top: 0;\n z-index: 1;\n}\n\n.resource-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], \n.resource-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%] {\n padding: var(--mj-space-3);\n text-align: left;\n border-bottom: 1px solid var(--mj-border-subtle);\n color: var(--mj-text-primary);\n}\n\n.resource-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%] {\n background-color: var(--mj-bg-surface-elevated);\n color: var(--mj-text-secondary);\n}\n\n.resource-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(even) {\n background-color: var(--mj-bg-surface-sunken);\n}\n\n.resource-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover {\n background-color: var(--mj-bg-surface-hover);\n}\n\n\n\nbutton.k-button[_ngcontent-%COMP%] {\n background-color: var(--mj-status-error);\n color: var(--mj-text-inverse);\n border: none;\n padding: var(--mj-space-1) var(--mj-space-2-5);\n border-radius: var(--mj-radius-sm);\n cursor: pointer;\n font-family: var(--mj-font-family);\n}\n\nbutton.k-button[_ngcontent-%COMP%]:hover {\n background-color: var(--mj-status-error-text);\n}\n\n.add-permission-label[_ngcontent-%COMP%] {\n margin-left: var(--mj-space-1);\n margin-right: var(--mj-space-1);\n font-weight: var(--mj-font-bold);\n color: var(--mj-text-primary);\n}\n\n.add-permission-section[_ngcontent-%COMP%] {\n margin-top: var(--mj-space-2-5);\n margin-bottom: var(--mj-space-2-5);\n}"] });
|
|
398
397
|
}
|
|
399
398
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ResourcePermissionsComponent, [{
|
|
400
399
|
type: Component,
|
|
401
|
-
args: [{ standalone: false, selector: 'mj-resource-permissions', template: "<div class=\"container\">\n @if(_Loading) {\n <mj-loading [showText]=\"false\" size=\"medium\"></mj-loading>\n }\n @if(ShowSaveButton) {\n <button
|
|
400
|
+
args: [{ standalone: false, selector: 'mj-resource-permissions', template: "<div class=\"container\">\n @if(_Loading) {\n <mj-loading [showText]=\"false\" size=\"medium\"></mj-loading>\n }\n @if(ShowSaveButton) {\n <button mjButton (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 <mj-dropdown\n [Data]=\"PermissionTypes\"\n [(ngModel)]=\"SelectedType\"\n style=\"width: 100px;\">\n </mj-dropdown>\n @if (SelectedType === 'User') {\n <mj-dropdown\n [Data]=\"AllUsers\"\n [(ngModel)]=\"SelectedUser\"\n TextField=\"Name\"\n ValueField=\"ID\"\n style=\"width: 225px;\">\n </mj-dropdown>\n }\n @else if (SelectedType === 'Role') {\n <mj-dropdown\n [Data]=\"AllRoles\"\n [(ngModel)]=\"SelectedRole\"\n TextField=\"Name\"\n ValueField=\"ID\"\n style=\"width: 150px;\">\n </mj-dropdown>\n }\n @else {\n SelectedType: {{ SelectedType }}\n }\n @if (ShowPermissionLevels) {\n <mj-dropdown\n [Data]=\"PermissionLevels\"\n [(ngModel)]=\"SelectedPermissionLevel\"\n style=\"width: 100px;\">\n </mj-dropdown>\n }\n <button mjButton (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 <mj-dropdown\n [(ngModel)]=\"p.PermissionLevel\"\n [Data]=\"PermissionLevels\"\n style=\"width: 100px;\">\n </mj-dropdown>\n }\n @else {\n {{ p.PermissionLevel }}\n }\n </td>\n }\n @if(AllowDeletePermissions) {\n <td>\n <button mjButton (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", styles: ["/* Container styling */\n.container {\n max-width: 100%;\n background: var(--mj-bg-surface);\n color: var(--mj-text-primary);\n}\n\n/* Table container for vertical scrolling */\n.table-container {\n max-height: 400px;\n /* Adjust as needed */\n overflow-y: auto;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n box-shadow: var(--mj-shadow-sm);\n}\n\n/* Table styling */\n.resource-table {\n width: 100%;\n border-collapse: collapse;\n}\n\n.resource-table thead {\n background-color: var(--mj-bg-surface-elevated);\n font-weight: var(--mj-font-bold);\n position: sticky;\n top: 0;\n z-index: 1;\n}\n\n.resource-table th,\n.resource-table td {\n padding: var(--mj-space-3);\n text-align: left;\n border-bottom: 1px solid var(--mj-border-subtle);\n color: var(--mj-text-primary);\n}\n\n.resource-table th {\n background-color: var(--mj-bg-surface-elevated);\n color: var(--mj-text-secondary);\n}\n\n.resource-table tbody tr:nth-child(even) {\n background-color: var(--mj-bg-surface-sunken);\n}\n\n.resource-table tbody tr:hover {\n background-color: var(--mj-bg-surface-hover);\n}\n\n/* Button styling */\nbutton.k-button {\n background-color: var(--mj-status-error);\n color: var(--mj-text-inverse);\n border: none;\n padding: var(--mj-space-1) var(--mj-space-2-5);\n border-radius: var(--mj-radius-sm);\n cursor: pointer;\n font-family: var(--mj-font-family);\n}\n\nbutton.k-button:hover {\n background-color: var(--mj-status-error-text);\n}\n\n.add-permission-label {\n margin-left: var(--mj-space-1);\n margin-right: var(--mj-space-1);\n font-weight: var(--mj-font-bold);\n color: var(--mj-text-primary);\n}\n\n.add-permission-section {\n margin-top: var(--mj-space-2-5);\n margin-bottom: var(--mj-space-2-5);\n}"] }]
|
|
402
401
|
}], null, { ResourceTypeID: [{
|
|
403
402
|
type: Input
|
|
404
403
|
}], ResourceRecordID: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-permissions.component.js","sourceRoot":"","sources":["../../src/lib/resource-permissions.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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"]}
|
|
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,iCAA6C;IAA5B,gMAAS,wBAAiB,KAAC;IAAC,oBAAI;IAAA,iBAAS;;;;IAYpD,uCAKwB;IAHtB,iVAA0B;IAI5B,iBAAc;;;IALZ,sCAAiB;IACjB,mDAA0B;;;;IAO5B,uCAKwB;IAHtB,iVAA0B;IAI5B,iBAAc;;;IALZ,sCAAiB;IACjB,mDAA0B;;;IAO5B,YACF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A,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;;;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 mjButton (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 <mj-dropdown\n [Data]=\"PermissionTypes\"\n [(ngModel)]=\"SelectedType\"\n style=\"width: 100px;\">\n </mj-dropdown>\n @if (SelectedType === 'User') {\n <mj-dropdown\n [Data]=\"AllUsers\"\n [(ngModel)]=\"SelectedUser\"\n TextField=\"Name\"\n ValueField=\"ID\"\n style=\"width: 225px;\">\n </mj-dropdown>\n }\n @else if (SelectedType === 'Role') {\n <mj-dropdown\n [Data]=\"AllRoles\"\n [(ngModel)]=\"SelectedRole\"\n TextField=\"Name\"\n ValueField=\"ID\"\n style=\"width: 150px;\">\n </mj-dropdown>\n }\n @else {\n SelectedType: {{ SelectedType }}\n }\n @if (ShowPermissionLevels) {\n <mj-dropdown\n [Data]=\"PermissionLevels\"\n [(ngModel)]=\"SelectedPermissionLevel\"\n style=\"width: 100px;\">\n </mj-dropdown>\n }\n <button mjButton (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 <mj-dropdown\n [(ngModel)]=\"p.PermissionLevel\"\n [Data]=\"PermissionLevels\"\n style=\"width: 100px;\">\n </mj-dropdown>\n }\n @else {\n {{ p.PermissionLevel }}\n }\n </td>\n }\n @if(AllowDeletePermissions) {\n <td>\n <button mjButton (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/dist/module.d.ts
CHANGED
|
@@ -3,21 +3,15 @@ import * as i1 from "./lib/resource-permissions.component";
|
|
|
3
3
|
import * as i2 from "./lib/available-resources.component";
|
|
4
4
|
import * as i3 from "./lib/request-access.component";
|
|
5
5
|
import * as i4 from "@angular/common";
|
|
6
|
-
import * as i5 from "
|
|
6
|
+
import * as i5 from "ag-grid-angular";
|
|
7
7
|
import * as i6 from "@angular/forms";
|
|
8
|
-
import * as i7 from "@
|
|
9
|
-
import * as i8 from "@
|
|
10
|
-
import * as i9 from "@memberjunction/ng-
|
|
11
|
-
import * as i10 from "@
|
|
12
|
-
import * as i11 from "@progress/kendo-angular-dropdowns";
|
|
13
|
-
import * as i12 from "@progress/kendo-angular-indicators";
|
|
14
|
-
import * as i13 from "@progress/kendo-angular-listview";
|
|
15
|
-
import * as i14 from "@progress/kendo-angular-layout";
|
|
16
|
-
import * as i15 from "@memberjunction/ng-generic-dialog";
|
|
17
|
-
import * as i16 from "@memberjunction/ng-shared-generic";
|
|
8
|
+
import * as i7 from "@memberjunction/ng-container-directives";
|
|
9
|
+
import * as i8 from "@memberjunction/ng-generic-dialog";
|
|
10
|
+
import * as i9 from "@memberjunction/ng-shared-generic";
|
|
11
|
+
import * as i10 from "@memberjunction/ng-ui-components";
|
|
18
12
|
export declare class ResourcePermissionsModule {
|
|
19
13
|
static ɵfac: i0.ɵɵFactoryDeclaration<ResourcePermissionsModule, never>;
|
|
20
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<ResourcePermissionsModule, [typeof i1.ResourcePermissionsComponent, typeof i2.AvailableResourcesComponent, typeof i3.RequestResourceAccessComponent], [typeof i4.CommonModule, typeof i5.
|
|
14
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ResourcePermissionsModule, [typeof i1.ResourcePermissionsComponent, typeof i2.AvailableResourcesComponent, typeof i3.RequestResourceAccessComponent], [typeof i4.CommonModule, typeof i5.AgGridModule, typeof i6.FormsModule, typeof i7.ContainerDirectivesModule, typeof i8.GenericDialogModule, typeof i9.SharedGenericModule, typeof i10.MJButtonDirective, typeof i10.MJDropdownComponent], [typeof i1.ResourcePermissionsComponent, typeof i2.AvailableResourcesComponent, typeof i3.RequestResourceAccessComponent]>;
|
|
21
15
|
static ɵinj: i0.ɵɵInjectorDeclaration<ResourcePermissionsModule>;
|
|
22
16
|
}
|
|
23
17
|
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;;AAcA,qBAsBa,yBAAyB;yCAAzB,yBAAyB;0CAAzB,yBAAyB;0CAAzB,yBAAyB;CAAI"}
|
package/dist/module.js
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
2
|
import { ResourcePermissionsComponent } from './lib/resource-permissions.component';
|
|
3
3
|
import { CommonModule } from '@angular/common';
|
|
4
|
-
|
|
5
|
-
import { GridModule } from '@progress/kendo-angular-grid';
|
|
6
|
-
import { ListViewModule } from '@progress/kendo-angular-listview';
|
|
7
|
-
import { LayoutModule } from '@progress/kendo-angular-layout';
|
|
8
|
-
import { ExcelExportModule } from '@progress/kendo-angular-excel-export';
|
|
9
|
-
import { DialogsModule } from "@progress/kendo-angular-dialog";
|
|
10
|
-
import { ButtonsModule } from '@progress/kendo-angular-buttons';
|
|
4
|
+
import { AgGridModule } from 'ag-grid-angular';
|
|
11
5
|
import { ContainerDirectivesModule } from '@memberjunction/ng-container-directives';
|
|
12
6
|
import { FormsModule } from '@angular/forms';
|
|
13
|
-
import { DropDownsModule } from '@progress/kendo-angular-dropdowns';
|
|
14
|
-
import { IndicatorsModule } from '@progress/kendo-angular-indicators';
|
|
15
7
|
import { AvailableResourcesComponent } from './lib/available-resources.component';
|
|
16
8
|
import { GenericDialogModule } from '@memberjunction/ng-generic-dialog';
|
|
17
9
|
import { RequestResourceAccessComponent } from './lib/request-access.component';
|
|
18
10
|
import { SharedGenericModule } from '@memberjunction/ng-shared-generic';
|
|
11
|
+
import { MJButtonDirective, MJDropdownComponent } from '@memberjunction/ng-ui-components';
|
|
19
12
|
import * as i0 from "@angular/core";
|
|
20
13
|
export class ResourcePermissionsModule {
|
|
21
14
|
static ɵfac = function ResourcePermissionsModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ResourcePermissionsModule)(); };
|
|
22
15
|
static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ResourcePermissionsModule });
|
|
23
16
|
static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
|
|
24
|
-
|
|
17
|
+
AgGridModule,
|
|
25
18
|
FormsModule,
|
|
26
|
-
DialogsModule,
|
|
27
|
-
ExcelExportModule,
|
|
28
19
|
ContainerDirectivesModule,
|
|
29
|
-
ButtonsModule,
|
|
30
|
-
DropDownsModule,
|
|
31
|
-
IndicatorsModule,
|
|
32
|
-
ListViewModule,
|
|
33
|
-
LayoutModule,
|
|
34
20
|
GenericDialogModule,
|
|
35
|
-
SharedGenericModule
|
|
21
|
+
SharedGenericModule,
|
|
22
|
+
MJDropdownComponent] });
|
|
36
23
|
}
|
|
37
24
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ResourcePermissionsModule, [{
|
|
38
25
|
type: NgModule,
|
|
@@ -44,18 +31,13 @@ export class ResourcePermissionsModule {
|
|
|
44
31
|
],
|
|
45
32
|
imports: [
|
|
46
33
|
CommonModule,
|
|
47
|
-
|
|
34
|
+
AgGridModule,
|
|
48
35
|
FormsModule,
|
|
49
|
-
DialogsModule,
|
|
50
|
-
ExcelExportModule,
|
|
51
36
|
ContainerDirectivesModule,
|
|
52
|
-
ButtonsModule,
|
|
53
|
-
DropDownsModule,
|
|
54
|
-
IndicatorsModule,
|
|
55
|
-
ListViewModule,
|
|
56
|
-
LayoutModule,
|
|
57
37
|
GenericDialogModule,
|
|
58
|
-
SharedGenericModule
|
|
38
|
+
SharedGenericModule,
|
|
39
|
+
MJButtonDirective,
|
|
40
|
+
MJDropdownComponent
|
|
59
41
|
],
|
|
60
42
|
exports: [
|
|
61
43
|
ResourcePermissionsComponent,
|
|
@@ -67,18 +49,13 @@ export class ResourcePermissionsModule {
|
|
|
67
49
|
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ResourcePermissionsModule, { declarations: [ResourcePermissionsComponent,
|
|
68
50
|
AvailableResourcesComponent,
|
|
69
51
|
RequestResourceAccessComponent], imports: [CommonModule,
|
|
70
|
-
|
|
52
|
+
AgGridModule,
|
|
71
53
|
FormsModule,
|
|
72
|
-
DialogsModule,
|
|
73
|
-
ExcelExportModule,
|
|
74
54
|
ContainerDirectivesModule,
|
|
75
|
-
ButtonsModule,
|
|
76
|
-
DropDownsModule,
|
|
77
|
-
IndicatorsModule,
|
|
78
|
-
ListViewModule,
|
|
79
|
-
LayoutModule,
|
|
80
55
|
GenericDialogModule,
|
|
81
|
-
SharedGenericModule
|
|
56
|
+
SharedGenericModule,
|
|
57
|
+
MJButtonDirective,
|
|
58
|
+
MJDropdownComponent], exports: [ResourcePermissionsComponent,
|
|
82
59
|
AvailableResourcesComponent,
|
|
83
60
|
RequestResourceAccessComponent] }); })();
|
|
84
61
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;;AAwB1F,MAAM,OAAO,yBAAyB;mHAAzB,yBAAyB;4DAAzB,yBAAyB;gEAflC,YAAY;YACZ,YAAY;YACZ,WAAW;YACX,yBAAyB;YACzB,mBAAmB;YACnB,mBAAmB;YAEnB,mBAAmB;;iFAQV,yBAAyB;cAtBrC,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,4BAA4B;oBAC5B,2BAA2B;oBAC3B,8BAA8B;iBAC/B;gBACD,OAAO,EAAE;oBACP,YAAY;oBACZ,YAAY;oBACZ,WAAW;oBACX,yBAAyB;oBACzB,mBAAmB;oBACnB,mBAAmB;oBACnB,iBAAiB;oBACjB,mBAAmB;iBACpB;gBACD,OAAO,EAAE;oBACP,4BAA4B;oBAC5B,2BAA2B;oBAC3B,8BAA8B;iBAC/B;aACF;;wFACY,yBAAyB,mBApBlC,4BAA4B;QAC5B,2BAA2B;QAC3B,8BAA8B,aAG9B,YAAY;QACZ,YAAY;QACZ,WAAW;QACX,yBAAyB;QACzB,mBAAmB;QACnB,mBAAmB;QACnB,iBAAiB;QACjB,mBAAmB,aAGnB,4BAA4B;QAC5B,2BAA2B;QAC3B,8BAA8B","sourcesContent":["import { NgModule } from '@angular/core';\nimport { ResourcePermissionsComponent } from './lib/resource-permissions.component';\nimport { CommonModule } from '@angular/common';\n\nimport { AgGridModule } from 'ag-grid-angular';\n\nimport { ContainerDirectivesModule } from '@memberjunction/ng-container-directives';\nimport { FormsModule } from '@angular/forms';\nimport { AvailableResourcesComponent } from './lib/available-resources.component';\nimport { GenericDialogModule } from '@memberjunction/ng-generic-dialog';\nimport { RequestResourceAccessComponent } from './lib/request-access.component';\nimport { SharedGenericModule } from '@memberjunction/ng-shared-generic';\nimport { MJButtonDirective, MJDropdownComponent } from '@memberjunction/ng-ui-components';\n\n@NgModule({\n declarations: [\n ResourcePermissionsComponent,\n AvailableResourcesComponent,\n RequestResourceAccessComponent\n ],\n imports: [\n CommonModule,\n AgGridModule,\n FormsModule,\n ContainerDirectivesModule,\n GenericDialogModule,\n SharedGenericModule,\n MJButtonDirective,\n MJDropdownComponent\n ],\n exports: [\n ResourcePermissionsComponent,\n AvailableResourcesComponent,\n RequestResourceAccessComponent\n ]\n})\nexport class ResourcePermissionsModule { }\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-resource-permissions",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.24.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,22 +27,17 @@
|
|
|
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.
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"@progress/kendo-angular-excel-export": "22.0.1",
|
|
42
|
-
"@progress/kendo-angular-grid": "22.0.1",
|
|
43
|
-
"@progress/kendo-angular-indicators": "22.0.1",
|
|
44
|
-
"@progress/kendo-angular-layout": "22.0.1",
|
|
45
|
-
"@progress/kendo-angular-listview": "22.0.1",
|
|
30
|
+
"@memberjunction/core": "5.24.0",
|
|
31
|
+
"@memberjunction/core-entities": "5.24.0",
|
|
32
|
+
"@memberjunction/global": "5.24.0",
|
|
33
|
+
"@memberjunction/ng-base-types": "5.24.0",
|
|
34
|
+
"@memberjunction/ng-container-directives": "5.24.0",
|
|
35
|
+
"@memberjunction/ng-generic-dialog": "5.24.0",
|
|
36
|
+
"@memberjunction/ng-notifications": "5.24.0",
|
|
37
|
+
"@memberjunction/ng-shared-generic": "5.24.0",
|
|
38
|
+
"@memberjunction/ng-ui-components": "5.24.0",
|
|
39
|
+
"ag-grid-angular": "^35.0.1",
|
|
40
|
+
"ag-grid-community": "^35.0.1",
|
|
46
41
|
"tslib": "^2.8.1"
|
|
47
42
|
},
|
|
48
43
|
"sideEffects": false,
|