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. 2
      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 () { $(document).ready(function () {
$("#critalPathBox").on("change", function (){ $("#critalPathBox").on("change", function (){

8
edit-mode/function/ganttEvent.js

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

2
edit-mode/function/restActivityLink.js

@ -29,6 +29,7 @@ gantt.ajax.get({
}); });
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
getGanttOpen();
}); });
if (Date.now() < timestamp) { if (Date.now() < timestamp) {
gantt.ajax.post({ gantt.ajax.post({
@ -80,6 +81,7 @@ function refresData(id){
}); });
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
getGanttOpen();
}); });
if(id){ if(id){
if(gantt.isTaskExists(id)){ if(gantt.isTaskExists(id)){

Loading…
Cancel
Save