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.

96 lines
2.4 KiB

2 years ago
gantt.attachEvent("onTaskDblClick", function(id,e){
return false;
});
gantt.attachEvent("onAfterTaskAdd", function(id,item){
if(item.parent > 0 && gantt.hasChild()) {
2 years ago
let parentId = item.parent;
gantt.getTask(parentId).type = "project";
gantt.updateTask(parentId);
} else if (item.parent && gantt.hasChild()) {
let parentId = item.parent;
gantt.getTask(parentId).type = "task";
gantt.updateTask(parentId);
}
2 years ago
});
gantt.attachEvent("onTaskRowClick", function(id,row){
activityId = id;
var activity = gantt.getTaskBy("id", id);
activityName = activity[0].name;
});
2 years ago
gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function(state){
let id = parseInt(state.id)
let ganttData = gantt.getTask(id);
if(ganttData.type_activity && ganttData.type_activity=="header"){
return false
}
let column = state.columnName
if(column=="progress" || column=="rencana_biaya"){
let hasChild = gantt.hasChild(id);
if(hasChild){
return false
}
}
if(column=="cost_actual"){
let progress = ganttData.progress ? ganttData.progress : 0
if(progress <= 0){
return false
}
}
return true
});
gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
// format progress
let progress = new_item.progress;
if(progress > 100){
progress = 100;
}else if(progress <= 0){
progress = 0;
}else if(progress <= 1 && progress > 0){
progress = progress*100
}
progress = progress/100;
new_item['progress'] = progress;
2 years ago
});
gantt.attachEvent("onBeforeLinkAdd", function(id,link){
//any custom logic here
let source = link.source;
let target = link.target;
let parents = gantt.getParent(source);
let parentt = gantt.getParent(target);
let childt = gantt.hasChild(target);
if(childt){
return false;
}
if(parents==target){
return false;
}
if(parentt==source){
return false
}
return true;
});
gantt.attachEvent("onGanttReady", function(){
2 years ago
});
gantt.attachEvent("onGanttRender", function(){
if(readOnly && parseInt(readOnly)==1){
gantt.config.readonly = true;
}else if(readOnly && parseInt(readOnly)==0){
gantt.config.readonly = false;
}else{
gantt.config.readonly = true;
}
});