@zeedhi/teknisa-components-common 1.63.0 → 1.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coverage/clover.xml +376 -380
- package/coverage/coverage-final.json +8 -8
- package/coverage/lcov-report/index.html +16 -16
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +2 -2
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
- package/coverage/lcov.info +716 -730
- package/dist/tek-components-common.esm.js +35 -48
- package/dist/tek-components-common.umd.js +35 -48
- package/package.json +2 -2
- package/tests/unit/components/tek-grid/grid.spec.ts +13 -18
- package/tests/unit/components/tree-grid/tree-grid.spec.ts +10 -16
- package/types/components/tek-grid/interfaces.d.ts +16 -16
- package/types/components/tek-notifications/interfaces.d.ts +5 -5
|
@@ -540,21 +540,15 @@ class Notifications extends Iterable {
|
|
|
540
540
|
this.createAccessors();
|
|
541
541
|
}
|
|
542
542
|
markAsRead({ event, element }) {
|
|
543
|
-
|
|
544
|
-
this.events.markAllAsReadClick({ event, element, component: this });
|
|
545
|
-
}
|
|
543
|
+
this.callEvent('markAllAsReadClick', { event, element, component: this });
|
|
546
544
|
}
|
|
547
545
|
showAll(event, element) {
|
|
548
|
-
|
|
549
|
-
this.events.showAllClick({ event, element, component: this });
|
|
550
|
-
}
|
|
546
|
+
this.callEvent('showAllClick', { event, element, component: this });
|
|
551
547
|
}
|
|
552
548
|
notificationClick(event, notification, element) {
|
|
553
|
-
|
|
554
|
-
this
|
|
555
|
-
|
|
556
|
-
});
|
|
557
|
-
}
|
|
549
|
+
this.callEvent('notificationClick', {
|
|
550
|
+
event, notification, element, component: this,
|
|
551
|
+
});
|
|
558
552
|
}
|
|
559
553
|
}
|
|
560
554
|
|
|
@@ -884,50 +878,34 @@ class GridBase {
|
|
|
884
878
|
];
|
|
885
879
|
}
|
|
886
880
|
addButtonClick({ event }) {
|
|
887
|
-
|
|
888
|
-
this.grid.events.addClick({ component: this.grid, event });
|
|
889
|
-
}
|
|
881
|
+
this.grid.callEvent('addClick', { component: this.grid, event });
|
|
890
882
|
}
|
|
891
883
|
deleteButtonClick({ event }) {
|
|
892
|
-
|
|
893
|
-
this.grid.events.beforeDelete({ component: this.grid, event });
|
|
894
|
-
}
|
|
884
|
+
this.grid.callEvent('beforeDelete', { component: this.grid, event });
|
|
895
885
|
if (!event.defaultPrevented) {
|
|
896
886
|
this.grid.deleteRows();
|
|
897
|
-
|
|
898
|
-
this.grid.events.afterDelete({ component: this.grid });
|
|
899
|
-
}
|
|
887
|
+
this.grid.callEvent('afterDelete', { component: this.grid });
|
|
900
888
|
}
|
|
901
889
|
}
|
|
902
890
|
reloadGrid() {
|
|
903
891
|
this.grid.reload();
|
|
904
892
|
}
|
|
905
893
|
saveChanges({ event }) {
|
|
906
|
-
|
|
907
|
-
this.grid.events.beforeSave({ component: this.grid, event });
|
|
908
|
-
}
|
|
894
|
+
this.grid.callEvent('beforeSave', { component: this.grid, event });
|
|
909
895
|
if (!event.defaultPrevented) {
|
|
910
896
|
this.grid.saveEditedRows();
|
|
911
|
-
|
|
912
|
-
this.grid.events.afterSave({ component: this.grid });
|
|
913
|
-
}
|
|
897
|
+
this.grid.callEvent('afterSave', { component: this.grid });
|
|
914
898
|
}
|
|
915
899
|
}
|
|
916
900
|
cancelChanges({ event }) {
|
|
917
|
-
|
|
918
|
-
this.grid.events.beforeCancel({ component: this.grid, event });
|
|
919
|
-
}
|
|
901
|
+
this.grid.callEvent('beforeCancel', { component: this.grid, event });
|
|
920
902
|
if (!event.defaultPrevented) {
|
|
921
903
|
this.grid.cancelEditedRows();
|
|
922
|
-
|
|
923
|
-
this.grid.events.afterCancel({ component: this.grid });
|
|
924
|
-
}
|
|
904
|
+
this.grid.callEvent('afterCancel', { component: this.grid });
|
|
925
905
|
}
|
|
926
906
|
}
|
|
927
907
|
filterClick({ event }) {
|
|
928
|
-
|
|
929
|
-
this.grid.events.filterClick({ event, component: this.grid });
|
|
930
|
-
}
|
|
908
|
+
this.grid.callEvent('filterClick', { component: this.grid, event });
|
|
931
909
|
if (!event.defaultPrevented) {
|
|
932
910
|
this.createFilterFromColumns();
|
|
933
911
|
}
|
|
@@ -1136,6 +1114,7 @@ class GridBase {
|
|
|
1136
1114
|
const filterForm = Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
1137
1115
|
if (filterForm.validate()) {
|
|
1138
1116
|
const { datasource } = this.grid;
|
|
1117
|
+
this.grid.callEvent('beforeApplyFilter', { component: this.grid, event });
|
|
1139
1118
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
1140
1119
|
const dynamicFilter = {};
|
|
1141
1120
|
Object.keys(filterForm.value).forEach((item) => {
|
|
@@ -1156,25 +1135,25 @@ class GridBase {
|
|
|
1156
1135
|
}
|
|
1157
1136
|
});
|
|
1158
1137
|
datasource.dynamicFilter = dynamicFilter;
|
|
1138
|
+
if (!event.defaultPrevented) {
|
|
1139
|
+
datasource.setDynamicFilter(dynamicFilter);
|
|
1140
|
+
this.filterModal.hide();
|
|
1141
|
+
}
|
|
1159
1142
|
}
|
|
1160
1143
|
else {
|
|
1144
|
+
const filter = {};
|
|
1161
1145
|
Object.keys(filterForm.value).forEach((item) => {
|
|
1162
1146
|
let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
|
|
1163
1147
|
columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
|
|
1164
1148
|
if (filterForm.value[item]) {
|
|
1165
|
-
|
|
1166
|
-
}
|
|
1167
|
-
else {
|
|
1168
|
-
delete datasource.filter[columnName];
|
|
1149
|
+
filter[columnName] = filterForm.value[item];
|
|
1169
1150
|
}
|
|
1170
1151
|
});
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
datasource.get();
|
|
1177
|
-
this.filterModal.hide();
|
|
1152
|
+
datasource.filter = filter;
|
|
1153
|
+
if (!event.defaultPrevented) {
|
|
1154
|
+
datasource.setFilter(filter);
|
|
1155
|
+
this.filterModal.hide();
|
|
1156
|
+
}
|
|
1178
1157
|
}
|
|
1179
1158
|
this.grid.changeLayout(event);
|
|
1180
1159
|
}
|
|
@@ -2403,13 +2382,17 @@ class TekGrid extends GridEditable {
|
|
|
2403
2382
|
const reportFilter = new ReportFilter(dynamicFilter);
|
|
2404
2383
|
filter = reportFilter.build();
|
|
2405
2384
|
}
|
|
2385
|
+
let beforeOpen;
|
|
2386
|
+
if (typeof this.events.beforeOpenReport === 'function') {
|
|
2387
|
+
beforeOpen = this.events.beforeOpenReport;
|
|
2388
|
+
}
|
|
2406
2389
|
return report.getReport(type, portrait, {
|
|
2407
2390
|
metaData: merge(rowObj, {
|
|
2408
2391
|
filter,
|
|
2409
2392
|
groups: reportGroups,
|
|
2410
2393
|
columns: reportAggregations,
|
|
2411
2394
|
}),
|
|
2412
|
-
},
|
|
2395
|
+
}, beforeOpen).then((reportUrl) => window.open(reportUrl));
|
|
2413
2396
|
});
|
|
2414
2397
|
}
|
|
2415
2398
|
initGrouping(lazyLoad) {
|
|
@@ -3146,13 +3129,17 @@ class TekTreeGrid extends TreeGridEditable {
|
|
|
3146
3129
|
const reportFilter = new ReportFilter(this.datasource.dynamicFilter);
|
|
3147
3130
|
filter = reportFilter.build();
|
|
3148
3131
|
}
|
|
3132
|
+
let beforeOpen;
|
|
3133
|
+
if (typeof this.events.beforeOpenReport === 'function') {
|
|
3134
|
+
beforeOpen = this.events.beforeOpenReport;
|
|
3135
|
+
}
|
|
3149
3136
|
return report.getReport(type, portrait, {
|
|
3150
3137
|
metaData: merge(rowObj, {
|
|
3151
3138
|
filter,
|
|
3152
3139
|
groups: reportGroups,
|
|
3153
3140
|
columns: reportAggregations,
|
|
3154
3141
|
}),
|
|
3155
|
-
},
|
|
3142
|
+
}, beforeOpen).then((reportUrl) => window.open(reportUrl));
|
|
3156
3143
|
});
|
|
3157
3144
|
}
|
|
3158
3145
|
setSearch(search) {
|
|
@@ -545,21 +545,15 @@
|
|
|
545
545
|
this.createAccessors();
|
|
546
546
|
}
|
|
547
547
|
markAsRead({ event, element }) {
|
|
548
|
-
|
|
549
|
-
this.events.markAllAsReadClick({ event, element, component: this });
|
|
550
|
-
}
|
|
548
|
+
this.callEvent('markAllAsReadClick', { event, element, component: this });
|
|
551
549
|
}
|
|
552
550
|
showAll(event, element) {
|
|
553
|
-
|
|
554
|
-
this.events.showAllClick({ event, element, component: this });
|
|
555
|
-
}
|
|
551
|
+
this.callEvent('showAllClick', { event, element, component: this });
|
|
556
552
|
}
|
|
557
553
|
notificationClick(event, notification, element) {
|
|
558
|
-
|
|
559
|
-
this
|
|
560
|
-
|
|
561
|
-
});
|
|
562
|
-
}
|
|
554
|
+
this.callEvent('notificationClick', {
|
|
555
|
+
event, notification, element, component: this,
|
|
556
|
+
});
|
|
563
557
|
}
|
|
564
558
|
}
|
|
565
559
|
|
|
@@ -889,50 +883,34 @@
|
|
|
889
883
|
];
|
|
890
884
|
}
|
|
891
885
|
addButtonClick({ event }) {
|
|
892
|
-
|
|
893
|
-
this.grid.events.addClick({ component: this.grid, event });
|
|
894
|
-
}
|
|
886
|
+
this.grid.callEvent('addClick', { component: this.grid, event });
|
|
895
887
|
}
|
|
896
888
|
deleteButtonClick({ event }) {
|
|
897
|
-
|
|
898
|
-
this.grid.events.beforeDelete({ component: this.grid, event });
|
|
899
|
-
}
|
|
889
|
+
this.grid.callEvent('beforeDelete', { component: this.grid, event });
|
|
900
890
|
if (!event.defaultPrevented) {
|
|
901
891
|
this.grid.deleteRows();
|
|
902
|
-
|
|
903
|
-
this.grid.events.afterDelete({ component: this.grid });
|
|
904
|
-
}
|
|
892
|
+
this.grid.callEvent('afterDelete', { component: this.grid });
|
|
905
893
|
}
|
|
906
894
|
}
|
|
907
895
|
reloadGrid() {
|
|
908
896
|
this.grid.reload();
|
|
909
897
|
}
|
|
910
898
|
saveChanges({ event }) {
|
|
911
|
-
|
|
912
|
-
this.grid.events.beforeSave({ component: this.grid, event });
|
|
913
|
-
}
|
|
899
|
+
this.grid.callEvent('beforeSave', { component: this.grid, event });
|
|
914
900
|
if (!event.defaultPrevented) {
|
|
915
901
|
this.grid.saveEditedRows();
|
|
916
|
-
|
|
917
|
-
this.grid.events.afterSave({ component: this.grid });
|
|
918
|
-
}
|
|
902
|
+
this.grid.callEvent('afterSave', { component: this.grid });
|
|
919
903
|
}
|
|
920
904
|
}
|
|
921
905
|
cancelChanges({ event }) {
|
|
922
|
-
|
|
923
|
-
this.grid.events.beforeCancel({ component: this.grid, event });
|
|
924
|
-
}
|
|
906
|
+
this.grid.callEvent('beforeCancel', { component: this.grid, event });
|
|
925
907
|
if (!event.defaultPrevented) {
|
|
926
908
|
this.grid.cancelEditedRows();
|
|
927
|
-
|
|
928
|
-
this.grid.events.afterCancel({ component: this.grid });
|
|
929
|
-
}
|
|
909
|
+
this.grid.callEvent('afterCancel', { component: this.grid });
|
|
930
910
|
}
|
|
931
911
|
}
|
|
932
912
|
filterClick({ event }) {
|
|
933
|
-
|
|
934
|
-
this.grid.events.filterClick({ event, component: this.grid });
|
|
935
|
-
}
|
|
913
|
+
this.grid.callEvent('filterClick', { component: this.grid, event });
|
|
936
914
|
if (!event.defaultPrevented) {
|
|
937
915
|
this.createFilterFromColumns();
|
|
938
916
|
}
|
|
@@ -1141,6 +1119,7 @@
|
|
|
1141
1119
|
const filterForm = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
1142
1120
|
if (filterForm.validate()) {
|
|
1143
1121
|
const { datasource } = this.grid;
|
|
1122
|
+
this.grid.callEvent('beforeApplyFilter', { component: this.grid, event });
|
|
1144
1123
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
1145
1124
|
const dynamicFilter = {};
|
|
1146
1125
|
Object.keys(filterForm.value).forEach((item) => {
|
|
@@ -1161,25 +1140,25 @@
|
|
|
1161
1140
|
}
|
|
1162
1141
|
});
|
|
1163
1142
|
datasource.dynamicFilter = dynamicFilter;
|
|
1143
|
+
if (!event.defaultPrevented) {
|
|
1144
|
+
datasource.setDynamicFilter(dynamicFilter);
|
|
1145
|
+
this.filterModal.hide();
|
|
1146
|
+
}
|
|
1164
1147
|
}
|
|
1165
1148
|
else {
|
|
1149
|
+
const filter = {};
|
|
1166
1150
|
Object.keys(filterForm.value).forEach((item) => {
|
|
1167
1151
|
let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
|
|
1168
1152
|
columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
|
|
1169
1153
|
if (filterForm.value[item]) {
|
|
1170
|
-
|
|
1171
|
-
}
|
|
1172
|
-
else {
|
|
1173
|
-
delete datasource.filter[columnName];
|
|
1154
|
+
filter[columnName] = filterForm.value[item];
|
|
1174
1155
|
}
|
|
1175
1156
|
});
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
datasource.get();
|
|
1182
|
-
this.filterModal.hide();
|
|
1157
|
+
datasource.filter = filter;
|
|
1158
|
+
if (!event.defaultPrevented) {
|
|
1159
|
+
datasource.setFilter(filter);
|
|
1160
|
+
this.filterModal.hide();
|
|
1161
|
+
}
|
|
1183
1162
|
}
|
|
1184
1163
|
this.grid.changeLayout(event);
|
|
1185
1164
|
}
|
|
@@ -2408,13 +2387,17 @@
|
|
|
2408
2387
|
const reportFilter = new ReportFilter(dynamicFilter);
|
|
2409
2388
|
filter = reportFilter.build();
|
|
2410
2389
|
}
|
|
2390
|
+
let beforeOpen;
|
|
2391
|
+
if (typeof this.events.beforeOpenReport === 'function') {
|
|
2392
|
+
beforeOpen = this.events.beforeOpenReport;
|
|
2393
|
+
}
|
|
2411
2394
|
return report.getReport(type, portrait, {
|
|
2412
2395
|
metaData: merge__default["default"](rowObj, {
|
|
2413
2396
|
filter,
|
|
2414
2397
|
groups: reportGroups,
|
|
2415
2398
|
columns: reportAggregations,
|
|
2416
2399
|
}),
|
|
2417
|
-
},
|
|
2400
|
+
}, beforeOpen).then((reportUrl) => window.open(reportUrl));
|
|
2418
2401
|
});
|
|
2419
2402
|
}
|
|
2420
2403
|
initGrouping(lazyLoad) {
|
|
@@ -3151,13 +3134,17 @@
|
|
|
3151
3134
|
const reportFilter = new ReportFilter(this.datasource.dynamicFilter);
|
|
3152
3135
|
filter = reportFilter.build();
|
|
3153
3136
|
}
|
|
3137
|
+
let beforeOpen;
|
|
3138
|
+
if (typeof this.events.beforeOpenReport === 'function') {
|
|
3139
|
+
beforeOpen = this.events.beforeOpenReport;
|
|
3140
|
+
}
|
|
3154
3141
|
return report.getReport(type, portrait, {
|
|
3155
3142
|
metaData: merge__default["default"](rowObj, {
|
|
3156
3143
|
filter,
|
|
3157
3144
|
groups: reportGroups,
|
|
3158
3145
|
columns: reportAggregations,
|
|
3159
3146
|
}),
|
|
3160
|
-
},
|
|
3147
|
+
}, beforeOpen).then((reportUrl) => window.open(reportUrl));
|
|
3161
3148
|
});
|
|
3162
3149
|
}
|
|
3163
3150
|
setSearch(search) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.65.0",
|
|
4
4
|
"description": "Teknisa Components Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@zeedhi/core": "*"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "83d40038a8a18ce4f1a59b888aa42b97d6f70cc6"
|
|
35
35
|
}
|
|
@@ -193,8 +193,10 @@ describe('TekGrid', () => {
|
|
|
193
193
|
|
|
194
194
|
describe('getReport()', () => {
|
|
195
195
|
let httpReportSpy: jest.SpyInstance;
|
|
196
|
+
let reportSpy: jest.SpyInstance;
|
|
196
197
|
|
|
197
198
|
beforeEach(() => {
|
|
199
|
+
reportSpy = jest.spyOn(Report.prototype, 'getReport').mockReturnValue(Promise.resolve(''));
|
|
198
200
|
httpReportSpy = jest.spyOn(Http, 'post').mockImplementation((url) => {
|
|
199
201
|
if (url === 'https://zhreport.teknisa.com/generateReport') {
|
|
200
202
|
return Promise.resolve({
|
|
@@ -207,6 +209,7 @@ describe('TekGrid', () => {
|
|
|
207
209
|
});
|
|
208
210
|
|
|
209
211
|
afterEach(() => {
|
|
212
|
+
reportSpy.mockClear();
|
|
210
213
|
httpReportSpy.mockReset();
|
|
211
214
|
});
|
|
212
215
|
|
|
@@ -216,9 +219,11 @@ describe('TekGrid', () => {
|
|
|
216
219
|
const instance = new TekGrid({
|
|
217
220
|
name: 'grid_getReport',
|
|
218
221
|
component: 'TekGrid',
|
|
222
|
+
events: {
|
|
223
|
+
beforeOpenReport: jest.fn(),
|
|
224
|
+
},
|
|
219
225
|
});
|
|
220
226
|
|
|
221
|
-
const spy = jest.spyOn(instance, 'getReport');
|
|
222
227
|
instance.onCreated();
|
|
223
228
|
|
|
224
229
|
const buttonProps = (instance as any).gridBase.exportConfigButtons[0] as IButton;
|
|
@@ -227,24 +232,13 @@ describe('TekGrid', () => {
|
|
|
227
232
|
const event = new Event('click');
|
|
228
233
|
button.click(event, {} as HTMLElement);
|
|
229
234
|
|
|
230
|
-
expect(
|
|
231
|
-
spy.mockReset();
|
|
235
|
+
expect(reportSpy).toBeCalledTimes(1);
|
|
232
236
|
|
|
233
237
|
(window as any).open.mockClear();
|
|
234
238
|
});
|
|
235
239
|
|
|
236
240
|
it('should call window open on getReport method', async () => {
|
|
237
241
|
(window as any).open = jest.fn();
|
|
238
|
-
const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
|
|
239
|
-
data: {
|
|
240
|
-
data: [],
|
|
241
|
-
pagination: {
|
|
242
|
-
page: 1,
|
|
243
|
-
total: 0,
|
|
244
|
-
limit: 10,
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
}));
|
|
248
242
|
|
|
249
243
|
const instance = new TekGrid({
|
|
250
244
|
name: 'grid',
|
|
@@ -253,7 +247,7 @@ describe('TekGrid', () => {
|
|
|
253
247
|
type: 'tek-rest',
|
|
254
248
|
uniqueKey: 'id',
|
|
255
249
|
route: '/zeedhi',
|
|
256
|
-
lazyLoad:
|
|
250
|
+
lazyLoad: true,
|
|
257
251
|
data: [
|
|
258
252
|
{ id: '1', department_id: '1' },
|
|
259
253
|
],
|
|
@@ -279,7 +273,6 @@ describe('TekGrid', () => {
|
|
|
279
273
|
|
|
280
274
|
(window as any).open.mockClear();
|
|
281
275
|
spy.mockReset();
|
|
282
|
-
httpSpy.mockReset();
|
|
283
276
|
});
|
|
284
277
|
|
|
285
278
|
it('when called with a dynamicFilter, should format the filter values', async () => {
|
|
@@ -2341,8 +2334,8 @@ describe('TekGrid', () => {
|
|
|
2341
2334
|
'grid_filterClick13-filter-AND-CONTAINS-salary-0': '1000',
|
|
2342
2335
|
};
|
|
2343
2336
|
const applyButtonObject = new Button(applyButton);
|
|
2344
|
-
setClick(applyButtonObject
|
|
2345
|
-
expect(
|
|
2337
|
+
setClick(applyButtonObject);
|
|
2338
|
+
expect(instance.datasource.filter).toEqual({
|
|
2346
2339
|
id: '1;2;3',
|
|
2347
2340
|
name: 'teste',
|
|
2348
2341
|
salary: '1000',
|
|
@@ -2350,7 +2343,9 @@ describe('TekGrid', () => {
|
|
|
2350
2343
|
expect(beforeApplyFilterCalled).toBeTruthy();
|
|
2351
2344
|
expect(changeLayoutCalled).toBeTruthy();
|
|
2352
2345
|
expect(instance.columnHasFilterData({ name: 'name' } as TekGridColumn)).toBeTruthy();
|
|
2353
|
-
|
|
2346
|
+
|
|
2347
|
+
setClick(applyButtonObject, { defaultPrevented: true });
|
|
2348
|
+
expect(spyDatasourceGet).toBeCalledTimes(1);
|
|
2354
2349
|
spyMetadata.mockReset();
|
|
2355
2350
|
spyDatasourceGet.mockReset();
|
|
2356
2351
|
spyModalService.mockReset();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Button, Form, IButton, IForm, IModal, Modal, ModalService, Text, TextInput,
|
|
2
|
+
Button, Form, IButton, IForm, IModal, Modal, ModalService, Report, Text, TextInput,
|
|
3
3
|
} from '@zeedhi/common';
|
|
4
4
|
import { Http, IDictionary, Metadata } from '@zeedhi/core';
|
|
5
5
|
import {
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
} from '../../../../src';
|
|
8
8
|
import { getChild, setClick } from '../../../__helpers__';
|
|
9
9
|
|
|
10
|
+
const flushPromises = () => new Promise(setImmediate);
|
|
11
|
+
|
|
10
12
|
const clickOnFilterButton = (grid: TekTreeGrid, event?: any) => {
|
|
11
13
|
const buttonProps = getChild<IButton>(grid.toolbarSlot, `${grid.name}_filterButton`);
|
|
12
14
|
const button = new Button(buttonProps);
|
|
@@ -336,8 +338,10 @@ describe('TekTreeGrid', () => {
|
|
|
336
338
|
|
|
337
339
|
describe('getReport()', () => {
|
|
338
340
|
let httpReportSpy: jest.SpyInstance;
|
|
341
|
+
let reportSpy: jest.SpyInstance;
|
|
339
342
|
|
|
340
343
|
beforeEach(() => {
|
|
344
|
+
reportSpy = jest.spyOn(Report.prototype, 'getReport').mockReturnValue(Promise.resolve(''));
|
|
341
345
|
httpReportSpy = jest.spyOn(Http, 'post').mockImplementation((url) => {
|
|
342
346
|
if (url === 'https://zhreport.teknisa.com/generateReport') {
|
|
343
347
|
return Promise.resolve({
|
|
@@ -350,6 +354,7 @@ describe('TekTreeGrid', () => {
|
|
|
350
354
|
});
|
|
351
355
|
|
|
352
356
|
afterEach(() => {
|
|
357
|
+
reportSpy.mockClear();
|
|
353
358
|
httpReportSpy.mockClear();
|
|
354
359
|
});
|
|
355
360
|
|
|
@@ -359,9 +364,11 @@ describe('TekTreeGrid', () => {
|
|
|
359
364
|
const instance = new TekTreeGrid({
|
|
360
365
|
name: 'grid_getReport',
|
|
361
366
|
component: 'TekTreeGrid',
|
|
367
|
+
events: {
|
|
368
|
+
beforeOpenReport: jest.fn(),
|
|
369
|
+
},
|
|
362
370
|
});
|
|
363
371
|
|
|
364
|
-
const spy = jest.spyOn(instance, 'getReport');
|
|
365
372
|
instance.onCreated();
|
|
366
373
|
|
|
367
374
|
const buttonProps = (instance as any).gridBase.exportConfigButtons[0] as IButton;
|
|
@@ -370,24 +377,13 @@ describe('TekTreeGrid', () => {
|
|
|
370
377
|
const event = new Event('click');
|
|
371
378
|
button.click(event, {} as HTMLElement);
|
|
372
379
|
|
|
373
|
-
expect(
|
|
374
|
-
spy.mockClear();
|
|
380
|
+
expect(reportSpy).toBeCalledTimes(1);
|
|
375
381
|
|
|
376
382
|
(window as any).open.mockClear();
|
|
377
383
|
});
|
|
378
384
|
|
|
379
385
|
it('should call window open on getReport method', async () => {
|
|
380
386
|
(window as any).open = jest.fn();
|
|
381
|
-
const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
|
|
382
|
-
data: {
|
|
383
|
-
data: [],
|
|
384
|
-
pagination: {
|
|
385
|
-
page: 1,
|
|
386
|
-
total: 0,
|
|
387
|
-
limit: 10,
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
}));
|
|
391
387
|
|
|
392
388
|
const instance = new TekTreeGrid({
|
|
393
389
|
name: 'grid',
|
|
@@ -420,7 +416,6 @@ describe('TekTreeGrid', () => {
|
|
|
420
416
|
|
|
421
417
|
(window as any).open.mockClear();
|
|
422
418
|
spy.mockClear();
|
|
423
|
-
httpSpy.mockClear();
|
|
424
419
|
});
|
|
425
420
|
});
|
|
426
421
|
|
|
@@ -462,7 +457,6 @@ describe('TekTreeGrid', () => {
|
|
|
462
457
|
});
|
|
463
458
|
|
|
464
459
|
it('should not call events.rowClick if cellClick prevents it', async () => {
|
|
465
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
466
460
|
const rowClick = jest.fn();
|
|
467
461
|
|
|
468
462
|
const data = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBeforeReportEvent, IComponent, IComponentEvents, IComponentRender, IGridColumnEditable, IGridEditable, IIterableColumnsButton } from '@zeedhi/common';
|
|
1
|
+
import { IBeforeReportEvent, IComponent, IComponentEvents, IComponentRender, IGridColumnEditable, IGridEditable, IIterableColumnsButton, EventDef } from '@zeedhi/common';
|
|
2
2
|
import { IDictionary, IEvent, IEventParam, IDateHelperValue, IDateHelperValues } from '@zeedhi/core';
|
|
3
3
|
import { IDynamicFilterItem, TekGridLayoutOptions } from '..';
|
|
4
4
|
export interface ITekGridLayoutEventParams extends IEventParam<ITekGrid> {
|
|
@@ -6,21 +6,21 @@ export interface ITekGridLayoutEventParams extends IEventParam<ITekGrid> {
|
|
|
6
6
|
}
|
|
7
7
|
export declare type ITekGridEvent<T> = (event: T) => Promise<any>;
|
|
8
8
|
export interface ITekGridEvents<T = IEventParam<any> | ITekGridLayoutEventParams> extends IComponentEvents<T> {
|
|
9
|
-
addClick?:
|
|
10
|
-
afterCancel?:
|
|
11
|
-
afterDelete?:
|
|
12
|
-
afterSave?:
|
|
13
|
-
beforeApplyFilter?:
|
|
14
|
-
beforeCancel?:
|
|
15
|
-
beforeDelete?:
|
|
16
|
-
beforeSave?:
|
|
17
|
-
filterClick?:
|
|
18
|
-
loadLayouts?: ITekGridEvent<T
|
|
19
|
-
saveLayouts?:
|
|
20
|
-
groupRowClick?:
|
|
21
|
-
groupSelect?:
|
|
22
|
-
groupUnselect?:
|
|
23
|
-
beforeOpenReport?: IBeforeReportEvent
|
|
9
|
+
addClick?: EventDef<T>;
|
|
10
|
+
afterCancel?: EventDef<T>;
|
|
11
|
+
afterDelete?: EventDef<T>;
|
|
12
|
+
afterSave?: EventDef<T>;
|
|
13
|
+
beforeApplyFilter?: EventDef<T>;
|
|
14
|
+
beforeCancel?: EventDef<T>;
|
|
15
|
+
beforeDelete?: EventDef<T>;
|
|
16
|
+
beforeSave?: EventDef<T>;
|
|
17
|
+
filterClick?: EventDef<T>;
|
|
18
|
+
loadLayouts?: EventDef<T, ITekGridEvent<T>>;
|
|
19
|
+
saveLayouts?: EventDef<T>;
|
|
20
|
+
groupRowClick?: EventDef<T>;
|
|
21
|
+
groupSelect?: EventDef<T>;
|
|
22
|
+
groupUnselect?: EventDef<T>;
|
|
23
|
+
beforeOpenReport?: EventDef<T, IBeforeReportEvent>;
|
|
24
24
|
[key: string]: any;
|
|
25
25
|
}
|
|
26
26
|
export declare type ITekGridLayoutOptionsEvent<T> = (event: T) => Promise<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IIterable, IComponentEvents } from '@zeedhi/common';
|
|
2
|
-
import { IEventParam
|
|
1
|
+
import { IIterable, IComponentEvents, EventDef } from '@zeedhi/common';
|
|
2
|
+
import { IEventParam } from '@zeedhi/core';
|
|
3
3
|
import { Notifications } from './notifications';
|
|
4
4
|
export interface INotification {
|
|
5
5
|
id: string;
|
|
@@ -12,9 +12,9 @@ export interface INotificationsEvent extends IEventParam<Notifications> {
|
|
|
12
12
|
notification: INotification;
|
|
13
13
|
}
|
|
14
14
|
export interface INotificationsEvents<T = INotificationsEvent | IEventParam<any>> extends IComponentEvents<T> {
|
|
15
|
-
showAllClick?:
|
|
16
|
-
notificationClick?:
|
|
17
|
-
markAllAsReadClick?:
|
|
15
|
+
showAllClick?: EventDef<T>;
|
|
16
|
+
notificationClick?: EventDef<T>;
|
|
17
|
+
markAllAsReadClick?: EventDef<T>;
|
|
18
18
|
}
|
|
19
19
|
export interface INotifications extends IIterable {
|
|
20
20
|
allNotificationsPath?: string;
|