@zeedhi/teknisa-components-common 1.131.0 → 1.132.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 +443 -390
- package/coverage/coverage-final.json +49 -48
- package/coverage/lcov-report/index.html +13 -13
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +1 -1
- 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 +696 -580
- package/dist/tek-components-common.esm.js +116 -33
- package/dist/tek-components-common.umd.js +116 -33
- package/package.json +2 -2
- package/tests/unit/components/tek-grid/grid.spec.ts +40 -0
- package/tests/unit/components/tek-grid/layout_options.spec.ts +516 -27
- package/tests/unit/utils/object-comparison.spec.ts +89 -0
- package/types/components/tek-grid/layout-options.d.ts +9 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/object-comparison.d.ts +3 -0
- package/.package.json +0 -39
- package/types/components/tek-ag-grid/default-icons.d.ts +0 -53
- package/types/components/tek-ag-grid/interfaces.d.ts +0 -9
- package/types/components/tek-ag-grid/tek-ag-grid.d.ts +0 -35
- package/types/components/tek-datasource/datasource.d.ts +0 -94
- package/types/components/tek-grid/default-icons.d.ts +0 -53
- package/types/components/tek-grid/filter-dynamic-values.d.ts +0 -9
- package/types/components/tek-grid/grid-controller.d.ts +0 -19
- package/types/components/tek-grid/grid_column.d.ts +0 -14
- package/types/components/tek-grid/grid_controller.d.ts +0 -15
- package/types/components/tek-grid/tek-grid.d.ts +0 -35
- package/types/components/tek-login/interfaces.d.ts +0 -3
- package/types/components/tek-login/login-children.d.ts +0 -3
- package/types/components/tek-login/login.d.ts +0 -58
- package/types/components/tek-login/login_children.d.ts +0 -3
|
@@ -1596,6 +1596,40 @@ const extractProperties = (obj, props) => {
|
|
|
1596
1596
|
return result;
|
|
1597
1597
|
};
|
|
1598
1598
|
|
|
1599
|
+
const EMPTY_VALUE = null;
|
|
1600
|
+
function cloneComparableValue(value) {
|
|
1601
|
+
return JSON.parse(JSON.stringify(value));
|
|
1602
|
+
}
|
|
1603
|
+
function normalizeComparableValue(value) {
|
|
1604
|
+
if (value === undefined || value === null || value === '') {
|
|
1605
|
+
return EMPTY_VALUE;
|
|
1606
|
+
}
|
|
1607
|
+
if (Array.isArray(value)) {
|
|
1608
|
+
if (!value.length)
|
|
1609
|
+
return EMPTY_VALUE;
|
|
1610
|
+
return value.map((item) => normalizeComparableValue(item));
|
|
1611
|
+
}
|
|
1612
|
+
if (value && typeof value === 'object') {
|
|
1613
|
+
const normalizedValue = Object.keys(value)
|
|
1614
|
+
.sort()
|
|
1615
|
+
.reduce((result, key) => {
|
|
1616
|
+
const normalizedItem = normalizeComparableValue(value[key]);
|
|
1617
|
+
if (normalizedItem !== EMPTY_VALUE) {
|
|
1618
|
+
result[key] = normalizedItem;
|
|
1619
|
+
}
|
|
1620
|
+
return result;
|
|
1621
|
+
}, {});
|
|
1622
|
+
if (!Object.keys(normalizedValue).length)
|
|
1623
|
+
return EMPTY_VALUE;
|
|
1624
|
+
return normalizedValue;
|
|
1625
|
+
}
|
|
1626
|
+
return value;
|
|
1627
|
+
}
|
|
1628
|
+
function areObjectsEqual(first, second) {
|
|
1629
|
+
return JSON.stringify(normalizeComparableValue(first))
|
|
1630
|
+
=== JSON.stringify(normalizeComparableValue(second));
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1599
1633
|
const DynamicFilterOperations = {
|
|
1600
1634
|
CONTAINS: true,
|
|
1601
1635
|
NOT_CONTAINS: true,
|
|
@@ -2417,7 +2451,7 @@ class TekGrid extends GridEditable {
|
|
|
2417
2451
|
*/
|
|
2418
2452
|
this.tasksBeforeLoad = [];
|
|
2419
2453
|
this.request = debounce(() => { this.datasource.get(); }, 500);
|
|
2420
|
-
this.updateGrouping = debounce((lazyLoad =
|
|
2454
|
+
this.updateGrouping = debounce((lazyLoad = this.defaultLazy) => {
|
|
2421
2455
|
this.updateGroupedData(lazyLoad);
|
|
2422
2456
|
}, 100);
|
|
2423
2457
|
this.title = this.getInitValue('title', props.title, this.title);
|
|
@@ -3906,7 +3940,7 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
3906
3940
|
return this.grid;
|
|
3907
3941
|
}
|
|
3908
3942
|
onGridChangeLayout() {
|
|
3909
|
-
this.layoutEdited =
|
|
3943
|
+
this.layoutEdited = this.hasLayoutChanges();
|
|
3910
3944
|
}
|
|
3911
3945
|
registerChangeLayoutEvent() {
|
|
3912
3946
|
if (!this.grid || this.changeLayoutEventGrid === this.grid)
|
|
@@ -3925,20 +3959,8 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
3925
3959
|
this.originalDatasourceOrder = [...this.grid.datasource.order];
|
|
3926
3960
|
this.originalDatasourceDynamicFilter = Object.assign({}, this.grid.datasource.dynamicFilter);
|
|
3927
3961
|
this.originalDatasourceFilter = Object.assign({}, this.grid.datasource.filter);
|
|
3928
|
-
this.originalColumnProps = this.grid.columns.map((column) => (
|
|
3929
|
-
|
|
3930
|
-
label: column.label,
|
|
3931
|
-
align: column.align,
|
|
3932
|
-
isVisible: column.isVisible,
|
|
3933
|
-
minWidth: column.minWidth,
|
|
3934
|
-
maxWidth: column.maxWidth,
|
|
3935
|
-
width: column.width,
|
|
3936
|
-
fixed: column.fixed,
|
|
3937
|
-
grouped: column.grouped,
|
|
3938
|
-
groupOpened: column.groupOpened,
|
|
3939
|
-
aggregation: column.aggregation,
|
|
3940
|
-
filterHelperValue: this.getHelperValue(column),
|
|
3941
|
-
}));
|
|
3962
|
+
this.originalColumnProps = this.grid.columns.map((column) => this.getLayoutColumnSnapshot(column));
|
|
3963
|
+
this.originalLayoutSnapshot = cloneComparableValue(this.getCurrentLayoutSnapshot(''));
|
|
3942
3964
|
let layoutsInfo = {};
|
|
3943
3965
|
const promise = this.loadLayoutsInfo();
|
|
3944
3966
|
if (this.grid instanceof TekGrid) {
|
|
@@ -3983,6 +4005,74 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
3983
4005
|
}
|
|
3984
4006
|
return '';
|
|
3985
4007
|
}
|
|
4008
|
+
getLayoutColumnSnapshot(column, isVisible = column.isVisible) {
|
|
4009
|
+
const filterHelperValue = this.getHelperValue(column);
|
|
4010
|
+
return {
|
|
4011
|
+
name: column.name,
|
|
4012
|
+
label: column.label,
|
|
4013
|
+
align: column.align,
|
|
4014
|
+
isVisible,
|
|
4015
|
+
minWidth: column.minWidth || '',
|
|
4016
|
+
maxWidth: column.maxWidth || '',
|
|
4017
|
+
width: column.width,
|
|
4018
|
+
fixed: !!column.fixed,
|
|
4019
|
+
grouped: !!column.grouped,
|
|
4020
|
+
groupOpened: !!column.groupOpened,
|
|
4021
|
+
aggregation: column.aggregation,
|
|
4022
|
+
filterHelperValue: Array.isArray(filterHelperValue)
|
|
4023
|
+
? filterHelperValue
|
|
4024
|
+
: filterHelperValue || '',
|
|
4025
|
+
};
|
|
4026
|
+
}
|
|
4027
|
+
getCurrentLayoutSnapshot(name) {
|
|
4028
|
+
if (this.viewGetCurrentLayout) {
|
|
4029
|
+
return this.viewGetCurrentLayout(name);
|
|
4030
|
+
}
|
|
4031
|
+
return {
|
|
4032
|
+
name,
|
|
4033
|
+
gridWidth: 'auto',
|
|
4034
|
+
order: [...this.grid.datasource.order],
|
|
4035
|
+
filter: Object.assign({}, this.grid.datasource.filter),
|
|
4036
|
+
dynamicFilter: Object.assign({}, this.grid.datasource.dynamicFilter),
|
|
4037
|
+
columns: this.grid.columns.map((column) => this.getLayoutColumnSnapshot(column)),
|
|
4038
|
+
};
|
|
4039
|
+
}
|
|
4040
|
+
getBaselineLayoutSnapshot() {
|
|
4041
|
+
if (this.currentLayoutName) {
|
|
4042
|
+
const currentLayout = this.layouts[this.currentLayoutName];
|
|
4043
|
+
return currentLayout;
|
|
4044
|
+
}
|
|
4045
|
+
return this.originalLayoutSnapshot;
|
|
4046
|
+
}
|
|
4047
|
+
getOriginalLayoutSnapshot() {
|
|
4048
|
+
return cloneComparableValue({
|
|
4049
|
+
name: '',
|
|
4050
|
+
gridWidth: 'auto',
|
|
4051
|
+
order: [...this.originalDatasourceOrder],
|
|
4052
|
+
filter: Object.assign({}, this.originalDatasourceFilter),
|
|
4053
|
+
dynamicFilter: Object.assign({}, this.originalDatasourceDynamicFilter),
|
|
4054
|
+
columns: this.originalColumnProps,
|
|
4055
|
+
});
|
|
4056
|
+
}
|
|
4057
|
+
hasLayoutChanges() {
|
|
4058
|
+
const baselineLayout = this.getBaselineLayoutSnapshot();
|
|
4059
|
+
if (!baselineLayout)
|
|
4060
|
+
return false;
|
|
4061
|
+
const currentLayout = this.getCurrentLayoutSnapshot(this.currentLayoutName);
|
|
4062
|
+
return !areObjectsEqual(currentLayout, baselineLayout);
|
|
4063
|
+
}
|
|
4064
|
+
getCurrentLayout() {
|
|
4065
|
+
return this.getCurrentLayoutSnapshot(this.currentLayoutName);
|
|
4066
|
+
}
|
|
4067
|
+
getLayout(name = this.currentLayoutName) {
|
|
4068
|
+
if (name === '') {
|
|
4069
|
+
return this.getOriginalLayoutSnapshot();
|
|
4070
|
+
}
|
|
4071
|
+
const layout = this.layouts[name];
|
|
4072
|
+
if (!layout)
|
|
4073
|
+
return undefined;
|
|
4074
|
+
return cloneComparableValue(layout);
|
|
4075
|
+
}
|
|
3986
4076
|
layoutHasFilter(layout) {
|
|
3987
4077
|
if (layout === '')
|
|
3988
4078
|
return false;
|
|
@@ -4087,16 +4177,16 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
4087
4177
|
this.layoutEdited = false;
|
|
4088
4178
|
}
|
|
4089
4179
|
applyLayout(name, save = true) {
|
|
4180
|
+
const layoutSelected = name === '' ? this.getLayout(name) : this.layouts[name];
|
|
4090
4181
|
if (this.grid.events.beforeApplyLayout) {
|
|
4091
4182
|
const canApply = this.grid.callEvent('beforeApplyLayout', {
|
|
4092
4183
|
component: this.grid,
|
|
4093
|
-
layout:
|
|
4184
|
+
layout: layoutSelected,
|
|
4094
4185
|
});
|
|
4095
4186
|
if (canApply === false)
|
|
4096
4187
|
return;
|
|
4097
4188
|
}
|
|
4098
4189
|
this.currentLayoutName = name;
|
|
4099
|
-
const layoutSelected = this.layouts[name];
|
|
4100
4190
|
if (this.viewApplyLayout) {
|
|
4101
4191
|
this.viewApplyLayout(layoutSelected);
|
|
4102
4192
|
}
|
|
@@ -4131,7 +4221,12 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
4131
4221
|
delete this.layouts[name];
|
|
4132
4222
|
this.saveLayouts();
|
|
4133
4223
|
}
|
|
4134
|
-
updateLayout(name, layout) {
|
|
4224
|
+
updateLayout(name = this.currentLayoutName, layout = this.getCurrentLayout()) {
|
|
4225
|
+
if (name === '') {
|
|
4226
|
+
this.updateDefaultLayout(layout);
|
|
4227
|
+
this.layoutEdited = false;
|
|
4228
|
+
return;
|
|
4229
|
+
}
|
|
4135
4230
|
this.fixColumns(layout);
|
|
4136
4231
|
this.currentLayoutName = name;
|
|
4137
4232
|
layout.name = name;
|
|
@@ -4153,6 +4248,7 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
4153
4248
|
return Object.assign(Object.assign({}, originalColumn), column);
|
|
4154
4249
|
});
|
|
4155
4250
|
}
|
|
4251
|
+
this.originalLayoutSnapshot = this.getOriginalLayoutSnapshot();
|
|
4156
4252
|
if (this.currentLayoutName === '') {
|
|
4157
4253
|
this.applyLayout(this.currentLayoutName, false);
|
|
4158
4254
|
}
|
|
@@ -4164,20 +4260,7 @@ class TekGridLayoutOptions extends ComponentRender {
|
|
|
4164
4260
|
this.grid.columns.forEach((gridColumn) => {
|
|
4165
4261
|
if (!hasLayoutColumns
|
|
4166
4262
|
|| layoutColumnNames.indexOf(gridColumn.name) === -1) {
|
|
4167
|
-
layout.columns.push(
|
|
4168
|
-
name: gridColumn.name,
|
|
4169
|
-
label: gridColumn.label,
|
|
4170
|
-
align: gridColumn.align,
|
|
4171
|
-
isVisible: !hasLayoutColumns && gridColumn.isVisible,
|
|
4172
|
-
width: gridColumn.width,
|
|
4173
|
-
minWidth: gridColumn.minWidth,
|
|
4174
|
-
maxWidth: gridColumn.maxWidth,
|
|
4175
|
-
fixed: gridColumn.fixed,
|
|
4176
|
-
grouped: gridColumn.grouped,
|
|
4177
|
-
groupOpened: gridColumn.groupOpened,
|
|
4178
|
-
aggregation: gridColumn.aggregation,
|
|
4179
|
-
filterHelperValue: this.getHelperValue(gridColumn),
|
|
4180
|
-
});
|
|
4263
|
+
layout.columns.push(this.getLayoutColumnSnapshot(gridColumn, !hasLayoutColumns && gridColumn.isVisible));
|
|
4181
4264
|
}
|
|
4182
4265
|
});
|
|
4183
4266
|
}
|
|
@@ -1600,6 +1600,40 @@
|
|
|
1600
1600
|
return result;
|
|
1601
1601
|
};
|
|
1602
1602
|
|
|
1603
|
+
const EMPTY_VALUE = null;
|
|
1604
|
+
function cloneComparableValue(value) {
|
|
1605
|
+
return JSON.parse(JSON.stringify(value));
|
|
1606
|
+
}
|
|
1607
|
+
function normalizeComparableValue(value) {
|
|
1608
|
+
if (value === undefined || value === null || value === '') {
|
|
1609
|
+
return EMPTY_VALUE;
|
|
1610
|
+
}
|
|
1611
|
+
if (Array.isArray(value)) {
|
|
1612
|
+
if (!value.length)
|
|
1613
|
+
return EMPTY_VALUE;
|
|
1614
|
+
return value.map((item) => normalizeComparableValue(item));
|
|
1615
|
+
}
|
|
1616
|
+
if (value && typeof value === 'object') {
|
|
1617
|
+
const normalizedValue = Object.keys(value)
|
|
1618
|
+
.sort()
|
|
1619
|
+
.reduce((result, key) => {
|
|
1620
|
+
const normalizedItem = normalizeComparableValue(value[key]);
|
|
1621
|
+
if (normalizedItem !== EMPTY_VALUE) {
|
|
1622
|
+
result[key] = normalizedItem;
|
|
1623
|
+
}
|
|
1624
|
+
return result;
|
|
1625
|
+
}, {});
|
|
1626
|
+
if (!Object.keys(normalizedValue).length)
|
|
1627
|
+
return EMPTY_VALUE;
|
|
1628
|
+
return normalizedValue;
|
|
1629
|
+
}
|
|
1630
|
+
return value;
|
|
1631
|
+
}
|
|
1632
|
+
function areObjectsEqual(first, second) {
|
|
1633
|
+
return JSON.stringify(normalizeComparableValue(first))
|
|
1634
|
+
=== JSON.stringify(normalizeComparableValue(second));
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1603
1637
|
const DynamicFilterOperations = {
|
|
1604
1638
|
CONTAINS: true,
|
|
1605
1639
|
NOT_CONTAINS: true,
|
|
@@ -2421,7 +2455,7 @@
|
|
|
2421
2455
|
*/
|
|
2422
2456
|
this.tasksBeforeLoad = [];
|
|
2423
2457
|
this.request = debounce__default["default"](() => { this.datasource.get(); }, 500);
|
|
2424
|
-
this.updateGrouping = debounce__default["default"]((lazyLoad =
|
|
2458
|
+
this.updateGrouping = debounce__default["default"]((lazyLoad = this.defaultLazy) => {
|
|
2425
2459
|
this.updateGroupedData(lazyLoad);
|
|
2426
2460
|
}, 100);
|
|
2427
2461
|
this.title = this.getInitValue('title', props.title, this.title);
|
|
@@ -3910,7 +3944,7 @@
|
|
|
3910
3944
|
return this.grid;
|
|
3911
3945
|
}
|
|
3912
3946
|
onGridChangeLayout() {
|
|
3913
|
-
this.layoutEdited =
|
|
3947
|
+
this.layoutEdited = this.hasLayoutChanges();
|
|
3914
3948
|
}
|
|
3915
3949
|
registerChangeLayoutEvent() {
|
|
3916
3950
|
if (!this.grid || this.changeLayoutEventGrid === this.grid)
|
|
@@ -3929,20 +3963,8 @@
|
|
|
3929
3963
|
this.originalDatasourceOrder = [...this.grid.datasource.order];
|
|
3930
3964
|
this.originalDatasourceDynamicFilter = Object.assign({}, this.grid.datasource.dynamicFilter);
|
|
3931
3965
|
this.originalDatasourceFilter = Object.assign({}, this.grid.datasource.filter);
|
|
3932
|
-
this.originalColumnProps = this.grid.columns.map((column) => (
|
|
3933
|
-
|
|
3934
|
-
label: column.label,
|
|
3935
|
-
align: column.align,
|
|
3936
|
-
isVisible: column.isVisible,
|
|
3937
|
-
minWidth: column.minWidth,
|
|
3938
|
-
maxWidth: column.maxWidth,
|
|
3939
|
-
width: column.width,
|
|
3940
|
-
fixed: column.fixed,
|
|
3941
|
-
grouped: column.grouped,
|
|
3942
|
-
groupOpened: column.groupOpened,
|
|
3943
|
-
aggregation: column.aggregation,
|
|
3944
|
-
filterHelperValue: this.getHelperValue(column),
|
|
3945
|
-
}));
|
|
3966
|
+
this.originalColumnProps = this.grid.columns.map((column) => this.getLayoutColumnSnapshot(column));
|
|
3967
|
+
this.originalLayoutSnapshot = cloneComparableValue(this.getCurrentLayoutSnapshot(''));
|
|
3946
3968
|
let layoutsInfo = {};
|
|
3947
3969
|
const promise = this.loadLayoutsInfo();
|
|
3948
3970
|
if (this.grid instanceof TekGrid) {
|
|
@@ -3987,6 +4009,74 @@
|
|
|
3987
4009
|
}
|
|
3988
4010
|
return '';
|
|
3989
4011
|
}
|
|
4012
|
+
getLayoutColumnSnapshot(column, isVisible = column.isVisible) {
|
|
4013
|
+
const filterHelperValue = this.getHelperValue(column);
|
|
4014
|
+
return {
|
|
4015
|
+
name: column.name,
|
|
4016
|
+
label: column.label,
|
|
4017
|
+
align: column.align,
|
|
4018
|
+
isVisible,
|
|
4019
|
+
minWidth: column.minWidth || '',
|
|
4020
|
+
maxWidth: column.maxWidth || '',
|
|
4021
|
+
width: column.width,
|
|
4022
|
+
fixed: !!column.fixed,
|
|
4023
|
+
grouped: !!column.grouped,
|
|
4024
|
+
groupOpened: !!column.groupOpened,
|
|
4025
|
+
aggregation: column.aggregation,
|
|
4026
|
+
filterHelperValue: Array.isArray(filterHelperValue)
|
|
4027
|
+
? filterHelperValue
|
|
4028
|
+
: filterHelperValue || '',
|
|
4029
|
+
};
|
|
4030
|
+
}
|
|
4031
|
+
getCurrentLayoutSnapshot(name) {
|
|
4032
|
+
if (this.viewGetCurrentLayout) {
|
|
4033
|
+
return this.viewGetCurrentLayout(name);
|
|
4034
|
+
}
|
|
4035
|
+
return {
|
|
4036
|
+
name,
|
|
4037
|
+
gridWidth: 'auto',
|
|
4038
|
+
order: [...this.grid.datasource.order],
|
|
4039
|
+
filter: Object.assign({}, this.grid.datasource.filter),
|
|
4040
|
+
dynamicFilter: Object.assign({}, this.grid.datasource.dynamicFilter),
|
|
4041
|
+
columns: this.grid.columns.map((column) => this.getLayoutColumnSnapshot(column)),
|
|
4042
|
+
};
|
|
4043
|
+
}
|
|
4044
|
+
getBaselineLayoutSnapshot() {
|
|
4045
|
+
if (this.currentLayoutName) {
|
|
4046
|
+
const currentLayout = this.layouts[this.currentLayoutName];
|
|
4047
|
+
return currentLayout;
|
|
4048
|
+
}
|
|
4049
|
+
return this.originalLayoutSnapshot;
|
|
4050
|
+
}
|
|
4051
|
+
getOriginalLayoutSnapshot() {
|
|
4052
|
+
return cloneComparableValue({
|
|
4053
|
+
name: '',
|
|
4054
|
+
gridWidth: 'auto',
|
|
4055
|
+
order: [...this.originalDatasourceOrder],
|
|
4056
|
+
filter: Object.assign({}, this.originalDatasourceFilter),
|
|
4057
|
+
dynamicFilter: Object.assign({}, this.originalDatasourceDynamicFilter),
|
|
4058
|
+
columns: this.originalColumnProps,
|
|
4059
|
+
});
|
|
4060
|
+
}
|
|
4061
|
+
hasLayoutChanges() {
|
|
4062
|
+
const baselineLayout = this.getBaselineLayoutSnapshot();
|
|
4063
|
+
if (!baselineLayout)
|
|
4064
|
+
return false;
|
|
4065
|
+
const currentLayout = this.getCurrentLayoutSnapshot(this.currentLayoutName);
|
|
4066
|
+
return !areObjectsEqual(currentLayout, baselineLayout);
|
|
4067
|
+
}
|
|
4068
|
+
getCurrentLayout() {
|
|
4069
|
+
return this.getCurrentLayoutSnapshot(this.currentLayoutName);
|
|
4070
|
+
}
|
|
4071
|
+
getLayout(name = this.currentLayoutName) {
|
|
4072
|
+
if (name === '') {
|
|
4073
|
+
return this.getOriginalLayoutSnapshot();
|
|
4074
|
+
}
|
|
4075
|
+
const layout = this.layouts[name];
|
|
4076
|
+
if (!layout)
|
|
4077
|
+
return undefined;
|
|
4078
|
+
return cloneComparableValue(layout);
|
|
4079
|
+
}
|
|
3990
4080
|
layoutHasFilter(layout) {
|
|
3991
4081
|
if (layout === '')
|
|
3992
4082
|
return false;
|
|
@@ -4091,16 +4181,16 @@
|
|
|
4091
4181
|
this.layoutEdited = false;
|
|
4092
4182
|
}
|
|
4093
4183
|
applyLayout(name, save = true) {
|
|
4184
|
+
const layoutSelected = name === '' ? this.getLayout(name) : this.layouts[name];
|
|
4094
4185
|
if (this.grid.events.beforeApplyLayout) {
|
|
4095
4186
|
const canApply = this.grid.callEvent('beforeApplyLayout', {
|
|
4096
4187
|
component: this.grid,
|
|
4097
|
-
layout:
|
|
4188
|
+
layout: layoutSelected,
|
|
4098
4189
|
});
|
|
4099
4190
|
if (canApply === false)
|
|
4100
4191
|
return;
|
|
4101
4192
|
}
|
|
4102
4193
|
this.currentLayoutName = name;
|
|
4103
|
-
const layoutSelected = this.layouts[name];
|
|
4104
4194
|
if (this.viewApplyLayout) {
|
|
4105
4195
|
this.viewApplyLayout(layoutSelected);
|
|
4106
4196
|
}
|
|
@@ -4135,7 +4225,12 @@
|
|
|
4135
4225
|
delete this.layouts[name];
|
|
4136
4226
|
this.saveLayouts();
|
|
4137
4227
|
}
|
|
4138
|
-
updateLayout(name, layout) {
|
|
4228
|
+
updateLayout(name = this.currentLayoutName, layout = this.getCurrentLayout()) {
|
|
4229
|
+
if (name === '') {
|
|
4230
|
+
this.updateDefaultLayout(layout);
|
|
4231
|
+
this.layoutEdited = false;
|
|
4232
|
+
return;
|
|
4233
|
+
}
|
|
4139
4234
|
this.fixColumns(layout);
|
|
4140
4235
|
this.currentLayoutName = name;
|
|
4141
4236
|
layout.name = name;
|
|
@@ -4157,6 +4252,7 @@
|
|
|
4157
4252
|
return Object.assign(Object.assign({}, originalColumn), column);
|
|
4158
4253
|
});
|
|
4159
4254
|
}
|
|
4255
|
+
this.originalLayoutSnapshot = this.getOriginalLayoutSnapshot();
|
|
4160
4256
|
if (this.currentLayoutName === '') {
|
|
4161
4257
|
this.applyLayout(this.currentLayoutName, false);
|
|
4162
4258
|
}
|
|
@@ -4168,20 +4264,7 @@
|
|
|
4168
4264
|
this.grid.columns.forEach((gridColumn) => {
|
|
4169
4265
|
if (!hasLayoutColumns
|
|
4170
4266
|
|| layoutColumnNames.indexOf(gridColumn.name) === -1) {
|
|
4171
|
-
layout.columns.push(
|
|
4172
|
-
name: gridColumn.name,
|
|
4173
|
-
label: gridColumn.label,
|
|
4174
|
-
align: gridColumn.align,
|
|
4175
|
-
isVisible: !hasLayoutColumns && gridColumn.isVisible,
|
|
4176
|
-
width: gridColumn.width,
|
|
4177
|
-
minWidth: gridColumn.minWidth,
|
|
4178
|
-
maxWidth: gridColumn.maxWidth,
|
|
4179
|
-
fixed: gridColumn.fixed,
|
|
4180
|
-
grouped: gridColumn.grouped,
|
|
4181
|
-
groupOpened: gridColumn.groupOpened,
|
|
4182
|
-
aggregation: gridColumn.aggregation,
|
|
4183
|
-
filterHelperValue: this.getHelperValue(gridColumn),
|
|
4184
|
-
});
|
|
4267
|
+
layout.columns.push(this.getLayoutColumnSnapshot(gridColumn, !hasLayoutColumns && gridColumn.isVisible));
|
|
4185
4268
|
}
|
|
4186
4269
|
});
|
|
4187
4270
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.132.0",
|
|
4
4
|
"description": "Teknisa Components Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@zeedhi/core": "^1.97.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "9f44cb7b5d254a6e8bdfc2ac2288239b75b31313"
|
|
36
36
|
}
|
|
@@ -1864,6 +1864,46 @@ describe('TekGrid', () => {
|
|
|
1864
1864
|
httpSpy.mockReset();
|
|
1865
1865
|
});
|
|
1866
1866
|
|
|
1867
|
+
it('should not call loadAfterTasks when initialized with lazyLoad datasource', async () => {
|
|
1868
|
+
const instance = createAndMount({
|
|
1869
|
+
name: 'grid_grouping_lazy_load',
|
|
1870
|
+
component: 'TekGrid',
|
|
1871
|
+
columns: [
|
|
1872
|
+
{
|
|
1873
|
+
name: 'id',
|
|
1874
|
+
label: 'id',
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
name: 'name',
|
|
1878
|
+
label: 'name',
|
|
1879
|
+
},
|
|
1880
|
+
{
|
|
1881
|
+
name: 'department',
|
|
1882
|
+
label: 'department',
|
|
1883
|
+
grouped: true,
|
|
1884
|
+
},
|
|
1885
|
+
],
|
|
1886
|
+
datasource: {
|
|
1887
|
+
uniqueKey: 'id',
|
|
1888
|
+
route: '/zeedhi',
|
|
1889
|
+
type: 'tek-rest',
|
|
1890
|
+
limit: 10,
|
|
1891
|
+
watchUrl: false,
|
|
1892
|
+
lazyLoad: true,
|
|
1893
|
+
},
|
|
1894
|
+
});
|
|
1895
|
+
|
|
1896
|
+
const updateGroupedDataSpy = jest.spyOn(instance, 'updateGroupedData');
|
|
1897
|
+
const loadAfterTasksSpy = jest.spyOn(instance, 'loadAfterTasks');
|
|
1898
|
+
|
|
1899
|
+
jest.runAllTimers();
|
|
1900
|
+
|
|
1901
|
+
expect(updateGroupedDataSpy).toHaveBeenCalled();
|
|
1902
|
+
expect(loadAfterTasksSpy).not.toHaveBeenCalled();
|
|
1903
|
+
|
|
1904
|
+
loadAfterTasksSpy.mockRestore();
|
|
1905
|
+
});
|
|
1906
|
+
|
|
1867
1907
|
it('editedRows should return cleaned rows', async () => {
|
|
1868
1908
|
const instance = new TekGrid({
|
|
1869
1909
|
name: 'grid_grouping_4',
|