@memberjunction/ng-user-view-grid 0.9.111 → 0.9.120

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.
@@ -1,1000 +1,1007 @@
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, ViewChild, ElementRef, Output, EventEmitter, Input } from '@angular/core';
11
- import { Metadata, RunView, EntityFieldTSType, LogError } from '@memberjunction/core';
12
- import { ViewInfo } from '@memberjunction/core-entities';
13
- import { GridComponent } from "@progress/kendo-angular-grid";
14
- import { Keys } from '@progress/kendo-angular-common';
15
- import { Subject } from 'rxjs';
16
- import { ExcelExportComponent } from '@progress/kendo-angular-excel-export';
17
- import { MJEventType, MJGlobal } from '@memberjunction/global';
18
- import * as i0 from "@angular/core";
19
- import * as i1 from "@angular/forms";
20
- import * as i2 from "@angular/router";
21
- import * as i3 from "@angular/common";
22
- import * as i4 from "@progress/kendo-angular-grid";
23
- import * as i5 from "@progress/kendo-angular-dialog";
24
- import * as i6 from "@progress/kendo-angular-excel-export";
25
- import * as i7 from "@progress/kendo-angular-buttons";
26
- import * as i8 from "@memberjunction/ng-compare-records";
27
- import * as i9 from "@memberjunction/ng-container-directives";
28
- const _c0 = ["kendoGrid"];
29
- const _c1 = ["excelExport"];
30
- const _c2 = ["recordCompareRef"];
31
- function UserViewGridComponent_ng_template_3_button_0_Template(rf, ctx) { if (rf & 1) {
32
- const _r16 = i0.ɵɵgetCurrentView();
33
- i0.ɵɵelementStart(0, "button", 14);
34
- i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_3_button_0_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r16); const ctx_r15 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r15.doExcelExport()); });
35
- i0.ɵɵtext(1, "Export to Excel");
36
- i0.ɵɵelementEnd();
37
- } }
38
- function UserViewGridComponent_ng_template_3_button_1_Template(rf, ctx) { if (rf & 1) {
39
- const _r18 = i0.ɵɵgetCurrentView();
40
- i0.ɵɵelementStart(0, "button", 15);
41
- i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_3_button_1_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r18); const ctx_r17 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r17.enableMergeOrCompare(false, "compare")); });
42
- i0.ɵɵtext(1, "Compare");
43
- i0.ɵɵelementEnd();
44
- } if (rf & 2) {
45
- const ctx_r8 = i0.ɵɵnextContext(2);
46
- i0.ɵɵproperty("disabled", ctx_r8.compareMode && ctx_r8.recordsToCompare.length < 2);
47
- } }
48
- function UserViewGridComponent_ng_template_3_button_2_Template(rf, ctx) { if (rf & 1) {
49
- const _r20 = i0.ɵɵgetCurrentView();
50
- i0.ɵɵelementStart(0, "button", 15);
51
- i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_3_button_2_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r20); const ctx_r19 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r19.enableMergeOrCompare(false, "compare")); });
52
- i0.ɵɵtext(1, "Compare");
53
- i0.ɵɵelementEnd();
54
- } if (rf & 2) {
55
- const ctx_r9 = i0.ɵɵnextContext(2);
56
- i0.ɵɵproperty("disabled", ctx_r9.compareMode && ctx_r9.recordsToCompare.length < 2);
57
- } }
58
- function UserViewGridComponent_ng_template_3_button_3_Template(rf, ctx) { if (rf & 1) {
59
- const _r22 = i0.ɵɵgetCurrentView();
60
- i0.ɵɵelementStart(0, "button", 16);
61
- i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_3_button_3_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r22); const ctx_r21 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r21.enableMergeOrCompare(true, "compare")); });
62
- i0.ɵɵtext(1, "Cancel");
63
- i0.ɵɵelementEnd();
64
- } }
65
- function UserViewGridComponent_ng_template_3_button_4_Template(rf, ctx) { if (rf & 1) {
66
- const _r24 = i0.ɵɵgetCurrentView();
67
- i0.ɵɵelementStart(0, "button", 15);
68
- i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_3_button_4_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r24); const ctx_r23 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r23.enableMergeOrCompare(false, "merge")); });
69
- i0.ɵɵtext(1, "Merge");
70
- i0.ɵɵelementEnd();
71
- } if (rf & 2) {
72
- const ctx_r11 = i0.ɵɵnextContext(2);
73
- i0.ɵɵproperty("disabled", ctx_r11.mergeMode && ctx_r11.recordsToCompare.length < 2);
74
- } }
75
- function UserViewGridComponent_ng_template_3_button_5_Template(rf, ctx) { if (rf & 1) {
76
- const _r26 = i0.ɵɵgetCurrentView();
77
- i0.ɵɵelementStart(0, "button", 16);
78
- i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_3_button_5_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r26); const ctx_r25 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r25.enableMergeOrCompare(false, "merge")); });
79
- i0.ɵɵtext(1, "Merge");
80
- i0.ɵɵelementEnd();
81
- } }
82
- function UserViewGridComponent_ng_template_3_button_6_Template(rf, ctx) { if (rf & 1) {
83
- const _r28 = i0.ɵɵgetCurrentView();
84
- i0.ɵɵelementStart(0, "button", 16);
85
- i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_3_button_6_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r28); const ctx_r27 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r27.enableMergeOrCompare(true, "merge")); });
86
- i0.ɵɵtext(1, "Cancel");
87
- i0.ɵɵelementEnd();
88
- } }
89
- function UserViewGridComponent_ng_template_3_button_7_Template(rf, ctx) { if (rf & 1) {
90
- const _r30 = i0.ɵɵgetCurrentView();
91
- i0.ɵɵelementStart(0, "button", 17);
92
- i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_3_button_7_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r30); const ctx_r29 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r29.RefreshFromSavedParams()); });
93
- i0.ɵɵtext(1, " Refresh ");
94
- i0.ɵɵelementEnd();
95
- } if (rf & 2) {
96
- i0.ɵɵproperty("primary", true);
97
- } }
98
- function UserViewGridComponent_ng_template_3_Template(rf, ctx) { if (rf & 1) {
99
- i0.ɵɵtemplate(0, UserViewGridComponent_ng_template_3_button_0_Template, 2, 0, "button", 10);
100
- i0.ɵɵtemplate(1, UserViewGridComponent_ng_template_3_button_1_Template, 2, 1, "button", 11);
101
- i0.ɵɵtemplate(2, UserViewGridComponent_ng_template_3_button_2_Template, 2, 1, "button", 11);
102
- i0.ɵɵtemplate(3, UserViewGridComponent_ng_template_3_button_3_Template, 2, 0, "button", 12);
103
- i0.ɵɵtemplate(4, UserViewGridComponent_ng_template_3_button_4_Template, 2, 1, "button", 11);
104
- i0.ɵɵtemplate(5, UserViewGridComponent_ng_template_3_button_5_Template, 2, 0, "button", 12);
105
- i0.ɵɵtemplate(6, UserViewGridComponent_ng_template_3_button_6_Template, 2, 0, "button", 12);
106
- i0.ɵɵtemplate(7, UserViewGridComponent_ng_template_3_button_7_Template, 2, 1, "button", 13);
107
- } if (rf & 2) {
108
- const ctx_r1 = i0.ɵɵnextContext();
109
- i0.ɵɵproperty("ngIf", !ctx_r1.compareMode && !ctx_r1.mergeMode);
110
- i0.ɵɵadvance(1);
111
- i0.ɵɵproperty("ngIf", !ctx_r1.compareMode && !ctx_r1.mergeMode);
112
- i0.ɵɵadvance(1);
113
- i0.ɵɵproperty("ngIf", ctx_r1.compareMode);
114
- i0.ɵɵadvance(1);
115
- i0.ɵɵproperty("ngIf", ctx_r1.compareMode);
116
- i0.ɵɵadvance(1);
117
- i0.ɵɵproperty("ngIf", ctx_r1.mergeMode);
118
- i0.ɵɵadvance(1);
119
- i0.ɵɵproperty("ngIf", !ctx_r1.mergeMode && !ctx_r1.compareMode);
120
- i0.ɵɵadvance(1);
121
- i0.ɵɵproperty("ngIf", ctx_r1.mergeMode);
122
- i0.ɵɵadvance(1);
123
- i0.ɵɵproperty("ngIf", ctx_r1.showRefreshButton && !ctx_r1.compareMode && !ctx_r1.mergeMode);
124
- } }
125
- const _c3 = function () { return { "text-align": "center", "vertical-align": "center" }; };
126
- const _c4 = function () { return { "font-weight": "bold", "background-color": "#a9c2af" }; };
127
- function UserViewGridComponent_kendo_grid_checkbox_column_4_Template(rf, ctx) { if (rf & 1) {
128
- i0.ɵɵelement(0, "kendo-grid-checkbox-column", 18);
129
- } if (rf & 2) {
130
- i0.ɵɵstyleMap(i0.ɵɵpureFunction0(4, _c3));
131
- i0.ɵɵproperty("width", 50)("headerStyle", i0.ɵɵpureFunction0(5, _c4));
132
- } }
133
- function UserViewGridComponent_kendo_grid_column_5_1_ng_template_0_Template(rf, ctx) { if (rf & 1) {
134
- i0.ɵɵtext(0);
135
- i0.ɵɵpipe(1, "number");
136
- i0.ɵɵpipe(2, "number");
137
- i0.ɵɵelement(3, "br");
138
- i0.ɵɵelementStart(4, "span", 21);
139
- i0.ɵɵtext(5);
140
- i0.ɵɵpipe(6, "number");
141
- i0.ɵɵelementEnd();
142
- } if (rf & 2) {
143
- const ctx_r33 = i0.ɵɵnextContext(3);
144
- i0.ɵɵtextInterpolate2(" ", i0.ɵɵpipeBind1(1, 3, ctx_r33.viewData.length), "", ctx_r33.totalRowCount > ctx_r33.viewData.length ? " of " + i0.ɵɵpipeBind1(2, 5, ctx_r33.totalRowCount) : " rows", "");
145
- i0.ɵɵadvance(5);
146
- i0.ɵɵtextInterpolate1("", i0.ɵɵpipeBind2(6, 7, ctx_r33.viewExecutionTime, "1.2-2"), " seconds");
147
- } }
148
- function UserViewGridComponent_kendo_grid_column_5_1_Template(rf, ctx) { if (rf & 1) {
149
- i0.ɵɵtemplate(0, UserViewGridComponent_kendo_grid_column_5_1_ng_template_0_Template, 7, 10, "ng-template", 20);
150
- } }
151
- function UserViewGridComponent_kendo_grid_column_5_Template(rf, ctx) { if (rf & 1) {
152
- i0.ɵɵelementStart(0, "kendo-grid-column", 19);
153
- i0.ɵɵtemplate(1, UserViewGridComponent_kendo_grid_column_5_1_Template, 1, 0, null, 9);
154
- i0.ɵɵelementEnd();
155
- } if (rf & 2) {
156
- const item_r31 = ctx.$implicit;
157
- const ctx_r3 = i0.ɵɵnextContext();
158
- i0.ɵɵstyleMap(ctx_r3.GetColumnCellStyle(item_r31));
159
- i0.ɵɵproperty("field", item_r31.Name)("title", ctx_r3.GetColumnTitle(item_r31))("width", item_r31.width ? item_r31.width : 100)("editable", item_r31.EntityField.AllowUpdateAPI)("editor", ctx_r3.getEditor(item_r31.EntityField))("headerStyle", i0.ɵɵpureFunction0(9, _c4));
160
- i0.ɵɵadvance(1);
161
- i0.ɵɵproperty("ngIf", item_r31 === ctx_r3.visibleColumns[0]);
162
- } }
163
- function UserViewGridComponent_kendo_excelexport_column_8_Template(rf, ctx) { if (rf & 1) {
164
- i0.ɵɵelement(0, "kendo-excelexport-column", 22);
165
- } if (rf & 2) {
166
- const exportCol_r34 = ctx.$implicit;
167
- i0.ɵɵproperty("field", exportCol_r34.Name)("title", exportCol_r34.Name);
168
- } }
169
- function UserViewGridComponent_div_9_kendo_window_2_button_6_Template(rf, ctx) { if (rf & 1) {
170
- const _r42 = i0.ɵɵgetCurrentView();
171
- i0.ɵɵelementStart(0, "button", 33);
172
- i0.ɵɵlistener("click", function UserViewGridComponent_div_9_kendo_window_2_button_6_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r42); const ctx_r41 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r41.closeCompareDialog("close")); });
173
- i0.ɵɵtext(1, "Close");
174
- i0.ɵɵelementEnd();
175
- } }
176
- function UserViewGridComponent_div_9_kendo_window_2_button_7_Template(rf, ctx) { if (rf & 1) {
177
- const _r44 = i0.ɵɵgetCurrentView();
178
- i0.ɵɵelementStart(0, "button", 33);
179
- i0.ɵɵlistener("click", function UserViewGridComponent_div_9_kendo_window_2_button_7_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r44); const ctx_r43 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r43.closeCompareDialog("cancel")); });
180
- i0.ɵɵtext(1, "Cancel");
181
- i0.ɵɵelementEnd();
182
- } }
183
- function UserViewGridComponent_div_9_kendo_window_2_button_8_Template(rf, ctx) { if (rf & 1) {
184
- const _r46 = i0.ɵɵgetCurrentView();
185
- i0.ɵɵelementStart(0, "button", 34);
186
- i0.ɵɵlistener("click", function UserViewGridComponent_div_9_kendo_window_2_button_8_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r46); const ctx_r45 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r45.closeCompareDialog("merge")); });
187
- i0.ɵɵtext(1, " Merge Records ");
188
- i0.ɵɵelementEnd();
189
- } }
190
- function UserViewGridComponent_div_9_kendo_window_2_kendo_dialog_9_Template(rf, ctx) { if (rf & 1) {
191
- const _r48 = i0.ɵɵgetCurrentView();
192
- i0.ɵɵelementStart(0, "kendo-dialog", 35);
193
- i0.ɵɵlistener("close", function UserViewGridComponent_div_9_kendo_window_2_kendo_dialog_9_Template_kendo_dialog_close_0_listener() { i0.ɵɵrestoreView(_r48); const ctx_r47 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r47.closeConfirmMergeDialog("cancel")); });
194
- i0.ɵɵelementStart(1, "p", 36);
195
- i0.ɵɵtext(2, " Are you sure you want to merge the records? This action cannot be undone. If you select \"Yes\", the records will be merged and the duplicate records will be deleted. ");
196
- i0.ɵɵelementEnd();
197
- i0.ɵɵelementStart(3, "kendo-dialog-actions")(4, "button", 37);
198
- i0.ɵɵlistener("click", function UserViewGridComponent_div_9_kendo_window_2_kendo_dialog_9_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r48); const ctx_r49 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r49.closeConfirmMergeDialog("no")); });
199
- i0.ɵɵtext(5, "No");
200
- i0.ɵɵelementEnd();
201
- i0.ɵɵelementStart(6, "button", 38);
202
- i0.ɵɵlistener("click", function UserViewGridComponent_div_9_kendo_window_2_kendo_dialog_9_Template_button_click_6_listener() { i0.ɵɵrestoreView(_r48); const ctx_r50 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r50.closeConfirmMergeDialog("yes")); });
203
- i0.ɵɵtext(7, " Yes ");
204
- i0.ɵɵelementEnd()()();
205
- } if (rf & 2) {
206
- i0.ɵɵproperty("minWidth", 250)("width", 450);
207
- } }
208
- function UserViewGridComponent_div_9_kendo_window_2_Template(rf, ctx) { if (rf & 1) {
209
- const _r52 = i0.ɵɵgetCurrentView();
210
- i0.ɵɵelementStart(0, "kendo-window", 25);
211
- i0.ɵɵlistener("close", function UserViewGridComponent_div_9_kendo_window_2_Template_kendo_window_close_0_listener($event) { i0.ɵɵrestoreView(_r52); const ctx_r51 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r51.closeCompareDialog($event)); });
212
- i0.ɵɵelementStart(1, "div", 26)(2, "div");
213
- i0.ɵɵelement(3, "mj-compare-records", 27, 28);
214
- i0.ɵɵelementEnd()();
215
- i0.ɵɵelementStart(5, "div", 29);
216
- i0.ɵɵtemplate(6, UserViewGridComponent_div_9_kendo_window_2_button_6_Template, 2, 0, "button", 30);
217
- i0.ɵɵtemplate(7, UserViewGridComponent_div_9_kendo_window_2_button_7_Template, 2, 0, "button", 30);
218
- i0.ɵɵtemplate(8, UserViewGridComponent_div_9_kendo_window_2_button_8_Template, 2, 0, "button", 31);
219
- i0.ɵɵelementEnd();
220
- i0.ɵɵtemplate(9, UserViewGridComponent_div_9_kendo_window_2_kendo_dialog_9_Template, 8, 2, "kendo-dialog", 32);
221
- i0.ɵɵelementEnd();
222
- } if (rf & 2) {
223
- const ctx_r35 = i0.ɵɵnextContext(2);
224
- i0.ɵɵproperty("minHeight", 300)("minWidth", 400)("resizable", true);
225
- i0.ɵɵadvance(3);
226
- i0.ɵɵproperty("entityName", ctx_r35._entityInfo ? ctx_r35._entityInfo.Name : "")("recordsToCompare", ctx_r35.recordsToCompare)("visibleColumns", ctx_r35.visibleColumns)("selectionMode", ctx_r35.mergeMode ? true : false);
227
- i0.ɵɵadvance(3);
228
- i0.ɵɵproperty("ngIf", ctx_r35.compareMode);
229
- i0.ɵɵadvance(1);
230
- i0.ɵɵproperty("ngIf", ctx_r35.mergeMode);
231
- i0.ɵɵadvance(1);
232
- i0.ɵɵproperty("ngIf", ctx_r35.mergeMode);
233
- i0.ɵɵadvance(1);
234
- i0.ɵɵproperty("ngIf", ctx_r35.isConfirmDialogOpen);
235
- } }
236
- function UserViewGridComponent_div_9_Template(rf, ctx) { if (rf & 1) {
237
- i0.ɵɵelementStart(0, "div");
238
- i0.ɵɵelement(1, "div", 23);
239
- i0.ɵɵtemplate(2, UserViewGridComponent_div_9_kendo_window_2_Template, 10, 11, "kendo-window", 24);
240
- i0.ɵɵelementEnd();
241
- } if (rf & 2) {
242
- const ctx_r6 = i0.ɵɵnextContext();
243
- i0.ɵɵadvance(2);
244
- i0.ɵɵproperty("ngIf", ctx_r6.isCompareDialogOpened);
245
- } }
246
- export class UserViewGridComponent {
247
- get PendingRecords() {
248
- return this._pendingRecords;
249
- }
250
- StartEditMode() {
251
- this.InEditMode = true;
252
- }
253
- EndEditMode() {
254
- this.InEditMode = false;
255
- this.editModeEnded.next();
256
- }
257
- EditingComplete() {
258
- if (this.InEditMode) {
259
- // we need to wait for edit mode to end before we can return true
260
- return new Promise((resolve, reject) => {
261
- const subscription = this.editModeEnded.subscribe(() => {
262
- resolve(true);
263
- subscription.unsubscribe();
264
- });
265
- });
266
- }
267
- else
268
- return Promise.resolve(true); // not in edit mode, so editing is complete!
269
- }
270
- IsDynamicView() {
271
- return !this._viewEntity; // if we have a viewEntity it is a stored view
272
- }
273
- pageChange(event) {
274
- this.skip = event.skip;
275
- this.virtualLoadData();
276
- }
277
- virtualLoadData() {
278
- // check to see if we have already formatted the slice of the data we need right now
279
- // we are storing the formattted data in the formattedData array and it has same set
280
- // of indexes as the viewData array (raw unformatted data). When we first get viewData
281
- // from the server we create an array of the same length as viewData, but have nulls in all of the
282
- // indexes. As we format each row of viewData we store the formatted row in the same index
283
- // in the formattedData array. So if we have already formatted the data we need for the current
284
- // page, we just use that data, otherwise we format the data we need for the current page
285
- try {
286
- // check to see if we have already formatted the data we need for the current page
287
- for (let i = this.skip; (i < (this.skip + this.pageSize)) && (i < this.viewData.length); i++) {
288
- if (!this.formattedData[i]) {
289
- // we have not formatted this row yet, so format it
290
- const r = this.viewColumns.map((c) => {
291
- if (c && c.EntityField && this.viewData[i] && this.viewData[i][c.EntityField.Name]) {
292
- if (!c.hidden && c.EntityField.Name !== 'ID') {
293
- const ef = c.EntityField;
294
- return { field: c.EntityField.Name, value: ef.FormatValue(this.viewData[i][c.EntityField.Name], 0, undefined, 300) };
295
- }
296
- else
297
- return { field: c.EntityField.Name, value: this.viewData[i][c.EntityField.Name] }; // hidden column, so just return the value, don't bother formatting
298
- }
299
- else
300
- return { field: c.Name, value: null };
301
- });
302
- // now r is an array of {field: string, value: any} objects, so we need to convert it to an object
303
- // with the field names as the keys and the values as the values
304
- const row = {};
305
- for (let j = 0; j < r.length; j++) {
306
- if (r[j] && r[j].field && r[j].field.length > 0)
307
- row[r[j].field] = r[j].value;
308
- }
309
- this.formattedData[i] = row;
310
- }
311
- }
312
- // now that we have made sure current page of data is formatted, we can return it
313
- this.gridView = {
314
- data: this.formattedData.slice(this.skip, this.skip + this.pageSize),
315
- total: this.viewData.length,
316
- };
317
- }
318
- catch (e) {
319
- LogError(e);
320
- }
321
- }
322
- constructor(formBuilder, router) {
323
- this.formBuilder = formBuilder;
324
- this.router = router;
325
- this.title = 'UserViewGrid';
326
- this.BottomMargin = 0;
327
- this.InEditMode = false;
328
- this.EditMode = "None";
329
- this.AutoNavigate = true;
330
- this.rowClicked = new EventEmitter();
331
- this.rowEdited = new EventEmitter();
332
- this.kendoGridElement = null;
333
- this.kendoGridElementRef = null;
334
- this.kendoExcelExport = null;
335
- this.recordCompareComponent = null;
336
- this._pendingRecords = [];
337
- this.viewData = [];
338
- this.totalRowCount = 0;
339
- this.formattedData = [];
340
- this.viewColumns = [];
341
- this.visibleColumns = [];
342
- this.sortSettings = [];
343
- this.entityRecord = null;
344
- this.skip = 0;
345
- this.pageSize = 40;
346
- this.isLoading = false;
347
- this.gridView = { data: [], total: 0 };
348
- this.gridHeight = 750;
349
- this._newGridState = {};
350
- this.editModeEnded = new Subject();
351
- this.recordsToCompare = [];
352
- this.compareMode = false;
353
- // public compareRecords: BaseEntity[] = [];
354
- this.mergeMode = false;
355
- // public mergeRecords: BaseEntity[] = [];
356
- this.selectableSettings = {
357
- enabled: false
358
- };
359
- this.selectedKeys = [];
360
- this.isCompareDialogOpened = false;
361
- this.isConfirmDialogOpen = false;
362
- this.showRefreshButton = true;
363
- this.viewExecutionTime = 0;
364
- this._viewDirty = false;
365
- this._deferLoadCount = 0;
366
- this._allowLoad = true;
367
- // Export Functionality
368
- this.exportColumns = [];
369
- this.exportData = [];
370
- }
371
- SaveView() {
372
- // debounced outer function...
373
- clearTimeout(this._saveTimeout);
374
- this._saveTimeout = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
375
- // when we actually call inner save view we do await
376
- yield this.innerSaveView();
377
- }), 5000); // 5 seconds delay
378
- }
379
- ;
380
- innerSaveView() {
381
- return __awaiter(this, void 0, void 0, function* () {
382
- if (this._viewDirty) {
383
- const md = new Metadata();
384
- if (this._viewEntity &&
385
- this._viewEntity.Get('UserID') === md.CurrentUser.ID) {
386
- // this view is a saved view, AND it belongs to the current user
387
- // update the grid state if we have settings updates for columns and/or sorts
388
- const tempGridState = JSON.parse(this._viewEntity.Get('GridState'));
389
- const tempColSettings = this._newGridState.columnSettings ? this._newGridState.columnSettings : tempGridState.columnSettings;
390
- tempColSettings.forEach((col) => { col.DisplayName, col.ID, col.Name, col.hidden, col.orderIndex, col.width; }); // remove EntityFieldInfo from the column settings
391
- tempGridState.columnSettings = tempColSettings;
392
- tempGridState.sortSettings = this._newGridState.sortSettings ? this._newGridState.sortSettings : tempGridState.sortSettings;
393
- // now stringify the grid state and save it
394
- this._viewEntity.Set('GridState', JSON.stringify(tempGridState));
395
- const newSortState = tempGridState.sortSettings.map((s) => { return { field: s.field, direction: s.dir }; });
396
- const oldSortState = JSON.parse(this._viewEntity.Get('SortState'));
397
- this._viewEntity.Set('SortState', JSON.stringify(newSortState));
398
- if (yield this._viewEntity.Save()) {
399
- // check to see if sort state changed and if so, refresh the grid
400
- if (JSON.stringify(newSortState) !== JSON.stringify(oldSortState)) {
401
- if (this.Params) // makes sure we have params before we refresh
402
- this.Refresh(this.Params);
403
- }
404
- this._viewDirty = false;
405
- }
406
- else {
407
- this.CreateSimpleNotification('Unable to save view settings', 'error', 5000);
408
- }
409
- }
410
- }
411
- });
412
- }
413
- CreateSimpleNotification(message, style, duration) {
414
- const data = {
415
- message: message,
416
- style: style,
417
- DisplayDuration: duration
418
- };
419
- MJGlobal.Instance.RaiseEvent({
420
- component: this,
421
- event: MJEventType.DisplaySimpleNotificationRequest,
422
- eventCode: "",
423
- args: data
424
- });
425
- }
426
- columnReorder(args) {
427
- return __awaiter(this, void 0, void 0, function* () {
428
- // Remove the column from the original position
429
- // need to find the column in the viewColumns array because args.old/new Indexes are from the visibleColumns array
430
- const fieldName = args.column.field;
431
- if (fieldName) {
432
- const vcOldIndex = this.viewColumns.findIndex((vc) => vc.Name === fieldName);
433
- const vcNewIndex = this.viewColumns.findIndex((vc) => vc.orderIndex === args.newIndex);
434
- if (vcOldIndex >= 0) {
435
- // got the index, now remove the element
436
- const element = this.viewColumns.splice(vcOldIndex, 1)[0];
437
- // Insert it at the new position
438
- this.viewColumns.splice(vcNewIndex, 0, element);
439
- // go through all of the columns and set orderIndex as that isn't done automatically
440
- let visColIndex = 0;
441
- for (let i = 0; i < this.viewColumns.length; i++) {
442
- if (!this.viewColumns[i].hidden) {
443
- this.viewColumns[i].orderIndex = visColIndex;
444
- visColIndex++;
445
- }
446
- }
447
- // now loop through all of the HIDDEN columns and set their orderIndex, done in second loop because we want first loop to give us total number of visible columns
448
- for (let i = 0; i < this.viewColumns.length; i++) {
449
- if (this.viewColumns[i].hidden) {
450
- this.viewColumns[i].orderIndex = visColIndex;
451
- visColIndex++;
452
- }
453
- }
454
- // make sure that _newGridState.columnSettings is set
455
- this._newGridState.columnSettings = this.viewColumns;
456
- this._viewDirty = true;
457
- this.SaveView();
458
- }
459
- }
460
- });
461
- }
462
- columnResize(args) {
463
- return __awaiter(this, void 0, void 0, function* () {
464
- for (const col of args) {
465
- const c = col.column;
466
- const viewCol = this.viewColumns.find(vc => vc.Name === c.field);
467
- const visCol = this.visibleColumns.find(vc => vc.Name === c.field);
468
- const visCols = this.visibleColumns;
469
- if (viewCol)
470
- viewCol.width = col.newWidth;
471
- }
472
- this._newGridState.columnSettings = this.viewColumns.map(vc => {
473
- return {
474
- Name: vc.Name,
475
- DisplayName: vc.DisplayName,
476
- width: vc.width,
477
- orderIndex: vc.orderIndex,
478
- hidden: vc.hidden
479
- };
480
- });
481
- this._viewDirty = true;
482
- this.SaveView();
483
- });
484
- }
485
- sortChanged(sort) {
486
- return __awaiter(this, void 0, void 0, function* () {
487
- if (sort && sort.length > 0) {
488
- // remove any sort settings that don't have a direction
489
- const filterSort = sort.filter((s) => s.dir !== undefined && s.dir !== null && s.dir !== "");
490
- this._newGridState.sortSettings = filterSort;
491
- }
492
- else
493
- this._newGridState.sortSettings = sort;
494
- this.sortSettings = this._newGridState.sortSettings; // for the UI display - grid binding to this shows that the sort is applied via arrows in the column headers
495
- if (this.IsDynamicView()) {
496
- // Dynamic View, we have this.Params and can add an OrderBy and then just Refresh() the entire component
497
- // that will result in going to the server for a refreshed set of data
498
- if (this.Params) {
499
- this.Params.OrderBy = sort[0].field + ' ' + (sort[0].dir);
500
- this.Refresh(this.Params);
501
- }
502
- else {
503
- LogError("sortChanged() called but this.Params is null or undefined"); // should never get here
504
- }
505
- }
506
- else {
507
- // Saved view - we do this on the server side only
508
- this._viewDirty = true;
509
- this.innerSaveView(); // for sort changes we call innerSaveView() directly, not through SaveView() which is debounced
510
- }
511
- });
512
- }
513
- cellClickHandler(args) {
514
- return __awaiter(this, void 0, void 0, function* () {
515
- if (this.compareMode || this.mergeMode)
516
- return;
517
- if (this._entityInfo) {
518
- const pkeyVals = [];
519
- this._entityInfo.PrimaryKeys.forEach((pkey) => {
520
- pkeyVals.push({ FieldName: pkey.Name, Value: this.viewData[args.rowIndex][pkey.Name] });
521
- });
522
- this.rowClicked.emit({
523
- entityId: this._entityInfo.ID,
524
- entityName: this._entityInfo.Name,
525
- primaryKeyValues: pkeyVals
526
- });
527
- if (this._entityInfo.AllowUpdateAPI &&
528
- this.EditMode !== "None") {
529
- const perm = this._entityInfo.GetUserPermisions(new Metadata().CurrentUser);
530
- if (perm.CanUpdate) {
531
- this.StartEditMode();
532
- args.sender.editCell(args.rowIndex, args.columnIndex, this.createFormGroup(args.dataItem));
533
- }
534
- }
535
- if (!this.InEditMode && this.AutoNavigate) {
536
- // tell app router to go to this record
537
- const pkVals = this.GeneratePrimaryKeyValueString(pkeyVals);
538
- this.router.navigate(['resource', 'record', pkVals], { queryParams: { Entity: this._entityInfo.Name } });
539
- }
540
- }
541
- });
542
- }
543
- GeneratePrimaryKeyValueString(pkVals) {
544
- return pkVals.length > 1 ? pkVals.map(pk => pk.FieldName + '|' + pk.Value).join('||') : pkVals[0].Value;
545
- }
546
- createFormGroup(dataItem) {
547
- const groupFields = {};
548
- this.viewColumns.forEach((vc) => {
549
- if (vc.EntityField.AllowUpdateAPI &&
550
- vc.EntityField.IsVirtual === false &&
551
- vc.EntityField.AllowUpdateInView)
552
- groupFields[vc.Name] = dataItem[vc.Name];
553
- });
554
- return this.formBuilder.group(groupFields);
555
- }
556
- getEditor(ef) {
557
- switch (ef.TSType) {
558
- case EntityFieldTSType.Boolean:
559
- return "boolean";
560
- case EntityFieldTSType.Date:
561
- return "date";
562
- case EntityFieldTSType.Number:
563
- return "numeric";
564
- default:
565
- return "text";
566
- }
567
- }
568
- cellCloseHandler(args) {
569
- var _a;
570
- return __awaiter(this, void 0, void 0, function* () {
571
- try {
572
- if (this._entityInfo && this.EditMode !== "None") {
573
- const { formGroup, dataItem } = args;
574
- if (!formGroup.valid) {
575
- // prevent closing the edited cell if there are invalid values.
576
- args.preventDefault();
577
- }
578
- else if (formGroup.dirty) {
579
- if (args.originalEvent && args.originalEvent.keyCode === Keys.Escape)
580
- return; // user hit escape, so don't save their changes
581
- // update the data item with the new values - this drives UI refresh while we save the record...
582
- Object.assign(dataItem, formGroup.value);
583
- const md = new Metadata();
584
- const pkey = this._entityInfo.PrimaryKey.Name;
585
- let record;
586
- let bSaved = false;
587
- if (this.EditMode === "Save") {
588
- record = yield md.GetEntityObject(this._entityInfo.Name);
589
- yield record.InnerLoad(this._entityInfo.PrimaryKeys.map(pk => {
590
- return {
591
- FieldName: pk.Name,
592
- Value: dataItem[pk.Name]
593
- };
594
- }));
595
- record.SetMany(formGroup.value);
596
- bSaved = yield record.Save();
597
- if (!bSaved)
598
- this.CreateSimpleNotification("Error saving record: " + record.Get(pkey), 'error', 5000);
599
- }
600
- else {
601
- record = (_a = this._pendingRecords.find((r) => r.record.Get(pkey) === dataItem[pkey])) === null || _a === void 0 ? void 0 : _a.record;
602
- if (!record) { // haven't edited this one before
603
- record = yield md.GetEntityObject(this._viewEntity.Get('Entity'));
604
- yield record.InnerLoad(this._entityInfo.PrimaryKeys.map(pk => {
605
- return {
606
- FieldName: pk.Name,
607
- Value: dataItem[pk.Name]
608
- };
609
- }));
610
- this._pendingRecords.push({ record,
611
- row: args.rowIndex,
612
- dataItem }); // don't save - put the changed record on a queue for saving later by our container
613
- }
614
- // go through the formGroup and only set the values that exist as columns in the grid
615
- const keys = Object.keys(formGroup.value);
616
- keys.forEach((k) => {
617
- const vc = this.viewColumns.find((vc) => vc.Name === k && vc.hidden === false);
618
- if (vc) {
619
- record.Set(k, formGroup.value[k]);
620
- }
621
- });
622
- //record.SetMany(formGroup.value);
623
- }
624
- this.rowEdited.emit({
625
- record: record,
626
- row: args.rowIndex,
627
- saved: bSaved
628
- });
629
- }
630
- }
631
- }
632
- catch (e) {
633
- console.error(e);
634
- }
635
- finally {
636
- this.EndEditMode();
637
- }
638
- });
639
- }
640
- // this handles reverting pending cahnges to records WITHIN the grid, not the user view settings, unrelated to that.
641
- RevertPendingChanges() {
642
- if (this._pendingRecords && this._pendingRecords.length > 0) {
643
- this._pendingRecords.forEach((r) => {
644
- r.record.Revert();
645
- Object.assign(r.dataItem, r.record.GetAll()); // copy the original values back to the data Item which gets the grid to display the old values again...
646
- });
647
- this._pendingRecords = [];
648
- if (this.Params)
649
- this.Refresh(this.Params);
650
- }
651
- }
652
- ngOnInit() {
653
- }
654
- ngAfterViewInit() {
655
- //this.setGridHeight();
656
- if (this.Params)
657
- this.Refresh(this.Params);
658
- }
659
- get AllowLoad() {
660
- return this._allowLoad;
661
- }
662
- set AllowLoad(value) {
663
- this._allowLoad = value;
664
- if (value === true && this._deferLoadCount === 0) {
665
- this._deferLoadCount++; // only do this one time
666
- if (this.Params)
667
- this.Refresh(this.Params);
668
- return;
669
- }
670
- }
671
- RefreshFromSavedParams() {
672
- return __awaiter(this, void 0, void 0, function* () {
673
- if (this.Params)
674
- this.Refresh(this.Params);
675
- });
676
- }
677
- Refresh(params) {
678
- var _a, _b, _c;
679
- return __awaiter(this, void 0, void 0, function* () {
680
- this.Params = params;
681
- if (this.AllowLoad === false) {
682
- return;
683
- }
684
- if (params && (params.ViewEntity || params.ViewID || params.ViewName || (params.EntityName && params.ExtraFilter))) {
685
- const startTime = new Date().getTime();
686
- this.isLoading = true;
687
- const md = new Metadata();
688
- const rv = new RunView();
689
- // get the view entity first so we can pass it in, otherwise it will end up getting loaded inside of RunView() which is inefficient as we need it too
690
- // this is done for performance purposes
691
- if (params.ViewEntity) {
692
- // When we receive the .ViewEntity via our params that is a time saver as we don't need to load it again, so ALWAYS use that instance of the entity object for the view entity
693
- this._viewEntity = params.ViewEntity;
694
- const e = md.Entities.find(x => { var _a; return x.ID === ((_a = this._viewEntity) === null || _a === void 0 ? void 0 : _a.EntityID); });
695
- if (e)
696
- this._entityInfo = e;
697
- else
698
- throw new Error("Unable to get entity info for view: " + ((_a = this._viewEntity) === null || _a === void 0 ? void 0 : _a.Name));
699
- }
700
- else if (!params.ViewEntity && (params.ViewID || params.ViewName)) {
701
- // this is NOT a dyamic view as we got either the ViewID or ViewName, so we can get the ViewEntity
702
- if (params.ViewID && params.ViewID > 0) {
703
- this._viewEntity = (yield ViewInfo.GetViewEntity(params.ViewID));
704
- }
705
- else if (params.ViewName) {
706
- this._viewEntity = (yield ViewInfo.GetViewEntityByName(params.ViewName));
707
- }
708
- params.ViewEntity = this._viewEntity;
709
- const e = md.Entities.find(x => { var _a; return x.ID === ((_a = this._viewEntity) === null || _a === void 0 ? void 0 : _a.EntityID); });
710
- if (e)
711
- this._entityInfo = e;
712
- else
713
- throw new Error("Unable to get entity info for view: " + ((_b = this._viewEntity) === null || _b === void 0 ? void 0 : _b.Name));
714
- }
715
- else if (params.EntityName) {
716
- // we don't have a ViewEntity because we're doing a dynamic view, so we need to get the entity info from the Entity Name
717
- const e = md.Entities.find(x => x.Name === params.EntityName);
718
- if (e)
719
- this._entityInfo = e;
720
- }
721
- else
722
- throw new Error("Invalid configuration, we need to receive either a ViewEntity, ViewID, ViewName, or EntityName and ExtraFilter in order to run a view");
723
- const rvResult = yield rv.RunView(params);
724
- if (!rvResult.Success) {
725
- // it failed
726
- this.CreateSimpleNotification("Error running view:\n\n" + rvResult.ErrorMessage, 'error', 5000);
727
- }
728
- else {
729
- // it worked
730
- this.viewData = rvResult.Results;
731
- this.totalRowCount = rvResult.TotalRowCount;
732
- this.formattedData = new Array(this.viewData.length);
733
- let cols;
734
- if (this._viewEntity)
735
- cols = this._viewEntity.Columns;
736
- else
737
- cols = (_c = this._entityInfo) === null || _c === void 0 ? void 0 : _c.Fields.filter((f) => f.DefaultInView).map((f) => {
738
- return {
739
- ID: f.ID,
740
- Name: f.Name,
741
- DisplayName: f.DisplayName,
742
- EntityField: f,
743
- hidden: false,
744
- orderIndex: f.Sequence,
745
- width: f.DefaultColumnWidth ? f.DefaultColumnWidth : 100,
746
- };
747
- });
748
- if (cols) {
749
- this.viewColumns = cols;
750
- const tempCols = cols.filter(x => x.hidden === false).sort((a, b) => {
751
- const aOrder = a.orderIndex != null ? a.orderIndex : 9999;
752
- const bOrder = b.orderIndex != null ? b.orderIndex : 9999;
753
- return aOrder - bOrder;
754
- });
755
- this.visibleColumns = tempCols;
756
- }
757
- // sorting setup
758
- if (this._viewEntity) {
759
- const temp = this._viewEntity.ViewSortInfo;
760
- const kendoSortSettings = temp.map((s) => {
761
- let dir;
762
- if (typeof s.direction === 'string')
763
- dir = s.direction.trim().toLowerCase();
764
- else if (typeof s.direction === 'number' && s.direction === 1)
765
- dir = 'asc';
766
- else if (typeof s.direction === 'number' && s.direction === 2)
767
- dir = 'desc';
768
- else
769
- dir = '';
770
- return { field: s.field, dir: dir };
771
- });
772
- this.sortSettings = kendoSortSettings;
773
- }
774
- this.skip = 0;
775
- this.virtualLoadData();
776
- }
777
- this.viewExecutionTime = (new Date().getTime() - startTime) / 1000; // in seconds
778
- this.isLoading = false;
779
- }
780
- else {
781
- LogError("Refresh(params) must have ViewID or ViewName or (EntityName and ExtraFilter)");
782
- }
783
- });
784
- }
785
- GetColumnTitle(col) {
786
- if (col.DisplayName)
787
- return col.DisplayName; // use view's display name first if it exists
788
- else if (col.EntityField.DisplayName)
789
- return col.EntityField.DisplayName; // then use entity display name, if that exist
790
- else
791
- return col.Name; // otherwise just use the column name
792
- }
793
- GetColumnCellStyle(col) {
794
- switch (col.EntityField.Type.trim().toLowerCase()) {
795
- case "money":
796
- case 'decimal':
797
- case 'real':
798
- case 'float':
799
- case 'int':
800
- return { 'text-align': 'right', 'vertical-align': 'top' }; // right align numbers,
801
- default:
802
- return { 'text-align': 'left', 'vertical-align': 'top' }; // left align everything else
803
- }
804
- }
805
- selectionChange(args) {
806
- // update recordsToCompare based on the this.selectedKeys property that is bound
807
- // selectedKeys is an array of indexes in the this.viewData, and we need to make our
808
- // this.recordsToCompare an array of records from this.viewData so just map() the selectedKeys for this
809
- this.recordsToCompare = this.selectedKeys.map((i) => this.viewData[i]);
810
- }
811
- enableMergeOrCompare(cancel = false, type) {
812
- if (!cancel && this.recordsToCompare.length >= 2) {
813
- // this scenario occurs when we've already started the merge/compare and the user has selected records, then clicked the merge/compare button again
814
- this.isCompareDialogOpened = true;
815
- }
816
- else if (cancel) {
817
- // the user clicked cancel in our toolbar
818
- if (type === 'merge')
819
- this.mergeMode = false;
820
- else
821
- this.compareMode = false;
822
- this.selectedKeys = [];
823
- this.recordsToCompare = [];
824
- }
825
- else {
826
- // just turning on merge mode from the merge/compare button, so just turn it on and let the user select records
827
- if (type === 'merge')
828
- this.mergeMode = true;
829
- else
830
- this.compareMode = true;
831
- }
832
- }
833
- closeConfirmMergeDialog(event) {
834
- return __awaiter(this, void 0, void 0, function* () {
835
- if (event === 'yes') {
836
- if (this._entityInfo && this.recordCompareComponent) {
837
- const md = new Metadata();
838
- const pkey = this._entityInfo.PrimaryKey.Name;
839
- const result = yield md.MergeRecords({
840
- EntityName: this._entityInfo.Name,
841
- RecordsToMerge: this.recordsToCompare.map((r) => r.Get(pkey)).filter((pkeyVal) => { var _a; return pkeyVal !== ((_a = this.recordCompareComponent) === null || _a === void 0 ? void 0 : _a.selectedRecordPKeyVal); }),
842
- SurvivingRecordPrimaryKeyValues: [{ FieldName: pkey, Value: this.recordCompareComponent.selectedRecordPKeyVal }],
843
- FieldMap: this.recordCompareComponent.fieldMap.map((fm) => {
844
- return {
845
- FieldName: fm.fieldName,
846
- Value: fm.value
847
- };
848
- })
849
- });
850
- if (result.Success) {
851
- // merge was successful, so refresh the grid
852
- this.selectedKeys = [];
853
- this.recordsToCompare = [];
854
- this.mergeMode = false;
855
- this.compareMode = false;
856
- // close the dialogs
857
- this.isCompareDialogOpened = false;
858
- this.isConfirmDialogOpen = false;
859
- // refresh the grid
860
- this.Refresh(this.Params);
861
- }
862
- else {
863
- // the merge failed, so show an error message
864
- this.isConfirmDialogOpen = false;
865
- this.CreateSimpleNotification("Error merging records: " + result.OverallStatus, 'error', 5000);
866
- }
867
- }
868
- }
869
- else {
870
- this.isConfirmDialogOpen = false;
871
- // close the dialog and let the user continue to work on the merge, so don't close the compare dialog
872
- }
873
- });
874
- }
875
- closeCompareDialog(event) {
876
- return __awaiter(this, void 0, void 0, function* () {
877
- console.log(event);
878
- switch (event) {
879
- case 'merge':
880
- // user has requested to merge the records and retain the selected record from the compare records component, so run the merge
881
- // first, confirm with the user to make 100% sure they want to do this as it is irreversible
882
- this.isConfirmDialogOpen = true;
883
- break;
884
- default: // close and cancel
885
- this.selectedKeys = [];
886
- this.recordsToCompare = [];
887
- this.mergeMode = false;
888
- this.compareMode = false;
889
- this.isCompareDialogOpened = false;
890
- break;
891
- }
892
- });
893
- }
894
- doExcelExport() {
895
- return __awaiter(this, void 0, void 0, function* () {
896
- if (this.kendoExcelExport === null)
897
- throw new Error("kendoExcelExport is null, cannot export data");
898
- try {
899
- this.CreateSimpleNotification("Working on the export, will notify you when it is complete...", 'info', 2000);
900
- const data = yield this.getExportData();
901
- // we have the data.
902
- const cols = this.viewColumns.filter((vc) => vc.hidden === false);
903
- this.exportColumns = cols;
904
- this.exportData = data;
905
- // before we call the save, we need to let Angular do its thing that will result in the kendoExcelExport component binding properly to
906
- // the exportColumns and exportData arrays. So we wait for the next tick before we call save()
907
- setTimeout(() => {
908
- this.kendoExcelExport.save();
909
- this.CreateSimpleNotification("Excel Export Complete", 'success', 2000);
910
- }, 100);
911
- }
912
- catch (e) {
913
- this.CreateSimpleNotification("Error exporting data", 'error', 5000);
914
- LogError(e);
915
- }
916
- });
917
- }
918
- getExportData() {
919
- return __awaiter(this, void 0, void 0, function* () {
920
- // Get the data for the ENTIRE view, not just the current page
921
- const md = new Metadata();
922
- const rv = new RunView();
923
- const p = Object.assign(Object.assign({}, this.Params), { IgnoreMaxRows: true, ForceAuditLog: true, AuditLogDescription: `Export of Data From ${this._viewEntity ? '"' + this._viewEntity.Get('Name') + '"' : ''} View for User ${md.CurrentUser.Email}` });
924
- const result = yield rv.RunView(p);
925
- if (result && result.Success) {
926
- return result.Results;
927
- }
928
- else
929
- throw new Error("Unable to get export data");
930
- });
931
- }
932
- }
933
- UserViewGridComponent.ɵfac = function UserViewGridComponent_Factory(t) { return new (t || UserViewGridComponent)(i0.ɵɵdirectiveInject(i1.FormBuilder), i0.ɵɵdirectiveInject(i2.Router)); };
934
- UserViewGridComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: UserViewGridComponent, selectors: [["mj-user-view-grid"]], viewQuery: function UserViewGridComponent_Query(rf, ctx) { if (rf & 1) {
935
- i0.ɵɵviewQuery(_c0, 5, GridComponent);
936
- i0.ɵɵviewQuery(_c0, 5, ElementRef);
937
- i0.ɵɵviewQuery(_c1, 5, ExcelExportComponent);
938
- i0.ɵɵviewQuery(_c2, 5);
939
- } if (rf & 2) {
940
- let _t;
941
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.kendoGridElement = _t.first);
942
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.kendoGridElementRef = _t.first);
943
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.kendoExcelExport = _t.first);
944
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.recordCompareComponent = _t.first);
945
- } }, inputs: { Params: "Params", BottomMargin: "BottomMargin", InEditMode: "InEditMode", EditMode: "EditMode", AutoNavigate: "AutoNavigate", AllowLoad: "AllowLoad" }, outputs: { rowClicked: "rowClicked", rowEdited: "rowEdited" }, decls: 10, vars: 19, consts: [["mjFillContainer", "", 1, "user-view-grid-wrap"], ["mjFillContainer", "", "scrollable", "virtual", "kendoGridSelectBy", "", 3, "resizable", "data", "skip", "pageSize", "rowHeight", "loading", "height", "sortable", "sort", "reorderable", "selectable", "selectedKeys", "pageChange", "selectedKeysChange", "cellClick", "cellClose", "columnReorder", "columnResize", "selectionChange", "sortChange"], ["kendoGrid", ""], ["kendoGridToolbarTemplate", ""], [3, "width", "headerStyle", "style", 4, "ngIf"], [3, "field", "title", "width", "editable", "editor", "headerStyle", "style", 4, "ngFor", "ngForOf"], [3, "data", "fileName"], ["excelExport", ""], [3, "field", "title", 4, "ngFor", "ngForOf"], [4, "ngIf"], ["kendoButton", "", "icon", "file-excel", 3, "click", 4, "ngIf"], ["class", "k-button k-button-md k-rounded-md k-button-solid-base k-button-solid", 3, "disabled", "click", 4, "ngIf"], ["class", "k-button k-button-md k-rounded-md k-button-solid-base k-button-solid", 3, "click", 4, "ngIf"], ["kendoButton", "", "icon", "refresh", 3, "primary", "click", 4, "ngIf"], ["kendoButton", "", "icon", "file-excel", 3, "click"], [1, "k-button", "k-button-md", "k-rounded-md", "k-button-solid-base", "k-button-solid", 3, "disabled", "click"], [1, "k-button", "k-button-md", "k-rounded-md", "k-button-solid-base", "k-button-solid", 3, "click"], ["kendoButton", "", "icon", "refresh", 3, "primary", "click"], [3, "width", "headerStyle"], [3, "field", "title", "width", "editable", "editor", "headerStyle"], ["kendoGridFooterTemplate", ""], [2, "font-size", "smaller", "font-weight", "normal"], [3, "field", "title"], [1, "k-overlay"], ["title", "Compare Records", 3, "minHeight", "minWidth", "resizable", "close", 4, "ngIf"], ["title", "Compare Records", 3, "minHeight", "minWidth", "resizable", "close"], [1, "k-d-flex", "k-flex-col", "k-justify-content-between", "k-h-full"], [3, "entityName", "recordsToCompare", "visibleColumns", "selectionMode"], ["recordCompareRef", ""], [1, "k-actions", "k-actions-end"], ["kendoButton", "", "type", "button", 3, "click", 4, "ngIf"], ["kendoButton", "", "themeColor", "primary", "type", "button", 3, "click", 4, "ngIf"], ["title", "Confirm Choice", 3, "minWidth", "width", "close", 4, "ngIf"], ["kendoButton", "", "type", "button", 3, "click"], ["kendoButton", "", "themeColor", "primary", "type", "button", 3, "click"], ["title", "Confirm Choice", 3, "minWidth", "width", "close"], [2, "margin", "30px", "text-align", "center"], ["kendoButton", "", 3, "click"], ["kendoButton", "", "themeColor", "primary", 3, "click"]], template: function UserViewGridComponent_Template(rf, ctx) { if (rf & 1) {
946
- i0.ɵɵelementStart(0, "div", 0)(1, "kendo-grid", 1, 2);
947
- i0.ɵɵlistener("pageChange", function UserViewGridComponent_Template_kendo_grid_pageChange_1_listener($event) { return ctx.pageChange($event); })("selectedKeysChange", function UserViewGridComponent_Template_kendo_grid_selectedKeysChange_1_listener($event) { return ctx.selectedKeys = $event; })("cellClick", function UserViewGridComponent_Template_kendo_grid_cellClick_1_listener($event) { return ctx.cellClickHandler($event); })("cellClose", function UserViewGridComponent_Template_kendo_grid_cellClose_1_listener($event) { return ctx.cellCloseHandler($event); })("columnReorder", function UserViewGridComponent_Template_kendo_grid_columnReorder_1_listener($event) { return ctx.columnReorder($event); })("columnResize", function UserViewGridComponent_Template_kendo_grid_columnResize_1_listener($event) { return ctx.columnResize($event); })("selectionChange", function UserViewGridComponent_Template_kendo_grid_selectionChange_1_listener($event) { return ctx.selectionChange($event); })("sortChange", function UserViewGridComponent_Template_kendo_grid_sortChange_1_listener($event) { return ctx.sortChanged($event); });
948
- i0.ɵɵtemplate(3, UserViewGridComponent_ng_template_3_Template, 8, 8, "ng-template", 3);
949
- i0.ɵɵtemplate(4, UserViewGridComponent_kendo_grid_checkbox_column_4_Template, 1, 6, "kendo-grid-checkbox-column", 4);
950
- i0.ɵɵtemplate(5, UserViewGridComponent_kendo_grid_column_5_Template, 2, 10, "kendo-grid-column", 5);
951
- i0.ɵɵelementStart(6, "kendo-excelexport", 6, 7);
952
- i0.ɵɵtemplate(8, UserViewGridComponent_kendo_excelexport_column_8_Template, 1, 2, "kendo-excelexport-column", 8);
953
- i0.ɵɵelementEnd()()();
954
- i0.ɵɵtemplate(9, UserViewGridComponent_div_9_Template, 3, 1, "div", 9);
955
- } if (rf & 2) {
956
- i0.ɵɵadvance(1);
957
- i0.ɵɵproperty("resizable", true)("data", ctx.gridView)("skip", ctx.skip)("pageSize", ctx.pageSize)("rowHeight", 36)("loading", ctx.isLoading)("height", ctx.gridHeight)("sortable", true)("sort", ctx.sortSettings)("resizable", true)("reorderable", true)("selectable", true)("selectedKeys", ctx.selectedKeys);
958
- i0.ɵɵadvance(3);
959
- i0.ɵɵproperty("ngIf", ctx.compareMode || ctx.mergeMode);
960
- i0.ɵɵadvance(1);
961
- i0.ɵɵproperty("ngForOf", ctx.visibleColumns);
962
- i0.ɵɵadvance(1);
963
- i0.ɵɵproperty("data", ctx.exportData)("fileName", (ctx._viewEntity ? ctx._viewEntity.Get("Name") : ctx._entityInfo == null ? null : ctx._entityInfo.Name) + ".xlsx");
964
- i0.ɵɵadvance(2);
965
- i0.ɵɵproperty("ngForOf", ctx.exportColumns);
966
- i0.ɵɵadvance(1);
967
- i0.ɵɵproperty("ngIf", ctx.isCompareDialogOpened);
968
- } }, dependencies: [i3.NgForOf, i3.NgIf, i4.GridComponent, i4.ToolbarTemplateDirective, i4.SelectionDirective, i4.ColumnComponent, i4.FooterTemplateDirective, i4.CheckboxColumnComponent, i5.DialogComponent, i5.DialogActionsComponent, i5.WindowComponent, i6.ExcelExportComponent, i6.ColumnComponent, i7.Button, i8.CompareRecordsComponent, i9.FillContainer, i3.DecimalPipe], styles: [".user-view-grid-wrap[_ngcontent-%COMP%] {\r\n height: calc(100vh-20px);\r\n}\r\n\r\n.user-view-grid-column-header[_ngcontent-%COMP%] {\r\n background-color: #a9c2af;\r\n font-size: 20pt;\r\n font-weight: bold;\r\n}"] });
969
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UserViewGridComponent, [{
970
- type: Component,
971
- args: [{ selector: 'mj-user-view-grid', template: "<div class=\"user-view-grid-wrap\" mjFillContainer>\r\n <kendo-grid #kendoGrid\r\n mjFillContainer\r\n [resizable]=\"true\"\r\n [data]=\"gridView\" \r\n [skip]=\"skip\"\r\n [pageSize]=\"pageSize\"\r\n scrollable=\"virtual\"\r\n [rowHeight]=\"36\"\r\n (pageChange)=\"pageChange($event)\"\r\n [loading]=\"isLoading\"\r\n [height]=\"gridHeight\"\r\n [sortable]=\"true\"\r\n [sort]=\"sortSettings\" \r\n [resizable]=\"true\"\r\n [reorderable]=\"true\"\r\n [selectable]=\"true\"\r\n kendoGridSelectBy\r\n [(selectedKeys)]=\"selectedKeys\"\r\n (cellClick)=\"cellClickHandler($event)\"\r\n (cellClose)=\"cellCloseHandler($event)\"\r\n (columnReorder)=\"columnReorder($event)\"\r\n (columnResize)=\"columnResize($event)\"\r\n (selectionChange)=\"selectionChange($event)\"\r\n (sortChange)=\"sortChanged($event)\"\r\n >\r\n <ng-template kendoGridToolbarTemplate>\r\n <button kendoButton icon=\"file-excel\" *ngIf=\"!compareMode && !mergeMode\" (click)=\"doExcelExport()\" >Export to Excel</button>\r\n <!-- 3 buttons for compare. First one only shows when comparison is going on in the grid, the next one is the one the user starts the process with before records are selected, last one is to cancel the pending compare. -->\r\n <button (click)=\"enableMergeOrCompare(false, 'compare')\" *ngIf=\"!compareMode && !mergeMode\" [disabled]=\"compareMode && recordsToCompare.length < 2\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Compare</button>\r\n <button (click)=\"enableMergeOrCompare(false, 'compare')\" *ngIf=\"compareMode\" [disabled]=\"compareMode && recordsToCompare.length < 2\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Compare</button>\r\n <button (click)=\"enableMergeOrCompare(true, 'compare')\" *ngIf=\"compareMode\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Cancel</button>\r\n\r\n <!-- 3 buttons for merge. First one only shows when merge is getting goin in the grid, the next one is the one the user starts the process with before records are selected, last one is to cancel the pending merge. -->\r\n <button (click)=\"enableMergeOrCompare(false, 'merge')\" *ngIf=\"mergeMode\" [disabled]=\"mergeMode && recordsToCompare.length < 2\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Merge</button>\r\n <button (click)=\"enableMergeOrCompare(false, 'merge')\" *ngIf=\"!mergeMode && !compareMode\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Merge</button>\r\n <button (click)=\"enableMergeOrCompare(true, 'merge')\" *ngIf=\"mergeMode\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Cancel</button>\r\n <button\r\n kendoButton\r\n [primary]=\"true\"\r\n icon=\"refresh\"\r\n *ngIf=\"showRefreshButton && !compareMode && !mergeMode\"\r\n (click)=\"RefreshFromSavedParams()\">\r\n Refresh\r\n </button>\r\n </ng-template>\r\n\r\n <kendo-grid-checkbox-column \r\n *ngIf=\"compareMode || mergeMode\" \r\n [width]=\"50\" \r\n [headerStyle]=\"{ 'font-weight' : 'bold', 'background-color': '#a9c2af' }\" \r\n [style]=\"{'text-align': 'center', 'vertical-align': 'center'}\">\r\n </kendo-grid-checkbox-column>\r\n \r\n <kendo-grid-column \r\n *ngFor=\"let item of visibleColumns\" \r\n [field]=\"item.Name\" \r\n [title]=\"GetColumnTitle(item)\"\r\n [width]=\"item.width ? item.width : 100\"\r\n [editable]=\"item.EntityField.AllowUpdateAPI\"\r\n [editor]=\"getEditor(item.EntityField)\"\r\n [headerStyle]=\"{ 'font-weight' : 'bold', 'background-color': '#a9c2af' }\"\r\n [style]=\"this.GetColumnCellStyle(item)\"\r\n >\r\n <ng-template *ngIf=\"item===visibleColumns[0]\" kendoGridFooterTemplate >\r\n {{this.viewData.length | number}}{{this.totalRowCount > this.viewData.length ? ' of ' + (this.totalRowCount | number) : ' rows'}}<br/><span style=\"font-size: smaller; font-weight: normal;\">{{viewExecutionTime | number:'1.2-2'}} seconds</span>\r\n </ng-template>\r\n </kendo-grid-column>\r\n\r\n <kendo-excelexport #excelExport [data]=\"exportData\" [fileName]=\"(_viewEntity ? _viewEntity.Get('Name') : _entityInfo?.Name) + '.xlsx'\">\r\n <kendo-excelexport-column *ngFor=\"let exportCol of exportColumns\" [field]=\"exportCol.Name\" [title]=\"exportCol.Name\">\r\n </kendo-excelexport-column>\r\n </kendo-excelexport>\r\n </kendo-grid>\r\n</div>\r\n\r\n<div *ngIf=\"isCompareDialogOpened\">\r\n <div class=\"k-overlay\"></div>\r\n <kendo-window\r\n [minHeight]=\"300\"\r\n [minWidth]=\"400\"\r\n [resizable]=\"true\"\r\n (close)=\"closeCompareDialog($event)\"\r\n title=\"Compare Records\"\r\n *ngIf=\"isCompareDialogOpened\"\r\n >\r\n <div class=\"k-d-flex k-flex-col k-justify-content-between k-h-full\">\r\n <div>\r\n <mj-compare-records\r\n #recordCompareRef\r\n [entityName]=\"_entityInfo ? _entityInfo.Name : ''\"\r\n [recordsToCompare]=\"recordsToCompare\" \r\n [visibleColumns]=\"visibleColumns\" \r\n [selectionMode]=\"mergeMode ? true : false\"\r\n >\r\n </mj-compare-records>\r\n </div>\r\n </div>\r\n <div class=\"k-actions k-actions-end\">\r\n <button *ngIf=\"compareMode\" kendoButton type=\"button\" (click)=\"closeCompareDialog('close')\">Close</button>\r\n <button *ngIf=\"mergeMode\"kendoButton type=\"button\" (click)=\"closeCompareDialog('cancel')\">Cancel</button>\r\n <button *ngIf=\"mergeMode\"\r\n kendoButton\r\n themeColor=\"primary\"\r\n type=\"button\"\r\n (click)=\"closeCompareDialog('merge')\"\r\n >\r\n Merge Records\r\n </button>\r\n </div> \r\n <kendo-dialog\r\n title=\"Confirm Choice\"\r\n *ngIf=\"isConfirmDialogOpen\"\r\n (close)=\"closeConfirmMergeDialog('cancel')\"\r\n [minWidth]=\"250\"\r\n [width]=\"450\"\r\n >\r\n <p style=\"margin: 30px; text-align: center;\">\r\n Are you sure you want to merge the records? This action cannot be undone. If you select \"Yes\", the records will be merged and the duplicate records will be deleted.\r\n </p>\r\n <kendo-dialog-actions>\r\n <button kendoButton (click)=\"closeConfirmMergeDialog('no')\">No</button>\r\n <button kendoButton (click)=\"closeConfirmMergeDialog('yes')\" themeColor=\"primary\">\r\n Yes\r\n </button>\r\n </kendo-dialog-actions>\r\n </kendo-dialog>\r\n </kendo-window>\r\n</div>", styles: [".user-view-grid-wrap {\r\n height: calc(100vh-20px);\r\n}\r\n\r\n.user-view-grid-column-header {\r\n background-color: #a9c2af;\r\n font-size: 20pt;\r\n font-weight: bold;\r\n}"] }]
972
- }], function () { return [{ type: i1.FormBuilder }, { type: i2.Router }]; }, { Params: [{
973
- type: Input
974
- }], BottomMargin: [{
975
- type: Input
976
- }], InEditMode: [{
977
- type: Input
978
- }], EditMode: [{
979
- type: Input
980
- }], AutoNavigate: [{
981
- type: Input
982
- }], rowClicked: [{
983
- type: Output
984
- }], rowEdited: [{
985
- type: Output
986
- }], kendoGridElement: [{
987
- type: ViewChild,
988
- args: ['kendoGrid', { read: GridComponent }]
989
- }], kendoGridElementRef: [{
990
- type: ViewChild,
991
- args: ['kendoGrid', { read: ElementRef }]
992
- }], kendoExcelExport: [{
993
- type: ViewChild,
994
- args: ['excelExport', { read: ExcelExportComponent }]
995
- }], recordCompareComponent: [{
996
- type: ViewChild,
997
- args: ['recordCompareRef', { static: false }]
998
- }], AllowLoad: [{
999
- type: Input
1000
- }] }); })();
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, ViewChild, ElementRef, Output, EventEmitter, Input } from '@angular/core';
11
+ import { Metadata, RunView, EntityFieldTSType, LogError } from '@memberjunction/core';
12
+ import { ViewInfo } from '@memberjunction/core-entities';
13
+ import { GridComponent } from "@progress/kendo-angular-grid";
14
+ import { Keys } from '@progress/kendo-angular-common';
15
+ import { Subject } from 'rxjs';
16
+ import { ExcelExportComponent } from '@progress/kendo-angular-excel-export';
17
+ import { MJEventType, MJGlobal } from '@memberjunction/global';
18
+ import { kendoSVGIcon } from '@memberjunction/ng-shared';
19
+ import * as i0 from "@angular/core";
20
+ import * as i1 from "@angular/forms";
21
+ import * as i2 from "@angular/router";
22
+ import * as i3 from "@angular/common";
23
+ import * as i4 from "@progress/kendo-angular-grid";
24
+ import * as i5 from "@progress/kendo-angular-dialog";
25
+ import * as i6 from "@progress/kendo-angular-excel-export";
26
+ import * as i7 from "@progress/kendo-angular-buttons";
27
+ import * as i8 from "@memberjunction/ng-compare-records";
28
+ import * as i9 from "@memberjunction/ng-container-directives";
29
+ import * as i10 from "@progress/kendo-angular-icons";
30
+ import * as i11 from "@progress/kendo-angular-layout";
31
+ const _c0 = ["kendoGrid"];
32
+ const _c1 = ["excelExport"];
33
+ const _c2 = ["recordCompareRef"];
34
+ function UserViewGridComponent_ng_template_5_button_0_Template(rf, ctx) { if (rf & 1) {
35
+ const _r16 = i0.ɵɵgetCurrentView();
36
+ i0.ɵɵelementStart(0, "button", 16);
37
+ i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_5_button_0_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r16); const ctx_r15 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r15.doExcelExport()); });
38
+ i0.ɵɵelement(1, "kendo-svgicon", 17);
39
+ i0.ɵɵtext(2, " Export to Excel ");
40
+ i0.ɵɵelementEnd();
41
+ } if (rf & 2) {
42
+ const ctx_r7 = i0.ɵɵnextContext(2);
43
+ i0.ɵɵadvance();
44
+ i0.ɵɵproperty("icon", ctx_r7.kendoSVGIcon("fileExcel"));
45
+ } }
46
+ function UserViewGridComponent_ng_template_5_button_1_Template(rf, ctx) { if (rf & 1) {
47
+ const _r18 = i0.ɵɵgetCurrentView();
48
+ i0.ɵɵelementStart(0, "button", 18);
49
+ i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_5_button_1_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r18); const ctx_r17 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r17.enableMergeOrCompare(false, "compare")); });
50
+ i0.ɵɵtext(1, "Compare");
51
+ i0.ɵɵelementEnd();
52
+ } if (rf & 2) {
53
+ const ctx_r8 = i0.ɵɵnextContext(2);
54
+ i0.ɵɵproperty("disabled", ctx_r8.compareMode && ctx_r8.recordsToCompare.length < 2);
55
+ } }
56
+ function UserViewGridComponent_ng_template_5_button_2_Template(rf, ctx) { if (rf & 1) {
57
+ const _r20 = i0.ɵɵgetCurrentView();
58
+ i0.ɵɵelementStart(0, "button", 18);
59
+ i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_5_button_2_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r20); const ctx_r19 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r19.enableMergeOrCompare(false, "compare")); });
60
+ i0.ɵɵtext(1, "Compare");
61
+ i0.ɵɵelementEnd();
62
+ } if (rf & 2) {
63
+ const ctx_r9 = i0.ɵɵnextContext(2);
64
+ i0.ɵɵproperty("disabled", ctx_r9.compareMode && ctx_r9.recordsToCompare.length < 2);
65
+ } }
66
+ function UserViewGridComponent_ng_template_5_button_3_Template(rf, ctx) { if (rf & 1) {
67
+ const _r22 = i0.ɵɵgetCurrentView();
68
+ i0.ɵɵelementStart(0, "button", 19);
69
+ i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_5_button_3_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r22); const ctx_r21 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r21.enableMergeOrCompare(true, "compare")); });
70
+ i0.ɵɵtext(1, "Cancel");
71
+ i0.ɵɵelementEnd();
72
+ } }
73
+ function UserViewGridComponent_ng_template_5_button_4_Template(rf, ctx) { if (rf & 1) {
74
+ const _r24 = i0.ɵɵgetCurrentView();
75
+ i0.ɵɵelementStart(0, "button", 18);
76
+ i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_5_button_4_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r24); const ctx_r23 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r23.enableMergeOrCompare(false, "merge")); });
77
+ i0.ɵɵtext(1, "Merge");
78
+ i0.ɵɵelementEnd();
79
+ } if (rf & 2) {
80
+ const ctx_r11 = i0.ɵɵnextContext(2);
81
+ i0.ɵɵproperty("disabled", ctx_r11.mergeMode && ctx_r11.recordsToCompare.length < 2);
82
+ } }
83
+ function UserViewGridComponent_ng_template_5_button_5_Template(rf, ctx) { if (rf & 1) {
84
+ const _r26 = i0.ɵɵgetCurrentView();
85
+ i0.ɵɵelementStart(0, "button", 19);
86
+ i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_5_button_5_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r26); const ctx_r25 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r25.enableMergeOrCompare(false, "merge")); });
87
+ i0.ɵɵtext(1, "Merge");
88
+ i0.ɵɵelementEnd();
89
+ } }
90
+ function UserViewGridComponent_ng_template_5_button_6_Template(rf, ctx) { if (rf & 1) {
91
+ const _r28 = i0.ɵɵgetCurrentView();
92
+ i0.ɵɵelementStart(0, "button", 19);
93
+ i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_5_button_6_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r28); const ctx_r27 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r27.enableMergeOrCompare(true, "merge")); });
94
+ i0.ɵɵtext(1, "Cancel");
95
+ i0.ɵɵelementEnd();
96
+ } }
97
+ function UserViewGridComponent_ng_template_5_button_7_Template(rf, ctx) { if (rf & 1) {
98
+ const _r30 = i0.ɵɵgetCurrentView();
99
+ i0.ɵɵelementStart(0, "button", 20);
100
+ i0.ɵɵlistener("click", function UserViewGridComponent_ng_template_5_button_7_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r30); const ctx_r29 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r29.RefreshFromSavedParams()); });
101
+ i0.ɵɵelement(1, "kendo-svgicon", 17);
102
+ i0.ɵɵtext(2, " Refresh ");
103
+ i0.ɵɵelementEnd();
104
+ } if (rf & 2) {
105
+ const ctx_r14 = i0.ɵɵnextContext(2);
106
+ i0.ɵɵproperty("primary", true);
107
+ i0.ɵɵadvance();
108
+ i0.ɵɵproperty("icon", ctx_r14.kendoSVGIcon("arrowRotateCcwSmall"));
109
+ } }
110
+ function UserViewGridComponent_ng_template_5_Template(rf, ctx) { if (rf & 1) {
111
+ i0.ɵɵtemplate(0, UserViewGridComponent_ng_template_5_button_0_Template, 3, 1, "button", 12)(1, UserViewGridComponent_ng_template_5_button_1_Template, 2, 1, "button", 13)(2, UserViewGridComponent_ng_template_5_button_2_Template, 2, 1, "button", 13)(3, UserViewGridComponent_ng_template_5_button_3_Template, 2, 0, "button", 14)(4, UserViewGridComponent_ng_template_5_button_4_Template, 2, 1, "button", 13)(5, UserViewGridComponent_ng_template_5_button_5_Template, 2, 0, "button", 14)(6, UserViewGridComponent_ng_template_5_button_6_Template, 2, 0, "button", 14)(7, UserViewGridComponent_ng_template_5_button_7_Template, 3, 2, "button", 15);
112
+ } if (rf & 2) {
113
+ const ctx_r1 = i0.ɵɵnextContext();
114
+ i0.ɵɵproperty("ngIf", !ctx_r1.compareMode && !ctx_r1.mergeMode);
115
+ i0.ɵɵadvance();
116
+ i0.ɵɵproperty("ngIf", !ctx_r1.compareMode && !ctx_r1.mergeMode);
117
+ i0.ɵɵadvance();
118
+ i0.ɵɵproperty("ngIf", ctx_r1.compareMode);
119
+ i0.ɵɵadvance();
120
+ i0.ɵɵproperty("ngIf", ctx_r1.compareMode);
121
+ i0.ɵɵadvance();
122
+ i0.ɵɵproperty("ngIf", ctx_r1.mergeMode);
123
+ i0.ɵɵadvance();
124
+ i0.ɵɵproperty("ngIf", !ctx_r1.mergeMode && !ctx_r1.compareMode);
125
+ i0.ɵɵadvance();
126
+ i0.ɵɵproperty("ngIf", ctx_r1.mergeMode);
127
+ i0.ɵɵadvance();
128
+ i0.ɵɵproperty("ngIf", ctx_r1.showRefreshButton && !ctx_r1.compareMode && !ctx_r1.mergeMode);
129
+ } }
130
+ const _c3 = () => ({ "text-align": "center", "vertical-align": "center" });
131
+ const _c4 = () => ({ "font-weight": "bold", "background-color": "#a9c2af" });
132
+ function UserViewGridComponent_kendo_grid_checkbox_column_6_Template(rf, ctx) { if (rf & 1) {
133
+ i0.ɵɵelement(0, "kendo-grid-checkbox-column", 21);
134
+ } if (rf & 2) {
135
+ i0.ɵɵstyleMap(i0.ɵɵpureFunction0(4, _c3));
136
+ i0.ɵɵproperty("width", 50)("headerStyle", i0.ɵɵpureFunction0(5, _c4));
137
+ } }
138
+ function UserViewGridComponent_kendo_grid_column_7_1_ng_template_0_Template(rf, ctx) { if (rf & 1) {
139
+ i0.ɵɵtext(0);
140
+ i0.ɵɵpipe(1, "number");
141
+ i0.ɵɵpipe(2, "number");
142
+ i0.ɵɵelement(3, "br");
143
+ i0.ɵɵelementStart(4, "span", 24);
144
+ i0.ɵɵtext(5);
145
+ i0.ɵɵpipe(6, "number");
146
+ i0.ɵɵelementEnd();
147
+ } if (rf & 2) {
148
+ const ctx_r33 = i0.ɵɵnextContext(3);
149
+ i0.ɵɵtextInterpolate2(" ", i0.ɵɵpipeBind1(1, 3, ctx_r33.viewData.length), "", ctx_r33.totalRowCount > ctx_r33.viewData.length ? " of " + i0.ɵɵpipeBind1(2, 5, ctx_r33.totalRowCount) : " rows", "");
150
+ i0.ɵɵadvance(5);
151
+ i0.ɵɵtextInterpolate1("", i0.ɵɵpipeBind2(6, 7, ctx_r33.viewExecutionTime, "1.2-2"), " seconds");
152
+ } }
153
+ function UserViewGridComponent_kendo_grid_column_7_1_Template(rf, ctx) { if (rf & 1) {
154
+ i0.ɵɵtemplate(0, UserViewGridComponent_kendo_grid_column_7_1_ng_template_0_Template, 7, 10, "ng-template", 23);
155
+ } }
156
+ function UserViewGridComponent_kendo_grid_column_7_Template(rf, ctx) { if (rf & 1) {
157
+ i0.ɵɵelementStart(0, "kendo-grid-column", 22);
158
+ i0.ɵɵtemplate(1, UserViewGridComponent_kendo_grid_column_7_1_Template, 1, 0, null, 11);
159
+ i0.ɵɵelementEnd();
160
+ } if (rf & 2) {
161
+ const item_r31 = ctx.$implicit;
162
+ const ctx_r3 = i0.ɵɵnextContext();
163
+ i0.ɵɵstyleMap(ctx_r3.GetColumnCellStyle(item_r31));
164
+ i0.ɵɵproperty("field", item_r31.Name)("title", ctx_r3.GetColumnTitle(item_r31))("width", item_r31.width ? item_r31.width : 100)("editable", item_r31.EntityField.AllowUpdateAPI)("editor", ctx_r3.getEditor(item_r31.EntityField))("headerStyle", i0.ɵɵpureFunction0(9, _c4));
165
+ i0.ɵɵadvance();
166
+ i0.ɵɵproperty("ngIf", item_r31 === ctx_r3.visibleColumns[0]);
167
+ } }
168
+ function UserViewGridComponent_kendo_excelexport_column_10_Template(rf, ctx) { if (rf & 1) {
169
+ i0.ɵɵelement(0, "kendo-excelexport-column", 25);
170
+ } if (rf & 2) {
171
+ const exportCol_r34 = ctx.$implicit;
172
+ i0.ɵɵproperty("field", exportCol_r34.Name)("title", exportCol_r34.Name);
173
+ } }
174
+ function UserViewGridComponent_div_15_kendo_window_2_button_6_Template(rf, ctx) { if (rf & 1) {
175
+ const _r42 = i0.ɵɵgetCurrentView();
176
+ i0.ɵɵelementStart(0, "button", 36);
177
+ i0.ɵɵlistener("click", function UserViewGridComponent_div_15_kendo_window_2_button_6_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r42); const ctx_r41 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r41.closeCompareDialog("close")); });
178
+ i0.ɵɵtext(1, "Close");
179
+ i0.ɵɵelementEnd();
180
+ } }
181
+ function UserViewGridComponent_div_15_kendo_window_2_button_7_Template(rf, ctx) { if (rf & 1) {
182
+ const _r44 = i0.ɵɵgetCurrentView();
183
+ i0.ɵɵelementStart(0, "button", 36);
184
+ i0.ɵɵlistener("click", function UserViewGridComponent_div_15_kendo_window_2_button_7_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r44); const ctx_r43 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r43.closeCompareDialog("cancel")); });
185
+ i0.ɵɵtext(1, "Cancel");
186
+ i0.ɵɵelementEnd();
187
+ } }
188
+ function UserViewGridComponent_div_15_kendo_window_2_button_8_Template(rf, ctx) { if (rf & 1) {
189
+ const _r46 = i0.ɵɵgetCurrentView();
190
+ i0.ɵɵelementStart(0, "button", 37);
191
+ i0.ɵɵlistener("click", function UserViewGridComponent_div_15_kendo_window_2_button_8_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r46); const ctx_r45 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r45.closeCompareDialog("merge")); });
192
+ i0.ɵɵtext(1, " Merge Records ");
193
+ i0.ɵɵelementEnd();
194
+ } }
195
+ function UserViewGridComponent_div_15_kendo_window_2_kendo_dialog_9_Template(rf, ctx) { if (rf & 1) {
196
+ const _r48 = i0.ɵɵgetCurrentView();
197
+ i0.ɵɵelementStart(0, "kendo-dialog", 38);
198
+ i0.ɵɵlistener("close", function UserViewGridComponent_div_15_kendo_window_2_kendo_dialog_9_Template_kendo_dialog_close_0_listener() { i0.ɵɵrestoreView(_r48); const ctx_r47 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r47.closeConfirmMergeDialog("cancel")); });
199
+ i0.ɵɵelementStart(1, "p", 39);
200
+ i0.ɵɵtext(2, " Are you sure you want to merge the records? This action cannot be undone. If you select \"Yes\", the records will be merged and the duplicate records will be deleted. ");
201
+ i0.ɵɵelementEnd();
202
+ i0.ɵɵelementStart(3, "kendo-dialog-actions")(4, "button", 16);
203
+ i0.ɵɵlistener("click", function UserViewGridComponent_div_15_kendo_window_2_kendo_dialog_9_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r48); const ctx_r49 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r49.closeConfirmMergeDialog("no")); });
204
+ i0.ɵɵtext(5, "No");
205
+ i0.ɵɵelementEnd();
206
+ i0.ɵɵelementStart(6, "button", 40);
207
+ i0.ɵɵlistener("click", function UserViewGridComponent_div_15_kendo_window_2_kendo_dialog_9_Template_button_click_6_listener() { i0.ɵɵrestoreView(_r48); const ctx_r50 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r50.closeConfirmMergeDialog("yes")); });
208
+ i0.ɵɵtext(7, " Yes ");
209
+ i0.ɵɵelementEnd()()();
210
+ } if (rf & 2) {
211
+ i0.ɵɵproperty("minWidth", 250)("width", 450);
212
+ } }
213
+ function UserViewGridComponent_div_15_kendo_window_2_Template(rf, ctx) { if (rf & 1) {
214
+ const _r52 = i0.ɵɵgetCurrentView();
215
+ i0.ɵɵelementStart(0, "kendo-window", 28);
216
+ i0.ɵɵlistener("close", function UserViewGridComponent_div_15_kendo_window_2_Template_kendo_window_close_0_listener($event) { i0.ɵɵrestoreView(_r52); const ctx_r51 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r51.closeCompareDialog($event)); });
217
+ i0.ɵɵelementStart(1, "div", 29)(2, "div");
218
+ i0.ɵɵelement(3, "mj-compare-records", 30, 31);
219
+ i0.ɵɵelementEnd()();
220
+ i0.ɵɵelementStart(5, "div", 32);
221
+ i0.ɵɵtemplate(6, UserViewGridComponent_div_15_kendo_window_2_button_6_Template, 2, 0, "button", 33)(7, UserViewGridComponent_div_15_kendo_window_2_button_7_Template, 2, 0, "button", 33)(8, UserViewGridComponent_div_15_kendo_window_2_button_8_Template, 2, 0, "button", 34);
222
+ i0.ɵɵelementEnd();
223
+ i0.ɵɵtemplate(9, UserViewGridComponent_div_15_kendo_window_2_kendo_dialog_9_Template, 8, 2, "kendo-dialog", 35);
224
+ i0.ɵɵelementEnd();
225
+ } if (rf & 2) {
226
+ const ctx_r35 = i0.ɵɵnextContext(2);
227
+ i0.ɵɵproperty("minHeight", 300)("minWidth", 400)("resizable", true);
228
+ i0.ɵɵadvance(3);
229
+ i0.ɵɵproperty("entityName", ctx_r35._entityInfo ? ctx_r35._entityInfo.Name : "")("recordsToCompare", ctx_r35.recordsToCompare)("visibleColumns", ctx_r35.visibleColumns)("selectionMode", ctx_r35.mergeMode ? true : false);
230
+ i0.ɵɵadvance(3);
231
+ i0.ɵɵproperty("ngIf", ctx_r35.compareMode);
232
+ i0.ɵɵadvance();
233
+ i0.ɵɵproperty("ngIf", ctx_r35.mergeMode);
234
+ i0.ɵɵadvance();
235
+ i0.ɵɵproperty("ngIf", ctx_r35.mergeMode);
236
+ i0.ɵɵadvance();
237
+ i0.ɵɵproperty("ngIf", ctx_r35.isConfirmDialogOpen);
238
+ } }
239
+ function UserViewGridComponent_div_15_Template(rf, ctx) { if (rf & 1) {
240
+ i0.ɵɵelementStart(0, "div");
241
+ i0.ɵɵelement(1, "div", 26);
242
+ i0.ɵɵtemplate(2, UserViewGridComponent_div_15_kendo_window_2_Template, 10, 11, "kendo-window", 27);
243
+ i0.ɵɵelementEnd();
244
+ } if (rf & 2) {
245
+ const ctx_r6 = i0.ɵɵnextContext();
246
+ i0.ɵɵadvance(2);
247
+ i0.ɵɵproperty("ngIf", ctx_r6.isCompareDialogOpened);
248
+ } }
249
+ export class UserViewGridComponent {
250
+ get PendingRecords() {
251
+ return this._pendingRecords;
252
+ }
253
+ StartEditMode() {
254
+ this.InEditMode = true;
255
+ }
256
+ EndEditMode() {
257
+ this.InEditMode = false;
258
+ this.editModeEnded.next();
259
+ }
260
+ EditingComplete() {
261
+ if (this.InEditMode) {
262
+ // we need to wait for edit mode to end before we can return true
263
+ return new Promise((resolve, reject) => {
264
+ const subscription = this.editModeEnded.subscribe(() => {
265
+ resolve(true);
266
+ subscription.unsubscribe();
267
+ });
268
+ });
269
+ }
270
+ else
271
+ return Promise.resolve(true); // not in edit mode, so editing is complete!
272
+ }
273
+ IsDynamicView() {
274
+ return !this._viewEntity; // if we have a viewEntity it is a stored view
275
+ }
276
+ pageChange(event) {
277
+ this.skip = event.skip;
278
+ this.virtualLoadData();
279
+ }
280
+ virtualLoadData() {
281
+ // check to see if we have already formatted the slice of the data we need right now
282
+ // we are storing the formattted data in the formattedData array and it has same set
283
+ // of indexes as the viewData array (raw unformatted data). When we first get viewData
284
+ // from the server we create an array of the same length as viewData, but have nulls in all of the
285
+ // indexes. As we format each row of viewData we store the formatted row in the same index
286
+ // in the formattedData array. So if we have already formatted the data we need for the current
287
+ // page, we just use that data, otherwise we format the data we need for the current page
288
+ try {
289
+ // check to see if we have already formatted the data we need for the current page
290
+ for (let i = this.skip; (i < (this.skip + this.pageSize)) && (i < this.viewData.length); i++) {
291
+ if (!this.formattedData[i]) {
292
+ // we have not formatted this row yet, so format it
293
+ const r = this.viewColumns.map((c) => {
294
+ if (c && c.EntityField && this.viewData[i] && this.viewData[i][c.EntityField.Name]) {
295
+ if (!c.hidden && c.EntityField.Name !== 'ID') {
296
+ const ef = c.EntityField;
297
+ return { field: c.EntityField.Name, value: ef.FormatValue(this.viewData[i][c.EntityField.Name], 0, undefined, 300) };
298
+ }
299
+ else
300
+ return { field: c.EntityField.Name, value: this.viewData[i][c.EntityField.Name] }; // hidden column, so just return the value, don't bother formatting
301
+ }
302
+ else
303
+ return { field: c.Name, value: null };
304
+ });
305
+ // now r is an array of {field: string, value: any} objects, so we need to convert it to an object
306
+ // with the field names as the keys and the values as the values
307
+ const row = {};
308
+ for (let j = 0; j < r.length; j++) {
309
+ if (r[j] && r[j].field && r[j].field.length > 0)
310
+ row[r[j].field] = r[j].value;
311
+ }
312
+ this.formattedData[i] = row;
313
+ }
314
+ }
315
+ // now that we have made sure current page of data is formatted, we can return it
316
+ this.gridView = {
317
+ data: this.formattedData.slice(this.skip, this.skip + this.pageSize),
318
+ total: this.viewData.length,
319
+ };
320
+ }
321
+ catch (e) {
322
+ LogError(e);
323
+ }
324
+ }
325
+ constructor(formBuilder, router) {
326
+ this.formBuilder = formBuilder;
327
+ this.router = router;
328
+ this.title = 'UserViewGrid';
329
+ this.BottomMargin = 0;
330
+ this.InEditMode = false;
331
+ this.EditMode = "None";
332
+ this.AutoNavigate = true;
333
+ this.rowClicked = new EventEmitter();
334
+ this.rowEdited = new EventEmitter();
335
+ this.kendoGridElement = null;
336
+ this.kendoGridElementRef = null;
337
+ this.kendoExcelExport = null;
338
+ this.recordCompareComponent = null;
339
+ this._pendingRecords = [];
340
+ this.viewData = [];
341
+ this.totalRowCount = 0;
342
+ this.formattedData = [];
343
+ this.viewColumns = [];
344
+ this.visibleColumns = [];
345
+ this.sortSettings = [];
346
+ this.entityRecord = null;
347
+ this.skip = 0;
348
+ this.pageSize = 40;
349
+ this.isLoading = false;
350
+ this.gridView = { data: [], total: 0 };
351
+ this.gridHeight = 750;
352
+ this._newGridState = {};
353
+ this.editModeEnded = new Subject();
354
+ this.recordsToCompare = [];
355
+ this.compareMode = false;
356
+ // public compareRecords: BaseEntity[] = [];
357
+ this.mergeMode = false;
358
+ // public mergeRecords: BaseEntity[] = [];
359
+ this.selectableSettings = {
360
+ enabled: false
361
+ };
362
+ this.selectedKeys = [];
363
+ this.isCompareDialogOpened = false;
364
+ this.isConfirmDialogOpen = false;
365
+ this.showRefreshButton = true;
366
+ this.viewExecutionTime = 0;
367
+ this._viewDirty = false;
368
+ this._deferLoadCount = 0;
369
+ this._allowLoad = true;
370
+ // Export Functionality
371
+ this.exportColumns = [];
372
+ this.exportData = [];
373
+ this.kendoSVGIcon = kendoSVGIcon;
374
+ }
375
+ SaveView() {
376
+ // debounced outer function...
377
+ clearTimeout(this._saveTimeout);
378
+ this._saveTimeout = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
379
+ // when we actually call inner save view we do await
380
+ yield this.innerSaveView();
381
+ }), 5000); // 5 seconds delay
382
+ }
383
+ ;
384
+ innerSaveView() {
385
+ return __awaiter(this, void 0, void 0, function* () {
386
+ if (this._viewDirty) {
387
+ const md = new Metadata();
388
+ if (this._viewEntity &&
389
+ this._viewEntity.Get('UserID') === md.CurrentUser.ID) {
390
+ // this view is a saved view, AND it belongs to the current user
391
+ // update the grid state if we have settings updates for columns and/or sorts
392
+ const tempGridState = JSON.parse(this._viewEntity.Get('GridState'));
393
+ const tempColSettings = this._newGridState.columnSettings ? this._newGridState.columnSettings : tempGridState.columnSettings;
394
+ tempColSettings.forEach((col) => { col.DisplayName, col.ID, col.Name, col.hidden, col.orderIndex, col.width; }); // remove EntityFieldInfo from the column settings
395
+ tempGridState.columnSettings = tempColSettings;
396
+ tempGridState.sortSettings = this._newGridState.sortSettings ? this._newGridState.sortSettings : tempGridState.sortSettings;
397
+ // now stringify the grid state and save it
398
+ this._viewEntity.Set('GridState', JSON.stringify(tempGridState));
399
+ const newSortState = tempGridState.sortSettings.map((s) => { return { field: s.field, direction: s.dir }; });
400
+ const oldSortState = JSON.parse(this._viewEntity.Get('SortState'));
401
+ this._viewEntity.Set('SortState', JSON.stringify(newSortState));
402
+ if (yield this._viewEntity.Save()) {
403
+ // check to see if sort state changed and if so, refresh the grid
404
+ if (JSON.stringify(newSortState) !== JSON.stringify(oldSortState)) {
405
+ if (this.Params) // makes sure we have params before we refresh
406
+ this.Refresh(this.Params);
407
+ }
408
+ this._viewDirty = false;
409
+ }
410
+ else {
411
+ this.CreateSimpleNotification('Unable to save view settings', 'error', 5000);
412
+ }
413
+ }
414
+ }
415
+ });
416
+ }
417
+ CreateSimpleNotification(message, style, duration) {
418
+ const data = {
419
+ message: message,
420
+ style: style,
421
+ DisplayDuration: duration
422
+ };
423
+ MJGlobal.Instance.RaiseEvent({
424
+ component: this,
425
+ event: MJEventType.DisplaySimpleNotificationRequest,
426
+ eventCode: "",
427
+ args: data
428
+ });
429
+ }
430
+ columnReorder(args) {
431
+ return __awaiter(this, void 0, void 0, function* () {
432
+ // Remove the column from the original position
433
+ // need to find the column in the viewColumns array because args.old/new Indexes are from the visibleColumns array
434
+ const fieldName = args.column.field;
435
+ if (fieldName) {
436
+ const vcOldIndex = this.viewColumns.findIndex((vc) => vc.Name === fieldName);
437
+ const vcNewIndex = this.viewColumns.findIndex((vc) => vc.orderIndex === args.newIndex);
438
+ if (vcOldIndex >= 0) {
439
+ // got the index, now remove the element
440
+ const element = this.viewColumns.splice(vcOldIndex, 1)[0];
441
+ // Insert it at the new position
442
+ this.viewColumns.splice(vcNewIndex, 0, element);
443
+ // go through all of the columns and set orderIndex as that isn't done automatically
444
+ let visColIndex = 0;
445
+ for (let i = 0; i < this.viewColumns.length; i++) {
446
+ if (!this.viewColumns[i].hidden) {
447
+ this.viewColumns[i].orderIndex = visColIndex;
448
+ visColIndex++;
449
+ }
450
+ }
451
+ // now loop through all of the HIDDEN columns and set their orderIndex, done in second loop because we want first loop to give us total number of visible columns
452
+ for (let i = 0; i < this.viewColumns.length; i++) {
453
+ if (this.viewColumns[i].hidden) {
454
+ this.viewColumns[i].orderIndex = visColIndex;
455
+ visColIndex++;
456
+ }
457
+ }
458
+ // make sure that _newGridState.columnSettings is set
459
+ this._newGridState.columnSettings = this.viewColumns;
460
+ this._viewDirty = true;
461
+ this.SaveView();
462
+ }
463
+ }
464
+ });
465
+ }
466
+ columnResize(args) {
467
+ return __awaiter(this, void 0, void 0, function* () {
468
+ for (const col of args) {
469
+ const c = col.column;
470
+ const viewCol = this.viewColumns.find(vc => vc.Name === c.field);
471
+ const visCol = this.visibleColumns.find(vc => vc.Name === c.field);
472
+ const visCols = this.visibleColumns;
473
+ if (viewCol)
474
+ viewCol.width = col.newWidth;
475
+ }
476
+ this._newGridState.columnSettings = this.viewColumns.map(vc => {
477
+ return {
478
+ Name: vc.Name,
479
+ DisplayName: vc.DisplayName,
480
+ width: vc.width,
481
+ orderIndex: vc.orderIndex,
482
+ hidden: vc.hidden
483
+ };
484
+ });
485
+ this._viewDirty = true;
486
+ this.SaveView();
487
+ });
488
+ }
489
+ sortChanged(sort) {
490
+ return __awaiter(this, void 0, void 0, function* () {
491
+ if (sort && sort.length > 0) {
492
+ // remove any sort settings that don't have a direction
493
+ const filterSort = sort.filter((s) => s.dir !== undefined && s.dir !== null && s.dir !== "");
494
+ this._newGridState.sortSettings = filterSort;
495
+ }
496
+ else
497
+ this._newGridState.sortSettings = sort;
498
+ this.sortSettings = this._newGridState.sortSettings; // for the UI display - grid binding to this shows that the sort is applied via arrows in the column headers
499
+ if (this.IsDynamicView()) {
500
+ // Dynamic View, we have this.Params and can add an OrderBy and then just Refresh() the entire component
501
+ // that will result in going to the server for a refreshed set of data
502
+ if (this.Params) {
503
+ this.Params.OrderBy = sort[0].field + ' ' + (sort[0].dir);
504
+ this.Refresh(this.Params);
505
+ }
506
+ else {
507
+ LogError("sortChanged() called but this.Params is null or undefined"); // should never get here
508
+ }
509
+ }
510
+ else {
511
+ // Saved view - we do this on the server side only
512
+ this._viewDirty = true;
513
+ this.innerSaveView(); // for sort changes we call innerSaveView() directly, not through SaveView() which is debounced
514
+ }
515
+ });
516
+ }
517
+ cellClickHandler(args) {
518
+ return __awaiter(this, void 0, void 0, function* () {
519
+ if (this.compareMode || this.mergeMode)
520
+ return;
521
+ if (this._entityInfo) {
522
+ const pkeyVals = [];
523
+ this._entityInfo.PrimaryKeys.forEach((pkey) => {
524
+ pkeyVals.push({ FieldName: pkey.Name, Value: this.viewData[args.rowIndex][pkey.Name] });
525
+ });
526
+ this.rowClicked.emit({
527
+ entityId: this._entityInfo.ID,
528
+ entityName: this._entityInfo.Name,
529
+ primaryKeyValues: pkeyVals
530
+ });
531
+ if (this._entityInfo.AllowUpdateAPI &&
532
+ this.EditMode !== "None") {
533
+ const perm = this._entityInfo.GetUserPermisions(new Metadata().CurrentUser);
534
+ if (perm.CanUpdate) {
535
+ this.StartEditMode();
536
+ args.sender.editCell(args.rowIndex, args.columnIndex, this.createFormGroup(args.dataItem));
537
+ }
538
+ }
539
+ if (!this.InEditMode && this.AutoNavigate) {
540
+ // tell app router to go to this record
541
+ const pkVals = this.GeneratePrimaryKeyValueString(pkeyVals);
542
+ this.router.navigate(['resource', 'record', pkVals], { queryParams: { Entity: this._entityInfo.Name } });
543
+ }
544
+ }
545
+ });
546
+ }
547
+ GeneratePrimaryKeyValueString(pkVals) {
548
+ return pkVals.length > 1 ? pkVals.map(pk => pk.FieldName + '|' + pk.Value).join('||') : pkVals[0].Value;
549
+ }
550
+ createFormGroup(dataItem) {
551
+ const groupFields = {};
552
+ this.viewColumns.forEach((vc) => {
553
+ if (vc.EntityField.AllowUpdateAPI &&
554
+ vc.EntityField.IsVirtual === false &&
555
+ vc.EntityField.AllowUpdateInView)
556
+ groupFields[vc.Name] = dataItem[vc.Name];
557
+ });
558
+ return this.formBuilder.group(groupFields);
559
+ }
560
+ getEditor(ef) {
561
+ switch (ef.TSType) {
562
+ case EntityFieldTSType.Boolean:
563
+ return "boolean";
564
+ case EntityFieldTSType.Date:
565
+ return "date";
566
+ case EntityFieldTSType.Number:
567
+ return "numeric";
568
+ default:
569
+ return "text";
570
+ }
571
+ }
572
+ cellCloseHandler(args) {
573
+ var _a;
574
+ return __awaiter(this, void 0, void 0, function* () {
575
+ try {
576
+ if (this._entityInfo && this.EditMode !== "None") {
577
+ const { formGroup, dataItem } = args;
578
+ if (!formGroup.valid) {
579
+ // prevent closing the edited cell if there are invalid values.
580
+ args.preventDefault();
581
+ }
582
+ else if (formGroup.dirty) {
583
+ if (args.originalEvent && args.originalEvent.keyCode === Keys.Escape)
584
+ return; // user hit escape, so don't save their changes
585
+ // update the data item with the new values - this drives UI refresh while we save the record...
586
+ Object.assign(dataItem, formGroup.value);
587
+ const md = new Metadata();
588
+ const pkey = this._entityInfo.PrimaryKey.Name;
589
+ let record;
590
+ let bSaved = false;
591
+ if (this.EditMode === "Save") {
592
+ record = yield md.GetEntityObject(this._entityInfo.Name);
593
+ yield record.InnerLoad(this._entityInfo.PrimaryKeys.map(pk => {
594
+ return {
595
+ FieldName: pk.Name,
596
+ Value: dataItem[pk.Name]
597
+ };
598
+ }));
599
+ record.SetMany(formGroup.value);
600
+ bSaved = yield record.Save();
601
+ if (!bSaved)
602
+ this.CreateSimpleNotification("Error saving record: " + record.Get(pkey), 'error', 5000);
603
+ }
604
+ else {
605
+ record = (_a = this._pendingRecords.find((r) => r.record.Get(pkey) === dataItem[pkey])) === null || _a === void 0 ? void 0 : _a.record;
606
+ if (!record) { // haven't edited this one before
607
+ record = yield md.GetEntityObject(this._viewEntity.Get('Entity'));
608
+ yield record.InnerLoad(this._entityInfo.PrimaryKeys.map(pk => {
609
+ return {
610
+ FieldName: pk.Name,
611
+ Value: dataItem[pk.Name]
612
+ };
613
+ }));
614
+ this._pendingRecords.push({ record,
615
+ row: args.rowIndex,
616
+ dataItem }); // don't save - put the changed record on a queue for saving later by our container
617
+ }
618
+ // go through the formGroup and only set the values that exist as columns in the grid
619
+ const keys = Object.keys(formGroup.value);
620
+ keys.forEach((k) => {
621
+ const vc = this.viewColumns.find((vc) => vc.Name === k && vc.hidden === false);
622
+ if (vc) {
623
+ record.Set(k, formGroup.value[k]);
624
+ }
625
+ });
626
+ //record.SetMany(formGroup.value);
627
+ }
628
+ this.rowEdited.emit({
629
+ record: record,
630
+ row: args.rowIndex,
631
+ saved: bSaved
632
+ });
633
+ }
634
+ }
635
+ }
636
+ catch (e) {
637
+ console.error(e);
638
+ }
639
+ finally {
640
+ this.EndEditMode();
641
+ }
642
+ });
643
+ }
644
+ // this handles reverting pending cahnges to records WITHIN the grid, not the user view settings, unrelated to that.
645
+ RevertPendingChanges() {
646
+ if (this._pendingRecords && this._pendingRecords.length > 0) {
647
+ this._pendingRecords.forEach((r) => {
648
+ r.record.Revert();
649
+ Object.assign(r.dataItem, r.record.GetAll()); // copy the original values back to the data Item which gets the grid to display the old values again...
650
+ });
651
+ this._pendingRecords = [];
652
+ if (this.Params)
653
+ this.Refresh(this.Params);
654
+ }
655
+ }
656
+ ngOnInit() {
657
+ }
658
+ ngAfterViewInit() {
659
+ //this.setGridHeight();
660
+ if (this.Params)
661
+ this.Refresh(this.Params);
662
+ }
663
+ get AllowLoad() {
664
+ return this._allowLoad;
665
+ }
666
+ set AllowLoad(value) {
667
+ this._allowLoad = value;
668
+ if (value === true && this._deferLoadCount === 0) {
669
+ this._deferLoadCount++; // only do this one time
670
+ if (this.Params)
671
+ this.Refresh(this.Params);
672
+ return;
673
+ }
674
+ }
675
+ RefreshFromSavedParams() {
676
+ return __awaiter(this, void 0, void 0, function* () {
677
+ if (this.Params)
678
+ this.Refresh(this.Params);
679
+ });
680
+ }
681
+ Refresh(params) {
682
+ var _a, _b, _c;
683
+ return __awaiter(this, void 0, void 0, function* () {
684
+ this.Params = params;
685
+ if (this.AllowLoad === false) {
686
+ return;
687
+ }
688
+ if (params && (params.ViewEntity || params.ViewID || params.ViewName || (params.EntityName && params.ExtraFilter))) {
689
+ const startTime = new Date().getTime();
690
+ this.isLoading = true;
691
+ const md = new Metadata();
692
+ const rv = new RunView();
693
+ // get the view entity first so we can pass it in, otherwise it will end up getting loaded inside of RunView() which is inefficient as we need it too
694
+ // this is done for performance purposes
695
+ if (params.ViewEntity) {
696
+ // When we receive the .ViewEntity via our params that is a time saver as we don't need to load it again, so ALWAYS use that instance of the entity object for the view entity
697
+ this._viewEntity = params.ViewEntity;
698
+ const e = md.Entities.find(x => { var _a; return x.ID === ((_a = this._viewEntity) === null || _a === void 0 ? void 0 : _a.EntityID); });
699
+ if (e)
700
+ this._entityInfo = e;
701
+ else
702
+ throw new Error("Unable to get entity info for view: " + ((_a = this._viewEntity) === null || _a === void 0 ? void 0 : _a.Name));
703
+ }
704
+ else if (!params.ViewEntity && (params.ViewID || params.ViewName)) {
705
+ // this is NOT a dyamic view as we got either the ViewID or ViewName, so we can get the ViewEntity
706
+ if (params.ViewID && params.ViewID > 0) {
707
+ this._viewEntity = (yield ViewInfo.GetViewEntity(params.ViewID));
708
+ }
709
+ else if (params.ViewName) {
710
+ this._viewEntity = (yield ViewInfo.GetViewEntityByName(params.ViewName));
711
+ }
712
+ params.ViewEntity = this._viewEntity;
713
+ const e = md.Entities.find(x => { var _a; return x.ID === ((_a = this._viewEntity) === null || _a === void 0 ? void 0 : _a.EntityID); });
714
+ if (e)
715
+ this._entityInfo = e;
716
+ else
717
+ throw new Error("Unable to get entity info for view: " + ((_b = this._viewEntity) === null || _b === void 0 ? void 0 : _b.Name));
718
+ }
719
+ else if (params.EntityName) {
720
+ // we don't have a ViewEntity because we're doing a dynamic view, so we need to get the entity info from the Entity Name
721
+ const e = md.Entities.find(x => x.Name === params.EntityName);
722
+ if (e)
723
+ this._entityInfo = e;
724
+ }
725
+ else
726
+ throw new Error("Invalid configuration, we need to receive either a ViewEntity, ViewID, ViewName, or EntityName and ExtraFilter in order to run a view");
727
+ const rvResult = yield rv.RunView(params);
728
+ if (!rvResult.Success) {
729
+ // it failed
730
+ this.CreateSimpleNotification("Error running view:\n\n" + rvResult.ErrorMessage, 'error', 5000);
731
+ }
732
+ else {
733
+ // it worked
734
+ this.viewData = rvResult.Results;
735
+ this.totalRowCount = rvResult.TotalRowCount;
736
+ this.formattedData = new Array(this.viewData.length);
737
+ let cols;
738
+ if (this._viewEntity)
739
+ cols = this._viewEntity.Columns;
740
+ else
741
+ cols = (_c = this._entityInfo) === null || _c === void 0 ? void 0 : _c.Fields.filter((f) => f.DefaultInView).map((f) => {
742
+ return {
743
+ ID: f.ID,
744
+ Name: f.Name,
745
+ DisplayName: f.DisplayName,
746
+ EntityField: f,
747
+ hidden: false,
748
+ orderIndex: f.Sequence,
749
+ width: f.DefaultColumnWidth ? f.DefaultColumnWidth : 100,
750
+ };
751
+ });
752
+ if (cols) {
753
+ this.viewColumns = cols;
754
+ const tempCols = cols.filter(x => x.hidden === false).sort((a, b) => {
755
+ const aOrder = a.orderIndex != null ? a.orderIndex : 9999;
756
+ const bOrder = b.orderIndex != null ? b.orderIndex : 9999;
757
+ return aOrder - bOrder;
758
+ });
759
+ this.visibleColumns = tempCols;
760
+ }
761
+ // sorting setup
762
+ if (this._viewEntity) {
763
+ const temp = this._viewEntity.ViewSortInfo;
764
+ const kendoSortSettings = temp.map((s) => {
765
+ let dir;
766
+ if (typeof s.direction === 'string')
767
+ dir = s.direction.trim().toLowerCase();
768
+ else if (typeof s.direction === 'number' && s.direction === 1)
769
+ dir = 'asc';
770
+ else if (typeof s.direction === 'number' && s.direction === 2)
771
+ dir = 'desc';
772
+ else
773
+ dir = '';
774
+ return { field: s.field, dir: dir };
775
+ });
776
+ this.sortSettings = kendoSortSettings;
777
+ }
778
+ this.skip = 0;
779
+ this.virtualLoadData();
780
+ }
781
+ this.viewExecutionTime = (new Date().getTime() - startTime) / 1000; // in seconds
782
+ this.isLoading = false;
783
+ }
784
+ else {
785
+ LogError("Refresh(params) must have ViewID or ViewName or (EntityName and ExtraFilter)");
786
+ }
787
+ });
788
+ }
789
+ GetColumnTitle(col) {
790
+ if (col.DisplayName)
791
+ return col.DisplayName; // use view's display name first if it exists
792
+ else if (col.EntityField.DisplayName)
793
+ return col.EntityField.DisplayName; // then use entity display name, if that exist
794
+ else
795
+ return col.Name; // otherwise just use the column name
796
+ }
797
+ GetColumnCellStyle(col) {
798
+ switch (col.EntityField.Type.trim().toLowerCase()) {
799
+ case "money":
800
+ case 'decimal':
801
+ case 'real':
802
+ case 'float':
803
+ case 'int':
804
+ return { 'text-align': 'right', 'vertical-align': 'top' }; // right align numbers,
805
+ default:
806
+ return { 'text-align': 'left', 'vertical-align': 'top' }; // left align everything else
807
+ }
808
+ }
809
+ selectionChange(args) {
810
+ // update recordsToCompare based on the this.selectedKeys property that is bound
811
+ // selectedKeys is an array of indexes in the this.viewData, and we need to make our
812
+ // this.recordsToCompare an array of records from this.viewData so just map() the selectedKeys for this
813
+ this.recordsToCompare = this.selectedKeys.map((i) => this.viewData[i]);
814
+ }
815
+ enableMergeOrCompare(cancel = false, type) {
816
+ if (!cancel && this.recordsToCompare.length >= 2) {
817
+ // this scenario occurs when we've already started the merge/compare and the user has selected records, then clicked the merge/compare button again
818
+ this.isCompareDialogOpened = true;
819
+ }
820
+ else if (cancel) {
821
+ // the user clicked cancel in our toolbar
822
+ if (type === 'merge')
823
+ this.mergeMode = false;
824
+ else
825
+ this.compareMode = false;
826
+ this.selectedKeys = [];
827
+ this.recordsToCompare = [];
828
+ }
829
+ else {
830
+ // just turning on merge mode from the merge/compare button, so just turn it on and let the user select records
831
+ if (type === 'merge')
832
+ this.mergeMode = true;
833
+ else
834
+ this.compareMode = true;
835
+ }
836
+ }
837
+ closeConfirmMergeDialog(event) {
838
+ return __awaiter(this, void 0, void 0, function* () {
839
+ if (event === 'yes') {
840
+ if (this._entityInfo && this.recordCompareComponent) {
841
+ const md = new Metadata();
842
+ const pkey = this._entityInfo.PrimaryKey.Name;
843
+ const result = yield md.MergeRecords({
844
+ EntityName: this._entityInfo.Name,
845
+ RecordsToMerge: this.recordsToCompare.map((r) => r.Get(pkey)).filter((pkeyVal) => { var _a; return pkeyVal !== ((_a = this.recordCompareComponent) === null || _a === void 0 ? void 0 : _a.selectedRecordPKeyVal); }),
846
+ SurvivingRecordPrimaryKeyValues: [{ FieldName: pkey, Value: this.recordCompareComponent.selectedRecordPKeyVal }],
847
+ FieldMap: this.recordCompareComponent.fieldMap.map((fm) => {
848
+ return {
849
+ FieldName: fm.fieldName,
850
+ Value: fm.value
851
+ };
852
+ })
853
+ });
854
+ if (result.Success) {
855
+ // merge was successful, so refresh the grid
856
+ this.selectedKeys = [];
857
+ this.recordsToCompare = [];
858
+ this.mergeMode = false;
859
+ this.compareMode = false;
860
+ // close the dialogs
861
+ this.isCompareDialogOpened = false;
862
+ this.isConfirmDialogOpen = false;
863
+ // refresh the grid
864
+ this.Refresh(this.Params);
865
+ }
866
+ else {
867
+ // the merge failed, so show an error message
868
+ this.isConfirmDialogOpen = false;
869
+ this.CreateSimpleNotification("Error merging records: " + result.OverallStatus, 'error', 5000);
870
+ }
871
+ }
872
+ }
873
+ else {
874
+ this.isConfirmDialogOpen = false;
875
+ // close the dialog and let the user continue to work on the merge, so don't close the compare dialog
876
+ }
877
+ });
878
+ }
879
+ closeCompareDialog(event) {
880
+ return __awaiter(this, void 0, void 0, function* () {
881
+ console.log(event);
882
+ switch (event) {
883
+ case 'merge':
884
+ // user has requested to merge the records and retain the selected record from the compare records component, so run the merge
885
+ // first, confirm with the user to make 100% sure they want to do this as it is irreversible
886
+ this.isConfirmDialogOpen = true;
887
+ break;
888
+ default: // close and cancel
889
+ this.selectedKeys = [];
890
+ this.recordsToCompare = [];
891
+ this.mergeMode = false;
892
+ this.compareMode = false;
893
+ this.isCompareDialogOpened = false;
894
+ break;
895
+ }
896
+ });
897
+ }
898
+ doExcelExport() {
899
+ return __awaiter(this, void 0, void 0, function* () {
900
+ if (this.kendoExcelExport === null)
901
+ throw new Error("kendoExcelExport is null, cannot export data");
902
+ try {
903
+ this.CreateSimpleNotification("Working on the export, will notify you when it is complete...", 'info', 2000);
904
+ const data = yield this.getExportData();
905
+ // we have the data.
906
+ const cols = this.viewColumns.filter((vc) => vc.hidden === false);
907
+ this.exportColumns = cols;
908
+ this.exportData = data;
909
+ // before we call the save, we need to let Angular do its thing that will result in the kendoExcelExport component binding properly to
910
+ // the exportColumns and exportData arrays. So we wait for the next tick before we call save()
911
+ setTimeout(() => {
912
+ this.kendoExcelExport.save();
913
+ this.CreateSimpleNotification("Excel Export Complete", 'success', 2000);
914
+ }, 100);
915
+ }
916
+ catch (e) {
917
+ this.CreateSimpleNotification("Error exporting data", 'error', 5000);
918
+ LogError(e);
919
+ }
920
+ });
921
+ }
922
+ getExportData() {
923
+ return __awaiter(this, void 0, void 0, function* () {
924
+ // Get the data for the ENTIRE view, not just the current page
925
+ const md = new Metadata();
926
+ const rv = new RunView();
927
+ const p = Object.assign(Object.assign({}, this.Params), { IgnoreMaxRows: true, ForceAuditLog: true, AuditLogDescription: `Export of Data From ${this._viewEntity ? '"' + this._viewEntity.Get('Name') + '"' : ''} View for User ${md.CurrentUser.Email}` });
928
+ const result = yield rv.RunView(p);
929
+ if (result && result.Success) {
930
+ return result.Results;
931
+ }
932
+ else
933
+ throw new Error("Unable to get export data");
934
+ });
935
+ }
936
+ }
937
+ UserViewGridComponent.ɵfac = function UserViewGridComponent_Factory(t) { return new (t || UserViewGridComponent)(i0.ɵɵdirectiveInject(i1.FormBuilder), i0.ɵɵdirectiveInject(i2.Router)); };
938
+ UserViewGridComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: UserViewGridComponent, selectors: [["mj-user-view-grid"]], viewQuery: function UserViewGridComponent_Query(rf, ctx) { if (rf & 1) {
939
+ i0.ɵɵviewQuery(_c0, 5, GridComponent);
940
+ i0.ɵɵviewQuery(_c0, 5, ElementRef);
941
+ i0.ɵɵviewQuery(_c1, 5, ExcelExportComponent);
942
+ i0.ɵɵviewQuery(_c2, 5);
943
+ } if (rf & 2) {
944
+ let _t;
945
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.kendoGridElement = _t.first);
946
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.kendoGridElementRef = _t.first);
947
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.kendoExcelExport = _t.first);
948
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.recordCompareComponent = _t.first);
949
+ } }, inputs: { Params: "Params", BottomMargin: "BottomMargin", InEditMode: "InEditMode", EditMode: "EditMode", AutoNavigate: "AutoNavigate", AllowLoad: "AllowLoad" }, outputs: { rowClicked: "rowClicked", rowEdited: "rowEdited" }, decls: 16, vars: 19, consts: [["mjFillContainer", "", 1, "user-view-grid-wrap"], ["title", "Data"], ["mjFillContainer", "", "scrollable", "virtual", "kendoGridSelectBy", "", 3, "resizable", "data", "skip", "pageSize", "rowHeight", "loading", "height", "sortable", "sort", "reorderable", "selectable", "selectedKeys", "pageChange", "selectedKeysChange", "cellClick", "cellClose", "columnReorder", "columnResize", "selectionChange", "sortChange"], ["kendoGrid", ""], ["kendoGridToolbarTemplate", ""], [3, "width", "headerStyle", "style", 4, "ngIf"], [3, "field", "title", "width", "editable", "editor", "headerStyle", "style", 4, "ngFor", "ngForOf"], [3, "data", "fileName"], ["excelExport", ""], [3, "field", "title", 4, "ngFor", "ngForOf"], ["title", "Analysis"], [4, "ngIf"], ["kendoButton", "", 3, "click", 4, "ngIf"], ["class", "k-button k-button-md k-rounded-md k-button-solid-base k-button-solid", 3, "disabled", "click", 4, "ngIf"], ["class", "k-button k-button-md k-rounded-md k-button-solid-base k-button-solid", 3, "click", 4, "ngIf"], ["kendoButton", "", 3, "primary", "click", 4, "ngIf"], ["kendoButton", "", 3, "click"], [3, "icon"], [1, "k-button", "k-button-md", "k-rounded-md", "k-button-solid-base", "k-button-solid", 3, "disabled", "click"], [1, "k-button", "k-button-md", "k-rounded-md", "k-button-solid-base", "k-button-solid", 3, "click"], ["kendoButton", "", 3, "primary", "click"], [3, "width", "headerStyle"], [3, "field", "title", "width", "editable", "editor", "headerStyle"], ["kendoGridFooterTemplate", ""], [2, "font-size", "smaller", "font-weight", "normal"], [3, "field", "title"], [1, "k-overlay"], ["title", "Compare Records", 3, "minHeight", "minWidth", "resizable", "close", 4, "ngIf"], ["title", "Compare Records", 3, "minHeight", "minWidth", "resizable", "close"], [1, "k-d-flex", "k-flex-col", "k-justify-content-between", "k-h-full"], [3, "entityName", "recordsToCompare", "visibleColumns", "selectionMode"], ["recordCompareRef", ""], [1, "k-actions", "k-actions-end"], ["kendoButton", "", "type", "button", 3, "click", 4, "ngIf"], ["kendoButton", "", "themeColor", "primary", "type", "button", 3, "click", 4, "ngIf"], ["title", "Confirm Choice", 3, "minWidth", "width", "close", 4, "ngIf"], ["kendoButton", "", "type", "button", 3, "click"], ["kendoButton", "", "themeColor", "primary", "type", "button", 3, "click"], ["title", "Confirm Choice", 3, "minWidth", "width", "close"], [2, "margin", "30px", "text-align", "center"], ["kendoButton", "", "themeColor", "primary", 3, "click"]], template: function UserViewGridComponent_Template(rf, ctx) { if (rf & 1) {
950
+ i0.ɵɵelementStart(0, "div", 0)(1, "kendo-tabstrip")(2, "kendo-tabstrip-tab", 1)(3, "kendo-grid", 2, 3);
951
+ i0.ɵɵlistener("pageChange", function UserViewGridComponent_Template_kendo_grid_pageChange_3_listener($event) { return ctx.pageChange($event); })("selectedKeysChange", function UserViewGridComponent_Template_kendo_grid_selectedKeysChange_3_listener($event) { return ctx.selectedKeys = $event; })("cellClick", function UserViewGridComponent_Template_kendo_grid_cellClick_3_listener($event) { return ctx.cellClickHandler($event); })("cellClose", function UserViewGridComponent_Template_kendo_grid_cellClose_3_listener($event) { return ctx.cellCloseHandler($event); })("columnReorder", function UserViewGridComponent_Template_kendo_grid_columnReorder_3_listener($event) { return ctx.columnReorder($event); })("columnResize", function UserViewGridComponent_Template_kendo_grid_columnResize_3_listener($event) { return ctx.columnResize($event); })("selectionChange", function UserViewGridComponent_Template_kendo_grid_selectionChange_3_listener($event) { return ctx.selectionChange($event); })("sortChange", function UserViewGridComponent_Template_kendo_grid_sortChange_3_listener($event) { return ctx.sortChanged($event); });
952
+ i0.ɵɵtemplate(5, UserViewGridComponent_ng_template_5_Template, 8, 8, "ng-template", 4)(6, UserViewGridComponent_kendo_grid_checkbox_column_6_Template, 1, 6, "kendo-grid-checkbox-column", 5)(7, UserViewGridComponent_kendo_grid_column_7_Template, 2, 10, "kendo-grid-column", 6);
953
+ i0.ɵɵelementStart(8, "kendo-excelexport", 7, 8);
954
+ i0.ɵɵtemplate(10, UserViewGridComponent_kendo_excelexport_column_10_Template, 1, 2, "kendo-excelexport-column", 9);
955
+ i0.ɵɵelementEnd()()();
956
+ i0.ɵɵelementStart(11, "kendo-tabstrip-tab", 10)(12, "div")(13, "span");
957
+ i0.ɵɵtext(14, " hi ");
958
+ i0.ɵɵelementEnd()()()();
959
+ i0.ɵɵtemplate(15, UserViewGridComponent_div_15_Template, 3, 1, "div", 11);
960
+ i0.ɵɵelementEnd();
961
+ } if (rf & 2) {
962
+ i0.ɵɵadvance(3);
963
+ i0.ɵɵproperty("resizable", true)("data", ctx.gridView)("skip", ctx.skip)("pageSize", ctx.pageSize)("rowHeight", 36)("loading", ctx.isLoading)("height", ctx.gridHeight)("sortable", true)("sort", ctx.sortSettings)("resizable", true)("reorderable", true)("selectable", true)("selectedKeys", ctx.selectedKeys);
964
+ i0.ɵɵadvance(3);
965
+ i0.ɵɵproperty("ngIf", ctx.compareMode || ctx.mergeMode);
966
+ i0.ɵɵadvance();
967
+ i0.ɵɵproperty("ngForOf", ctx.visibleColumns);
968
+ i0.ɵɵadvance();
969
+ i0.ɵɵproperty("data", ctx.exportData)("fileName", (ctx._viewEntity ? ctx._viewEntity.Get("Name") : ctx._entityInfo == null ? null : ctx._entityInfo.Name) + ".xlsx");
970
+ i0.ɵɵadvance(2);
971
+ i0.ɵɵproperty("ngForOf", ctx.exportColumns);
972
+ i0.ɵɵadvance(5);
973
+ i0.ɵɵproperty("ngIf", ctx.isCompareDialogOpened);
974
+ } }, dependencies: [i3.NgForOf, i3.NgIf, i4.GridComponent, i4.ToolbarTemplateDirective, i4.SelectionDirective, i4.ColumnComponent, i4.FooterTemplateDirective, i4.CheckboxColumnComponent, i5.DialogComponent, i5.DialogActionsComponent, i5.WindowComponent, i6.ExcelExportComponent, i6.ColumnComponent, i7.ButtonComponent, i8.CompareRecordsComponent, i9.FillContainer, i10.SVGIconComponent, i11.TabStripComponent, i11.TabStripTabComponent, i3.DecimalPipe], styles: [".user-view-grid-wrap[_ngcontent-%COMP%] {\r\n height: calc(100vh-20px);\r\n}\r\n\r\n.user-view-grid-column-header[_ngcontent-%COMP%] {\r\n background-color: #a9c2af;\r\n font-size: 20pt;\r\n font-weight: bold;\r\n}"] });
975
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UserViewGridComponent, [{
976
+ type: Component,
977
+ args: [{ selector: 'mj-user-view-grid', template: "<div class=\"user-view-grid-wrap\" mjFillContainer>\r\n <kendo-tabstrip>\r\n <kendo-tabstrip-tab title=\"Data\">\r\n <kendo-grid #kendoGrid\r\n mjFillContainer\r\n [resizable]=\"true\"\r\n [data]=\"gridView\" \r\n [skip]=\"skip\"\r\n [pageSize]=\"pageSize\"\r\n scrollable=\"virtual\"\r\n [rowHeight]=\"36\"\r\n (pageChange)=\"pageChange($event)\"\r\n [loading]=\"isLoading\"\r\n [height]=\"gridHeight\"\r\n [sortable]=\"true\"\r\n [sort]=\"sortSettings\" \r\n [resizable]=\"true\"\r\n [reorderable]=\"true\"\r\n [selectable]=\"true\"\r\n kendoGridSelectBy\r\n [(selectedKeys)]=\"selectedKeys\"\r\n (cellClick)=\"cellClickHandler($event)\"\r\n (cellClose)=\"cellCloseHandler($event)\"\r\n (columnReorder)=\"columnReorder($event)\"\r\n (columnResize)=\"columnResize($event)\"\r\n (selectionChange)=\"selectionChange($event)\"\r\n (sortChange)=\"sortChanged($event)\"\r\n >\r\n <ng-template kendoGridToolbarTemplate>\r\n <button kendoButton *ngIf=\"!compareMode && !mergeMode\" (click)=\"doExcelExport()\" >\r\n <kendo-svgicon [icon]=\"kendoSVGIcon('fileExcel')\"></kendo-svgicon>\r\n Export to Excel\r\n </button>\r\n <!-- 3 buttons for compare. First one only shows when comparison is going on in the grid, the next one is the one the user starts the process with before records are selected, last one is to cancel the pending compare. -->\r\n <button (click)=\"enableMergeOrCompare(false, 'compare')\" *ngIf=\"!compareMode && !mergeMode\" [disabled]=\"compareMode && recordsToCompare.length < 2\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Compare</button>\r\n <button (click)=\"enableMergeOrCompare(false, 'compare')\" *ngIf=\"compareMode\" [disabled]=\"compareMode && recordsToCompare.length < 2\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Compare</button>\r\n <button (click)=\"enableMergeOrCompare(true, 'compare')\" *ngIf=\"compareMode\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Cancel</button>\r\n \r\n <!-- 3 buttons for merge. First one only shows when merge is getting goin in the grid, the next one is the one the user starts the process with before records are selected, last one is to cancel the pending merge. -->\r\n <button (click)=\"enableMergeOrCompare(false, 'merge')\" *ngIf=\"mergeMode\" [disabled]=\"mergeMode && recordsToCompare.length < 2\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Merge</button>\r\n <button (click)=\"enableMergeOrCompare(false, 'merge')\" *ngIf=\"!mergeMode && !compareMode\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Merge</button>\r\n <button (click)=\"enableMergeOrCompare(true, 'merge')\" *ngIf=\"mergeMode\" class=\"k-button k-button-md k-rounded-md k-button-solid-base k-button-solid\">Cancel</button>\r\n <button\r\n kendoButton\r\n [primary]=\"true\"\r\n *ngIf=\"showRefreshButton && !compareMode && !mergeMode\"\r\n (click)=\"RefreshFromSavedParams()\">\r\n <kendo-svgicon [icon]=\"kendoSVGIcon('arrowRotateCcwSmall')\"></kendo-svgicon>\r\n Refresh\r\n </button>\r\n </ng-template>\r\n \r\n <kendo-grid-checkbox-column \r\n *ngIf=\"compareMode || mergeMode\" \r\n [width]=\"50\" \r\n [headerStyle]=\"{ 'font-weight' : 'bold', 'background-color': '#a9c2af' }\" \r\n [style]=\"{'text-align': 'center', 'vertical-align': 'center'}\">\r\n </kendo-grid-checkbox-column>\r\n \r\n <kendo-grid-column \r\n *ngFor=\"let item of visibleColumns\" \r\n [field]=\"item.Name\" \r\n [title]=\"GetColumnTitle(item)\"\r\n [width]=\"item.width ? item.width : 100\"\r\n [editable]=\"item.EntityField.AllowUpdateAPI\"\r\n [editor]=\"getEditor(item.EntityField)\"\r\n [headerStyle]=\"{ 'font-weight' : 'bold', 'background-color': '#a9c2af' }\"\r\n [style]=\"this.GetColumnCellStyle(item)\"\r\n >\r\n <ng-template *ngIf=\"item===visibleColumns[0]\" kendoGridFooterTemplate >\r\n {{this.viewData.length | number}}{{this.totalRowCount > this.viewData.length ? ' of ' + (this.totalRowCount | number) : ' rows'}}<br/><span style=\"font-size: smaller; font-weight: normal;\">{{viewExecutionTime | number:'1.2-2'}} seconds</span>\r\n </ng-template>\r\n </kendo-grid-column>\r\n \r\n <kendo-excelexport #excelExport [data]=\"exportData\" [fileName]=\"(_viewEntity ? _viewEntity.Get('Name') : _entityInfo?.Name) + '.xlsx'\">\r\n <kendo-excelexport-column *ngFor=\"let exportCol of exportColumns\" [field]=\"exportCol.Name\" [title]=\"exportCol.Name\">\r\n </kendo-excelexport-column>\r\n </kendo-excelexport>\r\n </kendo-grid> \r\n </kendo-tabstrip-tab>\r\n <kendo-tabstrip-tab title=\"Analysis\">\r\n <div>\r\n <span>\r\n hi\r\n </span>\r\n </div>\r\n </kendo-tabstrip-tab>\r\n </kendo-tabstrip>\r\n \r\n\r\n\r\n <div *ngIf=\"isCompareDialogOpened\">\r\n <div class=\"k-overlay\"></div>\r\n <kendo-window\r\n [minHeight]=\"300\"\r\n [minWidth]=\"400\"\r\n [resizable]=\"true\"\r\n (close)=\"closeCompareDialog($event)\"\r\n title=\"Compare Records\"\r\n *ngIf=\"isCompareDialogOpened\"\r\n >\r\n <div class=\"k-d-flex k-flex-col k-justify-content-between k-h-full\">\r\n <div>\r\n <mj-compare-records\r\n #recordCompareRef\r\n [entityName]=\"_entityInfo ? _entityInfo.Name : ''\"\r\n [recordsToCompare]=\"recordsToCompare\" \r\n [visibleColumns]=\"visibleColumns\" \r\n [selectionMode]=\"mergeMode ? true : false\"\r\n >\r\n </mj-compare-records>\r\n </div>\r\n </div>\r\n <div class=\"k-actions k-actions-end\">\r\n <button *ngIf=\"compareMode\" kendoButton type=\"button\" (click)=\"closeCompareDialog('close')\">Close</button>\r\n <button *ngIf=\"mergeMode\"kendoButton type=\"button\" (click)=\"closeCompareDialog('cancel')\">Cancel</button>\r\n <button *ngIf=\"mergeMode\"\r\n kendoButton\r\n themeColor=\"primary\"\r\n type=\"button\"\r\n (click)=\"closeCompareDialog('merge')\"\r\n >\r\n Merge Records\r\n </button>\r\n </div> \r\n <kendo-dialog\r\n title=\"Confirm Choice\"\r\n *ngIf=\"isConfirmDialogOpen\"\r\n (close)=\"closeConfirmMergeDialog('cancel')\"\r\n [minWidth]=\"250\"\r\n [width]=\"450\"\r\n >\r\n <p style=\"margin: 30px; text-align: center;\">\r\n Are you sure you want to merge the records? This action cannot be undone. If you select \"Yes\", the records will be merged and the duplicate records will be deleted.\r\n </p>\r\n <kendo-dialog-actions>\r\n <button kendoButton (click)=\"closeConfirmMergeDialog('no')\">No</button>\r\n <button kendoButton (click)=\"closeConfirmMergeDialog('yes')\" themeColor=\"primary\">\r\n Yes\r\n </button>\r\n </kendo-dialog-actions>\r\n </kendo-dialog>\r\n </kendo-window>\r\n </div> \r\n</div>\r\n", styles: [".user-view-grid-wrap {\r\n height: calc(100vh-20px);\r\n}\r\n\r\n.user-view-grid-column-header {\r\n background-color: #a9c2af;\r\n font-size: 20pt;\r\n font-weight: bold;\r\n}"] }]
978
+ }], () => [{ type: i1.FormBuilder }, { type: i2.Router }], { Params: [{
979
+ type: Input
980
+ }], BottomMargin: [{
981
+ type: Input
982
+ }], InEditMode: [{
983
+ type: Input
984
+ }], EditMode: [{
985
+ type: Input
986
+ }], AutoNavigate: [{
987
+ type: Input
988
+ }], rowClicked: [{
989
+ type: Output
990
+ }], rowEdited: [{
991
+ type: Output
992
+ }], kendoGridElement: [{
993
+ type: ViewChild,
994
+ args: ['kendoGrid', { read: GridComponent }]
995
+ }], kendoGridElementRef: [{
996
+ type: ViewChild,
997
+ args: ['kendoGrid', { read: ElementRef }]
998
+ }], kendoExcelExport: [{
999
+ type: ViewChild,
1000
+ args: ['excelExport', { read: ExcelExportComponent }]
1001
+ }], recordCompareComponent: [{
1002
+ type: ViewChild,
1003
+ args: ['recordCompareRef', { static: false }]
1004
+ }], AllowLoad: [{
1005
+ type: Input
1006
+ }] }); })();
1007
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(UserViewGridComponent, { className: "UserViewGridComponent", filePath: "src\\lib\\ng-user-view-grid.component.ts", lineNumber: 42 }); })();