From 7b78a884669e17d4ae5d162cbf632f8d16c328af Mon Sep 17 00:00:00 2001 From: Aleksander Sklorz Date: Tue, 28 Nov 2023 08:13:16 +0100 Subject: [PATCH 1/6] ACS-6323 Added draggable field to DocumentListPresetRef --- lib/extensions/src/lib/config/document-list.extensions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/extensions/src/lib/config/document-list.extensions.ts b/lib/extensions/src/lib/config/document-list.extensions.ts index 635da5b1ce7..2a8590b9df2 100644 --- a/lib/extensions/src/lib/config/document-list.extensions.ts +++ b/lib/extensions/src/lib/config/document-list.extensions.ts @@ -49,4 +49,5 @@ export interface DocumentListPresetRef extends ExtensionElement { [key: string]: string; visible?: string; }; + draggable?: boolean; } From 8e7441a30b260b55d9ab3dd126a45e5d73ab51f1 Mon Sep 17 00:00:00 2001 From: Aleksander Sklorz Date: Wed, 29 Nov 2023 12:30:51 +0100 Subject: [PATCH 2/6] ACS-6323 Allow to dragging column over columns in index range --- .../datatable/components/datatable/datatable.component.html | 1 + .../datatable/components/datatable/datatable.component.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.html b/lib/core/src/lib/datatable/components/datatable/datatable.component.html index 0adf2b8551e..a3069b2874c 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.html +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.html @@ -10,6 +10,7 @@ 0 && index < drop.getSortedItems().length; + } + private updateColumnsWidths(): void { const allColumns = this.data.getColumns(); From 134b91d0b590609f63a8db4807615ffb24a3fcf2 Mon Sep 17 00:00:00 2001 From: Aleksander Sklorz Date: Wed, 29 Nov 2023 14:42:15 +0100 Subject: [PATCH 3/6] ACS-6323 Allow to dragging column over only enabled columns --- .../lib/datatable/components/datatable/datatable.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.ts b/lib/core/src/lib/datatable/components/datatable/datatable.component.ts index e15a101ee77..391a60a9dc3 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.ts +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.ts @@ -976,7 +976,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges, } sortPredicate(index: number, _drag: CdkDrag, drop: CdkDropList): boolean { - return index > 0 && index < drop.getSortedItems().length; + return !drop.getSortedItems()[index].disabled; } private updateColumnsWidths(): void { From 4691ae703d870ba1af68883c3341fa64ab6f7eaa Mon Sep 17 00:00:00 2001 From: Aleksander Sklorz Date: Wed, 6 Dec 2023 11:30:35 +0100 Subject: [PATCH 4/6] ACS-6323 Fixed styles for drag and drop icon for first column --- .../lib/datatable/components/datatable/datatable.component.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.scss b/lib/core/src/lib/datatable/components/datatable/datatable.component.scss index 8fb3bfd37ad..19400dd3996 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.scss +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.scss @@ -386,7 +386,7 @@ $data-table-cell-min-width-file-size: $data-table-cell-min-width !default; min-height: inherit; &:first-child { - padding-left: 15px; + margin-left: 15px; box-sizing: content-box; } From 4464b85f5e85e601eef461163f8c3c0ba9bcdb91 Mon Sep 17 00:00:00 2001 From: Aleksander Sklorz Date: Thu, 7 Dec 2023 15:49:45 +0100 Subject: [PATCH 5/6] ACS-6323 Unit tests and function renaming --- .../datatable/datatable.component.html | 2 +- .../datatable/datatable.component.spec.ts | 35 ++++++++++++++++++- .../datatable/datatable.component.ts | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.html b/lib/core/src/lib/datatable/components/datatable/datatable.component.html index a3069b2874c..a97c6427796 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.html +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.html @@ -10,7 +10,7 @@ { describe('Header modes', () => { const newData = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]); const emptyData = new ObjectDataTableAdapter(); + const getDropList = (): CdkDropList => { + dataTable.showHeader = ShowHeaderMode.Data; + dataTable.loading = false; + dataTable.data = newData; + fixture.detectChanges(); + return fixture.debugElement.query(By.directive(CdkDropList)).injector.get(CdkDropList); + }; it('should show the header if showHeader is `Data` and there is data', () => { dataTable.showHeader = ShowHeaderMode.Data; @@ -285,6 +292,32 @@ describe('DataTable', () => { dataTable.loading = true; testNotShownHeader(emptyData); }); + + it('should have assigned filterDisabledColumns to sortPredicate of CdkDropList', () => { + expect(getDropList().sortPredicate).toBeDefined(); + }); + + it('should sortPredicate from CdkDropList return true if column is enabled', () => { + const dropList = getDropList(); + spyOn(dropList, 'getSortedItems').and.returnValue([{ + disabled: true + }, { + disabled: false + }] as CdkDrag[]); + + expect(dropList.sortPredicate(1, undefined, dropList)).toBeTrue(); + }); + + it('should sortPredicate from CdkDropList return false if column is disabled', () => { + const dropList = getDropList(); + spyOn(dropList, 'getSortedItems').and.returnValue([{ + disabled: true + }, { + disabled: true + }] as CdkDrag[]); + + expect(dropList.sortPredicate(1, undefined, dropList)).toBeFalse(); + }); }); it('should emit "sorting-changed" DOM event', (done) => { diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.ts b/lib/core/src/lib/datatable/components/datatable/datatable.component.ts index 391a60a9dc3..b76d6ec6858 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.ts +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.ts @@ -975,7 +975,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges, return `0 1 ${width < DataTableComponent.MINIMUM_COLUMN_SIZE ? DataTableComponent.MINIMUM_COLUMN_SIZE : width}px`; } - sortPredicate(index: number, _drag: CdkDrag, drop: CdkDropList): boolean { + filterDisabledColumns(index: number, _drag: CdkDrag, drop: CdkDropList): boolean { return !drop.getSortedItems()[index].disabled; } From 4d81773ec96ded8c36743d3f24703a7fc9c4ee2e Mon Sep 17 00:00:00 2001 From: Aleksander Sklorz Date: Thu, 7 Dec 2023 15:54:31 +0100 Subject: [PATCH 6/6] ACS-6323 Corrected unit test --- .../datatable/components/datatable/datatable.component.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.spec.ts b/lib/core/src/lib/datatable/components/datatable/datatable.component.spec.ts index 17c5ae6f1dd..baa2c4a1033 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.spec.ts +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.spec.ts @@ -294,7 +294,7 @@ describe('DataTable', () => { }); it('should have assigned filterDisabledColumns to sortPredicate of CdkDropList', () => { - expect(getDropList().sortPredicate).toBeDefined(); + expect(getDropList().sortPredicate).toBe(dataTable.filterDisabledColumns); }); it('should sortPredicate from CdkDropList return true if column is enabled', () => {