@zeedhi/teknisa-components-common 1.44.0 → 1.47.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 +551 -577
- package/coverage/coverage-final.json +11 -11
- package/coverage/lcov-report/index.html +14 -14
- package/coverage/lcov.info +1092 -1149
- package/dist/tek-components-common.esm.js +86 -187
- package/dist/tek-components-common.umd.js +84 -185
- package/package.json +2 -2
- package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +24 -0
- package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +28 -1
- package/tests/unit/components/tek-grid/filter-helper.spec.ts +5 -2
- package/tests/unit/components/tek-grid/grid-columns-button.spec.ts +25 -0
- package/tests/unit/components/tek-grid/grid.spec.ts +37 -130
- package/types/components/tek-grid/filter-helper.d.ts +0 -2
- package/types/components/tek-grid/grid-columns-button-controller.d.ts +1 -0
- package/types/components/tek-grid/interfaces.d.ts +3 -6
- package/types/components/tek-loading/interfaces.d.ts +2 -2
- package/types/components/tek-loading/loading.d.ts +2 -2
- package/types/utils/grid-base/grid-base.d.ts +1 -6
|
@@ -590,7 +590,7 @@
|
|
|
590
590
|
/**
|
|
591
591
|
* Teknisa component
|
|
592
592
|
*/
|
|
593
|
-
class Loading extends common.
|
|
593
|
+
class Loading extends common.Loading {
|
|
594
594
|
/**
|
|
595
595
|
* Creates a new instance of TekLoading
|
|
596
596
|
* @param props Image Link props
|
|
@@ -1140,9 +1140,11 @@
|
|
|
1140
1140
|
columnComponentName = `${this.grid.name}-filter-AND-CONTAINS-${column.name}-${index}`;
|
|
1141
1141
|
}
|
|
1142
1142
|
this.filterFormInputs[column.name].push(columnComponentName);
|
|
1143
|
-
|
|
1143
|
+
const newColumnComponent = Object.assign(Object.assign(Object.assign({ label: column.label }, column.componentProps), filterItem), { name: columnComponentName });
|
|
1144
1144
|
if (filterItem.helperOptions) {
|
|
1145
|
-
|
|
1145
|
+
if (!newColumnComponent.events)
|
|
1146
|
+
newColumnComponent.events = {};
|
|
1147
|
+
newColumnComponent.events.change = this.changeHelperEvent.bind(this, column);
|
|
1146
1148
|
}
|
|
1147
1149
|
filterColumns.push(newColumnComponent);
|
|
1148
1150
|
});
|
|
@@ -1150,54 +1152,9 @@
|
|
|
1150
1152
|
});
|
|
1151
1153
|
return filterColumns;
|
|
1152
1154
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
component: 'ZdTag',
|
|
1157
|
-
tag: 'span',
|
|
1158
|
-
cssClass: 'zd-display-flex',
|
|
1159
|
-
grid: component.grid,
|
|
1160
|
-
children: [
|
|
1161
|
-
Object.assign(Object.assign({}, component), { persistentHint: true, events: {
|
|
1162
|
-
onMounted: this.registerFilterComponentToForm.bind(this),
|
|
1163
|
-
change: this.clearFilterHelperValue.bind(this, column),
|
|
1164
|
-
} }),
|
|
1165
|
-
{
|
|
1166
|
-
name: `${component.name}_helperdropdown`,
|
|
1167
|
-
component: 'ZdDropdown',
|
|
1168
|
-
offsetY: true,
|
|
1169
|
-
activator: {
|
|
1170
|
-
name: `${component.name}_helperbutton`,
|
|
1171
|
-
component: 'ZdButton',
|
|
1172
|
-
iconName: 'magnify',
|
|
1173
|
-
icon: true,
|
|
1174
|
-
small: true,
|
|
1175
|
-
cssClass: `filter-helper-values-button ${component.showLabel !== false ? 'with-label' : ''}`,
|
|
1176
|
-
},
|
|
1177
|
-
children: this.createHelperValueOptions(component, helperValues, column),
|
|
1178
|
-
},
|
|
1179
|
-
],
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
createHelperValueOptions(component, helperValues, column) {
|
|
1183
|
-
return helperValues.map((value) => ({
|
|
1184
|
-
name: `${component.name}_helpervalue_${value}`,
|
|
1185
|
-
component: 'ZdText',
|
|
1186
|
-
cssClass: 'filter-helper-values-option',
|
|
1187
|
-
text: TekFilterHelper.getLabel(value),
|
|
1188
|
-
events: {
|
|
1189
|
-
click: this.helperValuesOptionClick.bind(this, component, value, column),
|
|
1190
|
-
},
|
|
1191
|
-
}));
|
|
1192
|
-
}
|
|
1193
|
-
helperValuesOptionClick(component, helperValue, column) {
|
|
1194
|
-
const value = TekFilterHelper.getValue(helperValue, column);
|
|
1195
|
-
const componentObject = core.Metadata.getInstance(component.name);
|
|
1196
|
-
componentObject.value = value;
|
|
1197
|
-
componentObject.hint = TekFilterHelper.getLabel(helperValue);
|
|
1198
|
-
this.setFilterPropsHelperValue(column, component.name, helperValue);
|
|
1199
|
-
}
|
|
1200
|
-
setFilterPropsHelperValue(column, componentName, helperValue) {
|
|
1155
|
+
changeHelperEvent(column, { component }) {
|
|
1156
|
+
const { helperValue } = component;
|
|
1157
|
+
const componentName = component.name;
|
|
1201
1158
|
if (!Array.isArray(column.filterProps)) {
|
|
1202
1159
|
column.filterProps.helperValue = helperValue;
|
|
1203
1160
|
}
|
|
@@ -1211,14 +1168,6 @@
|
|
|
1211
1168
|
});
|
|
1212
1169
|
}
|
|
1213
1170
|
}
|
|
1214
|
-
registerFilterComponentToForm({ component }) {
|
|
1215
|
-
const form = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
1216
|
-
form.registerInput(component);
|
|
1217
|
-
}
|
|
1218
|
-
clearFilterHelperValue(column, { component }) {
|
|
1219
|
-
this.setFilterPropsHelperValue(column, component.name, '');
|
|
1220
|
-
component.hint = '';
|
|
1221
|
-
}
|
|
1222
1171
|
loadFilterValues({ component }) {
|
|
1223
1172
|
const { datasource } = this.grid;
|
|
1224
1173
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
@@ -1693,6 +1642,8 @@
|
|
|
1693
1642
|
}
|
|
1694
1643
|
this.lazyLoad = this.getInitValue('lazyLoad', props.lazyLoad, this.lazyLoad);
|
|
1695
1644
|
this.createAccessors();
|
|
1645
|
+
this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
|
|
1646
|
+
this.createObjAccessors(this.searchJoin, 'searchJoin');
|
|
1696
1647
|
if (!this.lazyLoad) {
|
|
1697
1648
|
this.get();
|
|
1698
1649
|
}
|
|
@@ -1872,6 +1823,8 @@
|
|
|
1872
1823
|
this.searchJoin = this.getInitValue('searchJoin', props.searchJoin, {});
|
|
1873
1824
|
}
|
|
1874
1825
|
this.createAccessors();
|
|
1826
|
+
this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
|
|
1827
|
+
this.createObjAccessors(this.searchJoin, 'searchJoin');
|
|
1875
1828
|
this.get();
|
|
1876
1829
|
}
|
|
1877
1830
|
updateReservedKeys() {
|
|
@@ -2018,61 +1971,70 @@
|
|
|
2018
1971
|
}
|
|
2019
1972
|
getRowByDynamicFilter(row) {
|
|
2020
1973
|
let filtered;
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
1974
|
+
try {
|
|
1975
|
+
Object.keys(this.dynamicFilter).forEach((key) => {
|
|
1976
|
+
const filterItems = this.dynamicFilter[key];
|
|
1977
|
+
filterItems.forEach((item) => {
|
|
1978
|
+
if (filtered === false && item.relation === 'AND')
|
|
1979
|
+
return;
|
|
1980
|
+
if (filtered === true && item.relation === 'OR')
|
|
1981
|
+
return;
|
|
1982
|
+
const columnValue = core.Utils.normalize(row[key].toString());
|
|
1983
|
+
let value = '';
|
|
1984
|
+
if (Array.isArray(item.value)) {
|
|
1985
|
+
value = item.value.map((val) => core.Utils.normalize(val.toString()));
|
|
1986
|
+
switch (item.operation) {
|
|
1987
|
+
case 'IN':
|
|
1988
|
+
filtered = value.includes(columnValue);
|
|
1989
|
+
break;
|
|
1990
|
+
case 'NOT_IN':
|
|
1991
|
+
filtered = !value.includes(columnValue);
|
|
1992
|
+
break;
|
|
1993
|
+
case 'BETWEEN':
|
|
1994
|
+
filtered = (Number(columnValue) || columnValue) >= (Number(value[0]) || value[0])
|
|
1995
|
+
&& (Number(columnValue) || columnValue) <= (Number(value[1]) || value[1]);
|
|
1996
|
+
break;
|
|
1997
|
+
default:
|
|
1998
|
+
break;
|
|
1999
|
+
}
|
|
2043
2000
|
}
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2001
|
+
else {
|
|
2002
|
+
value = core.Utils.normalize(item.value.toString());
|
|
2003
|
+
switch (item.operation) {
|
|
2004
|
+
case 'CONTAINS':
|
|
2005
|
+
filtered = columnValue.indexOf(value) !== -1;
|
|
2006
|
+
break;
|
|
2007
|
+
case 'NOT_CONTAINS':
|
|
2008
|
+
filtered = columnValue.indexOf(value) === -1;
|
|
2009
|
+
break;
|
|
2010
|
+
case 'EQUALS':
|
|
2011
|
+
filtered = columnValue === value;
|
|
2012
|
+
break;
|
|
2013
|
+
case 'NOT_EQUALS':
|
|
2014
|
+
filtered = columnValue !== value;
|
|
2015
|
+
break;
|
|
2016
|
+
case 'GREATER_THAN':
|
|
2017
|
+
filtered = (Number(columnValue) || columnValue) > (Number(value) || value);
|
|
2018
|
+
break;
|
|
2019
|
+
case 'LESS_THAN':
|
|
2020
|
+
filtered = (Number(columnValue) || columnValue) < (Number(value) || value);
|
|
2021
|
+
break;
|
|
2022
|
+
case 'GREATER_THAN_EQUALS':
|
|
2023
|
+
filtered = (Number(columnValue) || columnValue) >= (Number(value) || value);
|
|
2024
|
+
break;
|
|
2025
|
+
case 'LESS_THAN_EQUALS':
|
|
2026
|
+
filtered = (Number(columnValue) || columnValue) <= (Number(value) || value);
|
|
2027
|
+
break;
|
|
2028
|
+
default:
|
|
2029
|
+
break;
|
|
2030
|
+
}
|
|
2072
2031
|
}
|
|
2073
|
-
}
|
|
2032
|
+
});
|
|
2074
2033
|
});
|
|
2075
|
-
}
|
|
2034
|
+
}
|
|
2035
|
+
catch (_a) {
|
|
2036
|
+
// do nothing
|
|
2037
|
+
}
|
|
2076
2038
|
return filtered;
|
|
2077
2039
|
}
|
|
2078
2040
|
getRowBySearchJoin(row) {
|
|
@@ -2842,6 +2804,12 @@
|
|
|
2842
2804
|
}
|
|
2843
2805
|
column.aggregation = newValue;
|
|
2844
2806
|
}
|
|
2807
|
+
showHideTekColumn(column, { component, event, element }) {
|
|
2808
|
+
if (!component.value && column.grouped)
|
|
2809
|
+
column.grouped = false;
|
|
2810
|
+
column.isVisible = component.value;
|
|
2811
|
+
this.iterableComponent.changeLayout(event, element);
|
|
2812
|
+
}
|
|
2845
2813
|
}
|
|
2846
2814
|
|
|
2847
2815
|
/**
|
|
@@ -3031,88 +2999,19 @@
|
|
|
3031
2999
|
}
|
|
3032
3000
|
|
|
3033
3001
|
class TekFilterHelper {
|
|
3034
|
-
static formatDate(date, column) {
|
|
3035
|
-
if (column.componentProps.dateFormat) {
|
|
3036
|
-
return core.dayjs(date).format(column.componentProps.dateFormat);
|
|
3037
|
-
}
|
|
3038
|
-
return core.dayjs(date).format(core.Config.dateFormat);
|
|
3039
|
-
}
|
|
3040
3002
|
static getLabel(name) {
|
|
3041
|
-
return core.
|
|
3003
|
+
return core.DateHelper.getLabel(name);
|
|
3042
3004
|
}
|
|
3043
3005
|
static getValue(name, column) {
|
|
3044
|
-
|
|
3045
|
-
return '';
|
|
3046
|
-
const value = this.values[name].fn();
|
|
3047
|
-
if (Array.isArray(value)) {
|
|
3048
|
-
return value.map((item) => this.formatDate(item, column));
|
|
3049
|
-
}
|
|
3050
|
-
return this.formatDate(value, column);
|
|
3006
|
+
return core.DateHelper.getValue(name, column.componentProps.dateFormat);
|
|
3051
3007
|
}
|
|
3052
3008
|
static register(name, label, fn) {
|
|
3053
|
-
|
|
3054
|
-
label,
|
|
3055
|
-
fn,
|
|
3056
|
-
};
|
|
3009
|
+
core.DateHelper.register(name, label, fn);
|
|
3057
3010
|
}
|
|
3058
3011
|
static unregister(name) {
|
|
3059
|
-
|
|
3012
|
+
core.DateHelper.unregister(name);
|
|
3060
3013
|
}
|
|
3061
|
-
}
|
|
3062
|
-
TekFilterHelper.values = {
|
|
3063
|
-
TODAY: {
|
|
3064
|
-
label: 'TEKGRID_HELPERVALUE_TODAY',
|
|
3065
|
-
fn: () => core.dayjs().toDate(),
|
|
3066
|
-
},
|
|
3067
|
-
TOMORROW: {
|
|
3068
|
-
label: 'TEKGRID_HELPERVALUE_TOMORROW',
|
|
3069
|
-
fn: () => core.dayjs().add(1, 'day').toDate(),
|
|
3070
|
-
},
|
|
3071
|
-
YESTERDAY: {
|
|
3072
|
-
label: 'TEKGRID_HELPERVALUE_YESTERDAY',
|
|
3073
|
-
fn: () => core.dayjs().subtract(1, 'day').toDate(),
|
|
3074
|
-
},
|
|
3075
|
-
LAST_7_DAYS: {
|
|
3076
|
-
label: 'TEKGRID_HELPERVALUE_LAST_7_DAYS',
|
|
3077
|
-
fn: () => {
|
|
3078
|
-
const end = core.dayjs().toDate();
|
|
3079
|
-
const start = core.dayjs().subtract(7, 'day').toDate();
|
|
3080
|
-
return [start, end];
|
|
3081
|
-
},
|
|
3082
|
-
},
|
|
3083
|
-
NEXT_7_DAYS: {
|
|
3084
|
-
label: 'TEKGRID_HELPERVALUE_NEXT_7_DAYS',
|
|
3085
|
-
fn: () => {
|
|
3086
|
-
const start = core.dayjs().toDate();
|
|
3087
|
-
const end = core.dayjs().add(7, 'day').toDate();
|
|
3088
|
-
return [start, end];
|
|
3089
|
-
},
|
|
3090
|
-
},
|
|
3091
|
-
CURRENT_WEEK: {
|
|
3092
|
-
label: 'TEKGRID_HELPERVALUE_CURRENT_WEEK',
|
|
3093
|
-
fn: () => {
|
|
3094
|
-
const start = core.dayjs().startOf('week').toDate();
|
|
3095
|
-
const end = core.dayjs().endOf('week').toDate();
|
|
3096
|
-
return [start, end];
|
|
3097
|
-
},
|
|
3098
|
-
},
|
|
3099
|
-
CURRENT_MONTH: {
|
|
3100
|
-
label: 'TEKGRID_HELPERVALUE_CURRENT_MONTH',
|
|
3101
|
-
fn: () => {
|
|
3102
|
-
const start = core.dayjs().startOf('month').toDate();
|
|
3103
|
-
const end = core.dayjs().endOf('month').toDate();
|
|
3104
|
-
return [start, end];
|
|
3105
|
-
},
|
|
3106
|
-
},
|
|
3107
|
-
CURRENT_YEAR: {
|
|
3108
|
-
label: 'TEKGRID_HELPERVALUE_CURRENT_YEAR',
|
|
3109
|
-
fn: () => {
|
|
3110
|
-
const start = core.dayjs().startOf('year').toDate();
|
|
3111
|
-
const end = core.dayjs().endOf('year').toDate();
|
|
3112
|
-
return [start, end];
|
|
3113
|
-
},
|
|
3114
|
-
},
|
|
3115
|
-
};
|
|
3014
|
+
}
|
|
3116
3015
|
|
|
3117
3016
|
/* TekTreeGrid Class */
|
|
3118
3017
|
class TekTreeGrid extends common.TreeGridEditable {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"description": "Teknisa Components Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@zeedhi/core": "*"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "abcaca117ec02f18fa6c8c1aef4bf6bb3582fdf7"
|
|
32
32
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
init,
|
|
2
3
|
Router,
|
|
3
4
|
URL,
|
|
4
5
|
} from '@zeedhi/core';
|
|
@@ -7,6 +8,14 @@ import {
|
|
|
7
8
|
} from '../../../../src';
|
|
8
9
|
|
|
9
10
|
describe('TekMemoryDatasource', () => {
|
|
11
|
+
init({
|
|
12
|
+
controllers: {
|
|
13
|
+
AppController: class AppController {
|
|
14
|
+
public value = '1';
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
10
19
|
let datasource: ITekMemoryDatasource;
|
|
11
20
|
let router: any;
|
|
12
21
|
|
|
@@ -56,6 +65,21 @@ describe('TekMemoryDatasource', () => {
|
|
|
56
65
|
expect(instance.searchJoin).toEqual({ col1: ['1', '2'], col2: [2], col3: [] });
|
|
57
66
|
});
|
|
58
67
|
|
|
68
|
+
it('should assign all properties with accessor', async () => {
|
|
69
|
+
const flushPromises = () => new Promise(setImmediate);
|
|
70
|
+
const instance = new TekMemoryDatasource({
|
|
71
|
+
...datasource,
|
|
72
|
+
dynamicFilter: {
|
|
73
|
+
name: [{ operation: 'EQUALS', relation: 'AND', value: '{{AppController.value}}' }],
|
|
74
|
+
},
|
|
75
|
+
searchJoin: { col1: ['1', '2'], col2: [2], col3: [] },
|
|
76
|
+
});
|
|
77
|
+
await flushPromises();
|
|
78
|
+
|
|
79
|
+
expect(instance.dynamicFilter).toEqual({ name: [{ operation: 'EQUALS', relation: 'AND', value: '1' }] });
|
|
80
|
+
expect(instance.searchJoin).toEqual({ col1: ['1', '2'], col2: [2], col3: [] });
|
|
81
|
+
});
|
|
82
|
+
|
|
59
83
|
it('should create using default parameters', async () => {
|
|
60
84
|
const instance = new TekMemoryDatasource({});
|
|
61
85
|
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
IConfig, Config, Router, Http, URL, IDictionary,
|
|
2
|
+
IConfig, Config, Router, Http, URL, IDictionary, init,
|
|
3
3
|
} from '@zeedhi/core';
|
|
4
4
|
import {
|
|
5
5
|
TekRestDatasource, ITekRestDatasource,
|
|
6
6
|
} from '../../../../src';
|
|
7
7
|
|
|
8
8
|
describe('TekRestDatasource', () => {
|
|
9
|
+
init({
|
|
10
|
+
controllers: {
|
|
11
|
+
AppController: class AppController {
|
|
12
|
+
public value = '1';
|
|
13
|
+
|
|
14
|
+
public join: string[] | number[] = ['1', '2'];
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
9
18
|
let datasource: ITekRestDatasource;
|
|
10
19
|
let router: any;
|
|
11
20
|
const config: IConfig = {
|
|
@@ -82,6 +91,24 @@ describe('TekRestDatasource', () => {
|
|
|
82
91
|
expect(instance.searchJoin).toEqual({ col1: ['1', '2'], col2: [2], col3: [] });
|
|
83
92
|
});
|
|
84
93
|
|
|
94
|
+
it('should assign all properties', async () => {
|
|
95
|
+
const flushPromises = () => new Promise(setImmediate);
|
|
96
|
+
const instance = new TekRestDatasource({
|
|
97
|
+
...datasource,
|
|
98
|
+
dynamicFilter: {
|
|
99
|
+
name: { operation: 'EQUALS', relation: 'AND', value: '{{AppController.value}}' },
|
|
100
|
+
},
|
|
101
|
+
searchJoin: { col1: '{{AppController.join}}' as any, col2: [2], col3: [] },
|
|
102
|
+
});
|
|
103
|
+
await flushPromises();
|
|
104
|
+
|
|
105
|
+
expect(instance.route).toBe('/zeedhi');
|
|
106
|
+
expect(instance.lazyLoad).toBeTruthy();
|
|
107
|
+
expect(instance.dynamicFilter).toEqual({ name: { operation: 'EQUALS', relation: 'AND', value: '1' } });
|
|
108
|
+
expect(instance.data.length).toBe(0);
|
|
109
|
+
expect(instance.searchJoin).toEqual({ col1: ['1', '2'], col2: [2], col3: [] });
|
|
110
|
+
});
|
|
111
|
+
|
|
85
112
|
it('should create without lazyLoad', async () => {
|
|
86
113
|
const flushPromises = () => new Promise(setImmediate);
|
|
87
114
|
const instance = new TekRestDatasource({
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { Config, dayjs } from '@zeedhi/core';
|
|
1
|
+
import { Config, DateHelper, dayjs } from '@zeedhi/core';
|
|
2
2
|
import { TekFilterHelper, TekGrid } from '../../../../src';
|
|
3
3
|
|
|
4
4
|
describe('TekFilterHelper', () => {
|
|
5
5
|
describe('getLabel', () => {
|
|
6
6
|
it('should return helper label', () => {
|
|
7
|
-
|
|
7
|
+
const dateHelperSpy = jest.spyOn(DateHelper, 'getLabel').mockImplementation((name: string) => name);
|
|
8
|
+
|
|
9
|
+
expect(TekFilterHelper.getLabel('TODAY')).toBe('TODAY');
|
|
10
|
+
dateHelperSpy.mockClear();
|
|
8
11
|
});
|
|
9
12
|
});
|
|
10
13
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Checkbox, Iterable } from '@zeedhi/common';
|
|
1
2
|
import { I18n } from '@zeedhi/core';
|
|
2
3
|
import { TekGrid, TekGridColumnsButton } from '../../../../src';
|
|
3
4
|
import { TekGridColumnsButtonController } from '../../../../src/components/tek-grid/grid-columns-button-controller';
|
|
@@ -39,9 +40,25 @@ describe('TekGridColumnsButton', () => {
|
|
|
39
40
|
|
|
40
41
|
describe('controller', () => {
|
|
41
42
|
it('should create component controller', () => {
|
|
43
|
+
const checkbox = new Checkbox({
|
|
44
|
+
name: 'checkbox',
|
|
45
|
+
component: 'ZdCheckbox',
|
|
46
|
+
value: false,
|
|
47
|
+
});
|
|
48
|
+
const iterable = new Iterable({
|
|
49
|
+
name: 'iterable',
|
|
50
|
+
component: 'ZdIterable',
|
|
51
|
+
columns: [
|
|
52
|
+
{
|
|
53
|
+
name: 'id',
|
|
54
|
+
grouped: false,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
42
58
|
const grid = new TekGrid({
|
|
43
59
|
name: 'grid-1',
|
|
44
60
|
component: 'TekGrid',
|
|
61
|
+
parent: iterable,
|
|
45
62
|
});
|
|
46
63
|
const instance = new TekGridColumnsButton({
|
|
47
64
|
name: 'columns-button-2',
|
|
@@ -50,6 +67,14 @@ describe('TekGridColumnsButton', () => {
|
|
|
50
67
|
});
|
|
51
68
|
instance.onCreated();
|
|
52
69
|
expect(instance.controller).toBeInstanceOf(TekGridColumnsButtonController);
|
|
70
|
+
expect(iterable.columns[0].isVisible).toBeTruthy();
|
|
71
|
+
instance.controller.showHideTekColumn(iterable.columns[0], { component: checkbox });
|
|
72
|
+
expect(iterable.columns[0].isVisible).toBeFalsy();
|
|
73
|
+
|
|
74
|
+
(iterable.columns[0] as any).grouped = true;
|
|
75
|
+
iterable.columns[0].isVisible = false;
|
|
76
|
+
instance.controller.showHideTekColumn(iterable.columns[0], { component: checkbox });
|
|
77
|
+
expect(iterable.columns[0].isVisible).toBeFalsy();
|
|
53
78
|
});
|
|
54
79
|
|
|
55
80
|
it('changeGroupedColumn', () => {
|