@zeedhi/teknisa-components-common 1.84.0 → 1.84.1
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 +418 -399
- package/coverage/coverage-final.json +40 -39
- package/coverage/lcov-report/index.html +14 -14
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +94 -0
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.html +19 -4
- 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 +774 -740
- package/dist/tek-components-common.esm.js +48 -19
- package/dist/tek-components-common.umd.js +48 -19
- package/package.json +2 -2
- package/tests/__helpers__/flush-promises-helper.ts +3 -0
- package/tests/unit/components/tek-grid/grid.spec.ts +18 -31
- package/types/components/crud/crud-form.d.ts +4 -0
- package/types/components/tek-ag-grid/default-icons.d.ts +53 -0
- package/types/components/tek-ag-grid/interfaces.d.ts +9 -0
- package/types/components/tek-ag-grid/tek-ag-grid.d.ts +35 -0
- package/types/components/tek-datasource/datasource.d.ts +94 -0
- package/types/components/tek-grid/default-icons.d.ts +53 -0
- package/types/components/tek-grid/filter-dynamic-values.d.ts +9 -0
- package/types/components/tek-grid/grid-controller.d.ts +19 -0
- package/types/components/tek-grid/grid.d.ts +11 -0
- package/types/components/tek-grid/grid_column.d.ts +14 -0
- package/types/components/tek-grid/grid_controller.d.ts +15 -0
- package/types/components/tek-grid/layout-options.d.ts +1 -0
- package/types/components/tek-grid/tek-grid.d.ts +35 -0
- package/types/components/tek-login/interfaces.d.ts +3 -0
- package/types/components/tek-login/login-children.d.ts +3 -0
- package/types/components/tek-login/login.d.ts +58 -0
- package/types/components/tek-login/login_children.d.ts +3 -0
|
@@ -19,11 +19,12 @@ class CrudForm extends Form {
|
|
|
19
19
|
*/
|
|
20
20
|
this.editing = false;
|
|
21
21
|
if (Object.keys(this.value).length > 0) {
|
|
22
|
-
this.
|
|
22
|
+
this.setValue(this.value);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
setValue(value, autoSave = true) {
|
|
26
26
|
this.value = value;
|
|
27
|
+
this.unSavedValue = value;
|
|
27
28
|
if (autoSave)
|
|
28
29
|
this.saveEdit();
|
|
29
30
|
}
|
|
@@ -41,7 +42,7 @@ class CrudForm extends Form {
|
|
|
41
42
|
*/
|
|
42
43
|
saveEdit() {
|
|
43
44
|
this.editing = false;
|
|
44
|
-
this.beforeEditValue = Object.assign({}, this.
|
|
45
|
+
this.beforeEditValue = Object.assign({}, this.unSavedValue);
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* Update value using child input value
|
|
@@ -66,6 +67,7 @@ class CrudForm extends Form {
|
|
|
66
67
|
return ['', null, undefined].includes(value) ? null : value;
|
|
67
68
|
}
|
|
68
69
|
onMounted(element) {
|
|
70
|
+
this.cancelEdit();
|
|
69
71
|
super.onMounted(element);
|
|
70
72
|
element.addEventListener('focus', this.focus.bind(this), true);
|
|
71
73
|
}
|
|
@@ -2413,11 +2415,17 @@ class TekGrid extends GridEditable {
|
|
|
2413
2415
|
this.groupColumns = [];
|
|
2414
2416
|
this.groupedData = [];
|
|
2415
2417
|
this.toolbarSlotProps = false;
|
|
2418
|
+
this.defaultLazy = false;
|
|
2416
2419
|
this.groups = [];
|
|
2417
2420
|
this.summary = {};
|
|
2421
|
+
/**
|
|
2422
|
+
* Tasks that should be finished before loading the grid data
|
|
2423
|
+
*/
|
|
2424
|
+
this.tasksBeforeLoad = [];
|
|
2425
|
+
this.request = debounce(() => { this.datasource.get(); }, 500);
|
|
2418
2426
|
this.updateGrouping = debounce((lazyLoad = false) => {
|
|
2419
2427
|
this.updateGroupedData(lazyLoad);
|
|
2420
|
-
},
|
|
2428
|
+
}, 100);
|
|
2421
2429
|
this.title = this.getInitValue('title', props.title, this.title);
|
|
2422
2430
|
this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
|
|
2423
2431
|
this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
|
|
@@ -2476,7 +2484,7 @@ class TekGrid extends GridEditable {
|
|
|
2476
2484
|
this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
|
|
2477
2485
|
this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
|
|
2478
2486
|
this.createAccessors();
|
|
2479
|
-
this.
|
|
2487
|
+
this.defaultLazy = (_a = props.datasource) === null || _a === void 0 ? void 0 : _a.lazyLoad;
|
|
2480
2488
|
}
|
|
2481
2489
|
onCreated() {
|
|
2482
2490
|
super.onCreated();
|
|
@@ -2497,6 +2505,7 @@ class TekGrid extends GridEditable {
|
|
|
2497
2505
|
onMounted(element) {
|
|
2498
2506
|
super.onMounted(element);
|
|
2499
2507
|
KeyMap.bind(this.keyShortcutKeyMapping, this, element);
|
|
2508
|
+
this.initGrouping(this.defaultLazy);
|
|
2500
2509
|
}
|
|
2501
2510
|
onBeforeDestroy() {
|
|
2502
2511
|
super.onBeforeDestroy();
|
|
@@ -2604,6 +2613,19 @@ class TekGrid extends GridEditable {
|
|
|
2604
2613
|
.then((reportUrl) => window.open(reportUrl));
|
|
2605
2614
|
});
|
|
2606
2615
|
}
|
|
2616
|
+
registerTask(task) {
|
|
2617
|
+
this.tasksBeforeLoad.push(task);
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* Loads grid data after resolving all tasks
|
|
2621
|
+
*/
|
|
2622
|
+
loadAfterTasks() {
|
|
2623
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2624
|
+
yield Promise.all(this.tasksBeforeLoad);
|
|
2625
|
+
this.tasksBeforeLoad = [];
|
|
2626
|
+
this.request();
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2607
2629
|
initGrouping(lazyLoad) {
|
|
2608
2630
|
this.initGroups();
|
|
2609
2631
|
this.initSummaryColumns();
|
|
@@ -2643,7 +2665,7 @@ class TekGrid extends GridEditable {
|
|
|
2643
2665
|
this.datasource.limit = this.originalDatasourceLimit;
|
|
2644
2666
|
}
|
|
2645
2667
|
if (!lazyLoad && this.datasource) {
|
|
2646
|
-
yield this.
|
|
2668
|
+
yield this.loadAfterTasks();
|
|
2647
2669
|
}
|
|
2648
2670
|
if (this.virtualScroll && this.viewUpdateScrollData) {
|
|
2649
2671
|
this.viewUpdateScrollData();
|
|
@@ -3099,21 +3121,11 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
3099
3121
|
filterHelperValue: this.getHelperValue(column),
|
|
3100
3122
|
}));
|
|
3101
3123
|
let layoutsInfo = {};
|
|
3102
|
-
const
|
|
3103
|
-
if (
|
|
3104
|
-
|
|
3105
|
-
}
|
|
3106
|
-
else if (Config.loadGridLayoutsEndPoint) {
|
|
3107
|
-
const route = Config.loadGridLayoutsEndPoint;
|
|
3108
|
-
const response = yield Http.get(`${route}?id=${this.grid.name}`);
|
|
3109
|
-
const responseData = response.data.data;
|
|
3110
|
-
layoutsInfo = responseData.length && responseData[0]
|
|
3111
|
-
? responseData[0].layouts
|
|
3112
|
-
: responseData.layouts || {};
|
|
3113
|
-
}
|
|
3114
|
-
else {
|
|
3115
|
-
layoutsInfo = JSON.parse(localStorage.getItem(this.grid.name) || '{}');
|
|
3124
|
+
const promise = this.loadLayoutsInfo();
|
|
3125
|
+
if (this.grid instanceof TekGrid) {
|
|
3126
|
+
this.grid.registerTask(promise);
|
|
3116
3127
|
}
|
|
3128
|
+
layoutsInfo = yield promise;
|
|
3117
3129
|
if (layoutsInfo.layouts) {
|
|
3118
3130
|
this.layouts = layoutsInfo.layouts;
|
|
3119
3131
|
this.layoutNames = Object.keys(this.layouts);
|
|
@@ -3124,6 +3136,23 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
3124
3136
|
}
|
|
3125
3137
|
});
|
|
3126
3138
|
}
|
|
3139
|
+
loadLayoutsInfo() {
|
|
3140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3141
|
+
const eventFunction = this.events.loadLayouts || this.grid.events.loadLayouts;
|
|
3142
|
+
if (eventFunction && typeof eventFunction === 'function') {
|
|
3143
|
+
return eventFunction({ component: this.grid });
|
|
3144
|
+
}
|
|
3145
|
+
if (Config.loadGridLayoutsEndPoint) {
|
|
3146
|
+
const route = Config.loadGridLayoutsEndPoint;
|
|
3147
|
+
const response = yield Http.get(`${route}?id=${this.grid.name}`);
|
|
3148
|
+
const responseData = response.data.data;
|
|
3149
|
+
return responseData.length && responseData[0]
|
|
3150
|
+
? responseData[0].layouts
|
|
3151
|
+
: responseData.layouts || {};
|
|
3152
|
+
}
|
|
3153
|
+
return JSON.parse(localStorage.getItem(this.grid.name) || '{}');
|
|
3154
|
+
});
|
|
3155
|
+
}
|
|
3127
3156
|
getHelperValue(column) {
|
|
3128
3157
|
if (column instanceof TekGridColumn) {
|
|
3129
3158
|
if (!Array.isArray(column.filterProps))
|
|
@@ -24,11 +24,12 @@
|
|
|
24
24
|
*/
|
|
25
25
|
this.editing = false;
|
|
26
26
|
if (Object.keys(this.value).length > 0) {
|
|
27
|
-
this.
|
|
27
|
+
this.setValue(this.value);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
setValue(value, autoSave = true) {
|
|
31
31
|
this.value = value;
|
|
32
|
+
this.unSavedValue = value;
|
|
32
33
|
if (autoSave)
|
|
33
34
|
this.saveEdit();
|
|
34
35
|
}
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
*/
|
|
47
48
|
saveEdit() {
|
|
48
49
|
this.editing = false;
|
|
49
|
-
this.beforeEditValue = Object.assign({}, this.
|
|
50
|
+
this.beforeEditValue = Object.assign({}, this.unSavedValue);
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* Update value using child input value
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
return ['', null, undefined].includes(value) ? null : value;
|
|
72
73
|
}
|
|
73
74
|
onMounted(element) {
|
|
75
|
+
this.cancelEdit();
|
|
74
76
|
super.onMounted(element);
|
|
75
77
|
element.addEventListener('focus', this.focus.bind(this), true);
|
|
76
78
|
}
|
|
@@ -2418,11 +2420,17 @@
|
|
|
2418
2420
|
this.groupColumns = [];
|
|
2419
2421
|
this.groupedData = [];
|
|
2420
2422
|
this.toolbarSlotProps = false;
|
|
2423
|
+
this.defaultLazy = false;
|
|
2421
2424
|
this.groups = [];
|
|
2422
2425
|
this.summary = {};
|
|
2426
|
+
/**
|
|
2427
|
+
* Tasks that should be finished before loading the grid data
|
|
2428
|
+
*/
|
|
2429
|
+
this.tasksBeforeLoad = [];
|
|
2430
|
+
this.request = debounce__default["default"](() => { this.datasource.get(); }, 500);
|
|
2423
2431
|
this.updateGrouping = debounce__default["default"]((lazyLoad = false) => {
|
|
2424
2432
|
this.updateGroupedData(lazyLoad);
|
|
2425
|
-
},
|
|
2433
|
+
}, 100);
|
|
2426
2434
|
this.title = this.getInitValue('title', props.title, this.title);
|
|
2427
2435
|
this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
|
|
2428
2436
|
this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
|
|
@@ -2481,7 +2489,7 @@
|
|
|
2481
2489
|
this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
|
|
2482
2490
|
this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
|
|
2483
2491
|
this.createAccessors();
|
|
2484
|
-
this.
|
|
2492
|
+
this.defaultLazy = (_a = props.datasource) === null || _a === void 0 ? void 0 : _a.lazyLoad;
|
|
2485
2493
|
}
|
|
2486
2494
|
onCreated() {
|
|
2487
2495
|
super.onCreated();
|
|
@@ -2502,6 +2510,7 @@
|
|
|
2502
2510
|
onMounted(element) {
|
|
2503
2511
|
super.onMounted(element);
|
|
2504
2512
|
core.KeyMap.bind(this.keyShortcutKeyMapping, this, element);
|
|
2513
|
+
this.initGrouping(this.defaultLazy);
|
|
2505
2514
|
}
|
|
2506
2515
|
onBeforeDestroy() {
|
|
2507
2516
|
super.onBeforeDestroy();
|
|
@@ -2609,6 +2618,19 @@
|
|
|
2609
2618
|
.then((reportUrl) => window.open(reportUrl));
|
|
2610
2619
|
});
|
|
2611
2620
|
}
|
|
2621
|
+
registerTask(task) {
|
|
2622
|
+
this.tasksBeforeLoad.push(task);
|
|
2623
|
+
}
|
|
2624
|
+
/**
|
|
2625
|
+
* Loads grid data after resolving all tasks
|
|
2626
|
+
*/
|
|
2627
|
+
loadAfterTasks() {
|
|
2628
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2629
|
+
yield Promise.all(this.tasksBeforeLoad);
|
|
2630
|
+
this.tasksBeforeLoad = [];
|
|
2631
|
+
this.request();
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2612
2634
|
initGrouping(lazyLoad) {
|
|
2613
2635
|
this.initGroups();
|
|
2614
2636
|
this.initSummaryColumns();
|
|
@@ -2648,7 +2670,7 @@
|
|
|
2648
2670
|
this.datasource.limit = this.originalDatasourceLimit;
|
|
2649
2671
|
}
|
|
2650
2672
|
if (!lazyLoad && this.datasource) {
|
|
2651
|
-
yield this.
|
|
2673
|
+
yield this.loadAfterTasks();
|
|
2652
2674
|
}
|
|
2653
2675
|
if (this.virtualScroll && this.viewUpdateScrollData) {
|
|
2654
2676
|
this.viewUpdateScrollData();
|
|
@@ -3104,21 +3126,11 @@
|
|
|
3104
3126
|
filterHelperValue: this.getHelperValue(column),
|
|
3105
3127
|
}));
|
|
3106
3128
|
let layoutsInfo = {};
|
|
3107
|
-
const
|
|
3108
|
-
if (
|
|
3109
|
-
|
|
3110
|
-
}
|
|
3111
|
-
else if (core.Config.loadGridLayoutsEndPoint) {
|
|
3112
|
-
const route = core.Config.loadGridLayoutsEndPoint;
|
|
3113
|
-
const response = yield core.Http.get(`${route}?id=${this.grid.name}`);
|
|
3114
|
-
const responseData = response.data.data;
|
|
3115
|
-
layoutsInfo = responseData.length && responseData[0]
|
|
3116
|
-
? responseData[0].layouts
|
|
3117
|
-
: responseData.layouts || {};
|
|
3118
|
-
}
|
|
3119
|
-
else {
|
|
3120
|
-
layoutsInfo = JSON.parse(localStorage.getItem(this.grid.name) || '{}');
|
|
3129
|
+
const promise = this.loadLayoutsInfo();
|
|
3130
|
+
if (this.grid instanceof TekGrid) {
|
|
3131
|
+
this.grid.registerTask(promise);
|
|
3121
3132
|
}
|
|
3133
|
+
layoutsInfo = yield promise;
|
|
3122
3134
|
if (layoutsInfo.layouts) {
|
|
3123
3135
|
this.layouts = layoutsInfo.layouts;
|
|
3124
3136
|
this.layoutNames = Object.keys(this.layouts);
|
|
@@ -3129,6 +3141,23 @@
|
|
|
3129
3141
|
}
|
|
3130
3142
|
});
|
|
3131
3143
|
}
|
|
3144
|
+
loadLayoutsInfo() {
|
|
3145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3146
|
+
const eventFunction = this.events.loadLayouts || this.grid.events.loadLayouts;
|
|
3147
|
+
if (eventFunction && typeof eventFunction === 'function') {
|
|
3148
|
+
return eventFunction({ component: this.grid });
|
|
3149
|
+
}
|
|
3150
|
+
if (core.Config.loadGridLayoutsEndPoint) {
|
|
3151
|
+
const route = core.Config.loadGridLayoutsEndPoint;
|
|
3152
|
+
const response = yield core.Http.get(`${route}?id=${this.grid.name}`);
|
|
3153
|
+
const responseData = response.data.data;
|
|
3154
|
+
return responseData.length && responseData[0]
|
|
3155
|
+
? responseData[0].layouts
|
|
3156
|
+
: responseData.layouts || {};
|
|
3157
|
+
}
|
|
3158
|
+
return JSON.parse(localStorage.getItem(this.grid.name) || '{}');
|
|
3159
|
+
});
|
|
3160
|
+
}
|
|
3132
3161
|
getHelperValue(column) {
|
|
3133
3162
|
if (column instanceof TekGridColumn) {
|
|
3134
3163
|
if (!Array.isArray(column.filterProps))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "1.84.
|
|
3
|
+
"version": "1.84.1",
|
|
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": "8bcccfd90c4cf7a1cb127a141ddaadb875efc03b"
|
|
35
35
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '../../../../src';
|
|
14
14
|
import { ReportFilter } from '../../../../src/utils';
|
|
15
15
|
import { setClick, getChild } from '../../../__helpers__';
|
|
16
|
+
import { flushPromises } from '../../../__helpers__/flush-promises-helper';
|
|
16
17
|
|
|
17
18
|
jest.mock('lodash.debounce', () => jest.fn((fn) => fn));
|
|
18
19
|
|
|
@@ -26,6 +27,12 @@ const clickOnFilterButton = (grid: TekGrid, event?: any) => {
|
|
|
26
27
|
return button;
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
const createAndMount = (props: ITekGrid) => {
|
|
31
|
+
const instance = new TekGrid(props);
|
|
32
|
+
instance.onMounted({} as HTMLElement);
|
|
33
|
+
return instance;
|
|
34
|
+
};
|
|
35
|
+
|
|
29
36
|
describe('TekGrid', () => {
|
|
30
37
|
beforeEach(() => {
|
|
31
38
|
// clear all metadata instances before testing
|
|
@@ -733,7 +740,6 @@ describe('TekGrid', () => {
|
|
|
733
740
|
},
|
|
734
741
|
},
|
|
735
742
|
}));
|
|
736
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
737
743
|
const instance = new TekGrid({
|
|
738
744
|
name: 'grid_navigation_1',
|
|
739
745
|
component: 'TekGrid',
|
|
@@ -799,7 +805,6 @@ describe('TekGrid', () => {
|
|
|
799
805
|
},
|
|
800
806
|
},
|
|
801
807
|
}));
|
|
802
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
803
808
|
const instance = new TekGrid({
|
|
804
809
|
name: 'grid_navigation_2',
|
|
805
810
|
component: 'TekGrid',
|
|
@@ -831,13 +836,13 @@ describe('TekGrid', () => {
|
|
|
831
836
|
},
|
|
832
837
|
});
|
|
833
838
|
|
|
834
|
-
await flushPromises();
|
|
835
|
-
|
|
836
839
|
const elem = document.createElement('DIV');
|
|
837
840
|
(KeyMap as any).isElementActive = () => true;
|
|
838
841
|
instance.onCreated();
|
|
839
842
|
instance.onMounted(elem);
|
|
840
843
|
|
|
844
|
+
await flushPromises();
|
|
845
|
+
|
|
841
846
|
dispatchEvent('arrowdown', {}); // arrow down
|
|
842
847
|
expect(instance.datasource.currentRow).toEqual(instance.groupedData[0]);
|
|
843
848
|
|
|
@@ -896,7 +901,6 @@ describe('TekGrid', () => {
|
|
|
896
901
|
});
|
|
897
902
|
|
|
898
903
|
it('should open filter modal input with keymap', async () => {
|
|
899
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
900
904
|
const instance = new TekGrid({
|
|
901
905
|
name: 'grid_navigation_2',
|
|
902
906
|
component: 'TekGrid',
|
|
@@ -931,7 +935,6 @@ describe('TekGrid', () => {
|
|
|
931
935
|
});
|
|
932
936
|
|
|
933
937
|
it('should open action dropdown with keymap', async () => {
|
|
934
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
935
938
|
const instance = new TekGrid({
|
|
936
939
|
name: 'grid_navigation_2',
|
|
937
940
|
component: 'TekGrid',
|
|
@@ -970,7 +973,6 @@ describe('TekGrid', () => {
|
|
|
970
973
|
});
|
|
971
974
|
|
|
972
975
|
it('should focus in searchInput with keymap', async () => {
|
|
973
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
974
976
|
const instance = new TekGrid({
|
|
975
977
|
name: 'grid_navigation_3',
|
|
976
978
|
component: 'TekGrid',
|
|
@@ -1056,8 +1058,7 @@ describe('TekGrid', () => {
|
|
|
1056
1058
|
|
|
1057
1059
|
describe('grouping', () => {
|
|
1058
1060
|
it('should group data based on columns that have grouped property', async () => {
|
|
1059
|
-
const
|
|
1060
|
-
const instance = new TekGrid({
|
|
1061
|
+
const instance = createAndMount({
|
|
1061
1062
|
name: 'grid_grouping_1',
|
|
1062
1063
|
component: 'TekGrid',
|
|
1063
1064
|
columns: [
|
|
@@ -1103,7 +1104,7 @@ describe('TekGrid', () => {
|
|
|
1103
1104
|
|
|
1104
1105
|
it('should call debounced updateGroupData', () => {
|
|
1105
1106
|
const spy = jest.spyOn(TekGrid.prototype, 'updateGroupedData');
|
|
1106
|
-
const instance =
|
|
1107
|
+
const instance = createAndMount({
|
|
1107
1108
|
name: 'grid_grouping_1',
|
|
1108
1109
|
component: 'TekGrid',
|
|
1109
1110
|
columns: [
|
|
@@ -1143,8 +1144,7 @@ describe('TekGrid', () => {
|
|
|
1143
1144
|
});
|
|
1144
1145
|
|
|
1145
1146
|
it('should group data with aggregations', async () => {
|
|
1146
|
-
const
|
|
1147
|
-
const instance = new TekGrid({
|
|
1147
|
+
const instance = createAndMount({
|
|
1148
1148
|
name: 'grid_aggregate_1',
|
|
1149
1149
|
component: 'TekGrid',
|
|
1150
1150
|
columns: [
|
|
@@ -1194,10 +1194,9 @@ describe('TekGrid', () => {
|
|
|
1194
1194
|
});
|
|
1195
1195
|
|
|
1196
1196
|
it('should group data with multiple groups', async () => {
|
|
1197
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
1198
1197
|
let viewUpdateScrollDataCalled = false;
|
|
1199
1198
|
|
|
1200
|
-
const instance =
|
|
1199
|
+
const instance = createAndMount({
|
|
1201
1200
|
name: 'grid_grouping_2',
|
|
1202
1201
|
component: 'TekGrid',
|
|
1203
1202
|
virtualScroll: true,
|
|
@@ -1271,8 +1270,7 @@ describe('TekGrid', () => {
|
|
|
1271
1270
|
});
|
|
1272
1271
|
|
|
1273
1272
|
it('should group data with multiple groups and aggregation', async () => {
|
|
1274
|
-
const
|
|
1275
|
-
const instance = new TekGrid({
|
|
1273
|
+
const instance = createAndMount({
|
|
1276
1274
|
name: 'grid_aggredate_2',
|
|
1277
1275
|
component: 'TekGrid',
|
|
1278
1276
|
showSummaryTotal: false,
|
|
@@ -1355,8 +1353,7 @@ describe('TekGrid', () => {
|
|
|
1355
1353
|
});
|
|
1356
1354
|
|
|
1357
1355
|
it('should aggregate even without groups', async () => {
|
|
1358
|
-
const
|
|
1359
|
-
const instance = new TekGrid({
|
|
1356
|
+
const instance = createAndMount({
|
|
1360
1357
|
name: 'grid_aggredate_3',
|
|
1361
1358
|
component: 'TekGrid',
|
|
1362
1359
|
showSummaryTotal: true,
|
|
@@ -1417,8 +1414,7 @@ describe('TekGrid', () => {
|
|
|
1417
1414
|
});
|
|
1418
1415
|
|
|
1419
1416
|
it('should aggregation with different functions', async () => {
|
|
1420
|
-
const
|
|
1421
|
-
const instance = new TekGrid({
|
|
1417
|
+
const instance = createAndMount({
|
|
1422
1418
|
name: 'grid_aggregate_4',
|
|
1423
1419
|
component: 'TekGrid',
|
|
1424
1420
|
showSummaryTotal: true,
|
|
@@ -1490,7 +1486,6 @@ describe('TekGrid', () => {
|
|
|
1490
1486
|
});
|
|
1491
1487
|
|
|
1492
1488
|
it('should group data on rest datasource with lazyLoad', async () => {
|
|
1493
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
1494
1489
|
const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
|
|
1495
1490
|
data: {
|
|
1496
1491
|
data: [
|
|
@@ -1508,7 +1503,7 @@ describe('TekGrid', () => {
|
|
|
1508
1503
|
},
|
|
1509
1504
|
}));
|
|
1510
1505
|
|
|
1511
|
-
const instance =
|
|
1506
|
+
const instance = createAndMount({
|
|
1512
1507
|
name: 'grid_grouping_3',
|
|
1513
1508
|
component: 'TekGrid',
|
|
1514
1509
|
columns: [
|
|
@@ -1548,7 +1543,6 @@ describe('TekGrid', () => {
|
|
|
1548
1543
|
});
|
|
1549
1544
|
|
|
1550
1545
|
it('editedRows should return cleaned rows', async () => {
|
|
1551
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
1552
1546
|
const instance = new TekGrid({
|
|
1553
1547
|
name: 'grid_grouping_4',
|
|
1554
1548
|
component: 'TekGrid',
|
|
@@ -1591,7 +1585,6 @@ describe('TekGrid', () => {
|
|
|
1591
1585
|
});
|
|
1592
1586
|
|
|
1593
1587
|
it('should do nothing if datasource is empty', async () => {
|
|
1594
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
1595
1588
|
const instance = new TekGrid({
|
|
1596
1589
|
name: 'grid_grouping_5',
|
|
1597
1590
|
component: 'TekGrid',
|
|
@@ -1624,11 +1617,10 @@ describe('TekGrid', () => {
|
|
|
1624
1617
|
});
|
|
1625
1618
|
|
|
1626
1619
|
it('should call view update methods', async () => {
|
|
1627
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
1628
1620
|
let viewUpdateScrollDataCalled = false;
|
|
1629
1621
|
let viewUpdateFixedColumnsCalled = false;
|
|
1630
1622
|
|
|
1631
|
-
const instance =
|
|
1623
|
+
const instance = createAndMount({
|
|
1632
1624
|
name: 'grid_grouping_6',
|
|
1633
1625
|
component: 'TekGrid',
|
|
1634
1626
|
virtualScroll: true,
|
|
@@ -2566,7 +2558,6 @@ describe('TekGrid', () => {
|
|
|
2566
2558
|
});
|
|
2567
2559
|
|
|
2568
2560
|
it('should set datasource search_join based on columns that have datasource', async () => {
|
|
2569
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
2570
2561
|
const instance = new TekGrid(baseProps);
|
|
2571
2562
|
|
|
2572
2563
|
instance.setSearch('1');
|
|
@@ -2693,7 +2684,6 @@ describe('TekGrid', () => {
|
|
|
2693
2684
|
});
|
|
2694
2685
|
|
|
2695
2686
|
it('should not call events.rowClick if cellClick prevents it', async () => {
|
|
2696
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
2697
2687
|
const rowClick = jest.fn();
|
|
2698
2688
|
|
|
2699
2689
|
const data = [
|
|
@@ -2730,7 +2720,6 @@ describe('TekGrid', () => {
|
|
|
2730
2720
|
|
|
2731
2721
|
describe('groupRowClick', () => {
|
|
2732
2722
|
it('groupRowClick method should call events.groupRowClick', async () => {
|
|
2733
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
2734
2723
|
const groupRowClick = jest.fn();
|
|
2735
2724
|
|
|
2736
2725
|
const data = [
|
|
@@ -2770,7 +2759,6 @@ describe('TekGrid', () => {
|
|
|
2770
2759
|
});
|
|
2771
2760
|
|
|
2772
2761
|
it('should not call events.groupRowClick if cellClick prevents it', async () => {
|
|
2773
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
2774
2762
|
const groupRowClick = jest.fn();
|
|
2775
2763
|
|
|
2776
2764
|
const data = [
|
|
@@ -2807,7 +2795,6 @@ describe('TekGrid', () => {
|
|
|
2807
2795
|
|
|
2808
2796
|
describe('selectGroupClick', () => {
|
|
2809
2797
|
it('should trigger events', async () => {
|
|
2810
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
2811
2798
|
const groupSelected = jest.fn();
|
|
2812
2799
|
const groupUnselected = jest.fn();
|
|
2813
2800
|
|
|
@@ -13,6 +13,10 @@ export declare class CrudForm extends Form implements ICrudForm {
|
|
|
13
13
|
* Stores value before editing
|
|
14
14
|
*/
|
|
15
15
|
private beforeEditValue?;
|
|
16
|
+
/**
|
|
17
|
+
* Stores unsaved Value
|
|
18
|
+
*/
|
|
19
|
+
private unSavedValue?;
|
|
16
20
|
/**
|
|
17
21
|
* Create new Crud Form
|
|
18
22
|
* @param props component properties
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
declare const defaultIcons: {
|
|
2
|
+
columnGroupOpened: string;
|
|
3
|
+
columnGroupClosed: string;
|
|
4
|
+
columnSelectClosed: string;
|
|
5
|
+
columnSelectOpen: string;
|
|
6
|
+
columnSelectIndeterminate: string;
|
|
7
|
+
columnMovePin: string;
|
|
8
|
+
columnMoveHide: string;
|
|
9
|
+
columnMoveMove: string;
|
|
10
|
+
columnMoveLeft: string;
|
|
11
|
+
columnMoveRight: string;
|
|
12
|
+
columnMoveGroup: string;
|
|
13
|
+
columnMoveValue: string;
|
|
14
|
+
dropNotAllowed: string;
|
|
15
|
+
groupContracted: string;
|
|
16
|
+
groupExpanded: string;
|
|
17
|
+
chart: string;
|
|
18
|
+
close: string;
|
|
19
|
+
cancel: string;
|
|
20
|
+
check: string;
|
|
21
|
+
first: string;
|
|
22
|
+
previous: string;
|
|
23
|
+
next: string;
|
|
24
|
+
last: string;
|
|
25
|
+
linked: string;
|
|
26
|
+
unlinked: string;
|
|
27
|
+
colorPicker: string;
|
|
28
|
+
groupLoading: string;
|
|
29
|
+
menu: string;
|
|
30
|
+
filter: string;
|
|
31
|
+
columns: string;
|
|
32
|
+
maximize: string;
|
|
33
|
+
minimize: string;
|
|
34
|
+
menuPin: string;
|
|
35
|
+
menuValue: string;
|
|
36
|
+
menuAddRowGroup: string;
|
|
37
|
+
menuRemoveRowGroup: string;
|
|
38
|
+
clipboardCopy: string;
|
|
39
|
+
clipboardPaste: string;
|
|
40
|
+
rowGroupPanel: string;
|
|
41
|
+
valuePanel: string;
|
|
42
|
+
columnDrag: string;
|
|
43
|
+
rowDrag: string;
|
|
44
|
+
save: string;
|
|
45
|
+
smallDown: string;
|
|
46
|
+
smallLeft: string;
|
|
47
|
+
smallRight: string;
|
|
48
|
+
smallUp: string;
|
|
49
|
+
sortAscending: string;
|
|
50
|
+
sortDescending: string;
|
|
51
|
+
sortUnSort: string;
|
|
52
|
+
};
|
|
53
|
+
export default defaultIcons;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IIterable } from '@zeedhi/common';
|
|
2
|
+
import { IDictionary } from '@zeedhi/core';
|
|
3
|
+
export interface ITekAgGrid extends IIterable {
|
|
4
|
+
dense?: boolean;
|
|
5
|
+
frameworkComponents?: IDictionary;
|
|
6
|
+
gridOptions?: IDictionary;
|
|
7
|
+
height?: string | number;
|
|
8
|
+
icons?: IDictionary<string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Iterable } from '@zeedhi/common';
|
|
2
|
+
import { IDictionary } from '@zeedhi/core';
|
|
3
|
+
import { ITekAgGrid } from './interfaces';
|
|
4
|
+
/** Grid Component */
|
|
5
|
+
export declare class TekAgGrid extends Iterable implements ITekAgGrid {
|
|
6
|
+
cssClass: string;
|
|
7
|
+
dense: boolean;
|
|
8
|
+
frameworkComponents: IDictionary;
|
|
9
|
+
gridOptions: IDictionary;
|
|
10
|
+
height: string | number;
|
|
11
|
+
icons: IDictionary<string>;
|
|
12
|
+
gridComponent: any;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new AgGrid.
|
|
15
|
+
* @param props AgGrid properties
|
|
16
|
+
*/
|
|
17
|
+
constructor(props: ITekAgGrid);
|
|
18
|
+
private createOptionsAccessors;
|
|
19
|
+
private setAccessor;
|
|
20
|
+
/**
|
|
21
|
+
* Reload dataset
|
|
22
|
+
*/
|
|
23
|
+
reload(): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Compares two dates
|
|
26
|
+
* @param date1
|
|
27
|
+
* @param date2
|
|
28
|
+
* @param format
|
|
29
|
+
* @returns -1 if date1 after date2
|
|
30
|
+
* @returns 0 if date1 equal date2
|
|
31
|
+
* @returns 1 if date1 before date2
|
|
32
|
+
*/
|
|
33
|
+
dateComparator(date1: string | Date, date2: string | Date, format?: string): 1 | -1 | 0;
|
|
34
|
+
private getDateAsString;
|
|
35
|
+
}
|