@memberjunction/ng-explorer-settings 0.9.10 → 0.9.13

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.
Files changed (25) hide show
  1. package/dist/lib/application-entities-grid/application-entities-grid.component.d.ts +51 -0
  2. package/dist/lib/application-entities-grid/application-entities-grid.component.js +348 -0
  3. package/dist/lib/entity-form-dialog/entity-form-dialog.component.d.ts +33 -0
  4. package/dist/lib/entity-form-dialog/entity-form-dialog.component.js +183 -0
  5. package/dist/lib/entity-form-window/entity-form-window.component.d.ts +17 -0
  6. package/dist/lib/entity-form-window/entity-form-window.component.js +99 -0
  7. package/dist/lib/module.d.ts +21 -14
  8. package/dist/lib/module.js +50 -8
  9. package/dist/lib/record-list/record-list.component.d.ts +41 -0
  10. package/dist/lib/record-list/record-list.component.js +324 -0
  11. package/dist/lib/roles-list/roles-list.component.d.ts +11 -1
  12. package/dist/lib/roles-list/roles-list.component.js +125 -26
  13. package/dist/lib/settings/settings.component.d.ts +26 -2
  14. package/dist/lib/settings/settings.component.js +136 -66
  15. package/dist/lib/single-application/single-application.component.d.ts +22 -0
  16. package/dist/lib/single-application/single-application.component.js +144 -0
  17. package/dist/lib/single-role/single-role.component.d.ts +16 -13
  18. package/dist/lib/single-role/single-role.component.js +112 -182
  19. package/dist/lib/single-user/single-user.component.d.ts +24 -0
  20. package/dist/lib/single-user/single-user.component.js +191 -0
  21. package/dist/lib/user-roles-grid/user-roles-grid.component.d.ts +41 -0
  22. package/dist/lib/user-roles-grid/user-roles-grid.component.js +320 -0
  23. package/dist/public-api.d.ts +4 -1
  24. package/dist/public-api.js +4 -1
  25. package/package.json +9 -4
@@ -0,0 +1,51 @@
1
+ import { OnInit, SimpleChanges, OnChanges } from '@angular/core';
2
+ import { kendoSVGIcon } from '@memberjunction/ng-shared';
3
+ import { ApplicationEntity, ApplicationEntityEntity, EntityEntity } from '@memberjunction/core-entities';
4
+ import { Router } from '@angular/router';
5
+ import * as i0 from "@angular/core";
6
+ export declare class ApplicationEntityEntity_Ext extends ApplicationEntityEntity {
7
+ private _selected;
8
+ get Selected(): boolean;
9
+ set Selected(value: boolean);
10
+ private _applicationName;
11
+ get SavedApplicationName(): string;
12
+ set SavedApplicationName(value: string);
13
+ private _entityID;
14
+ get SavedEntityID(): number;
15
+ set SavedEntityID(value: number);
16
+ }
17
+ export declare class ApplicationEntitiesGridComponent implements OnInit, OnChanges {
18
+ private router;
19
+ /**
20
+ * The name of the application we are working with, required if Mode is 'Applications'
21
+ */
22
+ ApplicationName: string;
23
+ /**
24
+ * The ID of the entity we are working with, required if Mode is 'Entities'
25
+ */
26
+ EntityID: number;
27
+ isLoading: boolean;
28
+ rows: ApplicationEntityEntity_Ext[];
29
+ Mode: 'Applications' | 'Entities';
30
+ /**
31
+ * The role record we are working with, required if Mode is 'Appliations'
32
+ */
33
+ ApplicationRecord: ApplicationEntity | null;
34
+ /**
35
+ * The user record we are working with, required if Mode is 'Entities'
36
+ */
37
+ EntityRecord: EntityEntity | null;
38
+ kendoSVGIcon: typeof kendoSVGIcon;
39
+ constructor(router: Router);
40
+ ngOnInit(): void;
41
+ ngOnChanges(changes: SimpleChanges): void;
42
+ Refresh(): Promise<void>;
43
+ save(): Promise<void>;
44
+ cancelEdit(): void;
45
+ flipAll(): void;
46
+ get NumDirty(): number;
47
+ protected IsReallyDirty(ae: ApplicationEntityEntity_Ext): boolean;
48
+ flipState($event: MouseEvent | undefined, ur: ApplicationEntityEntity_Ext, flipState: boolean): void;
49
+ static ɵfac: i0.ɵɵFactoryDeclaration<ApplicationEntitiesGridComponent, never>;
50
+ static ɵcmp: i0.ɵɵComponentDeclaration<ApplicationEntitiesGridComponent, "mj-application-entities-grid", never, { "ApplicationName": { "alias": "ApplicationName"; "required": false; }; "EntityID": { "alias": "EntityID"; "required": false; }; "Mode": { "alias": "Mode"; "required": false; }; "ApplicationRecord": { "alias": "ApplicationRecord"; "required": false; }; "EntityRecord": { "alias": "EntityRecord"; "required": false; }; }, {}, never, never, false, never>;
51
+ }
@@ -0,0 +1,348 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14
+ });
15
+ };
16
+ import { Component, Input } from '@angular/core';
17
+ import { BaseEntity, Metadata, RunView } from '@memberjunction/core';
18
+ import { kendoSVGIcon } from '@memberjunction/ng-shared';
19
+ import { ApplicationEntityEntity } from '@memberjunction/core-entities';
20
+ import { RegisterClass } from '@memberjunction/global';
21
+ import * as i0 from "@angular/core";
22
+ import * as i1 from "@angular/router";
23
+ import * as i2 from "@angular/common";
24
+ import * as i3 from "@angular/forms";
25
+ import * as i4 from "@progress/kendo-angular-buttons";
26
+ import * as i5 from "@progress/kendo-angular-indicators";
27
+ function ApplicationEntitiesGridComponent_div_0_Template(rf, ctx) { if (rf & 1) {
28
+ i0.ɵɵelementStart(0, "div");
29
+ i0.ɵɵelement(1, "kendo-loader");
30
+ i0.ɵɵelementEnd();
31
+ } }
32
+ function ApplicationEntitiesGridComponent_div_1_table_5_th_3_Template(rf, ctx) { if (rf & 1) {
33
+ i0.ɵɵelementStart(0, "th");
34
+ i0.ɵɵtext(1, "Entity");
35
+ i0.ɵɵelementEnd();
36
+ } }
37
+ function ApplicationEntitiesGridComponent_div_1_table_5_th_4_Template(rf, ctx) { if (rf & 1) {
38
+ i0.ɵɵelementStart(0, "th");
39
+ i0.ɵɵtext(1, "Application");
40
+ i0.ɵɵelementEnd();
41
+ } }
42
+ function ApplicationEntitiesGridComponent_div_1_table_5_tr_8_td_1_Template(rf, ctx) { if (rf & 1) {
43
+ i0.ɵɵelementStart(0, "td");
44
+ i0.ɵɵtext(1);
45
+ i0.ɵɵelementEnd();
46
+ } if (rf & 2) {
47
+ const r_r6 = i0.ɵɵnextContext().$implicit;
48
+ i0.ɵɵadvance();
49
+ i0.ɵɵtextInterpolate(r_r6.Entity);
50
+ } }
51
+ function ApplicationEntitiesGridComponent_div_1_table_5_tr_8_td_2_Template(rf, ctx) { if (rf & 1) {
52
+ i0.ɵɵelementStart(0, "td");
53
+ i0.ɵɵtext(1);
54
+ i0.ɵɵelementEnd();
55
+ } if (rf & 2) {
56
+ const r_r6 = i0.ɵɵnextContext().$implicit;
57
+ i0.ɵɵadvance();
58
+ i0.ɵɵtextInterpolate(r_r6.Application);
59
+ } }
60
+ function ApplicationEntitiesGridComponent_div_1_table_5_tr_8_Template(rf, ctx) { if (rf & 1) {
61
+ const _r12 = i0.ɵɵgetCurrentView();
62
+ i0.ɵɵelementStart(0, "tr");
63
+ i0.ɵɵtemplate(1, ApplicationEntitiesGridComponent_div_1_table_5_tr_8_td_1_Template, 2, 1, "td", 0)(2, ApplicationEntitiesGridComponent_div_1_table_5_tr_8_td_2_Template, 2, 1, "td", 0);
64
+ i0.ɵɵelementStart(3, "td", 6);
65
+ i0.ɵɵlistener("click", function ApplicationEntitiesGridComponent_div_1_table_5_tr_8_Template_td_click_3_listener($event) { const restoredCtx = i0.ɵɵrestoreView(_r12); const r_r6 = restoredCtx.$implicit; const ctx_r11 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r11.flipState($event, r_r6, true)); });
66
+ i0.ɵɵelementStart(4, "input", 8);
67
+ i0.ɵɵtwoWayListener("ngModelChange", function ApplicationEntitiesGridComponent_div_1_table_5_tr_8_Template_input_ngModelChange_4_listener($event) { const restoredCtx = i0.ɵɵrestoreView(_r12); const r_r6 = restoredCtx.$implicit; i0.ɵɵtwoWayBindingSet(r_r6.Selected, $event) || (r_r6.Selected = $event); return i0.ɵɵresetView($event); });
68
+ i0.ɵɵlistener("click", function ApplicationEntitiesGridComponent_div_1_table_5_tr_8_Template_input_click_4_listener($event) { const restoredCtx = i0.ɵɵrestoreView(_r12); const r_r6 = restoredCtx.$implicit; const ctx_r14 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r14.flipState($event, r_r6, false)); });
69
+ i0.ɵɵelementEnd()()();
70
+ } if (rf & 2) {
71
+ const r_r6 = ctx.$implicit;
72
+ const ctx_r5 = i0.ɵɵnextContext(3);
73
+ i0.ɵɵadvance();
74
+ i0.ɵɵproperty("ngIf", ctx_r5.Mode === "Applications");
75
+ i0.ɵɵadvance();
76
+ i0.ɵɵproperty("ngIf", ctx_r5.Mode === "Entities");
77
+ i0.ɵɵadvance(2);
78
+ i0.ɵɵtwoWayProperty("ngModel", r_r6.Selected);
79
+ } }
80
+ function ApplicationEntitiesGridComponent_div_1_table_5_Template(rf, ctx) { if (rf & 1) {
81
+ const _r16 = i0.ɵɵgetCurrentView();
82
+ i0.ɵɵelementStart(0, "table", 5)(1, "thead")(2, "tr");
83
+ i0.ɵɵtemplate(3, ApplicationEntitiesGridComponent_div_1_table_5_th_3_Template, 2, 0, "th", 0)(4, ApplicationEntitiesGridComponent_div_1_table_5_th_4_Template, 2, 0, "th", 0);
84
+ i0.ɵɵelementStart(5, "th", 6);
85
+ i0.ɵɵlistener("click", function ApplicationEntitiesGridComponent_div_1_table_5_Template_th_click_5_listener() { i0.ɵɵrestoreView(_r16); const ctx_r15 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r15.flipAll()); });
86
+ i0.ɵɵtext(6, "In Application");
87
+ i0.ɵɵelementEnd()()();
88
+ i0.ɵɵelementStart(7, "tbody");
89
+ i0.ɵɵtemplate(8, ApplicationEntitiesGridComponent_div_1_table_5_tr_8_Template, 5, 3, "tr", 7);
90
+ i0.ɵɵelementEnd()();
91
+ } if (rf & 2) {
92
+ const ctx_r2 = i0.ɵɵnextContext(2);
93
+ i0.ɵɵadvance(3);
94
+ i0.ɵɵproperty("ngIf", ctx_r2.Mode === "Applications");
95
+ i0.ɵɵadvance();
96
+ i0.ɵɵproperty("ngIf", ctx_r2.Mode === "Entities");
97
+ i0.ɵɵadvance(4);
98
+ i0.ɵɵproperty("ngForOf", ctx_r2.rows);
99
+ } }
100
+ function ApplicationEntitiesGridComponent_div_1_Template(rf, ctx) { if (rf & 1) {
101
+ const _r18 = i0.ɵɵgetCurrentView();
102
+ i0.ɵɵelementStart(0, "div", 2)(1, "button", 3);
103
+ i0.ɵɵlistener("click", function ApplicationEntitiesGridComponent_div_1_Template_button_click_1_listener() { i0.ɵɵrestoreView(_r18); const ctx_r17 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r17.save()); });
104
+ i0.ɵɵtext(2, "Save");
105
+ i0.ɵɵelementEnd();
106
+ i0.ɵɵelementStart(3, "button", 3);
107
+ i0.ɵɵlistener("click", function ApplicationEntitiesGridComponent_div_1_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r18); const ctx_r19 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r19.cancelEdit()); });
108
+ i0.ɵɵtext(4, "Cancel");
109
+ i0.ɵɵelementEnd();
110
+ i0.ɵɵtemplate(5, ApplicationEntitiesGridComponent_div_1_table_5_Template, 9, 3, "table", 4);
111
+ i0.ɵɵelementEnd();
112
+ } if (rf & 2) {
113
+ const ctx_r1 = i0.ɵɵnextContext();
114
+ i0.ɵɵadvance();
115
+ i0.ɵɵproperty("disabled", ctx_r1.NumDirty === 0);
116
+ i0.ɵɵadvance(2);
117
+ i0.ɵɵproperty("disabled", ctx_r1.NumDirty === 0);
118
+ i0.ɵɵadvance(2);
119
+ i0.ɵɵproperty("ngIf", !ctx_r1.isLoading);
120
+ } }
121
+ let ApplicationEntityEntity_Ext = class ApplicationEntityEntity_Ext extends ApplicationEntityEntity {
122
+ constructor() {
123
+ super(...arguments);
124
+ this._selected = false;
125
+ this._applicationName = '';
126
+ this._entityID = 0;
127
+ }
128
+ get Selected() {
129
+ return this._selected;
130
+ }
131
+ set Selected(value) {
132
+ this._selected = value;
133
+ }
134
+ get SavedApplicationName() {
135
+ return this._applicationName;
136
+ }
137
+ set SavedApplicationName(value) {
138
+ this._applicationName = value;
139
+ }
140
+ get SavedEntityID() {
141
+ return this._entityID;
142
+ }
143
+ set SavedEntityID(value) {
144
+ this._entityID = value;
145
+ }
146
+ };
147
+ ApplicationEntityEntity_Ext = __decorate([
148
+ RegisterClass(BaseEntity, 'Application Entities', 10) // register this with a high priority so we are used here, we just need to extend it to add a property as a flag to know if it's in the database or not
149
+ ], ApplicationEntityEntity_Ext);
150
+ export { ApplicationEntityEntity_Ext };
151
+ export class ApplicationEntitiesGridComponent {
152
+ constructor(router) {
153
+ this.router = router;
154
+ this.isLoading = false;
155
+ this.rows = [];
156
+ this.Mode = 'Applications';
157
+ /**
158
+ * The role record we are working with, required if Mode is 'Appliations'
159
+ */
160
+ this.ApplicationRecord = null;
161
+ /**
162
+ * The user record we are working with, required if Mode is 'Entities'
163
+ */
164
+ this.EntityRecord = null;
165
+ this.kendoSVGIcon = kendoSVGIcon;
166
+ }
167
+ ngOnInit() {
168
+ this.Refresh();
169
+ }
170
+ ngOnChanges(changes) {
171
+ if (changes && (changes.RoleRecord || changes.UserRecord))
172
+ this.Refresh();
173
+ }
174
+ Refresh() {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ if (this.Mode === 'Applications')
177
+ if (!this.ApplicationName || this.ApplicationName.length === 0 || !this.ApplicationRecord)
178
+ throw new Error("ApplicationName and ApplicationRecord are required when Mode is 'Applications'");
179
+ if (this.Mode === 'Entities')
180
+ if (!this.EntityID || !this.EntityRecord)
181
+ throw new Error("EntityID and EntityRecord are required when Mode is 'Entities'");
182
+ const md = new Metadata();
183
+ this.isLoading = true;
184
+ const rv = new RunView();
185
+ const filter = this.Mode === 'Applications' ? `Application='${this.ApplicationName}'` : `EntityID=${this.EntityID}`;
186
+ const result = yield rv.RunView({
187
+ EntityName: 'Application Entities',
188
+ ExtraFilter: filter,
189
+ ResultType: 'entity_object'
190
+ });
191
+ if (result.Success) {
192
+ // we have all of the saved records now
193
+ const existing = result.Results;
194
+ existing.forEach(ae => {
195
+ ae.Selected = true; // flip this on for all records that come from the DB
196
+ ae.SavedEntityID = ae.EntityID; // stash this in an extra property so we can later set it if we have a delete operation
197
+ ae.SavedApplicationName = ae.Application; // stash this in an extra property so we can later set it if we have a delete operation
198
+ });
199
+ if (this.Mode === 'Applications') {
200
+ const entitiesToAdd = md.Entities.filter(e => !existing.some(ee => ee.EntityID === e.ID));
201
+ for (const e of entitiesToAdd) {
202
+ const ae = yield md.GetEntityObject('Application Entities');
203
+ ae.NewRecord();
204
+ ae.Sequence = 1000; // default value, isn't used anywhere
205
+ ae.ApplicationName = this.ApplicationName;
206
+ ae.Set('Application', this.ApplicationName); // use weak typing to get around the readonly property
207
+ ae.SavedApplicationName = this.ApplicationName; // stash this in an extra property so we can later set it if we have a delete operation
208
+ ae.EntityID = e.ID;
209
+ ae.SavedEntityID = e.ID; // stash this in an extra property so we can later set it if we have a delete operation
210
+ ae.Set('Entity', e.Name); // use weak typing to get around the readonly property
211
+ existing.push(ae);
212
+ }
213
+ // finally sort the array
214
+ this.rows = existing.sort((a, b) => a.Entity.localeCompare(b.Entity));
215
+ }
216
+ else {
217
+ // for the mode of Entities, we want to bring in all of the possible applications and then add any that are not in the existing array
218
+ const appsToAdd = md.Applications.filter(a => !existing.some(e => e.Application === a.Name));
219
+ for (const a of appsToAdd) {
220
+ const ae = yield md.GetEntityObject('Application Entities');
221
+ ae.NewRecord();
222
+ ae.Sequence = 1000; // default value, isn't used anywhere
223
+ ae.ApplicationName = a.Name;
224
+ ae.Set('Application', a.Name); // use weak typing to get around the readonly property
225
+ ae.SavedApplicationName = a.Name; // stash this in an extra property so we can later set it if we have a delete operation
226
+ ae.EntityID = this.EntityID;
227
+ ae.SavedEntityID = this.EntityID; // stash this in an extra property so we can later set it if we have a delete operation
228
+ ae.Set('Entity', this.EntityRecord.Name); // use weak typing to get around the readonly property
229
+ existing.push(ae);
230
+ }
231
+ // finally sort the array
232
+ this.rows = existing.sort((a, b) => a.Application.localeCompare(b.Application));
233
+ }
234
+ }
235
+ else {
236
+ throw new Error("Error loading application entities: " + result.ErrorMessage);
237
+ }
238
+ this.isLoading = false;
239
+ });
240
+ }
241
+ save() {
242
+ return __awaiter(this, void 0, void 0, function* () {
243
+ // iterate through each permisison and for the ones that are dirty, add to transaction group then commit at once
244
+ const md = new Metadata();
245
+ const tg = yield md.CreateTransactionGroup();
246
+ let itemCount = 0;
247
+ this.rows.forEach(r => {
248
+ if (this.IsReallyDirty(r)) {
249
+ r.TransactionGroup = tg;
250
+ itemCount++;
251
+ // now, we have to determine if we are going to save the record or delete it
252
+ // if ur.Selected === false and we are in the database, we need to delete
253
+ // otherwise, we need to save
254
+ if (r.Selected)
255
+ r.Save();
256
+ else
257
+ r.Delete();
258
+ }
259
+ });
260
+ if (itemCount > 0) {
261
+ if (yield tg.Submit()) {
262
+ // for any items in the above that were deleted, we would have had the ApplicationName/Application and Entity property wiped out so we need to go check to see if we have a null ID and if so, copy the values back in
263
+ this.rows.forEach(r => {
264
+ if (r.Application === null || r.ApplicationName === null) {
265
+ r.Set('Application', r.SavedApplicationName); // get around the read-only property
266
+ r.ApplicationName = r.SavedApplicationName;
267
+ }
268
+ if (r.Entity === null || r.EntityID === null) {
269
+ r.EntityID = r.SavedEntityID; // get around the read-only property
270
+ const e = md.Entities.find(ee => ee.ID === r.SavedEntityID);
271
+ r.Set('Entity', e === null || e === void 0 ? void 0 : e.Name); // get around the read-only property
272
+ }
273
+ });
274
+ }
275
+ }
276
+ });
277
+ }
278
+ cancelEdit() {
279
+ if (this.NumDirty > 0) {
280
+ // go through and revert each permission that is REALLY dirty
281
+ this.rows.forEach(r => {
282
+ if (this.IsReallyDirty(r)) {
283
+ r.Selected = !r.Selected; // flip the state so we can revert
284
+ }
285
+ });
286
+ }
287
+ }
288
+ flipAll() {
289
+ // first, figure out what we have the majority of, if we have more ON, then we will flip to OFF, otherwise we will flip to ON
290
+ let onCount = 0;
291
+ let offCount = 0;
292
+ this.rows.forEach(r => {
293
+ if (r.Selected)
294
+ onCount++;
295
+ else
296
+ offCount++;
297
+ });
298
+ const value = offCount > onCount;
299
+ // now set the permission for each permission record
300
+ for (const r of this.rows) {
301
+ r.Selected = value;
302
+ this.flipState(undefined, r, false); // call this function but tell it to NOT actually flip the permission, just to fire the event
303
+ }
304
+ }
305
+ get NumDirty() {
306
+ return this.rows.filter(r => this.IsReallyDirty(r)).length;
307
+ }
308
+ IsReallyDirty(ae) {
309
+ // logic is simple, if we are in the database, but the checkbox is not checked (or vice versa), then we are dirty
310
+ if (ae.Selected && ae.ID > 0)
311
+ return false; // if we are in the database and the checkbox is checked, we are not dirty
312
+ else if (!ae.Selected && ae.ID > 0)
313
+ return true; // if we are in the database and the checkbox is not checked, we are dirty because we'd have to be removed
314
+ else if (ae.Selected)
315
+ return true; // if we are NOT in the database and the checkbox is checked, we are dirty because we'd have to be added
316
+ else
317
+ return false;
318
+ }
319
+ flipState($event, ur, flipState) {
320
+ if (flipState)
321
+ ur.Selected = !ur.Selected;
322
+ else if ($event)
323
+ $event.stopPropagation();
324
+ }
325
+ }
326
+ ApplicationEntitiesGridComponent.ɵfac = function ApplicationEntitiesGridComponent_Factory(t) { return new (t || ApplicationEntitiesGridComponent)(i0.ɵɵdirectiveInject(i1.Router)); };
327
+ ApplicationEntitiesGridComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ApplicationEntitiesGridComponent, selectors: [["mj-application-entities-grid"]], inputs: { ApplicationName: "ApplicationName", EntityID: "EntityID", Mode: "Mode", ApplicationRecord: "ApplicationRecord", EntityRecord: "EntityRecord" }, features: [i0.ɵɵNgOnChangesFeature], decls: 2, vars: 2, consts: [[4, "ngIf"], ["class", "content", 4, "ngIf"], [1, "content"], ["kendoButton", "", 3, "disabled", "click"], ["class", "grid", 4, "ngIf"], [1, "grid"], [3, "click"], [4, "ngFor", "ngForOf"], ["type", "checkbox", "kendoCheckBox", "", 3, "ngModel", "ngModelChange", "click"]], template: function ApplicationEntitiesGridComponent_Template(rf, ctx) { if (rf & 1) {
328
+ i0.ɵɵtemplate(0, ApplicationEntitiesGridComponent_div_0_Template, 2, 0, "div", 0)(1, ApplicationEntitiesGridComponent_div_1_Template, 6, 3, "div", 1);
329
+ } if (rf & 2) {
330
+ i0.ɵɵproperty("ngIf", ctx.isLoading);
331
+ i0.ɵɵadvance();
332
+ i0.ɵɵproperty("ngIf", !ctx.isLoading);
333
+ } }, dependencies: [i2.NgForOf, i2.NgIf, i3.CheckboxControlValueAccessor, i3.NgControlStatus, i3.NgModel, i4.ButtonComponent, i5.LoaderComponent], styles: ["button[_ngcontent-%COMP%] {\r\n margin-left: 5px;\r\n margin-top: 5px;\r\n width: 125px;\r\n}\r\n\r\n\n\r\n.grid[_ngcontent-%COMP%] {\r\n margin-left: 5px;\r\n margin-top: 5px;\r\n border-collapse: collapse;\r\n}\r\n\r\n\n\r\n.grid[_ngcontent-%COMP%] th[_ngcontent-%COMP%] {\r\n background-color: #f2f2f2;\r\n color: black;\r\n font-weight: bold;\r\n text-align: center;\r\n border: 1px solid gray;\r\n padding: 0 8px;\r\n cursor: pointer;\r\n}\r\n\r\n\n\r\n.grid[_ngcontent-%COMP%] td[_ngcontent-%COMP%] {\r\n border: 1px solid gray;\r\n height: 36px;\r\n text-align: center;\r\n padding: 0 8px;\r\n}\r\n\r\n\n\r\n.grid[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:first-child, .grid[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:first-child {\r\n min-width: 150px;\r\n text-align: left;\r\n}\r\n\r\n\n\r\n.grid[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:not(:first-child), .grid[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:not(:first-child) {\r\n width: 100px;\r\n}\r\n\r\n\n\r\n.grid[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(odd) {\r\n background-color: white;\r\n}\r\n\r\n.grid[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(even) {\r\n background-color: #e7f4ff;\r\n}"] });
334
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ApplicationEntitiesGridComponent, [{
335
+ type: Component,
336
+ args: [{ selector: 'mj-application-entities-grid', template: "<div *ngIf=\"isLoading\"><kendo-loader></kendo-loader></div>\r\n<div class=\"content\" *ngIf=\"!isLoading\">\r\n <button [disabled]=\"NumDirty === 0\" kendoButton (click)=\"save()\">Save</button>\r\n <button [disabled]=\"NumDirty === 0\" kendoButton (click)=\"cancelEdit()\">Cancel</button>\r\n <table *ngIf=\"!isLoading\" class=\"grid\">\r\n <thead>\r\n <tr>\r\n <th *ngIf=\"Mode === 'Applications'\">Entity</th>\r\n <th *ngIf=\"Mode === 'Entities'\">Application</th>\r\n <th (click)=\"flipAll()\">In Application</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let r of rows\">\r\n <td *ngIf=\"Mode === 'Applications'\">{{ r.Entity }}</td>\r\n <td *ngIf=\"Mode === 'Entities'\">{{ r.Application }}</td>\r\n <td (click)=\"flipState($event, r, true)\">\r\n <input type=\"checkbox\" kendoCheckBox [(ngModel)]=\"r.Selected\" (click)=\"flipState($event, r, false)\">\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table> \r\n</div>", styles: ["button {\r\n margin-left: 5px;\r\n margin-top: 5px;\r\n width: 125px;\r\n}\r\n\r\n/* Styles for the table with the 'grid' class */\r\n.grid {\r\n margin-left: 5px;\r\n margin-top: 5px;\r\n border-collapse: collapse;\r\n}\r\n\r\n/* Styles for th elements within the table with the 'grid' class */\r\n.grid th {\r\n background-color: #f2f2f2;\r\n color: black;\r\n font-weight: bold;\r\n text-align: center;\r\n border: 1px solid gray;\r\n padding: 0 8px;\r\n cursor: pointer;\r\n}\r\n\r\n/* Styles for td elements within the table with the 'grid' class */\r\n.grid td {\r\n border: 1px solid gray;\r\n height: 36px;\r\n text-align: center;\r\n padding: 0 8px;\r\n}\r\n\r\n/* Styles for the first child th and td within the table with the 'grid' class */\r\n.grid th:first-child,\r\n.grid td:first-child {\r\n min-width: 150px;\r\n text-align: left;\r\n}\r\n\r\n/* Styles for non-first-child th and td elements within the table with the 'grid' class */\r\n.grid th:not(:first-child),\r\n.grid td:not(:first-child) {\r\n width: 100px;\r\n}\r\n\r\n/* Alternating row background colors for the table with the 'grid' class */\r\n.grid tr:nth-child(odd) {\r\n background-color: white;\r\n}\r\n\r\n.grid tr:nth-child(even) {\r\n background-color: #e7f4ff;\r\n}\r\n\r\n"] }]
337
+ }], () => [{ type: i1.Router }], { ApplicationName: [{
338
+ type: Input
339
+ }], EntityID: [{
340
+ type: Input
341
+ }], Mode: [{
342
+ type: Input
343
+ }], ApplicationRecord: [{
344
+ type: Input
345
+ }], EntityRecord: [{
346
+ type: Input
347
+ }] }); })();
348
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ApplicationEntitiesGridComponent, { className: "ApplicationEntitiesGridComponent", filePath: "src\\lib\\application-entities-grid\\application-entities-grid.component.ts", lineNumber: 45 }); })();
@@ -0,0 +1,33 @@
1
+ import { ViewContainerRef, EventEmitter } from '@angular/core';
2
+ import { BaseEntity } from '@memberjunction/core';
3
+ import * as i0 from "@angular/core";
4
+ export declare class EntityFormDialog {
5
+ /**
6
+ * The title of the dialog
7
+ */
8
+ Title: string;
9
+ ShowSaveButton: boolean;
10
+ ShowCancelButton: boolean;
11
+ Width: number;
12
+ Height: number;
13
+ Mode: 'complete' | 'section';
14
+ SectionName: string;
15
+ Record: BaseEntity | null;
16
+ /**
17
+ * If true, when the user clicks the Save button, the Record will be saved. Only applicable if ShowSaveButton is true.
18
+ */
19
+ HandleSave: boolean;
20
+ /**
21
+ * If true, when the user clicks the Cancel button, the Record will be reverted to its original state. Only applicable if ShowCancelButton is true.
22
+ */
23
+ AutoRevertOnCancel: boolean;
24
+ close: EventEmitter<'Save' | 'Cancel'>;
25
+ private _visible;
26
+ set Visible(val: boolean);
27
+ get Visible(): boolean;
28
+ container: ViewContainerRef;
29
+ showForm(): void;
30
+ closeWindow(status: 'Save' | 'Cancel'): Promise<void>;
31
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityFormDialog, never>;
32
+ static ɵcmp: i0.ɵɵComponentDeclaration<EntityFormDialog, "mj-entity-form-dialog", never, { "Title": { "alias": "Title"; "required": false; }; "ShowSaveButton": { "alias": "ShowSaveButton"; "required": false; }; "ShowCancelButton": { "alias": "ShowCancelButton"; "required": false; }; "Width": { "alias": "Width"; "required": false; }; "Height": { "alias": "Height"; "required": false; }; "Mode": { "alias": "Mode"; "required": false; }; "SectionName": { "alias": "SectionName"; "required": false; }; "Record": { "alias": "Record"; "required": false; }; "HandleSave": { "alias": "HandleSave"; "required": false; }; "AutoRevertOnCancel": { "alias": "AutoRevertOnCancel"; "required": false; }; "Visible": { "alias": "Visible"; "required": false; }; }, { "close": "close"; }, never, never, false, never>;
33
+ }
@@ -0,0 +1,183 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Component, Input, Output, ViewChild, ViewContainerRef, EventEmitter } from '@angular/core';
11
+ import { SharedService } from '@memberjunction/ng-shared';
12
+ import { MJGlobal } from '@memberjunction/global';
13
+ import { BaseFormComponent, BaseFormSectionComponent } from '@memberjunction/ng-base-forms';
14
+ import * as i0 from "@angular/core";
15
+ import * as i1 from "@angular/common";
16
+ import * as i2 from "@progress/kendo-angular-dialog";
17
+ import * as i3 from "@progress/kendo-angular-buttons";
18
+ const _c0 = ["dynamicFormContainer"];
19
+ function EntityFormDialog_kendo_dialog_0_ng_template_1_Template(rf, ctx) { }
20
+ function EntityFormDialog_kendo_dialog_0_kendo_dialog_actions_3_button_1_Template(rf, ctx) { if (rf & 1) {
21
+ const _r7 = i0.ɵɵgetCurrentView();
22
+ i0.ɵɵelementStart(0, "button", 6);
23
+ i0.ɵɵlistener("click", function EntityFormDialog_kendo_dialog_0_kendo_dialog_actions_3_button_1_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r6.closeWindow("Save")); });
24
+ i0.ɵɵtext(1, "Save");
25
+ i0.ɵɵelementEnd();
26
+ } }
27
+ function EntityFormDialog_kendo_dialog_0_kendo_dialog_actions_3_button_2_Template(rf, ctx) { if (rf & 1) {
28
+ const _r9 = i0.ɵɵgetCurrentView();
29
+ i0.ɵɵelementStart(0, "button", 7);
30
+ i0.ɵɵlistener("click", function EntityFormDialog_kendo_dialog_0_kendo_dialog_actions_3_button_2_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r9); const ctx_r8 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r8.closeWindow("Cancel")); });
31
+ i0.ɵɵtext(1, "Cancel");
32
+ i0.ɵɵelementEnd();
33
+ } }
34
+ function EntityFormDialog_kendo_dialog_0_kendo_dialog_actions_3_Template(rf, ctx) { if (rf & 1) {
35
+ i0.ɵɵelementStart(0, "kendo-dialog-actions");
36
+ i0.ɵɵtemplate(1, EntityFormDialog_kendo_dialog_0_kendo_dialog_actions_3_button_1_Template, 2, 0, "button", 4)(2, EntityFormDialog_kendo_dialog_0_kendo_dialog_actions_3_button_2_Template, 2, 0, "button", 5);
37
+ i0.ɵɵelementEnd();
38
+ } if (rf & 2) {
39
+ const ctx_r3 = i0.ɵɵnextContext(2);
40
+ i0.ɵɵadvance();
41
+ i0.ɵɵproperty("ngIf", ctx_r3.ShowSaveButton);
42
+ i0.ɵɵadvance();
43
+ i0.ɵɵproperty("ngIf", ctx_r3.ShowCancelButton);
44
+ } }
45
+ function EntityFormDialog_kendo_dialog_0_Template(rf, ctx) { if (rf & 1) {
46
+ const _r11 = i0.ɵɵgetCurrentView();
47
+ i0.ɵɵelementStart(0, "kendo-dialog", 1);
48
+ i0.ɵɵlistener("close", function EntityFormDialog_kendo_dialog_0_Template_kendo_dialog_close_0_listener() { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r10.closeWindow("Cancel")); });
49
+ i0.ɵɵtemplate(1, EntityFormDialog_kendo_dialog_0_ng_template_1_Template, 0, 0, "ng-template", null, 2, i0.ɵɵtemplateRefExtractor)(3, EntityFormDialog_kendo_dialog_0_kendo_dialog_actions_3_Template, 3, 2, "kendo-dialog-actions", 3);
50
+ i0.ɵɵelementEnd();
51
+ } if (rf & 2) {
52
+ const ctx_r0 = i0.ɵɵnextContext();
53
+ i0.ɵɵproperty("title", ctx_r0.Title)("width", ctx_r0.Width)("height", ctx_r0.Height);
54
+ i0.ɵɵadvance(3);
55
+ i0.ɵɵproperty("ngIf", ctx_r0.ShowSaveButton || ctx_r0.ShowCancelButton);
56
+ } }
57
+ export class EntityFormDialog {
58
+ constructor() {
59
+ /**
60
+ * The title of the dialog
61
+ */
62
+ this.Title = '';
63
+ this.ShowSaveButton = true;
64
+ this.ShowCancelButton = true;
65
+ this.Width = 800;
66
+ this.Height = 600;
67
+ this.Mode = 'complete';
68
+ this.SectionName = '';
69
+ this.Record = null;
70
+ /**
71
+ * If true, when the user clicks the Save button, the Record will be saved. Only applicable if ShowSaveButton is true.
72
+ */
73
+ this.HandleSave = true;
74
+ /**
75
+ * If true, when the user clicks the Cancel button, the Record will be reverted to its original state. Only applicable if ShowCancelButton is true.
76
+ */
77
+ this.AutoRevertOnCancel = true;
78
+ this.close = new EventEmitter();
79
+ this._visible = false;
80
+ }
81
+ set Visible(val) {
82
+ this._visible = val;
83
+ if (val) {
84
+ Promise.resolve().then(() => {
85
+ // At this point, the DOM should be updated, and `this.container` should be available.
86
+ this.showForm();
87
+ });
88
+ }
89
+ }
90
+ get Visible() {
91
+ return this._visible;
92
+ }
93
+ showForm() {
94
+ var _a, _b;
95
+ if (!this.container)
96
+ throw new Error('Container not found');
97
+ if (!this.Record)
98
+ throw new Error('Record is a required property');
99
+ // Ensure the container is clear before inserting a new component
100
+ this.container.clear();
101
+ // here we want to grab the right type of object to instantiate based on the settings either mode of complete or section
102
+ // if section, we grab a sub-class of BaseFormSectionComponent, if complete, we grab a sub-class of the BaseForComponent class
103
+ let reg;
104
+ if (this.Mode === 'complete') {
105
+ reg = MJGlobal.Instance.ClassFactory.GetRegistration(BaseFormComponent, (_a = this.Record) === null || _a === void 0 ? void 0 : _a.EntityInfo.Name);
106
+ }
107
+ else {
108
+ reg = MJGlobal.Instance.ClassFactory.GetRegistration(BaseFormSectionComponent, ((_b = this.Record) === null || _b === void 0 ? void 0 : _b.EntityInfo.Name) + '.' + this.SectionName);
109
+ }
110
+ if (reg && reg.SubClass) {
111
+ // we have our class registration
112
+ const component = this.container.createComponent(reg.SubClass);
113
+ if (this.Record && component.instance instanceof BaseFormSectionComponent) {
114
+ component.instance.record = this.Record;
115
+ component.instance.EditMode = true;
116
+ }
117
+ else if (this.Record && component.instance instanceof BaseFormComponent) {
118
+ component.instance.record = this.Record;
119
+ component.instance.EditMode = true;
120
+ }
121
+ }
122
+ }
123
+ closeWindow(status) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ this.Visible = false;
126
+ if (this.Record) {
127
+ if (this.HandleSave && status === 'Save') {
128
+ if (!(yield this.Record.Save())) {
129
+ SharedService.Instance.CreateSimpleNotification(`Error saving ${this.Record.EntityInfo.Name} record, rolling back changes`, 'error');
130
+ this.Record.Revert();
131
+ }
132
+ }
133
+ if (this.AutoRevertOnCancel && status === 'Cancel') {
134
+ this.Record.Revert();
135
+ }
136
+ }
137
+ this.close.emit(status);
138
+ });
139
+ }
140
+ }
141
+ EntityFormDialog.ɵfac = function EntityFormDialog_Factory(t) { return new (t || EntityFormDialog)(); };
142
+ EntityFormDialog.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EntityFormDialog, selectors: [["mj-entity-form-dialog"]], viewQuery: function EntityFormDialog_Query(rf, ctx) { if (rf & 1) {
143
+ i0.ɵɵviewQuery(_c0, 5, ViewContainerRef);
144
+ } if (rf & 2) {
145
+ let _t;
146
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
147
+ } }, inputs: { Title: "Title", ShowSaveButton: "ShowSaveButton", ShowCancelButton: "ShowCancelButton", Width: "Width", Height: "Height", Mode: "Mode", SectionName: "SectionName", Record: "Record", HandleSave: "HandleSave", AutoRevertOnCancel: "AutoRevertOnCancel", Visible: "Visible" }, outputs: { close: "close" }, decls: 1, vars: 1, consts: [[3, "title", "width", "height", "close", 4, "ngIf"], [3, "title", "width", "height", "close"], ["dynamicFormContainer", ""], [4, "ngIf"], ["kendoButton", "", "themeColor", "primary", 3, "click", 4, "ngIf"], ["kendoButton", "", 3, "click", 4, "ngIf"], ["kendoButton", "", "themeColor", "primary", 3, "click"], ["kendoButton", "", 3, "click"]], template: function EntityFormDialog_Template(rf, ctx) { if (rf & 1) {
148
+ i0.ɵɵtemplate(0, EntityFormDialog_kendo_dialog_0_Template, 4, 4, "kendo-dialog", 0);
149
+ } if (rf & 2) {
150
+ i0.ɵɵproperty("ngIf", ctx.Visible);
151
+ } }, dependencies: [i1.NgIf, i2.DialogComponent, i2.DialogActionsComponent, i3.ButtonComponent] });
152
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EntityFormDialog, [{
153
+ type: Component,
154
+ args: [{ selector: 'mj-entity-form-dialog', template: "<kendo-dialog *ngIf=\"Visible\" \r\n [title]=\"Title\" \r\n [width]=\"Width\"\r\n [height]=\"Height\"\r\n (close)=\"closeWindow('Cancel')\" >\r\n <ng-template #dynamicFormContainer></ng-template>\r\n <kendo-dialog-actions *ngIf=\"ShowSaveButton || ShowCancelButton\">\r\n <button *ngIf=\"ShowSaveButton\" kendoButton (click)=\"closeWindow('Save')\" themeColor=\"primary\">Save</button>\r\n <button *ngIf=\"ShowCancelButton\" kendoButton (click)=\"closeWindow('Cancel')\">Cancel</button>\r\n </kendo-dialog-actions>\r\n</kendo-dialog>" }]
155
+ }], null, { Title: [{
156
+ type: Input
157
+ }], ShowSaveButton: [{
158
+ type: Input
159
+ }], ShowCancelButton: [{
160
+ type: Input
161
+ }], Width: [{
162
+ type: Input
163
+ }], Height: [{
164
+ type: Input
165
+ }], Mode: [{
166
+ type: Input
167
+ }], SectionName: [{
168
+ type: Input
169
+ }], Record: [{
170
+ type: Input
171
+ }], HandleSave: [{
172
+ type: Input
173
+ }], AutoRevertOnCancel: [{
174
+ type: Input
175
+ }], close: [{
176
+ type: Output
177
+ }], Visible: [{
178
+ type: Input
179
+ }], container: [{
180
+ type: ViewChild,
181
+ args: ['dynamicFormContainer', { read: ViewContainerRef }]
182
+ }] }); })();
183
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(EntityFormDialog, { className: "EntityFormDialog", filePath: "src\\lib\\entity-form-dialog\\entity-form-dialog.component.ts", lineNumber: 15 }); })();
@@ -0,0 +1,17 @@
1
+ import { ViewContainerRef, EventEmitter } from '@angular/core';
2
+ import { BaseEntity } from '@memberjunction/core';
3
+ import * as i0 from "@angular/core";
4
+ export declare class EntityFormWindow {
5
+ Mode: 'complete' | 'section';
6
+ SectionName: string;
7
+ Record: BaseEntity | null;
8
+ close: EventEmitter<void>;
9
+ private _visible;
10
+ set Visible(val: boolean);
11
+ get Visible(): boolean;
12
+ container: ViewContainerRef;
13
+ showForm(): void;
14
+ closeWindow(): void;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityFormWindow, never>;
16
+ static ɵcmp: i0.ɵɵComponentDeclaration<EntityFormWindow, "mj-entity-form-window", never, { "Mode": { "alias": "Mode"; "required": false; }; "SectionName": { "alias": "SectionName"; "required": false; }; "Record": { "alias": "Record"; "required": false; }; "Visible": { "alias": "Visible"; "required": false; }; }, { "close": "close"; }, never, never, false, never>;
17
+ }