From f66ded0927004cc232cb9a7608b912a8046ec9d1 Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 11 Oct 2023 09:25:58 +0700 Subject: [PATCH] fix hr date --- edit-mode/function/ganttConfig.js | 2 ++ edit-mode/function/ganttEvent.js | 2 ++ edit-mode/function/humanResource.js | 15 +++++++++++++++ edit-mode/index.html | 4 ++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/edit-mode/function/ganttConfig.js b/edit-mode/function/ganttConfig.js index 6263a9a..0c07b6a 100644 --- a/edit-mode/function/ganttConfig.js +++ b/edit-mode/function/ganttConfig.js @@ -10,6 +10,8 @@ let userToVersionGanttId = 0 let activityId = 0; let actionHappen = false; let activityName = ""; +let activityEarlyStart; +let activityEarlyFinish; let token = getUrlParameter("token"); let forceDurationUpdateTriggered = false; let editEndDateDurationTriggered = false; diff --git a/edit-mode/function/ganttEvent.js b/edit-mode/function/ganttEvent.js index 76f5914..47c6247 100644 --- a/edit-mode/function/ganttEvent.js +++ b/edit-mode/function/ganttEvent.js @@ -17,6 +17,8 @@ gantt.attachEvent("onTaskRowClick", function (id, row) { activityId = id; var activity = gantt.getTaskBy("id", id); activityName = activity[0]?.name; + activityEarlyStart = new Date(activity[0]?.start_date); + activityEarlyFinish = new Date(activity[0]?.end_date); }); gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function (state) { diff --git a/edit-mode/function/humanResource.js b/edit-mode/function/humanResource.js index 85058ac..d297fb7 100644 --- a/edit-mode/function/humanResource.js +++ b/edit-mode/function/humanResource.js @@ -153,6 +153,21 @@ $(document).ready(function () { }); + $("#hr-start-date").on('change', (e) => { + let start_date = new Date($("#hr-start-date").val()); + if (start_date < activityEarlyStart || start_date > activityEarlyFinish) { + gantt.alert("Start date should be inside activity date range !"); + $("#hr-start-date").val(""); + } + }) + + $("#hr-end-date").on('change', (e) => { + let end_date = new Date($("#hr-end-date").val()); + if (end_date < activityEarlyStart || end_date > activityEarlyFinish) { + gantt.alert("End date should be inside activity date range !"); + $("#hr-end-date").val(""); + } + }) $("#form-assign-hr").on('submit', function (e) { e.preventDefault(); diff --git a/edit-mode/index.html b/edit-mode/index.html index fc78a60..67213d6 100644 --- a/edit-mode/index.html +++ b/edit-mode/index.html @@ -138,7 +138,7 @@