Skip to content

Commit

Permalink
fix(links): build links when change view type
Browse files Browse the repository at this point in the history
  • Loading branch information
HandsomeButterball authored and walkerkay committed Jun 20, 2020
1 parent 5ef8441 commit 3f5655f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/gantt/src/components/links/links.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export class GanttLinksComponent implements OnInit, OnDestroy {
}

buildLinks() {
console.log(1);
this.computeItemPosition();
this.links = [];
this.linkItems.forEach((source) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/gantt/src/components/main/gantt-main.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class GanttMainComponent implements OnInit {

@Output() lineClick = new EventEmitter<GanttLineClickEvent>();

@ViewChild(GanttLinksComponent, { static: false, }) links: GanttLinksComponent;

@HostBinding('class.gantt-main-container') ganttMainClass = true;

constructor(@Inject(GANTT_REF_TOKEN) public ganttRef: GanttRef) {}
Expand Down
1 change: 1 addition & 0 deletions packages/gantt/src/gantt-upper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { Subject } from 'rxjs';
import { GanttCalendarComponent } from './components/calendar/calendar.component';
import { uniqBy } from './utils/helpers';


export abstract class GanttUpper {
@Input('items') originItems: GanttItem[] = [];

Expand Down
11 changes: 10 additions & 1 deletion packages/gantt/src/gantt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
TemplateRef,
ContentChildren,
QueryList,
AfterViewInit
AfterViewInit,
ViewChild
} from '@angular/core';
import { startWith, takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
Expand All @@ -27,6 +28,7 @@ import { GanttDragContainer } from './gantt-drag-container';
import { NgxGanttTableColumnComponent } from './table/gantt-column.component';
import { sideWidth } from './gantt.styles';
import { getColumnWidthConfig } from './utils/column-compute';
import { GanttMainComponent } from './components/main/gantt-main.component';

@Component({
selector: 'ngx-gantt',
Expand Down Expand Up @@ -60,6 +62,8 @@ export class NgxGanttComponent extends GanttUpper implements GanttRef, OnInit, A

@ContentChildren(NgxGanttTableColumnComponent, { descendants: true }) columns: QueryList<NgxGanttTableColumnComponent>;

@ViewChild(GanttMainComponent, { static: false }) mainContent: GanttMainComponent;

constructor(
elementRef: ElementRef<HTMLElement>,
cdr: ChangeDetectorRef,
Expand Down Expand Up @@ -111,6 +115,11 @@ export class NgxGanttComponent extends GanttUpper implements GanttRef, OnInit, A

ngOnChanges(changes: SimpleChanges) {
super.onChanges(changes);
if (!this.firstChange) {
if (changes.viewType && changes.viewType.currentValue) {
this.mainContent.links.buildLinks();
}
}
}

computeRefs() {
Expand Down

0 comments on commit 3f5655f

Please sign in to comment.