ng2-gantt
Version:
Angular 2 Gantt
93 lines (78 loc) • 2.56 kB
text/typescript
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { NgStyle } from '@angular/common';
import { GanttService } from './shared/services/gantt.service';
import { IGanttOptions, Project } from './shared/interfaces';
export class GanttComponent implements OnInit {
private _project: Project;
private _options: IGanttOptions;
//TODO(dale): this may be causing an issue in the tree builder?
set project(project: any) {
if (project) {
this._project = project;
} else {
this.setDefaultProject();
}
}
get project() { return this._project };
set options(options: any) {
if (options.scale) {
this._options = options;
} else {
this.setDefaultOptions();
}
}
get options() { return this._options };
onGridRowClick: EventEmitter<any> = new EventEmitter<any>();
private ganttContainerWidth: number;
constructor(private ganttService: GanttService) { }
ngOnInit() {
}
setSizes(): void {
this.ganttContainerWidth = this.ganttService.calculateContainerWidth();
}
setDefaultOptions() {
var scale = this.ganttService.calculateGridScale(this._project.tasks);
this._options = {
scale: scale
}
}
setDefaultProject() {
this._project = {
id: '',
name: '',
startDate: null,
tasks: []
}
}
gridRowClicked(task:any) {
this.onGridRowClick.emit(task);
}
onResize($event: any): void {
this.setSizes();
}
}