Browse Source

bugfix duration, type activity and rerender whole data after update any activity

pull/1/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
5a0a4b118e
  1. 7
      edit-mode/function/ganttConfig.js
  2. 14
      edit-mode/function/ganttEvent.js
  3. 28
      edit-mode/function/restActivityLink.js

7
edit-mode/function/ganttConfig.js

@ -179,7 +179,6 @@ function addWithoutParent() {
text: `New Activity`,
start_date: start_date,
biaya: 10000,
awaw: "wadad",
duration: 7
});
@ -201,7 +200,7 @@ function addWithParent(id) {
id: no,
text: `New Activity`,
start_date: start_date,
duration: task.duration
duration: 7
}, id);
no = no + 1;
@ -259,6 +258,9 @@ var allColumns = [
{ name: "end_date", label: "Finish Date", align: "center", min_width: 80, editor: editor.end_date, resize: true },
{ name: "duration", label: "Duration", align: "center", min_width: 50, editor: editor.duration, resize: true },
{ name: "rencana_biaya", label: "Cost Planning", align: "center", min_width: 100, resize: true, template: function (text) {
if(text.id == 2085 || text.id == 2089){
console.log("text", text);
}
if(!text.rencana_biaya){
return
}
@ -658,6 +660,7 @@ gantt.config.show_task_cells = false;
gantt.config.static_background = true;
gantt.config.branch_loading = true;
gantt.config.smart_scales = true;
// gantt.config.smart_rendering = true;
// gantt initialization
$(document).ready(function () {

14
edit-mode/function/ganttEvent.js

@ -3,11 +3,15 @@ gantt.attachEvent("onTaskDblClick", function(id,e){
});
gantt.attachEvent("onAfterTaskAdd", function(id,item){
if(item.parent && item.parent > 0){
if(item.parent > 0 && gantt.hasChild()) {
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);
}
});
gantt.attachEvent("onTaskRowClick", function(id,row){
@ -58,7 +62,7 @@ gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
costPlanning = replaceAll(costPlanning, ".", "");
costPlanning = replaceAll(costPlanning, ",", ".");
new_item['rencana_biaya'] = costPlanning;
new_item['progress'] = progress;
new_item['progress'] = progress;
});
@ -86,7 +90,7 @@ gantt.attachEvent("onBeforeLinkAdd", function(id,link){
});
gantt.attachEvent("onGanttReady", function(){
});
gantt.attachEvent("onGanttRender", function(){
@ -97,4 +101,4 @@ gantt.attachEvent("onGanttRender", function(){
}else{
gantt.config.readonly = true;
}
});
});

28
edit-mode/function/restActivityLink.js

@ -10,16 +10,12 @@ gantt.ajax.get({
let obj = JSON.parse(response);
data['data'] = obj.data.data;
data['links'] = obj.data.links;
// console.log("data parse wrong", data);
// check if baseline has been set
if (data.data && data.data.length > 0) {
console.log('baseline', data.data[0].planned_start);
if (data.data[0].planned_start !== null && data.data[0].planned_end !== null) {
console.log('baseline set');
isBaselineSet = true;
}
else {
console.log('baseline has not been set');
isBaselineSet = false;
}
}
@ -42,7 +38,6 @@ function refresData(id){
let obj = JSON.parse(response);
data['data'] = obj.data.data;
data['links'] = obj.data.links;
// console.log("data parse wrong", data);
gantt.silent(function () {
gantt.parse(data);
});
@ -84,7 +79,6 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
}).then(function(response){
let res = response.responseText
res = JSON.parse(res)
console.log("qqqqqqcek response", res)
if(entity=="link"){
gantt.changeLinkId(id, res.tid);
}else if(entity=="task"){
@ -110,7 +104,6 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
}
});
}
// console.log("cek data update", data)
// let dataProgress = parseInt(data.progress)
// dataProgress = dataProgress/100
return gantt.ajax.put({
@ -125,7 +118,6 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
let parent = data.parent;
let responseText = JSON.parse(response.responseText)
let resData = responseText
// console.log("dataRes", resData);
let updateBobot = resData.update_bobot || false
if(updateBobot){
refresData(id);
@ -134,25 +126,11 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
updateActivity(parent);
}
}
// console.log("data", data);
// refresData();
// if(resData && resData.rencana_biaya){
// if(data.rencana_biaya != resData.rencana_biaya){
// // gantt.getTask(id).bobot_planning = resData.bobot_planning;
// // gantt.updateTask(id);
// }else{
// if(parent && parent > 0){
// updateActivity(parent);
// }
// }
// }
}
});
break;
case "delete":
// console.log("cek data", data)
return gantt.ajax.del({
headers: {
"Authorization": `Bearer ${token}`
@ -173,13 +151,7 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
}
}
}
// console.log("cek data delete", data)
}
// let res = response.responseText
// res = JSON.parse(res)
// console.log("cek response", res)
// refresData();
});
break;
}

Loading…
Cancel
Save