@digital-realty/ix-grid 1.3.9 → 1.3.11
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/dist/IxGrid.d.ts +9 -0
- package/dist/IxGrid.js +61 -1
- package/dist/IxGrid.js.map +1 -1
- package/dist/components/IxGridRowFilter.d.ts +2 -0
- package/dist/components/IxGridRowFilter.js +37 -13
- package/dist/components/IxGridRowFilter.js.map +1 -1
- package/dist/components/grid-row-filter-styles.js +7 -1
- package/dist/components/grid-row-filter-styles.js.map +1 -1
- package/dist/ix-grid.min.js +4 -4
- package/dist/test/ix-grid-row-filter.test.js +21 -0
- package/dist/test/ix-grid-row-filter.test.js.map +1 -1
- package/dist/test/ix-grid.test.js +38 -1
- package/dist/test/ix-grid.test.js.map +1 -1
- package/package.json +4 -3
- package/src/IxGrid.ts +79 -1
- package/src/components/IxGridRowFilter.ts +36 -15
- package/src/components/grid-row-filter-styles.ts +7 -1
- package/src/test/ix-grid-row-filter.test.ts +30 -0
- package/src/test/ix-grid.test.ts +60 -1
|
@@ -385,5 +385,35 @@ describe('IxGridRowFilter', () => {
|
|
|
385
385
|
const today = new Date().toISOString().split('T')[0];
|
|
386
386
|
expect(dateInput?.getAttribute('max')).to.equal(today);
|
|
387
387
|
});
|
|
388
|
+
|
|
389
|
+
it('should render ix-date-next if "useNewDatePicker" is true', async () => {
|
|
390
|
+
const columnsWithDataType = [
|
|
391
|
+
{
|
|
392
|
+
name: 'dateField',
|
|
393
|
+
header: 'Date Field',
|
|
394
|
+
filterable: true,
|
|
395
|
+
filterOperators: ['='],
|
|
396
|
+
dataType: 'dateTime',
|
|
397
|
+
},
|
|
398
|
+
];
|
|
399
|
+
|
|
400
|
+
const el = await fixture(
|
|
401
|
+
html`<ix-grid-row-filter
|
|
402
|
+
.columns=${columnsWithDataType}
|
|
403
|
+
.useNewDatePicker=${true}
|
|
404
|
+
></ix-grid-row-filter>`
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
const openMenu = el.shadowRoot?.querySelector(
|
|
408
|
+
'.filter-button'
|
|
409
|
+
) as HTMLElement;
|
|
410
|
+
openMenu?.click();
|
|
411
|
+
await elementUpdated(el);
|
|
412
|
+
|
|
413
|
+
const dateInput = el.shadowRoot?.querySelector(
|
|
414
|
+
'div.filterValueField ix-date-next'
|
|
415
|
+
);
|
|
416
|
+
expect(dateInput).to.exist;
|
|
417
|
+
});
|
|
388
418
|
});
|
|
389
419
|
});
|
package/src/test/ix-grid.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-restricted-globals */
|
|
2
|
-
import { expect, fixture, oneEvent } from '@open-wc/testing';
|
|
2
|
+
import { elementUpdated, expect, fixture, oneEvent } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
+
|
|
4
5
|
import { IxGrid } from '../IxGrid.js';
|
|
5
6
|
import { IxGridRowFilter } from '../components/IxGridRowFilter.js';
|
|
6
7
|
import '../ix-grid-no-rows.js';
|
|
@@ -42,7 +43,13 @@ const columns = [
|
|
|
42
43
|
},
|
|
43
44
|
];
|
|
44
45
|
|
|
46
|
+
const sessionStorageKey = 'test-session-key';
|
|
47
|
+
|
|
45
48
|
describe('IxGrid', () => {
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
sessionStorage.clear();
|
|
51
|
+
});
|
|
52
|
+
|
|
46
53
|
it('renders a grid', async () => {
|
|
47
54
|
const el = await fixture<IxGrid>(html`<ix-grid></ix-grid>`);
|
|
48
55
|
|
|
@@ -87,6 +94,7 @@ describe('IxGrid', () => {
|
|
|
87
94
|
|
|
88
95
|
it('resets pagination upon filter change', async () => {
|
|
89
96
|
const el = await fixture<IxGrid>(html`<ix-grid
|
|
97
|
+
session-storage-key=${sessionStorageKey}
|
|
90
98
|
.columns=${columns}
|
|
91
99
|
.rows=${rows}
|
|
92
100
|
></ix-grid>`);
|
|
@@ -122,8 +130,11 @@ describe('IxGrid', () => {
|
|
|
122
130
|
.columns=${columns}
|
|
123
131
|
.rows=${rows}
|
|
124
132
|
.readParamsFromURL=${true}
|
|
133
|
+
session-storage-key=${sessionStorageKey}
|
|
125
134
|
></ix-grid>`);
|
|
126
135
|
|
|
136
|
+
sessionStorage.removeItem(`urlPageSizeRead`);
|
|
137
|
+
|
|
127
138
|
const url = '?sort=lastName&order=asc&page=2&size=5';
|
|
128
139
|
|
|
129
140
|
history.pushState(null, '', `${location.pathname}${url}`);
|
|
@@ -135,6 +146,52 @@ describe('IxGrid', () => {
|
|
|
135
146
|
expect(el.sortDirection).to.be.eq('asc');
|
|
136
147
|
});
|
|
137
148
|
|
|
149
|
+
it('sessionStorage sets the URL', async () => {
|
|
150
|
+
sessionStorage.setItem(
|
|
151
|
+
`grid-${sessionStorageKey}`,
|
|
152
|
+
JSON.stringify({
|
|
153
|
+
pageSize: 25,
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const el = await fixture<IxGrid>(html`<ix-grid
|
|
158
|
+
.columns=${columns}
|
|
159
|
+
.rows=${rows}
|
|
160
|
+
session-storage-key=${sessionStorageKey}
|
|
161
|
+
></ix-grid>`);
|
|
162
|
+
|
|
163
|
+
await elementUpdated(el);
|
|
164
|
+
|
|
165
|
+
expect(location.href).to.contain('size=25');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('page and page size from URL sets sessionStorage', async () => {
|
|
169
|
+
sessionStorage.setItem(
|
|
170
|
+
`grid-${sessionStorageKey}`,
|
|
171
|
+
JSON.stringify({
|
|
172
|
+
pageSize: 10,
|
|
173
|
+
})
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const el = await fixture<IxGrid>(html`<ix-grid
|
|
177
|
+
.columns=${columns}
|
|
178
|
+
.rows=${rows}
|
|
179
|
+
.readParamsFromURL=${true}
|
|
180
|
+
session-storage-key=${sessionStorageKey}
|
|
181
|
+
></ix-grid>`);
|
|
182
|
+
|
|
183
|
+
const url = '?sort=lastName&order=asc&page=2&size=25';
|
|
184
|
+
|
|
185
|
+
history.pushState(null, '', `${location.pathname}${url}`);
|
|
186
|
+
await elementUpdated(el);
|
|
187
|
+
|
|
188
|
+
const sessionData = JSON.parse(
|
|
189
|
+
sessionStorage.getItem(`grid-${sessionStorageKey}`) || '{}'
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
expect(sessionData.pageSize).to.be.eq(25);
|
|
193
|
+
});
|
|
194
|
+
|
|
138
195
|
it('should set sort, order, page, page size and filters in the URL when addParamsToURL is set to true', async () => {
|
|
139
196
|
const columnsWithFilters = [
|
|
140
197
|
{
|
|
@@ -166,6 +223,7 @@ describe('IxGrid', () => {
|
|
|
166
223
|
const el = await fixture<IxGrid>(html`<ix-grid
|
|
167
224
|
.columns=${columnsWithFilters}
|
|
168
225
|
.addParamsToURL=${true}
|
|
226
|
+
session-storage-key=${sessionStorageKey}
|
|
169
227
|
></ix-grid>`);
|
|
170
228
|
|
|
171
229
|
const rowFilter = el.shadowRoot?.querySelector('ix-grid-row-filter');
|
|
@@ -230,6 +288,7 @@ describe('IxGrid', () => {
|
|
|
230
288
|
.rows=${[]}
|
|
231
289
|
.addParamsToURL=${true}
|
|
232
290
|
.preservedQueryParamKeys=${['userId', 'token']}
|
|
291
|
+
session-storage-key=${sessionStorageKey}
|
|
233
292
|
></ix-grid>
|
|
234
293
|
`);
|
|
235
294
|
|