Browse Source

Fix horizontal scroll

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
7661232569
  1. 29
      edit-mode/function/function.js
  2. 4
      edit-mode/function/ganttEvent.js
  3. 6
      edit-mode/function/restActivityLink.js

29
edit-mode/function/function.js

@ -636,4 +636,33 @@ function expandTask() {
function resetActivity() { function resetActivity() {
localStorage.setItem('batchEntity', ''); localStorage.setItem('batchEntity', '');
gantt.alert("Actiivity Saved"); gantt.alert("Actiivity Saved");
}
// Function to get the earliest planned start date among all tasks
function getEarliestTaskDate() {
var earliestDate = null;
gantt.eachTask(function (task) {
var taskStartDate = task.planned_start || task.start_date;
if (!earliestDate || task.planned_start < earliestDate) {
earliestDate = taskStartDate;
if (task.start_date < earliestDate) {
earliestDate = task.start_date;
}
}
});
return earliestDate;
}
// Function to get the latest planned end date among all tasks
function getLatestTaskDate() {
var latestDate = null;
gantt.eachTask(function (task) {
var taskEndDate = task.planned_end || task.end_date;
if (!latestDate || task.planned_end > latestDate) {
latestDate = taskEndDate;
if (task.end_date > latestDate) {
latestDate = task.end_date;
}
}
});
return latestDate;
} }

4
edit-mode/function/ganttEvent.js

@ -168,11 +168,11 @@ gantt.attachEvent("onGanttScroll", function (left, top){
var max_allowed_date = gantt.date.add(gantt.config.end_date, -1, "day"); var max_allowed_date = gantt.date.add(gantt.config.end_date, -1, "day");
var repaint = false; var repaint = false;
if (+left_date <= +min_allowed_date){ if (earliest && +left_date <= +min_allowed_date && +left_date >= +earliest){
gantt.config.start_date = gantt.date.add(gantt.config.start_date, -1, "day"); gantt.config.start_date = gantt.date.add(gantt.config.start_date, -1, "day");
repaint = true; repaint = true;
} }
if (+right_date >= +max_allowed_date){ if (latest && +right_date >= +max_allowed_date && +right_date <= +latest){
gantt.config.end_date = gantt.date.add(gantt.config.end_date, 1, "day"); gantt.config.end_date = gantt.date.add(gantt.config.end_date, 1, "day");
repaint = true; repaint = true;
} }

6
edit-mode/function/restActivityLink.js

@ -1,4 +1,6 @@
let geom = []; let geom = [];
let latest;
let earliest;
$("body").addClass("loading"); $("body").addClass("loading");
gantt.ajax.get({ gantt.ajax.get({
url: `${base_url}activity/${ganttId}/${proyekId}/get`, url: `${base_url}activity/${ganttId}/${proyekId}/get`,
@ -33,6 +35,8 @@ gantt.ajax.get({
gantt.parse(data); gantt.parse(data);
getGanttOpen(); getGanttOpen();
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate();
latest = getLatestTaskDate();
}); });
}).catch(function (error) { }).catch(function (error) {
$("body").removeClass("loading"); $("body").removeClass("loading");
@ -77,6 +81,8 @@ function refresData(id) {
gantt.parse(data); gantt.parse(data);
getGanttOpen(); getGanttOpen();
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate();
latest = getLatestTaskDate();
}); });
if (id) { if (id) {
if (gantt.isTaskExists(id)) { if (gantt.isTaskExists(id)) {

Loading…
Cancel
Save