From 197d18ffbe50ce65732b77e64daac5e5a66c39c4 Mon Sep 17 00:00:00 2001 From: xinglu01 <15245457817@163.com> Date: Wed, 22 Feb 2023 11:22:23 +0800 Subject: [PATCH 1/3] feat(gantt): support fixed expand icon assign column(#INFR-6568) --- example/src/app/gantt/gantt.component.html | 10 +++++----- .../src/components/table/gantt-table.component.html | 2 +- .../src/components/table/gantt-table.component.ts | 5 +++++ packages/gantt/src/table/gantt-column.component.ts | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/example/src/app/gantt/gantt.component.html b/example/src/app/gantt/gantt.component.html index 876ea075..c7211891 100644 --- a/example/src/app/gantt/gantt.component.html +++ b/example/src/app/gantt/gantt.component.html @@ -45,17 +45,17 @@ (linkDragEnded)="linkDragEnded($event)" > - - {{ item.title }} - - {{ item.start * 1000 | date: 'yyyy-MM-dd' }} + {{ item.start * 1000 | date : 'yyyy-MM-dd' }} + + {{ item.title }} + - {{ item.end * 1000 | date: 'yyyy-MM-dd' }} + {{ item.end * 1000 | date : 'yyyy-MM-dd' }} diff --git a/packages/gantt/src/components/table/gantt-table.component.html b/packages/gantt/src/components/table/gantt-table.component.html index 2c123e59..37e08dc2 100644 --- a/packages/gantt/src/components/table/gantt-table.component.html +++ b/packages/gantt/src/components/table/gantt-table.component.html @@ -83,7 +83,7 @@ [ngTemplateOutletContext]="{ $implicit: item.origin, item: item.origin }" >
-
+
{ + return item.fixedExpandIcon; + }); } @Input() groupTemplate: TemplateRef; diff --git a/packages/gantt/src/table/gantt-column.component.ts b/packages/gantt/src/table/gantt-column.component.ts index 39d8dbd6..bc72b037 100644 --- a/packages/gantt/src/table/gantt-column.component.ts +++ b/packages/gantt/src/table/gantt-column.component.ts @@ -15,6 +15,8 @@ export class NgxGanttTableColumnComponent { @Input() name: string; + @Input() fixedExpandIcon: boolean; + @ContentChild('cell', { static: true }) templateRef: TemplateRef; @ContentChild('header', { static: true }) headerTemplateRef: TemplateRef; From f3fe9b36473b760476b8308cafcfbf75f29d5ebb Mon Sep 17 00:00:00 2001 From: xinglu01 <15245457817@163.com> Date: Wed, 22 Feb 2023 14:49:36 +0800 Subject: [PATCH 2/3] test(gantt): add fixed expand icon test(#INFR-6568) --- .../src/components/table/gantt-table.component.ts | 6 +++--- .../gantt/src/components/table/test/table.spec.ts | 15 ++++++++++++++- packages/gantt/src/test/mocks/data.ts | 14 ++++++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/packages/gantt/src/components/table/gantt-table.component.ts b/packages/gantt/src/components/table/gantt-table.component.ts index f9f5268a..1e9eeb7b 100644 --- a/packages/gantt/src/components/table/gantt-table.component.ts +++ b/packages/gantt/src/components/table/gantt-table.component.ts @@ -51,11 +51,11 @@ export class GanttTableComponent implements OnChanges { if (!column.columnWidth) { column.columnWidth = coerceCssPixelValue(defaultColumnWidth); } + if (column.fixedExpandIcon) { + this.hasFixedExpandIcon = true; + } }); this.columnList = columns; - this.hasFixedExpandIcon = !!this.columnList.toArray().find((item: NgxGanttTableColumnComponent) => { - return item.fixedExpandIcon; - }); } @Input() groupTemplate: TemplateRef; diff --git a/packages/gantt/src/components/table/test/table.spec.ts b/packages/gantt/src/components/table/test/table.spec.ts index 1a1523ac..d0d5ed41 100644 --- a/packages/gantt/src/components/table/test/table.spec.ts +++ b/packages/gantt/src/components/table/test/table.spec.ts @@ -11,7 +11,12 @@ import { GanttMainComponent } from 'ngx-gantt/components/main/gantt-main.compone template: ` - + + + {{ item.start * 1000 | date : 'yyyy-MM-dd' }} + + + {{ item.title }} @@ -34,6 +39,8 @@ export class TestGanttTableComponent { multiple = true; + fixedExpandIcon = true; + constructor() {} } @@ -202,4 +209,10 @@ describe('GanttTable', () => { itemNode.click(); expect(selectionModel.selected.length).toEqual(0); }); + + it('should fixed expand icon column', () => { + const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent)); + const column = ganttTable.queryAll(By.css('.gantt-table-item'))[0].queryAll(By.css('.gantt-table-column'))[1]; + expect(column.nativeElement.querySelector('.gantt-expand-icon').classList.contains('gantt-expand-icon')).toBeTrue(); + }); }); diff --git a/packages/gantt/src/test/mocks/data.ts b/packages/gantt/src/test/mocks/data.ts index 33e65d7a..21c92029 100644 --- a/packages/gantt/src/test/mocks/data.ts +++ b/packages/gantt/src/test/mocks/data.ts @@ -165,9 +165,19 @@ export function getMockGroupItems() { id: 'item-child-0101', title: 'VERSION Children 0101', start: new GanttDate('2020-05-21 12:34:35').getUnixTime(), - group_id: '00001', + group_id: 'item-0101', color: '#FF0000', - linkable: false + linkable: false, + children: [ + { + id: 'item-child-010101', + title: 'VERSION Children 010101', + start: new GanttDate('2020-05-21 12:34:35').getUnixTime(), + group_id: 'item-child-0101', + color: '#FF0000', + linkable: false + } + ] } ] }, From 4ce71848ac1775881c125a29086a6a627982f9df Mon Sep 17 00:00:00 2001 From: xinglu01 <15245457817@163.com> Date: Wed, 22 Feb 2023 15:55:17 +0800 Subject: [PATCH 3/3] test(gantt): add fixed expand icon test(#INFR-6568) --- packages/gantt/src/components/table/gantt-table.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/gantt/src/components/table/gantt-table.component.ts b/packages/gantt/src/components/table/gantt-table.component.ts index 1e9eeb7b..5bc62015 100644 --- a/packages/gantt/src/components/table/gantt-table.component.ts +++ b/packages/gantt/src/components/table/gantt-table.component.ts @@ -47,6 +47,7 @@ export class GanttTableComponent implements OnChanges { @Input() set columns(columns: QueryList) { + this.hasFixedExpandIcon = false; columns.forEach((column) => { if (!column.columnWidth) { column.columnWidth = coerceCssPixelValue(defaultColumnWidth);