@zeedhi/teknisa-components-common 1.37.0 → 1.41.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 +789 -617
- package/coverage/coverage-final.json +30 -27
- package/coverage/lcov-report/block-navigation.js +8 -0
- package/coverage/lcov-report/index.html +55 -19
- package/coverage/lcov-report/sorter.js +26 -0
- package/coverage/lcov.info +1506 -1181
- package/dist/tek-components-common.esm.js +1808 -1347
- package/dist/tek-components-common.umd.js +1808 -1344
- package/package.json +2 -2
- package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +20 -4
- package/tests/unit/components/tek-grid/filter-helper.spec.ts +145 -0
- package/tests/unit/components/tek-grid/grid.spec.ts +376 -58
- package/tests/unit/components/tek-grid/layout_options.spec.ts +58 -0
- package/tests/unit/components/tek-loading/Loading.spec.ts +30 -0
- package/tests/unit/components/tree-grid/tree-grid.spec.ts +469 -0
- package/tests/unit/{components/tek-grid → utils/grid-base}/grid-controller.spec.ts +3 -3
- package/types/components/index.d.ts +5 -0
- package/types/components/tek-datasource/memory-datasource.d.ts +1 -0
- package/types/components/tek-grid/filter-dynamic-values.d.ts +9 -0
- package/types/components/tek-grid/filter-helper.d.ts +9 -0
- package/types/components/tek-grid/grid-columns-button.d.ts +2 -0
- package/types/components/tek-grid/grid.d.ts +12 -19
- package/types/components/tek-grid/interfaces.d.ts +15 -1
- package/types/components/tek-grid/layout-options.d.ts +3 -2
- package/types/components/tek-loading/interfaces.d.ts +6 -0
- package/types/components/tek-loading/loading.d.ts +24 -0
- package/types/components/tek-tree-grid/interfaces.d.ts +19 -0
- package/types/components/tek-tree-grid/tree-grid.d.ts +76 -0
- package/types/utils/grid-base/grid-base.d.ts +267 -0
- package/types/utils/grid-base/grid-controller.d.ts +20 -0
- package/types/utils/index.d.ts +3 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
Button, Form, IButton, IForm, IModal, Modal, ModalService,
|
|
4
|
+
Button, Date, Form, IButton, IForm, IModal, Modal, ModalService, Text,
|
|
5
5
|
} from '@zeedhi/common';
|
|
6
6
|
import {
|
|
7
|
-
KeyMap, Http, Metadata,
|
|
7
|
+
KeyMap, Http, Metadata, dayjs, Config,
|
|
8
8
|
} from '@zeedhi/core';
|
|
9
9
|
import {
|
|
10
10
|
ITekGrid,
|
|
@@ -113,26 +113,40 @@ describe('TekGrid', () => {
|
|
|
113
113
|
component: 'TekGrid',
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
expect((instance as any).exportConfigButtons[0].label).toBe('Export as PDF');
|
|
117
|
-
expect((instance as any).exportConfigButtons[0].iconName).toBeUndefined();
|
|
118
|
-
expect((instance as any).exportConfigButtons[0].name).toBe('grid_export_pdf_portrait');
|
|
119
|
-
expect((instance as any).exportConfigButtons[0].component).toBe('ZdButton');
|
|
120
|
-
expect((instance as any).exportConfigButtons[0].flat).toBeTruthy();
|
|
121
|
-
expect((instance as any).exportConfigButtons[0].events).toBeDefined();
|
|
122
|
-
|
|
123
|
-
expect((instance as any).exportConfigButtons[1].label).toBe('Export as XLS');
|
|
124
|
-
expect((instance as any).exportConfigButtons[1].iconName).toBeUndefined();
|
|
125
|
-
expect((instance as any).exportConfigButtons[1].name).toBe('grid_export_xls_portrait');
|
|
126
|
-
expect((instance as any).exportConfigButtons[1].component).toBe('ZdButton');
|
|
127
|
-
expect((instance as any).exportConfigButtons[1].flat).toBeTruthy();
|
|
128
|
-
expect((instance as any).exportConfigButtons[1].events).toBeDefined();
|
|
129
|
-
|
|
130
|
-
expect((instance as any).exportConfigButtons[2].label).toBe('Export as
|
|
131
|
-
expect((instance as any).exportConfigButtons[2].iconName).toBeUndefined();
|
|
132
|
-
expect((instance as any).exportConfigButtons[2].name).toBe('
|
|
133
|
-
expect((instance as any).exportConfigButtons[2].component).toBe('ZdButton');
|
|
134
|
-
expect((instance as any).exportConfigButtons[2].flat).toBeTruthy();
|
|
135
|
-
expect((instance as any).exportConfigButtons[2].events).toBeDefined();
|
|
116
|
+
expect((instance as any).gridBase.exportConfigButtons[0].label).toBe('Export as PDF');
|
|
117
|
+
expect((instance as any).gridBase.exportConfigButtons[0].iconName).toBeUndefined();
|
|
118
|
+
expect((instance as any).gridBase.exportConfigButtons[0].name).toBe('grid_export_pdf_portrait');
|
|
119
|
+
expect((instance as any).gridBase.exportConfigButtons[0].component).toBe('ZdButton');
|
|
120
|
+
expect((instance as any).gridBase.exportConfigButtons[0].flat).toBeTruthy();
|
|
121
|
+
expect((instance as any).gridBase.exportConfigButtons[0].events).toBeDefined();
|
|
122
|
+
|
|
123
|
+
expect((instance as any).gridBase.exportConfigButtons[1].label).toBe('Export as XLS TEKGRID_WITHOUT_GROUPS');
|
|
124
|
+
expect((instance as any).gridBase.exportConfigButtons[1].iconName).toBeUndefined();
|
|
125
|
+
expect((instance as any).gridBase.exportConfigButtons[1].name).toBe('grid_export_xls_portrait');
|
|
126
|
+
expect((instance as any).gridBase.exportConfigButtons[1].component).toBe('ZdButton');
|
|
127
|
+
expect((instance as any).gridBase.exportConfigButtons[1].flat).toBeTruthy();
|
|
128
|
+
expect((instance as any).gridBase.exportConfigButtons[1].events).toBeDefined();
|
|
129
|
+
|
|
130
|
+
expect((instance as any).gridBase.exportConfigButtons[2].label).toBe('Export as XLS TEKGRID_WITH_GROUPS');
|
|
131
|
+
expect((instance as any).gridBase.exportConfigButtons[2].iconName).toBeUndefined();
|
|
132
|
+
expect((instance as any).gridBase.exportConfigButtons[2].name).toBe('grid_export_xls2_portrait');
|
|
133
|
+
expect((instance as any).gridBase.exportConfigButtons[2].component).toBe('ZdButton');
|
|
134
|
+
expect((instance as any).gridBase.exportConfigButtons[2].flat).toBeTruthy();
|
|
135
|
+
expect((instance as any).gridBase.exportConfigButtons[2].events).toBeDefined();
|
|
136
|
+
|
|
137
|
+
expect((instance as any).gridBase.exportConfigButtons[3].label).toBe('Export as XLS TEKGRID_GRID_MIRROR');
|
|
138
|
+
expect((instance as any).gridBase.exportConfigButtons[3].iconName).toBeUndefined();
|
|
139
|
+
expect((instance as any).gridBase.exportConfigButtons[3].name).toBe('grid_export_xls3_portrait');
|
|
140
|
+
expect((instance as any).gridBase.exportConfigButtons[3].component).toBe('ZdButton');
|
|
141
|
+
expect((instance as any).gridBase.exportConfigButtons[3].flat).toBeTruthy();
|
|
142
|
+
expect((instance as any).gridBase.exportConfigButtons[3].events).toBeDefined();
|
|
143
|
+
|
|
144
|
+
expect((instance as any).gridBase.exportConfigButtons[4].label).toBe('Export as CSV');
|
|
145
|
+
expect((instance as any).gridBase.exportConfigButtons[4].iconName).toBeUndefined();
|
|
146
|
+
expect((instance as any).gridBase.exportConfigButtons[4].name).toBe('grid_export_csv_portrait');
|
|
147
|
+
expect((instance as any).gridBase.exportConfigButtons[4].component).toBe('ZdButton');
|
|
148
|
+
expect((instance as any).gridBase.exportConfigButtons[4].flat).toBeTruthy();
|
|
149
|
+
expect((instance as any).gridBase.exportConfigButtons[4].events).toBeDefined();
|
|
136
150
|
});
|
|
137
151
|
|
|
138
152
|
it('should change export buttons from exportConfig', () => {
|
|
@@ -148,12 +162,12 @@ describe('TekGrid', () => {
|
|
|
148
162
|
],
|
|
149
163
|
});
|
|
150
164
|
|
|
151
|
-
expect((instance as any).exportConfigButtons[0].label).toBeUndefined();
|
|
152
|
-
expect((instance as any).exportConfigButtons[0].iconName).toBe('icon');
|
|
153
|
-
expect((instance as any).exportConfigButtons[0].name).toBe('grid_export_pdf_landscape');
|
|
154
|
-
expect((instance as any).exportConfigButtons[0].component).toBe('ZdButton');
|
|
155
|
-
expect((instance as any).exportConfigButtons[0].flat).toBeTruthy();
|
|
156
|
-
expect((instance as any).exportConfigButtons[0].events).toBeDefined();
|
|
165
|
+
expect((instance as any).gridBase.exportConfigButtons[0].label).toBeUndefined();
|
|
166
|
+
expect((instance as any).gridBase.exportConfigButtons[0].iconName).toBe('icon');
|
|
167
|
+
expect((instance as any).gridBase.exportConfigButtons[0].name).toBe('grid_export_pdf_landscape');
|
|
168
|
+
expect((instance as any).gridBase.exportConfigButtons[0].component).toBe('ZdButton');
|
|
169
|
+
expect((instance as any).gridBase.exportConfigButtons[0].flat).toBeTruthy();
|
|
170
|
+
expect((instance as any).gridBase.exportConfigButtons[0].events).toBeDefined();
|
|
157
171
|
});
|
|
158
172
|
});
|
|
159
173
|
|
|
@@ -187,7 +201,7 @@ describe('TekGrid', () => {
|
|
|
187
201
|
const spy = jest.spyOn(instance, 'getReport');
|
|
188
202
|
instance.onCreated();
|
|
189
203
|
|
|
190
|
-
const buttonProps = (instance as any).exportConfigButtons[0] as IButton;
|
|
204
|
+
const buttonProps = (instance as any).gridBase.exportConfigButtons[0] as IButton;
|
|
191
205
|
const button = new Button(buttonProps);
|
|
192
206
|
|
|
193
207
|
const event = new Event('click');
|
|
@@ -1334,7 +1348,7 @@ describe('TekGrid', () => {
|
|
|
1334
1348
|
button.click(event, {} as HTMLElement);
|
|
1335
1349
|
expect(spy).toBeCalledTimes(1);
|
|
1336
1350
|
expect(button.isVisible).toBeFalsy();
|
|
1337
|
-
instance.hideFilterModal();
|
|
1351
|
+
(instance as any).gridBase.hideFilterModal();
|
|
1338
1352
|
}
|
|
1339
1353
|
spy.mockClear();
|
|
1340
1354
|
});
|
|
@@ -1437,7 +1451,7 @@ describe('TekGrid', () => {
|
|
|
1437
1451
|
const button = new Button(filterTooltip.children[0]);
|
|
1438
1452
|
const event = new Event('click');
|
|
1439
1453
|
button.click(event, {} as HTMLElement);
|
|
1440
|
-
expect(formElements[0].name).toBe('grid_filterClick5-filter-AND-CONTAINS-name');
|
|
1454
|
+
expect(formElements[0].name).toBe('grid_filterClick5-filter-AND-CONTAINS-name-0');
|
|
1441
1455
|
}
|
|
1442
1456
|
spy.mockClear();
|
|
1443
1457
|
});
|
|
@@ -1480,17 +1494,262 @@ describe('TekGrid', () => {
|
|
|
1480
1494
|
const button = new Button(filterTooltip.children[0]);
|
|
1481
1495
|
const event = new Event('click');
|
|
1482
1496
|
button.click(event, {} as HTMLElement);
|
|
1483
|
-
expect(formElements[0].name).toBe('grid_filterClick6-filter-AND-CONTAINS-id');
|
|
1484
|
-
expect(formElements[1].name).toBe('grid_filterClick6-filter-OR-NOT_EQUALS-name');
|
|
1497
|
+
expect(formElements[0].name).toBe('grid_filterClick6-filter-AND-CONTAINS-id-0');
|
|
1498
|
+
expect(formElements[1].name).toBe('grid_filterClick6-filter-OR-NOT_EQUALS-name-0');
|
|
1485
1499
|
expect(formElements[1].component).toBe('ZdSelect');
|
|
1486
1500
|
}
|
|
1487
1501
|
spy.mockClear();
|
|
1488
1502
|
});
|
|
1489
1503
|
|
|
1490
|
-
it('should
|
|
1504
|
+
it('should create modal with helper component', () => {
|
|
1491
1505
|
const instance = new TekGrid({
|
|
1492
1506
|
name: 'grid_filterClick7',
|
|
1493
1507
|
component: 'TekGrid',
|
|
1508
|
+
datasource: {
|
|
1509
|
+
type: 'tek-rest',
|
|
1510
|
+
},
|
|
1511
|
+
columns: [
|
|
1512
|
+
{
|
|
1513
|
+
name: 'id',
|
|
1514
|
+
filterProps: [{ name: 'id_edit' }],
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
name: 'date',
|
|
1518
|
+
componentProps: { name: 'date_edit', component: 'ZdDate' },
|
|
1519
|
+
filterProps: [
|
|
1520
|
+
{
|
|
1521
|
+
name: 'date_edit1',
|
|
1522
|
+
label: 'date1',
|
|
1523
|
+
operation: 'NOT_EQUALS',
|
|
1524
|
+
relation: 'OR',
|
|
1525
|
+
helperOptions: [
|
|
1526
|
+
'TODAY',
|
|
1527
|
+
'TOMORROW',
|
|
1528
|
+
],
|
|
1529
|
+
},
|
|
1530
|
+
{
|
|
1531
|
+
name: 'date_edit2',
|
|
1532
|
+
label: 'date2',
|
|
1533
|
+
showLabel: false,
|
|
1534
|
+
operation: 'NOT_EQUALS',
|
|
1535
|
+
relation: 'OR',
|
|
1536
|
+
helperOptions: [
|
|
1537
|
+
'TODAY',
|
|
1538
|
+
'TOMORROW',
|
|
1539
|
+
],
|
|
1540
|
+
},
|
|
1541
|
+
],
|
|
1542
|
+
},
|
|
1543
|
+
],
|
|
1544
|
+
});
|
|
1545
|
+
|
|
1546
|
+
let formElements: any = [];
|
|
1547
|
+
let form: IForm;
|
|
1548
|
+
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1549
|
+
if (modal.children && modal.children.length > 1) {
|
|
1550
|
+
form = modal.children[1] as IForm;
|
|
1551
|
+
formElements = form.children;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
return new Modal(modal);
|
|
1555
|
+
});
|
|
1556
|
+
instance.onCreated();
|
|
1557
|
+
const filterTooltip = instance.toolbarSlot[6];
|
|
1558
|
+
if (filterTooltip && filterTooltip.children && filterTooltip.children.length > 0) {
|
|
1559
|
+
const button = new Button(filterTooltip.children[0]);
|
|
1560
|
+
const event = new Event('click');
|
|
1561
|
+
button.click(event, {} as HTMLElement);
|
|
1562
|
+
expect(formElements[0].name).toBe('grid_filterClick7-filter-AND-CONTAINS-id-0');
|
|
1563
|
+
expect(formElements[1].name).toBe('grid_filterClick7-filter-OR-NOT_EQUALS-date-0_helperspan');
|
|
1564
|
+
expect(formElements[1].component).toBe('ZdTag');
|
|
1565
|
+
expect(formElements[1].children.length).toBe(2);
|
|
1566
|
+
expect(formElements[1].children[0].name).toBe('grid_filterClick7-filter-OR-NOT_EQUALS-date-0');
|
|
1567
|
+
expect(formElements[1].children[0].component).toBe('ZdDate');
|
|
1568
|
+
expect(formElements[1].children[1].name).toBe('grid_filterClick7-filter-OR-NOT_EQUALS-date-0_helperdropdown');
|
|
1569
|
+
expect(formElements[1].children[1].component).toBe('ZdDropdown');
|
|
1570
|
+
expect(formElements[1].children[1].activator.cssClass).toBe('filter-helper-values-button with-label');
|
|
1571
|
+
expect(formElements[1].children[1].children.length).toBe(2);
|
|
1572
|
+
expect(formElements[1].children[1].children[0].component).toBe('ZdText');
|
|
1573
|
+
expect(formElements[1].children[1].children[0].text).toBe('TEKGRID_HELPERVALUE_TODAY');
|
|
1574
|
+
expect(formElements[1].children[1].children[1].component).toBe('ZdText');
|
|
1575
|
+
expect(formElements[1].children[1].children[1].text).toBe('TEKGRID_HELPERVALUE_TOMORROW');
|
|
1576
|
+
expect(formElements[2].name).toBe('grid_filterClick7-filter-OR-NOT_EQUALS-date-1_helperspan');
|
|
1577
|
+
expect(formElements[2].component).toBe('ZdTag');
|
|
1578
|
+
expect(formElements[2].children.length).toBe(2);
|
|
1579
|
+
expect(formElements[2].children[0].name).toBe('grid_filterClick7-filter-OR-NOT_EQUALS-date-1');
|
|
1580
|
+
expect(formElements[2].children[0].component).toBe('ZdDate');
|
|
1581
|
+
expect(formElements[2].children[1].name).toBe('grid_filterClick7-filter-OR-NOT_EQUALS-date-1_helperdropdown');
|
|
1582
|
+
expect(formElements[2].children[1].component).toBe('ZdDropdown');
|
|
1583
|
+
expect(formElements[2].children[1].activator.cssClass).toBe('filter-helper-values-button ');
|
|
1584
|
+
}
|
|
1585
|
+
spy.mockClear();
|
|
1586
|
+
});
|
|
1587
|
+
|
|
1588
|
+
it('should apply helper value', () => {
|
|
1589
|
+
const instance = new TekGrid({
|
|
1590
|
+
name: 'grid_filterClick8',
|
|
1591
|
+
component: 'TekGrid',
|
|
1592
|
+
datasource: {
|
|
1593
|
+
type: 'tek-rest',
|
|
1594
|
+
},
|
|
1595
|
+
columns: [
|
|
1596
|
+
{
|
|
1597
|
+
name: 'date',
|
|
1598
|
+
componentProps: { name: 'date_edit', component: 'ZdDate' },
|
|
1599
|
+
filterProps: {
|
|
1600
|
+
name: 'date_edit',
|
|
1601
|
+
label: 'date',
|
|
1602
|
+
operation: 'NOT_EQUALS',
|
|
1603
|
+
relation: 'OR',
|
|
1604
|
+
helperOptions: [
|
|
1605
|
+
'TODAY',
|
|
1606
|
+
'TOMORROW',
|
|
1607
|
+
],
|
|
1608
|
+
},
|
|
1609
|
+
},
|
|
1610
|
+
],
|
|
1611
|
+
});
|
|
1612
|
+
|
|
1613
|
+
let formElements: any = [];
|
|
1614
|
+
let form: IForm;
|
|
1615
|
+
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1616
|
+
if (modal.children && modal.children.length > 1) {
|
|
1617
|
+
form = modal.children[1] as IForm;
|
|
1618
|
+
formElements = form.children;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
return new Modal(modal);
|
|
1622
|
+
});
|
|
1623
|
+
instance.onCreated();
|
|
1624
|
+
const filterTooltip = instance.toolbarSlot[6];
|
|
1625
|
+
if (filterTooltip && filterTooltip.children && filterTooltip.children.length > 0) {
|
|
1626
|
+
const button = new Button(filterTooltip.children[0]);
|
|
1627
|
+
const event = new Event('click');
|
|
1628
|
+
button.click(event, {} as HTMLElement);
|
|
1629
|
+
const todayHelper = new Text(formElements[0].children[1].children[0]);
|
|
1630
|
+
const dateComp = new Date(formElements[0].children[0]);
|
|
1631
|
+
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => dateComp);
|
|
1632
|
+
todayHelper.click(event, {} as HTMLElement);
|
|
1633
|
+
expect(dateComp.value).toBe(dayjs().format(Config.dateFormat));
|
|
1634
|
+
expect(dateComp.hint).toBe('TEKGRID_HELPERVALUE_TODAY');
|
|
1635
|
+
dateComp.change(event, {} as HTMLElement);
|
|
1636
|
+
expect(dateComp.hint).toBe('');
|
|
1637
|
+
spyMetadata.mockClear();
|
|
1638
|
+
}
|
|
1639
|
+
spy.mockClear();
|
|
1640
|
+
});
|
|
1641
|
+
|
|
1642
|
+
it('should apply helper value on filterProps as an array', () => {
|
|
1643
|
+
const instance = new TekGrid({
|
|
1644
|
+
name: 'grid_filterClick8_1',
|
|
1645
|
+
component: 'TekGrid',
|
|
1646
|
+
datasource: {
|
|
1647
|
+
type: 'tek-rest',
|
|
1648
|
+
},
|
|
1649
|
+
columns: [
|
|
1650
|
+
{
|
|
1651
|
+
name: 'date',
|
|
1652
|
+
componentProps: { name: 'date_edit', component: 'ZdDate' },
|
|
1653
|
+
filterProps: [
|
|
1654
|
+
{
|
|
1655
|
+
name: 'date_edit',
|
|
1656
|
+
label: 'date',
|
|
1657
|
+
helperOptions: [
|
|
1658
|
+
'TODAY',
|
|
1659
|
+
'TOMORROW',
|
|
1660
|
+
],
|
|
1661
|
+
},
|
|
1662
|
+
],
|
|
1663
|
+
},
|
|
1664
|
+
],
|
|
1665
|
+
});
|
|
1666
|
+
|
|
1667
|
+
let formElements: any = [];
|
|
1668
|
+
let form: IForm;
|
|
1669
|
+
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1670
|
+
if (modal.children && modal.children.length > 1) {
|
|
1671
|
+
form = modal.children[1] as IForm;
|
|
1672
|
+
formElements = form.children;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
return new Modal(modal);
|
|
1676
|
+
});
|
|
1677
|
+
instance.onCreated();
|
|
1678
|
+
const filterTooltip = instance.toolbarSlot[6];
|
|
1679
|
+
if (filterTooltip && filterTooltip.children && filterTooltip.children.length > 0) {
|
|
1680
|
+
const button = new Button(filterTooltip.children[0]);
|
|
1681
|
+
const event = new Event('click');
|
|
1682
|
+
button.click(event, {} as HTMLElement);
|
|
1683
|
+
const todayHelper = new Text(formElements[0].children[1].children[0]);
|
|
1684
|
+
const dateComp = new Date(formElements[0].children[0]);
|
|
1685
|
+
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => dateComp);
|
|
1686
|
+
todayHelper.click(event, {} as HTMLElement);
|
|
1687
|
+
expect(dateComp.value).toBe(dayjs().format(Config.dateFormat));
|
|
1688
|
+
expect(dateComp.hint).toBe('TEKGRID_HELPERVALUE_TODAY');
|
|
1689
|
+
dateComp.change(event, {} as HTMLElement);
|
|
1690
|
+
expect(dateComp.hint).toBe('');
|
|
1691
|
+
spyMetadata.mockClear();
|
|
1692
|
+
}
|
|
1693
|
+
spy.mockClear();
|
|
1694
|
+
});
|
|
1695
|
+
|
|
1696
|
+
it('should apply helper value on filterProps as an array', () => {
|
|
1697
|
+
const instance = new TekGrid({
|
|
1698
|
+
name: 'grid_filterClick8_2',
|
|
1699
|
+
component: 'TekGrid',
|
|
1700
|
+
datasource: {
|
|
1701
|
+
type: 'tek-rest',
|
|
1702
|
+
},
|
|
1703
|
+
columns: [
|
|
1704
|
+
{
|
|
1705
|
+
name: 'date',
|
|
1706
|
+
componentProps: { name: 'date_edit', component: 'ZdDate' },
|
|
1707
|
+
filterProps: {
|
|
1708
|
+
name: 'date_edit',
|
|
1709
|
+
label: 'date',
|
|
1710
|
+
helperOptions: [
|
|
1711
|
+
'TODAY',
|
|
1712
|
+
'TOMORROW',
|
|
1713
|
+
],
|
|
1714
|
+
},
|
|
1715
|
+
},
|
|
1716
|
+
],
|
|
1717
|
+
});
|
|
1718
|
+
|
|
1719
|
+
let formElements: any = [];
|
|
1720
|
+
let form: IForm | undefined;
|
|
1721
|
+
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1722
|
+
if (modal.children && modal.children.length > 1) {
|
|
1723
|
+
form = modal.children[1] as IForm;
|
|
1724
|
+
formElements = form.children;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
return new Modal(modal);
|
|
1728
|
+
});
|
|
1729
|
+
instance.onCreated();
|
|
1730
|
+
const filterTooltip = instance.toolbarSlot[6];
|
|
1731
|
+
if (filterTooltip && filterTooltip.children && filterTooltip.children.length > 0) {
|
|
1732
|
+
const button = new Button(filterTooltip.children[0]);
|
|
1733
|
+
const event = new Event('click');
|
|
1734
|
+
button.click(event, {} as HTMLElement);
|
|
1735
|
+
const dateComp = new Date(formElements[0].children[0]);
|
|
1736
|
+
if (form) {
|
|
1737
|
+
const formObj = new Form(form);
|
|
1738
|
+
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => formObj);
|
|
1739
|
+
dateComp.onMounted({} as HTMLElement);
|
|
1740
|
+
expect(formObj.value).toEqual({
|
|
1741
|
+
'grid_filterClick8_2-filter-AND-CONTAINS-date-0': undefined,
|
|
1742
|
+
});
|
|
1743
|
+
spyMetadata.mockClear();
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
spy.mockClear();
|
|
1747
|
+
});
|
|
1748
|
+
|
|
1749
|
+
it('should load form values from tekdatasource', () => {
|
|
1750
|
+
const instance = new TekGrid({
|
|
1751
|
+
name: 'grid_filterClick9',
|
|
1752
|
+
component: 'TekGrid',
|
|
1494
1753
|
datasource: {
|
|
1495
1754
|
type: 'tek-rest',
|
|
1496
1755
|
dynamicFilter: {
|
|
@@ -1507,6 +1766,13 @@ describe('TekGrid', () => {
|
|
|
1507
1766
|
value: '9',
|
|
1508
1767
|
},
|
|
1509
1768
|
],
|
|
1769
|
+
date: [
|
|
1770
|
+
{
|
|
1771
|
+
operation: 'IN',
|
|
1772
|
+
relation: 'OR',
|
|
1773
|
+
value: ['2021-11-12', '2021-12-12'],
|
|
1774
|
+
},
|
|
1775
|
+
],
|
|
1510
1776
|
},
|
|
1511
1777
|
},
|
|
1512
1778
|
columns: [
|
|
@@ -1517,14 +1783,18 @@ describe('TekGrid', () => {
|
|
|
1517
1783
|
{
|
|
1518
1784
|
name: 'name',
|
|
1519
1785
|
componentProps: { name: 'name_edit', component: 'ZdSelect' },
|
|
1520
|
-
filterProps:
|
|
1786
|
+
filterProps: {
|
|
1521
1787
|
name: 'name_edit', label: 'name', operation: 'NOT_EQUALS', relation: 'OR',
|
|
1522
|
-
}
|
|
1788
|
+
},
|
|
1523
1789
|
},
|
|
1524
1790
|
{
|
|
1525
1791
|
name: 'phone',
|
|
1526
1792
|
filterProps: [{ name: 'phone_edit' }],
|
|
1527
1793
|
},
|
|
1794
|
+
{
|
|
1795
|
+
name: 'date',
|
|
1796
|
+
filterProps: { name: 'date_edit', helperValue: 'TODAY' },
|
|
1797
|
+
},
|
|
1528
1798
|
],
|
|
1529
1799
|
});
|
|
1530
1800
|
|
|
@@ -1542,20 +1812,27 @@ describe('TekGrid', () => {
|
|
|
1542
1812
|
const button = new Button(filterTooltip.children[0]);
|
|
1543
1813
|
const event = new Event('click');
|
|
1544
1814
|
button.click(event, {} as HTMLElement);
|
|
1545
|
-
expect(form.name).toBe('
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
'
|
|
1550
|
-
|
|
1551
|
-
|
|
1815
|
+
expect(form.name).toBe('grid_filterClick9-filter-form');
|
|
1816
|
+
if (form) {
|
|
1817
|
+
const formObject = new Form(form);
|
|
1818
|
+
const dateObject = new Date({ name: 'date', component: 'ZdDate' });
|
|
1819
|
+
const spyMetadata = jest.spyOn(Metadata, 'getInstances').mockImplementation(() => [dateObject]);
|
|
1820
|
+
formObject.onMounted({} as HTMLElement);
|
|
1821
|
+
expect(formObject.value).toEqual({
|
|
1822
|
+
'grid_filterClick9-filter-OR-NOT_EQUALS-name-0': 'teste',
|
|
1823
|
+
'grid_filterClick9-filter-AND-CONTAINS-phone-0': '9',
|
|
1824
|
+
'grid_filterClick9-filter-OR-IN-date-0': ['2021-11-12', '2021-12-12'],
|
|
1825
|
+
});
|
|
1826
|
+
expect(dateObject.hint).toBe('TEKGRID_HELPERVALUE_TODAY');
|
|
1827
|
+
spyMetadata.mockClear();
|
|
1828
|
+
}
|
|
1552
1829
|
}
|
|
1553
1830
|
spy.mockClear();
|
|
1554
1831
|
});
|
|
1555
1832
|
|
|
1556
1833
|
it('should load form values from datasource', () => {
|
|
1557
1834
|
const instance = new TekGrid({
|
|
1558
|
-
name: '
|
|
1835
|
+
name: 'grid_filterClick10',
|
|
1559
1836
|
component: 'TekGrid',
|
|
1560
1837
|
datasource: {
|
|
1561
1838
|
filter: {
|
|
@@ -1594,8 +1871,8 @@ describe('TekGrid', () => {
|
|
|
1594
1871
|
const formObject = new Form(form);
|
|
1595
1872
|
formObject.onMounted({} as HTMLElement);
|
|
1596
1873
|
expect(formObject.value).toEqual({
|
|
1597
|
-
'
|
|
1598
|
-
'
|
|
1874
|
+
'grid_filterClick10-filter-AND-CONTAINS-name-0': 'teste',
|
|
1875
|
+
'grid_filterClick10-filter-AND-CONTAINS-phone-0': '9',
|
|
1599
1876
|
});
|
|
1600
1877
|
}
|
|
1601
1878
|
spy.mockClear();
|
|
@@ -1603,7 +1880,7 @@ describe('TekGrid', () => {
|
|
|
1603
1880
|
|
|
1604
1881
|
it('should apply filter from form to tekdatasource', () => {
|
|
1605
1882
|
const instance = new TekGrid({
|
|
1606
|
-
name: '
|
|
1883
|
+
name: 'grid_filterClick11',
|
|
1607
1884
|
component: 'TekGrid',
|
|
1608
1885
|
datasource: {
|
|
1609
1886
|
type: 'tek-rest',
|
|
@@ -1659,11 +1936,11 @@ describe('TekGrid', () => {
|
|
|
1659
1936
|
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => formObject);
|
|
1660
1937
|
const spyDatasourceGet = jest.spyOn(instance.datasource, 'get');
|
|
1661
1938
|
formObject.value = {
|
|
1662
|
-
'
|
|
1663
|
-
'
|
|
1664
|
-
'
|
|
1665
|
-
'
|
|
1666
|
-
'
|
|
1939
|
+
'grid_filterClick11-filter-AND-IN-id-0': ['1', '2', '3'],
|
|
1940
|
+
'grid_filterClick11-filter-OR-NOT_EQUALS-name-0': 'teste',
|
|
1941
|
+
'grid_filterClick11-filter-AND-CONTAINS-phone-0': '',
|
|
1942
|
+
'grid_filterClick11-filter-AND-GREATER_THAN_EQUALS-salary-0': '1000',
|
|
1943
|
+
'grid_filterClick11-filter-AND-LESS_THAN_EQUALS-salary-0': '2000',
|
|
1667
1944
|
};
|
|
1668
1945
|
const applyButtonObject = new Button(applyButton);
|
|
1669
1946
|
formObject.validate = () => false;
|
|
@@ -1712,7 +1989,7 @@ describe('TekGrid', () => {
|
|
|
1712
1989
|
let beforeApplyFilterCalled = false;
|
|
1713
1990
|
let changeLayoutCalled = false;
|
|
1714
1991
|
const instance = new TekGrid({
|
|
1715
|
-
name: '
|
|
1992
|
+
name: 'grid_filterClick12',
|
|
1716
1993
|
component: 'TekGrid',
|
|
1717
1994
|
columns: [
|
|
1718
1995
|
{
|
|
@@ -1759,15 +2036,15 @@ describe('TekGrid', () => {
|
|
|
1759
2036
|
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => formObject);
|
|
1760
2037
|
const spyDatasourceGet = jest.spyOn(instance.datasource, 'get');
|
|
1761
2038
|
formObject.value = {
|
|
1762
|
-
'
|
|
1763
|
-
'
|
|
1764
|
-
'
|
|
1765
|
-
'
|
|
2039
|
+
'grid_filterClick12-filter-AND-CONTAINS-id-0': '1;2;3',
|
|
2040
|
+
'grid_filterClick12-filter-AND-CONTAINS-name-0': 'teste',
|
|
2041
|
+
'grid_filterClick12-filter-AND-CONTAINS-phone-0': '',
|
|
2042
|
+
'grid_filterClick12-filter-AND-CONTAINS-salary-0': '1000',
|
|
1766
2043
|
};
|
|
1767
2044
|
const applyButtonObject = new Button(applyButton);
|
|
1768
2045
|
applyButtonObject.click({ defaultPrevented: true } as Event, {} as HTMLElement);
|
|
1769
2046
|
expect((instance.datasource as TekRestDatasource).filter).toEqual({
|
|
1770
|
-
id: '1;
|
|
2047
|
+
id: '1;2;3',
|
|
1771
2048
|
name: 'teste',
|
|
1772
2049
|
salary: '1000',
|
|
1773
2050
|
});
|
|
@@ -2107,4 +2384,45 @@ describe('TekGrid', () => {
|
|
|
2107
2384
|
expect(groupRowClick).not.toHaveBeenCalled();
|
|
2108
2385
|
});
|
|
2109
2386
|
});
|
|
2387
|
+
|
|
2388
|
+
describe('selectGroupClick', () => {
|
|
2389
|
+
it('should trigger events', async () => {
|
|
2390
|
+
const flushPromises = () => new Promise(setImmediate);
|
|
2391
|
+
const groupSelected = jest.fn();
|
|
2392
|
+
const groupUnselected = jest.fn();
|
|
2393
|
+
|
|
2394
|
+
const data = [
|
|
2395
|
+
{ id: '1', name: 'First', department: 1 },
|
|
2396
|
+
{ id: '2', name: 'Second', department: 1 },
|
|
2397
|
+
{ id: '3', name: 'Third', department: 1 },
|
|
2398
|
+
];
|
|
2399
|
+
const grid = new TekGrid({
|
|
2400
|
+
name: 'grid',
|
|
2401
|
+
component: 'TekGrid',
|
|
2402
|
+
columns: [
|
|
2403
|
+
{ name: 'id' },
|
|
2404
|
+
{ name: 'name' },
|
|
2405
|
+
{ name: 'department', grouped: true },
|
|
2406
|
+
],
|
|
2407
|
+
datasource: {
|
|
2408
|
+
data,
|
|
2409
|
+
},
|
|
2410
|
+
events: {
|
|
2411
|
+
groupSelected,
|
|
2412
|
+
groupUnselected,
|
|
2413
|
+
},
|
|
2414
|
+
});
|
|
2415
|
+
|
|
2416
|
+
await flushPromises();
|
|
2417
|
+
|
|
2418
|
+
const event = new Event('click');
|
|
2419
|
+
const element = document.createElement('div');
|
|
2420
|
+
|
|
2421
|
+
grid.selectGroupClick(grid.groupedData[0], true, event, element);
|
|
2422
|
+
expect(groupSelected).toHaveBeenCalled();
|
|
2423
|
+
|
|
2424
|
+
grid.selectGroupClick(grid.groupedData[0], false, event, element);
|
|
2425
|
+
expect(groupUnselected).toHaveBeenCalled();
|
|
2426
|
+
});
|
|
2427
|
+
});
|
|
2110
2428
|
});
|
|
@@ -61,6 +61,26 @@ describe('LayoutOptions', () => {
|
|
|
61
61
|
{ name: 'id' },
|
|
62
62
|
{ name: 'name' },
|
|
63
63
|
{ name: 'salary' },
|
|
64
|
+
{
|
|
65
|
+
name: 'date1',
|
|
66
|
+
filterProps: {
|
|
67
|
+
name: 'date1-filter',
|
|
68
|
+
helperValue: 'TODAY',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'date2',
|
|
73
|
+
filterProps: [
|
|
74
|
+
{
|
|
75
|
+
name: 'date2-filter1',
|
|
76
|
+
helperValue: 'TODAY',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'date2-filter2',
|
|
80
|
+
helperValue: 'TOMORROW',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
64
84
|
],
|
|
65
85
|
});
|
|
66
86
|
const instance = new TekGridLayoutOptions({ name: 'layout', component: 'TekGridLayoutOptions' });
|
|
@@ -83,6 +103,7 @@ describe('LayoutOptions', () => {
|
|
|
83
103
|
align: 'left',
|
|
84
104
|
groupOpened: undefined,
|
|
85
105
|
label: '',
|
|
106
|
+
filterHelperValue: [],
|
|
86
107
|
},
|
|
87
108
|
{
|
|
88
109
|
name: 'name',
|
|
@@ -95,6 +116,7 @@ describe('LayoutOptions', () => {
|
|
|
95
116
|
align: 'left',
|
|
96
117
|
groupOpened: undefined,
|
|
97
118
|
label: '',
|
|
119
|
+
filterHelperValue: [],
|
|
98
120
|
},
|
|
99
121
|
{
|
|
100
122
|
name: 'salary',
|
|
@@ -107,6 +129,33 @@ describe('LayoutOptions', () => {
|
|
|
107
129
|
align: 'left',
|
|
108
130
|
groupOpened: undefined,
|
|
109
131
|
label: '',
|
|
132
|
+
filterHelperValue: [],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: 'date1',
|
|
136
|
+
isVisible: true,
|
|
137
|
+
fixed: false,
|
|
138
|
+
grouped: false,
|
|
139
|
+
minWidth: '',
|
|
140
|
+
maxWidth: '',
|
|
141
|
+
aggregation: undefined,
|
|
142
|
+
align: 'left',
|
|
143
|
+
groupOpened: undefined,
|
|
144
|
+
label: '',
|
|
145
|
+
filterHelperValue: 'TODAY',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'date2',
|
|
149
|
+
isVisible: true,
|
|
150
|
+
fixed: false,
|
|
151
|
+
grouped: false,
|
|
152
|
+
minWidth: '',
|
|
153
|
+
maxWidth: '',
|
|
154
|
+
aggregation: undefined,
|
|
155
|
+
align: 'left',
|
|
156
|
+
groupOpened: undefined,
|
|
157
|
+
label: '',
|
|
158
|
+
filterHelperValue: ['TODAY', 'TOMORROW'],
|
|
110
159
|
},
|
|
111
160
|
]);
|
|
112
161
|
});
|
|
@@ -136,6 +185,9 @@ describe('LayoutOptions', () => {
|
|
|
136
185
|
align: 'left',
|
|
137
186
|
groupOpened: undefined,
|
|
138
187
|
label: '',
|
|
188
|
+
filterHelperValue: '',
|
|
189
|
+
fixed: undefined,
|
|
190
|
+
grouped: undefined,
|
|
139
191
|
},
|
|
140
192
|
{
|
|
141
193
|
name: 'name',
|
|
@@ -146,6 +198,9 @@ describe('LayoutOptions', () => {
|
|
|
146
198
|
align: 'left',
|
|
147
199
|
groupOpened: undefined,
|
|
148
200
|
label: '',
|
|
201
|
+
filterHelperValue: '',
|
|
202
|
+
fixed: undefined,
|
|
203
|
+
grouped: undefined,
|
|
149
204
|
},
|
|
150
205
|
{
|
|
151
206
|
name: 'salary',
|
|
@@ -156,6 +211,9 @@ describe('LayoutOptions', () => {
|
|
|
156
211
|
align: 'left',
|
|
157
212
|
groupOpened: undefined,
|
|
158
213
|
label: '',
|
|
214
|
+
filterHelperValue: '',
|
|
215
|
+
fixed: undefined,
|
|
216
|
+
grouped: undefined,
|
|
159
217
|
},
|
|
160
218
|
]);
|
|
161
219
|
});
|