UNPKG

ng-gantt-extended

Version:

Angular Gantt Editor (wrapper for [jsgantt-improved](https://github.com/jsGanttImproved/jsgantt-improved)). View/Edit Gantt file with formatting.

126 lines (120 loc) 4.78 kB
import { Component, ViewChild, Input, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { __assign } from 'tslib'; import { GanttChart } from 'jsgantt-improved'; var GanttEditorOptions = /** @class */ (function () { // public onEditable: (node: GanttEditorTreeNode | {}) => boolean | { field: boolean, value: boolean }; // public theme: Number; // public language: String; // public languages: Object; function GanttEditorOptions() { // this.escapeUnicode = false; // this.sortObjectKeys = false; // this.history = true; } return GanttEditorOptions; }()); var GanttEditorComponent = /** @class */ (function () { function GanttEditorComponent() { 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"; } Object.defineProperty(GanttEditorComponent.prototype, "data", { set: function (value) { this._data = value; if (this.editor) { this.destroy(); this.ngOnInit(); } }, enumerable: false, configurable: true }); GanttEditorComponent.prototype.ngOnInit = function () { var optionsBefore = this.options; if (!this.optionsChanged && this.editor) { optionsBefore = this.editor.options; } // document.getElementById('embedded-Gantt') var g = (this.editor = new GanttChart(this.ganttEditorContainer.nativeElement, this.format)); if (g.getDivId() != null) { // JSGantt.parseJSON('./fixes/data.json', g); g.setOptions(__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(function (row) { row.pGantt = g; g.AddTaskItemObject(row); }); } g.Draw(); } }; // public get(): JSON { // return this.editor.get(); // } GanttEditorComponent.prototype.setOptions = function (newOptions) { if (this.editor) { this.destroy(); } this.optionsChanged = true; this.options = newOptions; this.ngOnInit(); }; GanttEditorComponent.prototype.addLang = function (lang, option) { if (this.editor) { var g = this.editor; g.addLang(lang, option); } }; GanttEditorComponent.prototype.destroy = function () { // this.editor.destroy(); }; GanttEditorComponent.prototype.getEditor = function () { 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 = function () { return []; }; GanttEditorComponent.propDecorators = { ganttEditorContainer: [{ type: ViewChild, args: ["ganttEditorContainer", { static: true },] }], options: [{ type: Input }], format: [{ type: Input }], data: [{ type: Input, args: ["data",] }] }; return GanttEditorComponent; }()); var NgGanttEditorModule = /** @class */ (function () { function NgGanttEditorModule() { } NgGanttEditorModule.forRoot = function () { return { ngModule: NgGanttEditorModule, providers: [], }; }; NgGanttEditorModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule], declarations: [GanttEditorComponent], exports: [GanttEditorComponent], },] } ]; return NgGanttEditorModule; }()); /** * Generated bundle index. Do not edit. */ export { GanttEditorComponent, GanttEditorOptions, NgGanttEditorModule }; //# sourceMappingURL=ng-gantt-extended.js.map