diff --git a/edit-mode/function/function.js b/edit-mode/function/function.js
index c62e1b3..b0985ca 100644
--- a/edit-mode/function/function.js
+++ b/edit-mode/function/function.js
@@ -15,23 +15,22 @@ function getUrlParameter(sParam) {
};
const formatNumber = (angka) => {
- var number_string = angka.replace(/[^,\d]/g, '').toString(),
- split = number_string.split(','),
- sisa = split[0].length % 3,
- rupiah = split[0].substr(0, sisa),
- ribuan = split[0].substr(sisa).match(/\d{3}/gi);
- var separator = "";
- if(ribuan){
- separator = sisa ? '.' : '';
- rupiah += separator + ribuan.join('.');
- }
-
- rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
- return rupiah
+ var number_string = angka.replace(/[^,\d]/g, '').toString(),
+ split = number_string.split(','),
+ sisa = split[0].length % 3,
+ rupiah = split[0].substr(0, sisa),
+ ribuan = split[0].substr(sisa).match(/\d{3}/gi);
+ var separator = "";
+ if (ribuan) {
+ separator = sisa ? '.' : '';
+ rupiah += separator + ribuan.join('.');
+ }
+
+ rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
+ return rupiah
}
-function getCodeLinkByType(type)
-{
+function getCodeLinkByType(type) {
type = parseInt(type);
switch (type) {
case 1:
@@ -49,7 +48,7 @@ function getCodeLinkByType(type)
}
}
-var getInput = function(node){
+var getInput = function (node) {
return node.querySelector("input");
};
@@ -103,7 +102,7 @@ gantt.config.editor_types.progressCustom = {
hide: function () {
},
set_value: function (value, id, column, node) {
- value = value*100
+ value = value * 100
getInput(node).value = value;
},
get_value: function (id, column, node) {
@@ -131,12 +130,12 @@ gantt.config.editor_types.progressCustom = {
}
};
-function initializationProject(){
+function initializationProject() {
let projectId = getUrlParameter("proyek_id");
- if(projectId && projectId > 0){
+ if (projectId && projectId > 0) {
$.ajax({
url: `${base_url}project/edit/${projectId}`,
- type:"GET",
+ type: "GET",
success: function (result) {
let data = result.data;
let projectName = data.nama;
@@ -148,18 +147,18 @@ function initializationProject(){
}
}
-function getSatuan(){
+function getSatuan() {
$.ajax({
url: `${base_url}satuan/list`,
- type:"GET",
+ type: "GET",
success: function (result) {
let satuanList = [];
let resSatuan = result.data || []
resSatuan.map((val, index) => {
let satuan = {
- key:val.id,
- label:val.name,
- text:val.name
+ key: val.id,
+ label: val.name,
+ text: val.name
}
satuanList.push(satuan)
});
@@ -192,7 +191,7 @@ function getSatuan(){
allowClear: true
});
- if(satuanList.length > 0){
+ if (satuanList.length > 0) {
gantt.updateCollection("satuan", satuanList);
gantt.refreshData();
gantt.render();
@@ -204,11 +203,10 @@ function getSatuan(){
});
}
-function updateActivity(id)
-{
+function updateActivity(id) {
$.ajax({
url: `${base_url}task/get-update/${id}`,
- type:"GET",
+ type: "GET",
success: function (result) {
let data = result.data;
gantt.getTask(id).assign_hr = data.assign_hr;
@@ -230,18 +228,17 @@ function updateActivity(id)
/* Fungsi format ribuan label*/
function formatRupiah(n) {
- var parts=n.toString().split(".");
+ var parts = n.toString().split(".");
return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".") + (parts[1] ? "," + parts[1] : "");
}
/* Fungsi format ribuan inputan*/
-function formatRibuanInput(angka, prefix)
-{
+function formatRibuanInput(angka, prefix) {
var number_string = angka.replace(/[^,\d]/g, '').toString(),
- split = number_string.split(','),
- sisa = split[0].length % 3,
- rupiah = split[0].substr(0, sisa),
- ribuan = split[0].substr(sisa).match(/\d{3}/gi);
+ split = number_string.split(','),
+ sisa = split[0].length % 3,
+ rupiah = split[0].substr(0, sisa),
+ ribuan = split[0].substr(sisa).match(/\d{3}/gi);
if (ribuan) {
separator = sisa ? '.' : '';
@@ -253,13 +250,13 @@ function formatRibuanInput(angka, prefix)
}
/* Fungsi replace titik, untuk save ke DB*/
-function formatReplaceTitikRibuan(param){
+function formatReplaceTitikRibuan(param) {
let myStr = param;
let newStr = myStr.replace(/\./g, '');
return newStr;
}
-function formatDate(params){
+function formatDate(params) {
let today = new Date(params);
let yyyy = today.getFullYear();
let mm = today.getMonth() + 1; // Months start at 0!
@@ -273,55 +270,54 @@ function formatDate(params){
}
function roundToTwo(num) {
- return +(Math.round(num + "e+2") + "e-2");
+ return +(Math.round(num + "e+2") + "e-2");
}
-function initialProperty()
-{
+function initialProperty() {
$.ajax({
url: `${base_url}user-to-version-gantt/get-by-gantt/${ganttId}`,
- type:"GET",
+ type: "GET",
success: function (result) {
let data = result.data;
- if(data.status && data.status=="not have"){
+ if (data.status && data.status == "not have") {
toggleCollapseTasks();
- }else{
- if(data.id){
+ } else {
+ if (data.id) {
userToVersionGanttId = data.id
}
- if(data.critical_path){
+ if (data.critical_path) {
gantt.config.highlight_critical_path = true;
$("#critalPathBox").prop("checked", true);
}
- if(data.auto_schedule){
+ if (data.auto_schedule) {
gantt.config.auto_schedule = true;
$("#autoSchedule").prop("checked", true);
}
- if(data.committed_cost){
- $("#committedCostBox").val(data.committed_cost);
- }
+ if (data.committed_cost) {
+ $("#committedCostBox").val(data.committed_cost);
+ }
- if(data.cost_to_complete){
- $("#costToCompleteBox").val(data.cost_to_complete);
- }
+ if (data.cost_to_complete) {
+ $("#costToCompleteBox").val(data.cost_to_complete);
+ }
- if(data.zoom){
+ if (data.zoom) {
gantt.ext.zoom.setLevel(data.zoom);
- $('input[value="'+data.zoom+'"]').prop("checked", true);
+ $('input[value="' + data.zoom + '"]').prop("checked", true);
}
- if(data.task_open){
- gantt.eachTask(function(task){
+ if (data.task_open) {
+ gantt.eachTask(function (task) {
task.$open = true;
});
toggleTasks = "Collapse";
$("#gantt_toggle_task_btn").prop('title', 'Collapse Activities');
$("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt');
$("#gantt_toggle_task_btn").children().addClass('fa-compress-alt');
- }else{
+ } else {
toggleCollapseTasks();
}
@@ -334,18 +330,17 @@ function initialProperty()
});
}
-function initializationColumn()
-{
+function initializationColumn() {
$.ajax({
url: `${base_url}gantt-show-hide/get-by-gantt/${ganttId}`,
- type:"GET",
+ type: "GET",
success: function (result) {
let data = result.data;
- if(data.status=="not yet have"){
+ if (data.status == "not yet have") {
addShowHideColumn();
- }else if(data.status=="not have access"){
+ } else if (data.status == "not have access") {
- }else{
+ } else {
setUpForShowHideColumn(data);
}
},
@@ -355,8 +350,8 @@ function initializationColumn()
});
}
-function setGanttOpen(){
- let ganttOpen = [];
+function setGanttOpen() {
+ let ganttOpen = [];
gantt.eachTask(function (task) {
const existingIndex = ganttOpen.findIndex(item => item.id === task.id);
if (existingIndex !== -1) {
@@ -371,73 +366,73 @@ function setGanttOpen(){
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;
- }
- });
- }
+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 (){
+ $("#critalPathBox").on("change", function () {
let checked = $(this).is(":checked");
- if(checked){
+ if (checked) {
gantt.config.highlight_critical_path = true;
- updateProperty({critical_path:true})
- }else{
+ updateProperty({ critical_path: true })
+ } else {
gantt.config.highlight_critical_path = false;
- updateProperty({critical_path:false})
+ updateProperty({ critical_path: false })
}
gantt.render();
});
- $("#autoSchedule").on("change", function (){
+ $("#autoSchedule").on("change", function () {
let checked = $(this).is(":checked");
- if(checked){
+ if (checked) {
gantt.config.auto_schedule = true;
- updateProperty({auto_schedule:true})
- }else{
+ updateProperty({ auto_schedule: true })
+ } else {
gantt.config.auto_schedule = false;
- updateProperty({auto_schedule:false})
+ updateProperty({ auto_schedule: false })
}
gantt.render();
});
});
-function linkLagEditor(){
+function linkLagEditor() {
- function endPopup(){
+ function endPopup() {
modal = null;
editLinkId = null;
}
- function cancelEditLink(){
+ function cancelEditLink() {
endPopup()
}
- function deleteLink(){
+ function deleteLink() {
gantt.deleteLink(editLinkId);
endPopup()
}
- function saveLink(){
+ function saveLink() {
var link = gantt.getLink(editLinkId);
var lagValue = modal.querySelector(".lag-input").value;
- if(!isNaN(parseInt(lagValue, 10))){
+ if (!isNaN(parseInt(lagValue, 10))) {
link.lag = parseInt(lagValue, 10);
}
gantt.updateLink(link.id);
- if(gantt.autoSchedule){
+ if (gantt.autoSchedule) {
gantt.autoSchedule(link.source);
}
endPopup();
@@ -447,11 +442,11 @@ function linkLagEditor(){
var modal;
var editLinkId;
- gantt.attachEvent("onLinkDblClick", function(id,e){
+ gantt.attachEvent("onLinkDblClick", function (id, e) {
editLinkId = id;
var link = gantt.getLink(id);
var linkTitle;
- switch(link.type){
+ switch (link.type) {
case gantt.config.links.finish_to_start:
linkTitle = "FS";
break;
@@ -471,17 +466,17 @@ function linkLagEditor(){
modal = gantt.modalbox({
title: linkTitle,
text: "
" +
- "" +
- "
",
+ "" +
+ "",
buttons: [
- {label:"Save", css:"link-save-btn", value:"save"},
- {label:"Cancel", css:"link-cancel-btn", value:"cancel"},
- {label:"Delete", css:"link-delete-btn", value:"delete"}
+ { label: "Save", css: "link-save-btn", value: "save" },
+ { label: "Cancel", css: "link-cancel-btn", value: "cancel" },
+ { label: "Delete", css: "link-delete-btn", value: "delete" }
],
width: "500px",
type: "popup-css-class-here",
- callback: function(result){
- switch(result){
+ callback: function (result) {
+ switch (result) {
case "save":
saveLink();
break;
@@ -504,24 +499,22 @@ function linkLagEditor(){
}
-function addShowHideColumn()
-{
+function addShowHideColumn() {
let allColumn = [];
- allColumns.forEach(function(column){
+ allColumns.forEach(function (column) {
allColumn.push(column.name);
});
submitShowHideColumn(allColumn);
}
-function submitShowHideColumn(allColumn)
-{
+function submitShowHideColumn(allColumn) {
let payload = {
- version_gantt_id:ganttId,
- columns:allColumn
+ version_gantt_id: ganttId,
+ columns: allColumn
}
$.ajax({
- data: JSON.stringify(payload),
+ data: JSON.stringify(payload),
url: `${base_url}gantt-show-hide/add`,
type: "POST",
processData: false,
@@ -535,8 +528,7 @@ function submitShowHideColumn(allColumn)
});
}
-function setUpForShowHideColumn(data)
-{
+function setUpForShowHideColumn(data) {
let columns = data || []
let configColumn = {}
@@ -550,14 +542,13 @@ function setUpForShowHideColumn(data)
gantt.render();
}
-function updateShowHideColumn(data)
-{
+function updateShowHideColumn(data) {
let payload = {
- columns:data
+ columns: data
}
$.ajax({
- data: JSON.stringify(payload),
+ data: JSON.stringify(payload),
url: `${base_url}gantt-show-hide/update/${ganttId}`,
type: "POST",
processData: false,
@@ -582,7 +573,7 @@ function colAjaxReq(type) {
isFound = ganttColumnsByType.find(obj => {
return obj.column_name == val.name;
});
- if(isFound)
+ if (isFound)
return val;
});
gantt.config.columns = x.filter(item => item);
@@ -592,14 +583,14 @@ function colAjaxReq(type) {
});
}
-async function reRenderColumns(type){
+async function reRenderColumns(type) {
await colAjaxReq(type);
}
-function updateProperty(payload){
- if(userToVersionGanttId > 0 && readOnly && parseInt(readOnly)==0){
+function updateProperty(payload) {
+ if (userToVersionGanttId > 0 && readOnly && parseInt(readOnly) == 0) {
$.ajax({
- data: JSON.stringify(payload),
+ data: JSON.stringify(payload),
url: `${base_url}user-to-version-gantt/update/${userToVersionGanttId}`,
type: "PUT",
processData: false,
@@ -612,7 +603,7 @@ function updateProperty(payload){
}
}
-function costPlanningChange(e){
+function costPlanningChange(e) {
let value = e.value;
value = replaceAll(value, ".", "")
value = replaceAll(value, ",", ".")
@@ -625,18 +616,18 @@ function escapeRegExp(string) {
}
function replaceAll(str, find, replace) {
- if(str){
+ if (str) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
return str
}
-function expandTask(){
- gantt.eachTask(function(task){
- task.$open = true;
- });
- toggleTasks = "Collapse";
- $("#gantt_toggle_task_btn").prop('title', 'Collapse Activities');
- $("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt');
- $("#gantt_toggle_task_btn").children().addClass('fa-compress-alt');
- gantt.render();
+function expandTask() {
+ gantt.eachTask(function (task) {
+ task.$open = true;
+ });
+ toggleTasks = "Collapse";
+ $("#gantt_toggle_task_btn").prop('title', 'Collapse Activities');
+ $("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt');
+ $("#gantt_toggle_task_btn").children().addClass('fa-compress-alt');
+ gantt.render();
}
diff --git a/edit-mode/function/ganttEvent.js b/edit-mode/function/ganttEvent.js
index 8c7fd4e..011b413 100644
--- a/edit-mode/function/ganttEvent.js
+++ b/edit-mode/function/ganttEvent.js
@@ -1,57 +1,57 @@
-gantt.attachEvent("onTaskDblClick", function(id,e){
+gantt.attachEvent("onTaskDblClick", function (id, e) {
return false;
});
-gantt.attachEvent("onAfterTaskAdd", function(id,item){
- if(item.parent && gantt.hasChild()) {
+gantt.attachEvent("onAfterTaskAdd", function (id, item) {
+ if (item.parent && gantt.hasChild()) {
let parentId = item.parent;
- if(gantt.getTask(parentId).parent_id != null){
- gantt.getTask(parentId).type = "project";
- gantt.updateTask(parentId);
- }
- }
+ if (gantt.getTask(parentId).parent_id != null) {
+ gantt.getTask(parentId).type = "project";
+ gantt.updateTask(parentId);
+ }
+ }
});
-gantt.attachEvent("onTaskRowClick", function(id,row){
+gantt.attachEvent("onTaskRowClick", function (id, row) {
activityId = id;
var activity = gantt.getTaskBy("id", id);
activityName = activity[0]?.name;
});
-gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function(state){
+gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function (state) {
let id = parseInt(state.id)
let ganttData = gantt.getTask(id);
- if(ganttData?.type_activity=="header"){
+ if (ganttData?.type_activity == "header") {
return false
}
let column = state.columnName
- if(column=="progress" || column=="rencana_biaya"){
+ if (column == "progress" || column == "rencana_biaya") {
let hasChild = gantt.hasChild(id);
- if(hasChild){
+ if (hasChild) {
return false
}
}
- if(column=="cost_actual"){
+ if (column == "cost_actual") {
let progress = ganttData.progress ? ganttData.progress : 0
- if(progress <= 0){
+ if (progress <= 0) {
return false
}
}
return true
- });
+});
-gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
+gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) {
// format progress
let progress = new_item.progress;
- if(progress > 100){
+ if (progress > 100) {
progress = 100;
- }else if(progress <= 0){
+ } else if (progress <= 0) {
progress = 0;
- }else if(progress <= 1 && progress > 0){
- progress = progress*100
+ } else if (progress <= 1 && progress > 0) {
+ progress = progress * 100
}
- progress = progress/100;
+ progress = progress / 100;
let task = gantt.getTask(id);
let link = task.$target;
// link.length > 0 -> successor
@@ -76,44 +76,44 @@ gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
}
});
-gantt.attachEvent("onAfterTaskDrag", function(id, mode, e){
+gantt.attachEvent("onAfterTaskDrag", function (id, mode, e) {
var task = gantt.getTask(id);
task.end_date = gantt.calculateEndDate(task);
gantt.updateTask(id);
});
-gantt.attachEvent("onBeforeLinkAdd", function(id,link){
+gantt.attachEvent("onBeforeLinkAdd", function (id, link) {
//any custom logic here
let source = link.source;
let target = link.target;
let parents = gantt.getParent(source);
let parentt = gantt.getParent(target);
- let childt = gantt.hasChild(target);
- if(childt){
+ let childt = gantt.hasChild(target);
+ if (childt) {
return false;
}
- if(parents==target){
+ if (parents == target) {
return false;
}
- if(parentt==source){
+ if (parentt == source) {
return false
}
return true;
});
-gantt.attachEvent("onGanttReady", function(){
+gantt.attachEvent("onGanttReady", function () {
});
-gantt.attachEvent("onGanttRender", function(){
- if(readOnly && parseInt(readOnly)==1){
+gantt.attachEvent("onGanttRender", function () {
+ if (readOnly && parseInt(readOnly) == 1) {
gantt.config.readonly = true;
- }else if(readOnly && parseInt(readOnly)==0){
+ } else if (readOnly && parseInt(readOnly) == 0) {
gantt.config.readonly = false;
- }else{
+ } else {
gantt.config.readonly = true;
}
});
diff --git a/edit-mode/function/restActivityLink.js b/edit-mode/function/restActivityLink.js
index 8b39953..4e7e86b 100644
--- a/edit-mode/function/restActivityLink.js
+++ b/edit-mode/function/restActivityLink.js
@@ -7,7 +7,7 @@ gantt.ajax.get({
}
}).then(function (xhr) {
let data = {};
- let response = xhr.responseText;
+ let response = xhr.responseText;
let obj = JSON.parse(response);
data['data'] = obj.data.data;
data['links'] = obj.data.links;
@@ -20,38 +20,38 @@ gantt.ajax.get({
isBaselineSet = false;
}
}
- geom = [];
- data.data.forEach(element => {
- geom.push({
- "activity_id": element.id,
- "geom": element.geom
- })
- });
+ geom = [];
+ data.data.forEach(element => {
+ geom.push({
+ "activity_id": element.id,
+ "geom": element.geom
+ })
+ });
gantt.silent(function () {
gantt.parse(data);
getGanttOpen();
});
- if (Date.now() < timestamp) {
- gantt.ajax.post({
- headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${token}`
- },
- url: `${base_url}activity/import-update`,
- dataType: "json",
- data: JSON.stringify(allTasks)
- }).then(function(response){
- let res = response.responseText
- res = JSON.parse(res)
- if (res) {
- refresData();
- }
- });
- }
+ if (Date.now() < timestamp) {
+ gantt.ajax.post({
+ headers: {
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${token}`
+ },
+ url: `${base_url}activity/import-update`,
+ dataType: "json",
+ data: JSON.stringify(allTasks)
+ }).then(function (response) {
+ let res = response.responseText
+ res = JSON.parse(res)
+ if (res) {
+ refresData();
+ }
+ });
+ }
});
-function refresData(id){
- console.log("refres triggered!!");
+function refresData(id) {
+ console.log("refres triggered!!");
// Store the current scroll position
var scrollState = {
@@ -68,30 +68,30 @@ function refresData(id){
}).then(function (xhr) {
gantt.clearAll();
let data = {};
- let response = xhr.responseText;
+ let response = xhr.responseText;
let obj = JSON.parse(response);
data['data'] = obj.data.data;
data['links'] = obj.data.links;
- geom = [];
- data.data.forEach(element => {
- geom.push({
- "activity_id": element.id,
- "geom": element.geom
- })
- });
+ geom = [];
+ data.data.forEach(element => {
+ geom.push({
+ "activity_id": element.id,
+ "geom": element.geom
+ })
+ });
gantt.silent(function () {
gantt.parse(data);
getGanttOpen();
});
- if(id){
- if(gantt.isTaskExists(id)){
+ if (id) {
+ if (gantt.isTaskExists(id)) {
expandTask();
}
}
// Restore the scroll position
gantt.scrollTo(scrollState.x, scrollState.y);
-
+
});
}
@@ -99,68 +99,68 @@ function refresData(id){
// action - "create"|"update"|"delete"
// data - an object with task or link data
// id – the id of a processed object (task or link)
-var dp = gantt.createDataProcessor(function(entity, action, data, id) {
- switch(action) {
+var dp = gantt.createDataProcessor(function (entity, action, data, id) {
+ switch (action) {
case "create":
- if(entity=="task"){
+ if (entity == "task") {
data['proyek_id'] = proyekId;
//TODO : Possible end date bug
data['start_date'] = `${data.start_date}+07`;
let endDate = moment(data.end_date, "YYYY-MM-DD");
- data['end_date'] = endDate.format("YYYY-MM-DD")+" 23:59:59+07";
+ data['end_date'] = endDate.format("YYYY-MM-DD") + " 23:59:59+07";
let newDuration = gantt.calculateDuration({
- start_date: new Date(data['start_date']),
- end_date: new Date(data['end_date'])
+ start_date: new Date(data['start_date']),
+ end_date: new Date(data['end_date'])
})
data['duration'] = newDuration;
- if(data && data.parent){
+ if (data && data.parent) {
data['parent_id'] = data.parent;
}
}
data['version_gantt_id'] = ganttId;
return gantt.ajax.post({
headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${token}`
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${token}`
},
url: base_url + entity,
- data:JSON.stringify(data)
- }).then(function(response){
+ data: JSON.stringify(data)
+ }).then(function (response) {
let res = response.responseText
res = JSON.parse(res)
- if(entity=="link"){
+ if (entity == "link") {
gantt.changeLinkId(id, res.tid);
- }else if(entity=="task"){
+ } else if (entity == "task") {
gantt.changeTaskId(id, res.tid);
}
});
- break;
+ break;
case "update":
- if(entity=="task"){
- // let startDate = moment(data.start_date, "YYYY-MM-DD").subtract(1, "days");
- let startDate = moment(data.start_date, "YYYY-MM-DD");
- // data['start_date'] = startDate.format("YYYY-MM-DD")+" 00:00:00+07";
- let endDate = moment(data.end_date, "YYYY-MM-DD");
+ if (entity == "task") {
+ // let startDate = moment(data.start_date, "YYYY-MM-DD").subtract(1, "days");
+ let startDate = moment(data.start_date, "YYYY-MM-DD");
+ // data['start_date'] = startDate.format("YYYY-MM-DD")+" 00:00:00+07";
+ let endDate = moment(data.end_date, "YYYY-MM-DD");
- if(startDate > endDate){
- gantt.alert({
- title:"Peringatan",
- type:"alert-error",
- text:"Tanggal selesai tidak bisa sebelum tanggal mulai!"
- });
- data['end_date'] = data['start_date'];
- refresData(id);
- return;
- }
+ if (startDate > endDate) {
+ gantt.alert({
+ title: "Peringatan",
+ type: "alert-error",
+ text: "Tanggal selesai tidak bisa sebelum tanggal mulai!"
+ });
+ data['end_date'] = data['start_date'];
+ refresData(id);
+ return;
+ }
- if(data && data.parent){
+ if (data && data.parent) {
data['parent_id'] = data.parent;
}
- Object.keys(data).forEach(function(key) {
- if(data[key]==""){
- data[key]=null;
+ Object.keys(data).forEach(function (key) {
+ if (data[key] == "") {
+ data[key] = null;
}
});
}
@@ -170,50 +170,50 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
data['duration'] = gantt.calculateDuration({
start_date: newStart,
end_date: newEnd
- });
+ });
}
data['geom'] = geom.find(obj => obj.activity_id == id)?.geom;
return gantt.ajax.put({
headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${token}`
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${token}`
},
url: base_url + entity + "/" + id,
- data:JSON.stringify(data)
- }).then(function(response){
- if(entity=="task"){
+ data: JSON.stringify(data)
+ }).then(function (response) {
+ if (entity == "task") {
let parent = data.parent;
let responseText = JSON.parse(response.responseText)
let resData = responseText
let updateBobot = resData.update_bobot || false
if (updateBobot) {
- if (parent && parent > 0) {
- updateActivity(parent);
- }
- refresData(id);
+ if (parent && parent > 0) {
+ updateActivity(parent);
+ }
+ refresData(id);
} else if (parent && parent > 0) {
- updateActivity(parent);
+ updateActivity(parent);
}
}
});
- break;
+ break;
case "delete":
return gantt.ajax.del({
headers: {
- "Authorization": `Bearer ${token}`
+ "Authorization": `Bearer ${token}`
},
url: base_url + entity + "/" + id
- }).then(function(response){
- if(entity=="task"){
+ }).then(function (response) {
+ if (entity == "task") {
let parent = data.parent;
- if(parent && parent > 0){
+ if (parent && parent > 0) {
let children = gantt.getChildren(parent);
updateActivity(parent);
- if(children && children.length > 0){
+ if (children && children.length > 0) {
- }else{
- if(gantt.isTaskExists(parent)){
+ } else {
+ if (gantt.isTaskExists(parent)) {
gantt.getTask(parent).type = "task";
gantt.updateTask(parent);
}
@@ -221,6 +221,6 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
}
}
});
- break;
- }
+ break;
+ }
});