Browse Source

Add task open state

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
acd982a7eb
  1. 31
      edit-mode/function/function.js
  2. 8
      edit-mode/function/ganttEvent.js
  3. 14
      edit-mode/function/restActivityLink.js

31
edit-mode/function/function.js

@ -355,6 +355,37 @@ function initializationColumn()
});
}
function setGanttOpen(){
let ganttOpen = [];
gantt.eachTask(function (task) {
const existingIndex = ganttOpen.findIndex(item => item.id === task.id);
if (existingIndex !== -1) {
ganttOpen[existingIndex].open = task.$open;
} else {
ganttOpen.push({
"id": task.id,
"open": task.$open
});
}
});
localStorage.setItem('ganttOpen', JSON.stringify(ganttOpen));
}
function getGanttOpen(){
let ganttOpen = localStorage.getItem('ganttOpen');
if (ganttOpen) {
// Parse the stored data into a JavaScript object
ganttOpen = JSON.parse(ganttOpen);
gantt.eachTask(function (task) {
const index = ganttOpen.findIndex(item => item.id == task.id);
if (index !== -1) {
task.$open = ganttOpen[index].open;
} else {
task.$open = false;
}
});
}
}
$(document).ready(function () {
$("#critalPathBox").on("change", function (){

8
edit-mode/function/ganttEvent.js

@ -117,3 +117,11 @@ gantt.attachEvent("onGanttRender", function(){
gantt.config.readonly = true;
}
});
gantt.attachEvent("onTaskOpened", function (id) {
setGanttOpen()
});
gantt.attachEvent("onTaskClosed", function (id) {
setGanttOpen()
});

14
edit-mode/function/restActivityLink.js

@ -27,9 +27,10 @@ gantt.ajax.get({
"geom": element.geom
})
});
gantt.silent(function () {
gantt.parse(data);
});
gantt.silent(function () {
gantt.parse(data);
getGanttOpen();
});
if (Date.now() < timestamp) {
gantt.ajax.post({
headers: {
@ -78,9 +79,10 @@ function refresData(id){
"geom": element.geom
})
});
gantt.silent(function () {
gantt.parse(data);
});
gantt.silent(function () {
gantt.parse(data);
getGanttOpen();
});
if(id){
if(gantt.isTaskExists(id)){
expandTask();

Loading…
Cancel
Save