Skip to content

Commit

Permalink
fix: add class in GanttGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
HandsomeButterball committed Jan 4, 2021
1 parent cf0d647 commit a32dd04
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
3 changes: 2 additions & 1 deletion example/src/app/gantt/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export const mockGroups = [
{
id: '00001',
title: 'Project 1'
title: 'Project 1',
class: 'test'
},
{
id: '00002',
Expand Down
3 changes: 3 additions & 0 deletions packages/gantt/src/class/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface GanttGroup<T = unknown> {
title: string;
expanded?: boolean;
origin?: T;
class?: string;
}

export class GanttGroupInternal {
Expand All @@ -17,13 +18,15 @@ export class GanttGroupInternal {
refs?: {
height?: number;
} = {};
class?: string;
constructor(group: GanttGroup) {
this.id = group.id;
this.origin = group;
this.title = group.title;
this.expanded = group.expanded === undefined ? true : group.expanded;
this.items = [];
this.mergedItems = [[]];
this.class = group.class || '';
}

setExpand(expanded: boolean) {
Expand Down
15 changes: 3 additions & 12 deletions packages/gantt/src/components/main/gantt-main.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<gantt-links-overlay
[groups]="groups"
[items]="items"
(lineClick)="lineClick.emit($event)"
></gantt-links-overlay>
<gantt-links-overlay [groups]="groups" [items]="items" (lineClick)="lineClick.emit($event)"></gantt-links-overlay>
<!-- groups -->
<div class="gantt-main-groups" *ngIf="groups && groups.length > 0; else itemsTemplate" [style.width.px]="ganttUpper.view.width">
<ng-container *ngFor="let group of groups; trackBy: trackBy">
<div class="gantt-group">
<div class="gantt-group" [ngClass]="group.class">
<ng-template [ngTemplateOutlet]="groupHeaderTemplate" [ngTemplateOutletContext]="{ group: group }"></ng-template>
</div>
<div *ngIf="group.expanded" class="gantt-items">
Expand All @@ -28,12 +24,7 @@
<ng-template [ngTemplateOutlet]="itemTemplate" [ngTemplateOutletContext]="{ item: item.origin, refs: item.refs }"></ng-template>
</ng-container>
<gantt-range *ngIf="item.type | isGanttRangeItem" [template]="rangeTemplate" [item]="item"></gantt-range>
<gantt-bar
*ngIf="item.type | isGanttBarItem"
[item]="item"
[template]="barTemplate"
(barClick)="barClick.emit($event)"
></gantt-bar>
<gantt-bar *ngIf="item.type | isGanttBarItem" [item]="item" [template]="barTemplate" (barClick)="barClick.emit($event)"></gantt-bar>
</div>
<ng-template
*ngIf="item.children && item.expanded"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="gantt-table-body">
<ng-container *ngIf="groups && groups.length > 0; else itemsTemplate">
<ng-container *ngFor="let group of groups">
<div class="gantt-table-group">
<div class="gantt-table-group" [ngClass]="group.class">
<div class="gantt-table-group-title" [class.expanded]="group.expanded" (click)="expandGroup(group)">
<gantt-icon class="expand-icon" [iconName]="group.expanded ? 'angle-down' : 'angle-right'"></gantt-icon>
<ng-container *ngIf="groupTemplate; else default">
Expand Down
4 changes: 1 addition & 3 deletions packages/gantt/src/flat/gantt-flat.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<ngx-gantt-root [sideWidth]="300">
<ng-template #sideTemplate>
<div class="gantt-flat-side-header">
项目
</div>
<div class="gantt-flat-side-header">项目</div>
<div class="gantt-flat-side-body">
<div class="gantt-group" *ngFor="let group of groups; trackBy: trackBy">
<div class="gantt-group-title" [class.expanded]="group.expanded" (click)="group.expanded = !group.expanded">
Expand Down

0 comments on commit a32dd04

Please sign in to comment.