|
41 | 41 |
|
42 | 42 | <test-fixture id="groups">
|
43 | 43 | <template>
|
44 |
| - <vaadin-grid style="width: 400px; height: 200px;" size="1" column-reordering-allowed> |
45 |
| - <dom-repeat is="dom-repeat" items="[1, 2]" as="colgroup"> |
| 44 | + <vaadin-grid style="width: 800px; height: 200px;" size="1" column-reordering-allowed> |
| 45 | + <dom-repeat is="dom-repeat" items="[1, 2, 3]" as="colgroup"> |
46 | 46 | <template>
|
47 | 47 | <vaadin-grid-column-group>
|
48 | 48 | <template class="header">[[colgroup]]</template>
|
49 | 49 | <template class="footer">[[colgroup]]</template>
|
50 | 50 | <dom-repeat is="dom-repeat" items="[1, 2]" as="col">
|
51 | 51 | <template>
|
52 |
| - <vaadin-grid-column> |
| 52 | + <vaadin-grid-column width="50px" flex-grow="0"> |
53 | 53 | <template class="header">[[colgroup]][[col]]</template>
|
54 | 54 | <template>[[colgroup]][[col]]</template>
|
55 | 55 | <template class="footer">[[colgroup]][[col]]</template>
|
|
358 | 358 | });
|
359 | 359 |
|
360 | 360 | it('should reorder multiple columns while dragging', () => {
|
| 361 | + // Start column order [1, 2, 3, 4] |
| 362 | + |
| 363 | + // Drag column 1 on top of column 2. Expected order [2, 1, 3, 4] |
361 | 364 | dragOver(headerContent[0], headerContent[1]);
|
| 365 | + // Keep dragging the column all the way over to the last column. Expected order [2, 3, 4, 1] |
362 | 366 | dragOver(headerContent[0], headerContent[3]);
|
363 | 367 | flushGrid(grid);
|
364 |
| - expectVisualOrder(grid, [2, 4, 3, 1]); |
| 368 | + expectVisualOrder(grid, [2, 3, 4, 1]); |
| 369 | + }); |
| 370 | + |
| 371 | + it('should shift columns in between when dragged as last', () => { |
| 372 | + // Start column order [1, 2, 3, 4] |
| 373 | + |
| 374 | + // Drag column 2 all the way over to the last column. Expected order [1, 3, 4, 2] |
| 375 | + dragOver(headerContent[1], headerContent[3]); |
| 376 | + flushGrid(grid); |
| 377 | + expectVisualOrder(grid, [1, 3, 4, 2]); |
| 378 | + }); |
| 379 | + |
| 380 | + it('should shift columns in between when dragged as first', () => { |
| 381 | + // Start column order [1, 2, 3, 4] |
| 382 | + |
| 383 | + // Drag column 3 over the very first column. Expected order [3, 1, 2, 4] |
| 384 | + dragOver(headerContent[2], headerContent[0]); |
| 385 | + flushGrid(grid); |
| 386 | + expectVisualOrder(grid, [3, 1, 2, 4]); |
365 | 387 | });
|
366 | 388 |
|
367 | 389 | it('should update first-column attribute', () => {
|
|
516 | 538 | expectVisualOrder(grid, [21, 22, 11, 12]);
|
517 | 539 | });
|
518 | 540 |
|
| 541 | + it('should reorder all the groups', () => { |
| 542 | + // Start order |
| 543 | + // [1, 2, 3 ] <- groups |
| 544 | + // [11, 12, 21, 22, 31, 32] <- columns |
| 545 | + |
| 546 | + // Drag the first group over the last group |
| 547 | + dragAndDropOver(getVisualHeaderCellContent(grid, 0, 0), getVisualHeaderCellContent(grid, 0, 5)); |
| 548 | + |
| 549 | + // Expected order |
| 550 | + // [2, 3, 1 ] <- groups |
| 551 | + // [21, 22, 31, 32, 11, 12] <- columns |
| 552 | + expectVisualOrder(grid, [21, 22, 31, 32, 11, 12]); |
| 553 | + }); |
| 554 | + |
519 | 555 | it('should allow dropping group over other groups column header', () => {
|
520 | 556 | dragAndDropOver(
|
521 | 557 | getVisualHeaderCellContent(grid, 0, 0),
|
|
0 commit comments