Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gantt): support fixed expand icon assign column #INFR-6568 @zhangwen (#INFR-6568) #307

Merged
merged 3 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions example/src/app/gantt/gantt.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@
(linkDragEnded)="linkDragEnded($event)"
>
<ngx-gantt-table>
<ngx-gantt-column name="标题" width="180px">
<ng-template #cell let-item="item"> {{ item.title }} </ng-template>
</ngx-gantt-column>
<ngx-gantt-column name="开始时间" width="140px">
<ng-template #cell let-item="item">
{{ item.start * 1000 | date: 'yyyy-MM-dd' }}
{{ item.start * 1000 | date : 'yyyy-MM-dd' }}
</ng-template>
</ngx-gantt-column>
<ngx-gantt-column name="标题" width="180px" [fixedExpandIcon]="true">
<ng-template #cell let-item="item"> {{ item.title }} </ng-template>
</ngx-gantt-column>
<ngx-gantt-column name="截止时间" width="140px">
<ng-template #cell let-item="item">
{{ item.end * 1000 | date: 'yyyy-MM-dd' }}
{{ item.end * 1000 | date : 'yyyy-MM-dd' }}
</ng-template>
</ngx-gantt-column>
</ngx-gantt-table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
[ngTemplateOutletContext]="{ $implicit: item.origin, item: item.origin }"
></ng-template>
<div class="gantt-table-column" *ngFor="let column of columnList; let first = first" [style.width]="column.columnWidth">
<div *ngIf="first" class="gantt-expand-icon" [style.marginLeft.px]="level * 20">
<div *ngIf="column?.fixedExpandIcon || (!hasFixedExpandIcon && first)" class="gantt-expand-icon" [style.marginLeft.px]="level * 20">
<ng-container *ngIf="level < gantt.maxLevel - 1 && item.expandable">
<gantt-icon
*ngIf="!item.loading"
Expand Down
5 changes: 5 additions & 0 deletions packages/gantt/src/components/table/gantt-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class GanttTableComponent implements OnChanges {

public dragStartLeft: number;

public hasFixedExpandIcon = false;

@Input() groups: GanttGroupInternal[];

@Input() items: GanttItemInternal[];
Expand All @@ -51,6 +53,9 @@ export class GanttTableComponent implements OnChanges {
}
});
this.columnList = columns;
this.hasFixedExpandIcon = !!this.columnList.toArray().find((item: NgxGanttTableColumnComponent) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasFixedExpandIcon 是不是可以在 forEach 里就可以判断了,这样就不用再 find 一下了

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有,补充下测试吧

return item.fixedExpandIcon;
});
}

@Input() groupTemplate: TemplateRef<any>;
Expand Down
2 changes: 2 additions & 0 deletions packages/gantt/src/table/gantt-column.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class NgxGanttTableColumnComponent {

@Input() name: string;

@Input() fixedExpandIcon: boolean;

@ContentChild('cell', { static: true }) templateRef: TemplateRef<any>;

@ContentChild('header', { static: true }) headerTemplateRef: TemplateRef<any>;
Expand Down