ng-gantt-extended
Version:
Angular Gantt Editor (wrapper for [jsgantt-improved](https://github.com/jsGanttImproved/jsgantt-improved)). View/Edit Gantt file with formatting.
116 lines (110 loc) • 3.96 kB
JavaScript
import { Component, ViewChild, Input, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GanttChart } from 'jsgantt-improved';
class GanttEditorOptions {
// public onEditable: (node: GanttEditorTreeNode | {}) => boolean | { field: boolean, value: boolean };
// public theme: Number;
// public language: String;
// public languages: Object;
constructor() {
// this.escapeUnicode = false;
// this.sortObjectKeys = false;
// this.history = true;
}
}
class GanttEditorComponent {
constructor() {
this.id = "anggantteditor" + Math.floor(Math.random() * 1000000);
this.optionsChanged = false;
this.formats = ["Hour", "Day", "Week", "Month", "Quarter"];
this.showQueryBuilder = false;
this.query = null;
this.options = new GanttEditorOptions();
this.format = "week";
}
set data(value) {
this._data = value;
if (this.editor) {
this.destroy();
this.ngOnInit();
}
}
ngOnInit() {
let optionsBefore = this.options;
if (!this.optionsChanged && this.editor) {
optionsBefore = this.editor.options;
}
// document.getElementById('embedded-Gantt')
const g = (this.editor = new GanttChart(this.ganttEditorContainer.nativeElement, this.format));
if (g.getDivId() != null) {
// JSGantt.parseJSON('./fixes/data.json', g);
g.setOptions(Object.assign({ vCaptionType: "Complete", vQuarterColWidth: 36, vDateTaskDisplayFormat: "day dd month yyyy", vDayMajorDateDisplayFormat: "mon yyyy - Week ww", vWeekMinorDateDisplayFormat: "dd mon", vShowTaskInfoLink: 1, vShowEndWeekDate: 0, vUseSingleCell: 10000,
// Even with setUseSingleCell using Hour format on such a large chart can cause issues in some browsers
vFormatArr: this.formats.slice(1) }, optionsBefore));
if (this._data && this._data.forEach) {
this._data.forEach((row) => {
row.pGantt = g;
g.AddTaskItemObject(row);
});
}
g.Draw();
}
}
// public get(): JSON {
// return this.editor.get();
// }
setOptions(newOptions) {
if (this.editor) {
this.destroy();
}
this.optionsChanged = true;
this.options = newOptions;
this.ngOnInit();
}
addLang(lang, option) {
if (this.editor) {
const g = this.editor;
g.addLang(lang, option);
}
}
destroy() {
// this.editor.destroy();
}
getEditor() {
return this.editor;
}
}
GanttEditorComponent.decorators = [
{ type: Component, args: [{
// tslint:disable-next-line:component-selector
selector: "ng-gantt",
template: '<div [id]="id" #ganttEditorContainer></div>'
},] }
];
GanttEditorComponent.ctorParameters = () => [];
GanttEditorComponent.propDecorators = {
ganttEditorContainer: [{ type: ViewChild, args: ["ganttEditorContainer", { static: true },] }],
options: [{ type: Input }],
format: [{ type: Input }],
data: [{ type: Input, args: ["data",] }]
};
class NgGanttEditorModule {
static forRoot() {
return {
ngModule: NgGanttEditorModule,
providers: [],
};
}
}
NgGanttEditorModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
declarations: [GanttEditorComponent],
exports: [GanttEditorComponent],
},] }
];
/**
* Generated bundle index. Do not edit.
*/
export { GanttEditorComponent, GanttEditorOptions, NgGanttEditorModule };
//# sourceMappingURL=ng-gantt-extended.js.map