devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
878 lines (877 loc) • 61.8 kB
JavaScript
/**
* DevExtreme (cjs/__internal/ui/gantt/ui.gantt.js)
* Version: 25.2.7
* Build date: Tue May 05 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _m_utils = _interopRequireDefault(require("../../../__internal/grids/grid_core/m_utils"));
var _component_registrator = _interopRequireDefault(require("../../../core/component_registrator"));
var _renderer = _interopRequireDefault(require("../../../core/renderer"));
var _data = require("../../../core/utils/data");
var _extend = require("../../../core/utils/extend");
var _size = require("../../../core/utils/size");
var _type = require("../../../core/utils/type");
var _window = require("../../../core/utils/window");
var _splitter_control = _interopRequireDefault(require("../../../ui/splitter_control"));
var _widget = _interopRequireDefault(require("../../core/widget/widget"));
var _uiGantt = require("../../ui/gantt/ui.gantt.actions");
var _uiGantt2 = require("../../ui/gantt/ui.gantt.bars");
var _uiGantt3 = require("../../ui/gantt/ui.gantt.custom_fields");
var _uiGanttData = _interopRequireDefault(require("../../ui/gantt/ui.gantt.data.option"));
var _uiGantt4 = require("../../ui/gantt/ui.gantt.data_changes_processing_helper");
var _uiGantt5 = require("../../ui/gantt/ui.gantt.dialogs");
var _uiGantt6 = require("../../ui/gantt/ui.gantt.export_helper");
var _uiGantt7 = require("../../ui/gantt/ui.gantt.helper");
var _uiGantt8 = require("../../ui/gantt/ui.gantt.mapping_helper");
var _uiGantt9 = require("../../ui/gantt/ui.gantt.model_changes_listener");
var _uiGantt0 = require("../../ui/gantt/ui.gantt.size_helper");
var _uiGantt1 = require("../../ui/gantt/ui.gantt.templates");
var _uiGantt10 = require("../../ui/gantt/ui.gantt.treelist");
var _uiGantt11 = require("../../ui/gantt/ui.gantt.view");
var _load_panel = _interopRequireDefault(require("../../ui/load_panel"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
const window = (0, _window.getWindow)();
const GANTT_CLASS = "dx-gantt";
const GANTT_VIEW_CLASS = "dx-gantt-view";
const GANTT_TREE_LIST_WRAPPER = "dx-gantt-treelist-wrapper";
const GANTT_TOOLBAR_WRAPPER = "dx-gantt-toolbar-wrapper";
const GANTT_MAIN_WRAPPER = "dx-gantt-main-wrapper";
const GANTT_TASKS = "tasks";
const GANTT_DEPENDENCIES = "dependencies";
const GANTT_RESOURCES = "resources";
const GANTT_RESOURCE_ASSIGNMENTS = "resourceAssignments";
const GANTT_NEW_TASK_CACHE_KEY = "gantt_new_task_key";
class Gantt extends _widget.default {
_init() {
super._init();
_m_utils.default.logHeaderFilterDeprecatedWarningIfNeed(this);
this._initGantt();
this._isGanttRendered = false;
this._initHelpers()
}
_initGantt() {
this._refreshDataSources()
}
_initMarkup() {
super._initMarkup();
this.$element().addClass("dx-gantt");
this._$toolbarWrapper = (0, _renderer.default)("<div>").addClass(GANTT_TOOLBAR_WRAPPER).appendTo(this.$element());
this._$toolbar = (0, _renderer.default)("<div>").appendTo(this._$toolbarWrapper);
this._$mainWrapper = (0, _renderer.default)("<div>").addClass(GANTT_MAIN_WRAPPER).appendTo(this.$element());
this._$treeListWrapper = (0, _renderer.default)("<div>").addClass(GANTT_TREE_LIST_WRAPPER).appendTo(this._$mainWrapper);
this._$treeList = (0, _renderer.default)("<div>").appendTo(this._$treeListWrapper);
this._$splitter = (0, _renderer.default)("<div>").appendTo(this._$mainWrapper);
this._$ganttView = (0, _renderer.default)("<div>").addClass("dx-gantt-view").appendTo(this._$mainWrapper);
this._$dialog = (0, _renderer.default)("<div>").appendTo(this.$element());
this._$loadPanel = (0, _renderer.default)("<div>").appendTo(this.$element());
this._$contextMenu = (0, _renderer.default)("<div>").appendTo(this.$element())
}
_clean() {
var _this$_ganttView, _this$_ganttView2;
this._savedGanttViewState = null === (_this$_ganttView = this._ganttView) || void 0 === _this$_ganttView ? void 0 : _this$_ganttView.getVisualStateToRestore();
null === (_this$_ganttView2 = this._ganttView) || void 0 === _this$_ganttView2 || _this$_ganttView2._ganttViewCore.cleanMarkup();
delete this._ganttView;
delete this._dialogInstance;
delete this._loadPanel;
delete this._exportHelper;
super._clean()
}
_refresh() {
this._isGanttRendered = false;
this._contentReadyRaised = false;
super._refresh()
}
_fireContentReadyAction() {
if (!this._contentReadyRaised) {
super._fireContentReadyAction()
}
this._contentReadyRaised = true
}
_dimensionChanged() {
var _this$_ganttView3;
null === (_this$_ganttView3 = this._ganttView) || void 0 === _this$_ganttView3 || _this$_ganttView3._onDimensionChanged()
}
_visibilityChanged(visible) {
if (visible) {
this._refreshGantt()
}
}
_refreshGantt() {
this._refreshDataSources();
setTimeout(() => this._refresh())
}
_refreshDataSources() {
this._refreshDataSource("tasks");
this._refreshDataSource("dependencies");
this._refreshDataSource("resources");
this._refreshDataSource("resourceAssignments")
}
_renderContent() {
this._isMainElementVisible = this.$element().is(":visible");
if (this._isMainElementVisible && !this._isGanttRendered) {
this._isGanttRendered = true;
this._renderBars();
this._renderTreeList();
this._renderSplitter()
}
}
_renderTreeList() {
this._ganttTreeList = new _uiGantt10.GanttTreeList(this);
this._treeList = this._ganttTreeList.getTreeList();
this._ganttTreeList.onAfterTreeListCreate()
}
_renderSplitter() {
this._splitter = this._createComponent(this._$splitter, _splitter_control.default, {
container: this.$element(),
leftElement: this._$treeListWrapper,
rightElement: this._$ganttView,
onApplyPanelSize: e => {
var _this$_sizeHelper;
null === (_this$_sizeHelper = this._sizeHelper) || void 0 === _this$_sizeHelper || _this$_sizeHelper.onApplyPanelSize(e)
}
});
const {
taskListWidth: taskListWidth
} = this.option();
this._splitter.option("initialLeftPanelWidth", taskListWidth)
}
_renderBars() {
this._bars = [];
this._toolbar = new _uiGantt2.GanttToolbar(this._$toolbar, this);
this._updateToolbarContent();
this._bars.push(this._toolbar);
this._contextMenuBar = new _uiGantt2.GanttContextMenuBar(this._$contextMenu, this);
this._updateContextMenu();
this._bars.push(this._contextMenuBar)
}
_initHelpers() {
this._mappingHelper = new _uiGantt8.GanttMappingHelper(this);
this._customFieldsManager = new _uiGantt3.GanttCustomFieldsManager(this);
this._actionsManager = new _uiGantt.GanttActionsManager(this);
this._ganttTemplatesManager = new _uiGantt1.GanttTemplatesManager(this);
this._sizeHelper = new _uiGantt0.GanttSizeHelper(this);
this._dataProcessingHelper = new _uiGantt4.GanttDataChangesProcessingHelper
}
_initGanttView() {
var _this$_ganttTreeList, _this$_ganttTreeList2, _this$_ganttTreeList3, _this$_ganttTemplates, _this$_ganttTemplates2, _this$_ganttTemplates3, _this$_ganttTemplates4;
if (this._ganttView) {
return
}
const {
allowSelection: allowSelection,
selectedRowKey: selectedRowKey,
showResources: showResources,
showDependencies: showDependencies,
startDateRange: startDateRange,
endDateRange: endDateRange,
taskTitlePosition: taskTitlePosition,
firstDayOfWeek: firstDayOfWeek,
showRowLines: showRowLines,
scaleType: scaleType,
scaleTypeRange: scaleTypeRange,
editing: editing,
validation: validation,
stripLines: stripLines,
taskTooltipContentTemplate: taskTooltipContentTemplate,
taskProgressTooltipContentTemplate: taskProgressTooltipContentTemplate,
taskTimeTooltipContentTemplate: taskTimeTooltipContentTemplate,
taskContentTemplate: taskContentTemplate
} = this.option();
this._ganttView = this._createComponent(this._$ganttView, _uiGantt11.GanttView, {
width: "100%",
height: null === (_this$_ganttTreeList = this._ganttTreeList) || void 0 === _this$_ganttTreeList ? void 0 : _this$_ganttTreeList.getOffsetHeight(),
rowHeight: null === (_this$_ganttTreeList2 = this._ganttTreeList) || void 0 === _this$_ganttTreeList2 ? void 0 : _this$_ganttTreeList2.getRowHeight(),
headerHeight: null === (_this$_ganttTreeList3 = this._ganttTreeList) || void 0 === _this$_ganttTreeList3 ? void 0 : _this$_ganttTreeList3.getHeaderHeight(),
tasks: this._tasks,
dependencies: this._dependencies,
resources: this._resources,
resourceAssignments: this._resourceAssignments,
allowSelection: allowSelection,
selectedRowKey: selectedRowKey,
showResources: showResources,
showDependencies: showDependencies,
startDateRange: startDateRange,
endDateRange: endDateRange,
taskTitlePosition: taskTitlePosition,
firstDayOfWeek: firstDayOfWeek,
showRowLines: showRowLines,
scaleType: scaleType,
scaleTypeRange: scaleTypeRange,
editing: editing,
validation: validation,
stripLines: null === stripLines || void 0 === stripLines ? void 0 : stripLines.map(item => Object.assign({}, item)),
bars: this._bars,
mainElement: this.$element(),
onSelectionChanged: e => {
var _this$_ganttTreeList4;
null === (_this$_ganttTreeList4 = this._ganttTreeList) || void 0 === _this$_ganttTreeList4 || _this$_ganttTreeList4.selectRows(_uiGantt7.GanttHelper.getArrayFromOneElement(e.id))
},
onViewTypeChanged: e => {
this._onViewTypeChanged(e.type)
},
onScroll: e => {
var _this$_ganttTreeList5;
null === (_this$_ganttTreeList5 = this._ganttTreeList) || void 0 === _this$_ganttTreeList5 || _this$_ganttTreeList5.scrollBy(e.scrollTop)
},
onDialogShowing: this._showDialog.bind(this),
onPopupMenuShowing: this._showPopupMenu.bind(this),
onPopupMenuHiding: this._hidePopupMenu.bind(this),
onExpandAll: this._expandAll.bind(this),
onCollapseAll: this._collapseAll.bind(this),
modelChangesListener: _uiGantt9.ModelChangesListener.create(this),
exportHelper: this._getExportHelper(),
taskTooltipContentTemplate: null === (_this$_ganttTemplates = this._ganttTemplatesManager) || void 0 === _this$_ganttTemplates ? void 0 : _this$_ganttTemplates.getTaskTooltipContentTemplateFunc(taskTooltipContentTemplate),
taskProgressTooltipContentTemplate: null === (_this$_ganttTemplates2 = this._ganttTemplatesManager) || void 0 === _this$_ganttTemplates2 ? void 0 : _this$_ganttTemplates2.getTaskProgressTooltipContentTemplateFunc(taskProgressTooltipContentTemplate),
taskTimeTooltipContentTemplate: null === (_this$_ganttTemplates3 = this._ganttTemplatesManager) || void 0 === _this$_ganttTemplates3 ? void 0 : _this$_ganttTemplates3.getTaskTimeTooltipContentTemplateFunc(taskTimeTooltipContentTemplate),
taskContentTemplate: null === (_this$_ganttTemplates4 = this._ganttTemplatesManager) || void 0 === _this$_ganttTemplates4 ? void 0 : _this$_ganttTemplates4.getTaskContentTemplateFunc(taskContentTemplate),
onTaskClick: e => {
var _this$_ganttTreeList6;
null === (_this$_ganttTreeList6 = this._ganttTreeList) || void 0 === _this$_ganttTreeList6 || _this$_ganttTreeList6.onRowClick(e)
},
onTaskDblClick: e => {
var _this$_ganttTreeList7;
null === (_this$_ganttTreeList7 = this._ganttTreeList) || void 0 === _this$_ganttTreeList7 || _this$_ganttTreeList7.onRowDblClick(e)
},
onAdjustControl: () => {
var _this$_sizeHelper2;
null === (_this$_sizeHelper2 = this._sizeHelper) || void 0 === _this$_sizeHelper2 || _this$_sizeHelper2.onAdjustControl()
},
onContentReady: this._onGanttViewContentReady.bind(this),
visualState: this._savedGanttViewState
});
delete this._savedGanttViewState
}
_onGanttViewContentReady(e) {
if (!this._isParentAutoUpdateMode()) {
this._fireContentReadyAction()
}
}
_isParentAutoUpdateMode() {
const {
validation: validation = {}
} = this.option() ?? {};
return null === validation || void 0 === validation ? void 0 : validation.autoUpdateParentTasks
}
_onTreeListContentReady(e) {
var _this$_dataProcessing;
if (this._isParentAutoUpdateMode() && this._treeListParentRecalculatedDataUpdating) {
this._fireContentReadyAction()
}
delete this._treeListParentRecalculatedDataUpdating;
null === (_this$_dataProcessing = this._dataProcessingHelper) || void 0 === _this$_dataProcessing || _this$_dataProcessing.onTreeListReady()
}
_onViewTypeChanged(type) {
var _this$_actionsManager;
this.option("scaleType", null === (_this$_actionsManager = this._actionsManager) || void 0 === _this$_actionsManager ? void 0 : _this$_actionsManager._getScaleType(type))
}
_refreshDataSource(name) {
let dataOption = this[`_${name}Option`];
if (dataOption) {
dataOption.dispose();
delete this[`_${name}Option`];
delete this[`_${name}`]
}
dataOption = new _uiGanttData.default(name, this._getLoadPanel.bind(this), (resultName, resultData) => {
this._dataSourceChanged(resultName, resultData)
});
dataOption.option("dataSource", this._getSpecificDataSourceOption(name));
dataOption._refreshDataSource();
this[`_${name}Option`] = dataOption
}
_getSpecificDataSourceOption(name) {
const dataSource = this.option(`${name}.dataSource`);
if (!dataSource || Array.isArray(dataSource)) {
return {
store: {
type: "array",
data: dataSource ?? [],
key: this.option(`${name}.keyExpr`)
}
}
}
return dataSource
}
_dataSourceChanged(dataSourceName, data) {
const getters = _uiGantt7.GanttHelper.compileGettersByOption(this.option(dataSourceName));
const validatedData = this._validateSourceData(dataSourceName, data);
const mappedData = validatedData.map(_uiGantt7.GanttHelper.prepareMapHandler(getters));
this[`_${dataSourceName}`] = mappedData;
this._setGanttViewOption(dataSourceName, mappedData);
if ("tasks" === dataSourceName) {
var _this$_ganttTreeList8, _this$_ganttTreeList9, _this$_ganttTreeList0;
this._tasksRaw = validatedData;
const forceUpdate = !(null !== (_this$_ganttTreeList8 = this._ganttTreeList) && void 0 !== _this$_ganttTreeList8 && _this$_ganttTreeList8.getDataSource()) && !this._ganttView;
null === (_this$_ganttTreeList9 = this._ganttTreeList) || void 0 === _this$_ganttTreeList9 || _this$_ganttTreeList9.saveExpandedKeys();
null === (_this$_ganttTreeList0 = this._ganttTreeList) || void 0 === _this$_ganttTreeList0 || _this$_ganttTreeList0.updateDataSource(validatedData, forceUpdate)
}
}
_validateSourceData(dataSourceName, data) {
return data && "tasks" === dataSourceName ? this._validateTaskData(data) : data
}
_validateTaskData(data) {
const keyGetter = (0, _data.compileGetter)(this.option("tasks.keyExpr"));
const parentIdGetter = (0, _data.compileGetter)(this.option("tasks.parentIdExpr"));
const rootValue = this.option("rootValue") ?? "dx_dxt_gantt_default_root_value";
const validationTree = {};
for (let i = 0; i < data.length; i += 1) {
const item = data[i];
if (item) {
const key = keyGetter(item);
const isRootTask = key === rootValue;
const treeItem = validationTree[key] ?? (validationTree[key] = {
key: key,
children: []
});
if (!isRootTask) {
const parentId = parentIdGetter(item) ?? rootValue;
const parentTreeItem = validationTree[parentId] ?? (validationTree[parentId] = {
key: parentId,
children: []
});
parentTreeItem.children.push(treeItem);
treeItem.parent = parentTreeItem
}
}
}
const validKeys = [rootValue];
this._appendChildKeys(validationTree[rootValue], validKeys);
return data.filter(item => validKeys.includes(keyGetter(item)))
}
_appendChildKeys(treeItem, keys) {
const children = null === treeItem || void 0 === treeItem ? void 0 : treeItem.children;
for (let i = 0; i < (null === children || void 0 === children ? void 0 : children.length); i += 1) {
const child = children[i];
keys.push(child.key);
this._appendChildKeys(child, keys)
}
}
_onRecordInserted(optionName, record, callback) {
const dataOption = this[`_${optionName}Option`];
if (dataOption) {
const data = _uiGantt7.GanttHelper.getStoreObject(this.option(optionName), record);
const isTaskInsert = "tasks" === optionName;
if (isTaskInsert) {
var _this$_customFieldsMa;
null === (_this$_customFieldsMa = this._customFieldsManager) || void 0 === _this$_customFieldsMa || _this$_customFieldsMa.addCustomFieldsDataFromCache("gantt_new_task_key", data)
}
dataOption.insert(data, response => {
var _this$_dataProcessing2, _this$_ganttTreeList1;
const keyGetter = (0, _data.compileGetter)(this.option(`${optionName}.keyExpr`));
const insertedId = keyGetter(response);
callback(insertedId);
this._executeFuncSetters(optionName, record, insertedId);
null === (_this$_dataProcessing2 = this._dataProcessingHelper) || void 0 === _this$_dataProcessing2 || _this$_dataProcessing2.addCompletionAction(() => {
var _this$_actionsManager2;
null === (_this$_actionsManager2 = this._actionsManager) || void 0 === _this$_actionsManager2 || _this$_actionsManager2.raiseInsertedAction(optionName, data, insertedId)
}, true, isTaskInsert);
null === (_this$_ganttTreeList1 = this._ganttTreeList) || void 0 === _this$_ganttTreeList1 || _this$_ganttTreeList1.saveExpandedKeys();
dataOption._reloadDataSource().done(() => {
if (isTaskInsert) {
var _this$_ganttTreeList10;
null === (_this$_ganttTreeList10 = this._ganttTreeList) || void 0 === _this$_ganttTreeList10 || _this$_ganttTreeList10.onTaskInserted(insertedId, record.parentId)
}
})
})
}
}
_onRecordUpdated(optionName, key, values) {
const dataOption = this[`_${optionName}Option`];
const isTaskUpdated = "tasks" === optionName;
if (dataOption) {
var _this$_mappingHelper, _this$_customFieldsMa2;
const data = null === (_this$_mappingHelper = this._mappingHelper) || void 0 === _this$_mappingHelper ? void 0 : _this$_mappingHelper.convertCoreToMappedData(optionName, values);
const hasCustomFieldsData = isTaskUpdated && (null === (_this$_customFieldsMa2 = this._customFieldsManager) || void 0 === _this$_customFieldsMa2 ? void 0 : _this$_customFieldsMa2.cache.hasData(key));
if (hasCustomFieldsData) {
var _this$_customFieldsMa3;
null === (_this$_customFieldsMa3 = this._customFieldsManager) || void 0 === _this$_customFieldsMa3 || _this$_customFieldsMa3.addCustomFieldsDataFromCache(key, data)
}
dataOption.update(key, data, () => {
var _this$_ganttTreeList11, _this$_dataProcessing3;
this._executeFuncSetters(optionName, values, key);
null === (_this$_ganttTreeList11 = this._ganttTreeList) || void 0 === _this$_ganttTreeList11 || _this$_ganttTreeList11.saveExpandedKeys();
null === (_this$_dataProcessing3 = this._dataProcessingHelper) || void 0 === _this$_dataProcessing3 || _this$_dataProcessing3.addCompletionAction(() => {
var _this$_actionsManager3;
null === (_this$_actionsManager3 = this._actionsManager) || void 0 === _this$_actionsManager3 || _this$_actionsManager3.raiseUpdatedAction(optionName, data, key)
}, true, isTaskUpdated);
dataOption._reloadDataSource()
})
}
}
_onRecordRemoved(optionName, key, data) {
const dataOption = this[`_${optionName}Option`];
if (dataOption) {
dataOption.remove(key, () => {
var _this$_ganttTreeList12, _this$_dataProcessing4;
null === (_this$_ganttTreeList12 = this._ganttTreeList) || void 0 === _this$_ganttTreeList12 || _this$_ganttTreeList12.saveExpandedKeys();
null === (_this$_dataProcessing4 = this._dataProcessingHelper) || void 0 === _this$_dataProcessing4 || _this$_dataProcessing4.addCompletionAction(() => {
var _this$_actionsManager4, _this$_mappingHelper2;
null === (_this$_actionsManager4 = this._actionsManager) || void 0 === _this$_actionsManager4 || _this$_actionsManager4.raiseDeletedAction(optionName, key, null === (_this$_mappingHelper2 = this._mappingHelper) || void 0 === _this$_mappingHelper2 ? void 0 : _this$_mappingHelper2.convertCoreToMappedData(optionName, data))
}, true, "tasks" === optionName);
dataOption._reloadDataSource()
})
}
}
_onParentTaskUpdated(data) {
var _this$_actionsManager5;
const mappedData = this.getTaskDataByCoreData(data);
null === (_this$_actionsManager5 = this._actionsManager) || void 0 === _this$_actionsManager5 || _this$_actionsManager5.raiseUpdatedAction("tasks", mappedData, data.id)
}
_onParentTasksRecalculated(data) {
if (!this.isSieving) {
var _this$_customFieldsMa4;
const setters = _uiGantt7.GanttHelper.compileSettersByOption(this.option("tasks"));
const treeDataSource = null === (_this$_customFieldsMa4 = this._customFieldsManager) || void 0 === _this$_customFieldsMa4 ? void 0 : _this$_customFieldsMa4.appendCustomFields(data.map(_uiGantt7.GanttHelper.prepareSetterMapHandler(setters)));
setTimeout(() => {
var _this$_ganttTreeList13;
this._treeListParentRecalculatedDataUpdating = true;
null === (_this$_ganttTreeList13 = this._ganttTreeList) || void 0 === _this$_ganttTreeList13 || _this$_ganttTreeList13.setDataSource(treeDataSource)
})
}
this.isSieving = false
}
_onGanttViewCoreUpdated() {
var _this$_dataProcessing5;
null === (_this$_dataProcessing5 = this._dataProcessingHelper) || void 0 === _this$_dataProcessing5 || _this$_dataProcessing5.onGanttViewReady()
}
_executeFuncSetters(optionName, coreData, key) {
const funcSetters = _uiGantt7.GanttHelper.compileFuncSettersByOption(this.option(optionName));
const keysToUpdate = Object.keys(funcSetters).filter(k => (0, _type.isDefined)(coreData[k]));
if (keysToUpdate.length > 0) {
const dataObject = this._getDataSourceItem(optionName, key);
keysToUpdate.forEach(k => {
const setter = funcSetters[k];
setter(dataObject, coreData[k])
})
}
}
_sortAndFilter() {
var _this$_savedSortFilte, _this$_savedSortFilte2, _this$_savedSortFilte3;
const treeList = this._treeList;
const columns = null === treeList || void 0 === treeList ? void 0 : treeList.getColumns();
const sortedColumns = columns.filter(c => c.sortIndex > -1);
const sortedState = sortedColumns.map(c => ({
sortIndex: c.sortIndex,
sortOrder: c.sortOrder
}));
const sortedStateChanged = !this._compareSortedState(null === (_this$_savedSortFilte = this._savedSortFilterState) || void 0 === _this$_savedSortFilte ? void 0 : _this$_savedSortFilte.sort, sortedState);
const filterValue = null === treeList || void 0 === treeList ? void 0 : treeList.option("filterValue");
const filterChanged = (null === treeList || void 0 === treeList ? void 0 : treeList.option("expandNodesOnFiltering")) && filterValue !== (null === (_this$_savedSortFilte2 = this._savedSortFilterState) || void 0 === _this$_savedSortFilte2 ? void 0 : _this$_savedSortFilte2.filter);
const sieveColumn = sortedColumns[0] || columns.filter(c => {
var _c$filterValues;
return (0, _type.isDefined)(c.filterValue) || (null === (_c$filterValues = c.filterValues) || void 0 === _c$filterValues ? void 0 : _c$filterValues.length)
})[0];
const isClearSieving = (null === (_this$_savedSortFilte3 = this._savedSortFilterState) || void 0 === _this$_savedSortFilte3 ? void 0 : _this$_savedSortFilte3.sieveColumn) && !sieveColumn;
if (sieveColumn || isClearSieving) {
var _this$_ganttTreeList14;
const sieveOptions = sieveColumn && {
sievedItems: null === (_this$_ganttTreeList14 = this._ganttTreeList) || void 0 === _this$_ganttTreeList14 ? void 0 : _this$_ganttTreeList14.getSievedItems(),
sieveColumn: sieveColumn,
expandTasks: filterChanged || filterValue && sortedStateChanged
};
this.isSieving = !isClearSieving;
this._setGanttViewOption("sieve", sieveOptions)
}
this._savedSortFilterState = {
sort: sortedState,
filter: filterValue,
sieveColumn: sieveColumn
}
}
_compareSortedState(state1, state2) {
if (!state1 || !state2 || state1.length !== state2.length) {
return false
}
return state1.every((c, i) => c.sortIndex === state2[i].sortIndex && c.sortOrder === state2[i].sortOrder)
}
_getToolbarItems() {
const {
toolbar: toolbar
} = this.option();
return (null === toolbar || void 0 === toolbar ? void 0 : toolbar.items) || []
}
_updateToolbarContent() {
var _this$_toolbar;
const items = this._getToolbarItems();
if (null !== items && void 0 !== items && items.length) {
this._$toolbarWrapper.show()
} else {
this._$toolbarWrapper.hide()
}
null === (_this$_toolbar = this._toolbar) || void 0 === _this$_toolbar || _this$_toolbar.createItems(items);
this._updateBarItemsState()
}
_updateContextMenu() {
const {
contextMenu: contextMenu
} = this.option();
if (null !== contextMenu && void 0 !== contextMenu && contextMenu.enabled && this._contextMenuBar) {
this._contextMenuBar.createItems(null === contextMenu || void 0 === contextMenu ? void 0 : contextMenu.items);
this._updateBarItemsState()
}
}
_updateBarItemsState() {
var _this$_ganttView4;
null === (_this$_ganttView4 = this._ganttView) || void 0 === _this$_ganttView4 || _this$_ganttView4.updateBarItemsState()
}
_showDialog(e) {
if (!this._dialogInstance) {
this._dialogInstance = new _uiGantt5.GanttDialog(this, this._$dialog)
}
this._dialogInstance.show(e.name, e.parameters, e.callback, e.afterClosing, this.option("editing"))
}
_showPopupMenu(info) {
if (this.option("contextMenu.enabled")) {
var _this$_ganttView5, _this$_contextMenuBar, _this$_actionsManager6;
null === (_this$_ganttView5 = this._ganttView) || void 0 === _this$_ganttView5 || _this$_ganttView5.getBarManager().updateContextMenu();
const args = {
cancel: false,
event: info.event,
targetType: info.type,
targetKey: info.key,
items: (0, _extend.extend)(true, [], null === (_this$_contextMenuBar = this._contextMenuBar) || void 0 === _this$_contextMenuBar ? void 0 : _this$_contextMenuBar._items),
data: "task" === info.type ? this.getTaskData(info.key) : this.getDependencyData(info.key)
};
null === (_this$_actionsManager6 = this._actionsManager) || void 0 === _this$_actionsManager6 || _this$_actionsManager6.raiseContextMenuPreparing(args);
if (!args.cancel) {
var _this$_contextMenuBar2;
null === (_this$_contextMenuBar2 = this._contextMenuBar) || void 0 === _this$_contextMenuBar2 || _this$_contextMenuBar2.show(info.position, args.items)
}
}
}
_hidePopupMenu() {
var _this$_contextMenuBar3;
null === (_this$_contextMenuBar3 = this._contextMenuBar) || void 0 === _this$_contextMenuBar3 || _this$_contextMenuBar3.hide()
}
_getLoadPanel() {
if (!this._loadPanel) {
this._loadPanel = this._createComponent(this._$loadPanel, _load_panel.default, {
position: {
of: this.$element()
}
})
}
return this._loadPanel
}
_getTaskKeyGetter() {
return this._getDataSourceItemKeyGetter("tasks")
}
_findTaskByKey(key) {
return this._getDataSourceItem("tasks", key)
}
_getDataSourceItem(dataOptionName, key) {
const dataOption = this[`_${dataOptionName}Option`];
const keyGetter = this._getDataSourceItemKeyGetter(dataOptionName);
const items = null === dataOption || void 0 === dataOption ? void 0 : dataOption._getItems();
return items.find(t => keyGetter(t) === key)
}
_getDataSourceItemKeyGetter(dataOptionName) {
return (0, _data.compileGetter)(this.option(`${dataOptionName}.keyExpr`))
}
_setGanttViewOption(optionName, value) {
var _this$_ganttView6;
null === (_this$_ganttView6 = this._ganttView) || void 0 === _this$_ganttView6 || _this$_ganttView6.option(optionName, value)
}
_getGanttViewOption(optionName, value) {
var _this$_ganttView7;
return null === (_this$_ganttView7 = this._ganttView) || void 0 === _this$_ganttView7 ? void 0 : _this$_ganttView7.option(optionName)
}
_getExportHelper() {
this._exportHelper ?? (this._exportHelper = new _uiGantt6.GanttExportHelper(this));
return this._exportHelper
}
_executeCoreCommand(id) {
var _this$_ganttView8;
null === (_this$_ganttView8 = this._ganttView) || void 0 === _this$_ganttView8 || _this$_ganttView8.executeCoreCommand(id)
}
_expandAll() {
this._changeExpandAll(true)
}
_collapseAll() {
this._changeExpandAll(false)
}
_onTreeListRowExpandChanged(e, expanded) {
if (!this._lockRowExpandEvent) {
var _this$_ganttView9, _this$_sizeHelper3;
null === (_this$_ganttView9 = this._ganttView) || void 0 === _this$_ganttView9 || _this$_ganttView9.changeTaskExpanded(e.key, expanded);
null === (_this$_sizeHelper3 = this._sizeHelper) || void 0 === _this$_sizeHelper3 || _this$_sizeHelper3.adjustHeight()
}
}
_changeExpandAll(expanded, level, rowKey) {
var _this$_treeList, _promise;
const allExpandableNodes = [];
const nodesToExpand = [];
null === (_this$_treeList = this._treeList) || void 0 === _this$_treeList || _this$_treeList.forEachNode(node => {
var _node$children;
if (null !== (_node$children = node.children) && void 0 !== _node$children && _node$children.length) {
allExpandableNodes.push(node)
}
});
if (rowKey) {
var _this$_treeList2;
const node = null === (_this$_treeList2 = this._treeList) || void 0 === _this$_treeList2 ? void 0 : _this$_treeList2.getNodeByKey(rowKey);
_uiGantt7.GanttHelper.getAllParentNodesKeys(node, nodesToExpand)
}
let promise;
this._lockRowExpandEvent = allExpandableNodes.length > 0;
const state = allExpandableNodes.reduce((previous, node, index) => {
var _this$_treeList3, _this$_treeList4;
if (rowKey) {
expanded = nodesToExpand.includes(node.key)
} else if (level) {
expanded = node.level < level
}
previous[node.key] = expanded;
const action = expanded ? null === (_this$_treeList3 = this._treeList) || void 0 === _this$_treeList3 ? void 0 : _this$_treeList3.expandRow : null === (_this$_treeList4 = this._treeList) || void 0 === _this$_treeList4 ? void 0 : _this$_treeList4.collapseRow;
const isLast = index === allExpandableNodes.length - 1;
if (isLast) {
promise = action(node.key)
} else {
action(node.key)
}
return previous
}, {});
null === (_promise = promise) || void 0 === _promise || _promise.then(() => {
var _this$_ganttView0, _this$_sizeHelper4;
null === (_this$_ganttView0 = this._ganttView) || void 0 === _this$_ganttView0 || _this$_ganttView0.applyTasksExpandedState(state);
null === (_this$_sizeHelper4 = this._sizeHelper) || void 0 === _this$_sizeHelper4 || _this$_sizeHelper4.adjustHeight();
delete this._lockRowExpandEvent
})
}
getTaskResources(key) {
var _this$_ganttView1;
if (!(0, _type.isDefined)(key)) {
return null
}
const coreData = null === (_this$_ganttView1 = this._ganttView) || void 0 === _this$_ganttView1 ? void 0 : _this$_ganttView1._ganttViewCore.getTaskResources(key);
return coreData.map(r => {
var _this$_mappingHelper3;
return null === (_this$_mappingHelper3 = this._mappingHelper) || void 0 === _this$_mappingHelper3 ? void 0 : _this$_mappingHelper3.convertCoreToMappedData("resources", r)
})
}
getVisibleTaskKeys() {
var _this$_ganttView10;
return null === (_this$_ganttView10 = this._ganttView) || void 0 === _this$_ganttView10 ? void 0 : _this$_ganttView10._ganttViewCore.getVisibleTaskKeys()
}
getVisibleDependencyKeys() {
var _this$_ganttView11;
return null === (_this$_ganttView11 = this._ganttView) || void 0 === _this$_ganttView11 ? void 0 : _this$_ganttView11._ganttViewCore.getVisibleDependencyKeys()
}
getVisibleResourceKeys() {
var _this$_ganttView12;
return null === (_this$_ganttView12 = this._ganttView) || void 0 === _this$_ganttView12 ? void 0 : _this$_ganttView12._ganttViewCore.getVisibleResourceKeys()
}
getVisibleResourceAssignmentKeys() {
var _this$_ganttView13;
return null === (_this$_ganttView13 = this._ganttView) || void 0 === _this$_ganttView13 ? void 0 : _this$_ganttView13._ganttViewCore.getVisibleResourceAssignmentKeys()
}
getTaskData(key) {
var _this$_ganttView14;
if (!(0, _type.isDefined)(key)) {
return null
}
const coreData = null === (_this$_ganttView14 = this._ganttView) || void 0 === _this$_ganttView14 ? void 0 : _this$_ganttView14._ganttViewCore.getTaskData(key);
const mappedData = this.getTaskDataByCoreData(coreData);
return mappedData
}
getTaskDataByCoreData(coreData) {
var _this$_mappingHelper4, _this$_customFieldsMa5;
const mappedData = coreData ? null === (_this$_mappingHelper4 = this._mappingHelper) || void 0 === _this$_mappingHelper4 ? void 0 : _this$_mappingHelper4.convertCoreToMappedData("tasks", coreData) : null;
null === (_this$_customFieldsMa5 = this._customFieldsManager) || void 0 === _this$_customFieldsMa5 || _this$_customFieldsMa5.addCustomFieldsData(null === coreData || void 0 === coreData ? void 0 : coreData.id, mappedData);
return mappedData
}
insertTask(data) {
var _this$_customFieldsMa6, _this$_ganttView15, _this$_mappingHelper5;
null === (_this$_customFieldsMa6 = this._customFieldsManager) || void 0 === _this$_customFieldsMa6 || _this$_customFieldsMa6.saveCustomFieldsDataToCache("gantt_new_task_key", data);
null === (_this$_ganttView15 = this._ganttView) || void 0 === _this$_ganttView15 || _this$_ganttView15._ganttViewCore.insertTask(null === (_this$_mappingHelper5 = this._mappingHelper) || void 0 === _this$_mappingHelper5 ? void 0 : _this$_mappingHelper5.convertMappedToCoreData("tasks", data))
}
deleteTask(key) {
var _this$_ganttView16;
null === (_this$_ganttView16 = this._ganttView) || void 0 === _this$_ganttView16 || _this$_ganttView16._ganttViewCore.deleteTask(key)
}
updateTask(key, data) {
var _this$_mappingHelper6, _this$_customFieldsMa7;
const coreTaskData = null === (_this$_mappingHelper6 = this._mappingHelper) || void 0 === _this$_mappingHelper6 ? void 0 : _this$_mappingHelper6.convertMappedToCoreData("tasks", data);
const isCustomFieldsUpdateOnly = !Object.keys(coreTaskData).length;
null === (_this$_customFieldsMa7 = this._customFieldsManager) || void 0 === _this$_customFieldsMa7 || _this$_customFieldsMa7.saveCustomFieldsDataToCache(key, data, true, isCustomFieldsUpdateOnly);
if (isCustomFieldsUpdateOnly) {
var _this$_customFieldsMa8;
const customFieldsData = null === (_this$_customFieldsMa8 = this._customFieldsManager) || void 0 === _this$_customFieldsMa8 ? void 0 : _this$_customFieldsMa8._getCustomFieldsData(data);
if (Object.keys(customFieldsData).length > 0) {
var _this$_actionsManager7;
null === (_this$_actionsManager7 = this._actionsManager) || void 0 === _this$_actionsManager7 || _this$_actionsManager7.raiseUpdatingAction("tasks", {
cancel: false,
key: key,
newValues: {}
})
}
} else {
var _this$_ganttView17;
null === (_this$_ganttView17 = this._ganttView) || void 0 === _this$_ganttView17 || _this$_ganttView17._ganttViewCore.updateTask(key, coreTaskData)
}
}
getDependencyData(key) {
var _this$_ganttView18, _this$_mappingHelper7;
if (!(0, _type.isDefined)(key)) {
return null
}
const coreData = null === (_this$_ganttView18 = this._ganttView) || void 0 === _this$_ganttView18 ? void 0 : _this$_ganttView18._ganttViewCore.getDependencyData(key);
return coreData ? null === (_this$_mappingHelper7 = this._mappingHelper) || void 0 === _this$_mappingHelper7 ? void 0 : _this$_mappingHelper7.convertCoreToMappedData("dependencies", coreData) : null
}
insertDependency(data) {
var _this$_ganttView19, _this$_mappingHelper8;
null === (_this$_ganttView19 = this._ganttView) || void 0 === _this$_ganttView19 || _this$_ganttView19._ganttViewCore.insertDependency(null === (_this$_mappingHelper8 = this._mappingHelper) || void 0 === _this$_mappingHelper8 ? void 0 : _this$_mappingHelper8.convertMappedToCoreData("dependencies", data))
}
deleteDependency(key) {
var _this$_ganttView20;
null === (_this$_ganttView20 = this._ganttView) || void 0 === _this$_ganttView20 || _this$_ganttView20._ganttViewCore.deleteDependency(key)
}
getResourceData(key) {
var _this$_ganttView21, _this$_mappingHelper9;
const coreData = null === (_this$_ganttView21 = this._ganttView) || void 0 === _this$_ganttView21 ? void 0 : _this$_ganttView21._ganttViewCore.getResourceData(key);
return coreData ? null === (_this$_mappingHelper9 = this._mappingHelper) || void 0 === _this$_mappingHelper9 ? void 0 : _this$_mappingHelper9.convertCoreToMappedData("resources", coreData) : null
}
deleteResource(key) {
var _this$_ganttView22;
null === (_this$_ganttView22 = this._ganttView) || void 0 === _this$_ganttView22 || _this$_ganttView22._ganttViewCore.deleteResource(key)
}
insertResource(data, taskKeys) {
var _this$_ganttView23, _this$_mappingHelper0;
null === (_this$_ganttView23 = this._ganttView) || void 0 === _this$_ganttView23 || _this$_ganttView23._ganttViewCore.insertResource(null === (_this$_mappingHelper0 = this._mappingHelper) || void 0 === _this$_mappingHelper0 ? void 0 : _this$_mappingHelper0.convertMappedToCoreData("resources", data), taskKeys)
}
getResourceAssignmentData(key) {
var _this$_ganttView24, _this$_mappingHelper1;
const coreData = null === (_this$_ganttView24 = this._ganttView) || void 0 === _this$_ganttView24 ? void 0 : _this$_ganttView24._ganttViewCore.getResourceAssignmentData(key);
return coreData ? null === (_this$_mappingHelper1 = this._mappingHelper) || void 0 === _this$_mappingHelper1 ? void 0 : _this$_mappingHelper1.convertCoreToMappedData("resourceAssignments", coreData) : null
}
assignResourceToTask(resourceKey, taskKey) {
var _this$_ganttView25;
null === (_this$_ganttView25 = this._ganttView) || void 0 === _this$_ganttView25 || _this$_ganttView25._ganttViewCore.assignResourceToTask(resourceKey, taskKey)
}
unassignResourceFromTask(resourceKey, taskKey) {
var _this$_ganttView26;
null === (_this$_ganttView26 = this._ganttView) || void 0 === _this$_ganttView26 || _this$_ganttView26._ganttViewCore.unassignResourceFromTask(resourceKey, taskKey)
}
unassignAllResourcesFromTask(taskKey) {
var _this$_ganttView27;
null === (_this$_ganttView27 = this._ganttView) || void 0 === _this$_ganttView27 || _this$_ganttView27._ganttViewCore.unassignAllResourcesFromTask(taskKey)
}
updateDimensions() {
var _this$_sizeHelper5;
null === (_this$_sizeHelper5 = this._sizeHelper) || void 0 === _this$_sizeHelper5 || _this$_sizeHelper5.onAdjustControl()
}
scrollToDate(date) {
var _this$_ganttView28;
null === (_this$_ganttView28 = this._ganttView) || void 0 === _this$_ganttView28 || _this$_ganttView28._ganttViewCore.scrollToDate(date)
}
showResourceManagerDialog() {
var _this$_ganttView29;
null === (_this$_ganttView29 = this._ganttView) || void 0 === _this$_ganttView29 || _this$_ganttView29._ganttViewCore.showResourcesDialog()
}
showTaskDetailsDialog(taskKey) {
var _this$_ganttView30;
null === (_this$_ganttView30 = this._ganttView) || void 0 === _this$_ganttView30 || _this$_ganttView30._ganttViewCore.showTaskDetailsDialog(taskKey)
}
exportToPdf(options) {
return this._exportToPdf(options)
}
_exportToPdf(options) {
var _this$_exportHelper, _window$jspdf;
null === (_this$_exportHelper = this._exportHelper) || void 0 === _this$_exportHelper || _this$_exportHelper.reset();
const fullOptions = (0, _extend.extend)({}, options);
if (fullOptions.createDocumentMethod) {
fullOptions.docCreateMethod = fullOptions.createDocumentMethod
}
fullOptions.pdfDocument ?? (fullOptions.pdfDocument = fullOptions.jsPDFDocument);
fullOptions.docCreateMethod ?? (fullOptions.docCreateMethod = (null === (_window$jspdf = window.jspdf) || void 0 === _window$jspdf ? void 0 : _window$jspdf.jsPDF) ?? window.jsPDF);
fullOptions.format ?? (fullOptions.format = "a4");
return new Promise(resolve => {
var _this$_ganttView31;
const doc = null === (_this$_ganttView31 = this._ganttView) || void 0 === _this$_ganttView31 ? void 0 : _this$_ganttView31._ganttViewCore.exportToPdf(fullOptions);
resolve(doc)
})
}
refresh() {
return new Promise((resolve, reject) => {
try {
this._refreshGantt();
resolve()
} catch (e) {
reject(e.message)
}
})
}
expandAll() {
this._expandAll()
}
collapseAll() {
this._collapseAll()
}
expandAllToLevel(level) {
this._changeExpandAll(false, level)
}
expandToTask(key) {
var _this$_treeList5, _node$parent;
const node = null === (_this$_treeList5 = this._treeList) || void 0 === _this$_treeList5 ? void 0 : _this$_treeList5.getNodeByKey(key);
this._changeExpandAll(false, 0, null === node || void 0 === node || null === (_node$parent = node.parent) || void 0 === _node$parent ? void 0 : _node$parent.key)
}
collapseTask(key) {
var _this$_treeList6;
null === (_this$_treeList6 = this._treeList) || void 0 === _this$_treeList6 || _this$_treeList6.collapseRow(key)
}
expandTask(key) {
var _this$_treeList7;
null === (_this$_treeList7 = this._treeList) || void 0 === _this$_treeList7 || _this$_treeList7.expandRow(key)
}
showResources(value) {
this.option("showResources", value)
}
showDependencies(value) {
this.option("showDependencies", value)
}
zoomIn() {
var _this$_ganttView32;
null === (_this$_ganttView32 = this._ganttView) || void 0 === _this$_ganttView32 || _this$_ganttView32._ganttViewCore.zoomIn()
}
zoomOut() {
var _this$_ganttView33;
null === (_this$_ganttView33 = this._ganttView) || void 0 === _this$_ganttView33 || _this$_ganttView33._ganttViewCore.zoomOut()
}
_getDefaultOptions() {
return (0, _extend.extend)(super._getDefaultOptions(), _uiGantt7.GanttHelper.getDefaultOptions())
}
_optionChanged(args) {
var _this$_ganttTreeList15, _this$_sizeHelper6, _this$_ganttTreeList16, _this$_actionsManager8, _this$_actionsManager9, _this$_actionsManager0, _this$_actionsManager1, _this$_actionsManager10, _this$_actionsManager11, _this$_actionsManager12, _this$_actionsManager13, _this$_actionsManager14, _this$_actionsManager15, _this$_actionsManager16, _this$_actionsManager17, _this$_actionsManager18, _this$_actionsManager19, _this$_actionsManager20, _this$_actionsManager21, _this$_actionsManager22, _this$_actionsManager23, _this$_actionsManager24, _this$_actionsManager25, _this$_actionsManager26, _this$_actionsManager27, _this$_actionsManager28, _this$_actionsManager29, _this$_actionsManager30, _this$_actionsManager31, _this$_actionsManager32, _this$_ganttTreeList17, _this$_ganttTreeList18, _this$_ganttTemplates5, _this$_ganttTemplates6, _this$_ganttTemplates7, _this$_ganttTemplates8, _this$_ganttTreeList19, _this$_sizeHelper7, _this$_sizeHelper8, _this$_ganttTreeList20, _this$_ganttTreeList21, _this$_ganttTreeList22;
const {
name: name,
fullName: fullName,
value: value
} = args;
switch (name) {
case "tasks":
this._refreshDataSource("tasks");
break;
case "dependencies":
this._refreshDataSource("dependencies");
break;
case "resources":
this._refreshDataSource("resources");
break;
case "resourceAssignments":
this._refreshDataSource("resourceAssignments");
break;
case "columns":
null === (_this$_ganttTreeList15 = this._ganttTreeList) || void 0 === _this$_ganttTreeList15 || _this$_ganttTreeList15.setOption("columns", this._ganttTreeList.getColumns());
break;
case "taskListWidth":
null === (_this$_sizeHelper6 = this._sizeHelper) || void 0 === _this$_sizeHelper6 || _this$_sizeHelp