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

@ -637,3 +637,32 @@ function resetActivity() {
localStorage.setItem('batchEntity', '');
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 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");
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");
repaint = true;
}

6
edit-mode/function/restActivityLink.js

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

Loading…
Cancel
Save