You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.6 KiB

1 year ago
gantt.attachEvent("onTaskDblClick", function (id, e) {
2 years ago
return false;
});
1 year ago
gantt.attachEvent("onAfterTaskAdd", function (id, item) {
if (item.parent && gantt.hasChild()) {
2 years ago
let parentId = item.parent;
1 year ago
if (gantt.getTask(parentId).parent_id != null) {
gantt.getTask(parentId).type = "project";
gantt.updateTask(parentId);
}
}
2 years ago
});
1 year ago
gantt.attachEvent("onTaskRowClick", function (id, row) {
activityId = id;
var activity = gantt.getTaskBy("id", id);
activityName = activity[0]?.name;
});
2 years ago
1 year ago
gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function (state) {
2 years ago
let id = parseInt(state.id)
let ganttData = gantt.getTask(id);
1 year ago
if (ganttData?.type_activity == "header") {
2 years ago
return false
}
let column = state.columnName
1 year ago
if (column == "progress" || column == "rencana_biaya") {
2 years ago
let hasChild = gantt.hasChild(id);
1 year ago
if (hasChild) {
2 years ago
return false
}
}
1 year ago
if (column == "cost_actual") {
2 years ago
let progress = ganttData.progress ? ganttData.progress : 0
1 year ago
if (progress <= 0) {
2 years ago
return false
}
}
return true
1 year ago
});
2 years ago
1 year ago
gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) {
2 years ago
// format progress
let progress = new_item.progress;
1 year ago
if (progress > 100) {
2 years ago
progress = 100;
1 year ago
} else if (progress <= 0) {
2 years ago
progress = 0;
1 year ago
} else if (progress <= 1 && progress > 0) {
progress = progress * 100
2 years ago
}
1 year ago
progress = progress / 100;
1 year ago
let task = gantt.getTask(id);
let link = task.$target;
// link.length > 0 -> successor
new_item['progress'] = progress;
1 year ago
if (editEndDateTriggered) {
new_item['duration'] = new_item['duration'] + (link.length == 0 ? 0 : 1);
new_item['end_date'] = gantt.calculateEndDate({
start_date: new_item['start_date'],
duration: new_item['duration']
})
new_item['end_date'].setHours(23, 59, 59);
if (editDurationTriggered) {
let tempDuration = new_item['duration'] - 1;
new_item['end_date'] = gantt.calculateEndDate({
start_date: new_item['start_date'],
duration: tempDuration
})
new_item['end_date'].setHours(23, 59, 59);
editDurationTriggered = false;
}
editEndDateTriggered = false;
}
2 years ago
});
1 year ago
gantt.attachEvent("onAfterTaskDrag", function (id, mode, e) {
var task = gantt.getTask(id);
task.end_date = gantt.calculateEndDate(task);
gantt.updateTask(id);
});
2 years ago
1 year ago
gantt.attachEvent("onBeforeLinkAdd", function (id, link) {
2 years ago
//any custom logic here
let source = link.source;
let target = link.target;
let parents = gantt.getParent(source);
let parentt = gantt.getParent(target);
1 year ago
let childt = gantt.hasChild(target);
if (childt) {
2 years ago
return false;
}
1 year ago
if (parents == target) {
2 years ago
return false;
}
1 year ago
if (parentt == source) {
2 years ago
return false
}
return true;
});
1 year ago
gantt.attachEvent("onGanttReady", function () {
2 years ago
});
1 year ago
gantt.attachEvent("onGanttRender", function () {
if (readOnly && parseInt(readOnly) == 1) {
2 years ago
gantt.config.readonly = true;
1 year ago
} else if (readOnly && parseInt(readOnly) == 0) {
2 years ago
gantt.config.readonly = false;
1 year ago
} else {
2 years ago
gantt.config.readonly = true;
}
});
gantt.attachEvent("onTaskOpened", function (id) {
setGanttOpen()
});
gantt.attachEvent("onTaskClosed", function (id) {
setGanttOpen()
});