Browse Source

Add formatting

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
be7ddd5ffc
  1. 99
      edit-mode/function/ganttConfig.js

99
edit-mode/function/ganttConfig.js

@ -27,8 +27,7 @@ axiosInstance.interceptors.request.use(async (config) => {
try {
$("body").addClass("loading");
}
catch(e)
{
catch (e) {
$("body").removeClass("loading");
alert('Error request' + e);
}
@ -40,8 +39,7 @@ axiosInstance.interceptors.response.use(async (config) => {
try {
$("body").removeClass("loading");
}
catch(e)
{
catch (e) {
$("body").removeClass("loading");
alert('Error response' + e);
}
@ -275,34 +273,43 @@ var allColumns = [
{ name: "text", label: "Activity", tree: true, min_width: 150, editor: editor.text, resize: true },
{ name: "start_date", label: "Start Date", align: "center", min_width: 80, editor: editor.start_date, resize: true },
{ name: "end_date", label: "Finish Date", align: "center", min_width: 80, editor: editor.end_date, resize: true },
{ name: "planned_start", label: "Planned Start", align: "center", min_width: 80, editor: editor.planned_start, resize: true, template: function (text) {
{
name: "planned_start", label: "Planned Start", align: "center", min_width: 80, editor: editor.planned_start, resize: true, template: function (text) {
if (!text.planned_start) {
return text.start_date;
}
return text.planned_start;
} },
{ name: "planned_end", label: "Planned End", align: "center", min_width: 80, editor: editor.planned_end, resize: true, template: function (text) {
}
},
{
name: "planned_end", label: "Planned End", align: "center", min_width: 80, editor: editor.planned_end, resize: true, template: function (text) {
if (!text.planned_end) {
return text.end_date;
}
return text.planned_end;
} },
}
},
{ name: "duration", label: "Duration (Day)", align: "center", min_width: 50, resize: true, editor: editor.duration },
{ name: "rencana_biaya", label: "Cost Planning", align: "right", min_width: 100, resize: true, template: function (text) {
{
name: "rencana_biaya", label: "Cost Planning", align: "right", min_width: 100, resize: true, template: function (text) {
if (!text.rencana_biaya) {
return
}
let rencana_biaya = roundToTwo(text.rencana_biaya)
return "Rp. " + formatRupiah(rencana_biaya)
} },
{ name: "cost_actual", label: "Cost Actual", align: "right", min_width: 100, resize: true, template: function (text) {
}
},
{
name: "cost_actual", label: "Cost Actual", align: "right", min_width: 100, resize: true, template: function (text) {
if (!text.biaya_actual) {
return
}
let biaya_actual = roundToTwo(text.biaya_actual)
return "Rp. " + formatRupiah(biaya_actual)
} },
{ name: "assign_hr", label: "Assign To", align: "center", min_width: 150, resize: true, template: function (text) {
}
},
{
name: "assign_hr", label: "Assign To", align: "center", min_width: 150, resize: true, template: function (text) {
if (text.type == "project" || text.type == "milestone" || text.type == "header") {
return;
}
@ -324,7 +331,8 @@ var allColumns = [
</div>`
}
},
{ name: "material", label: "Material", align: "center", min_width: 150, resize: true, template: function (text) {
{
name: "material", label: "Material", align: "center", min_width: 150, resize: true, template: function (text) {
if (text.type == "project" || text.type == "milestone" || text.type == "header") {
return;
}
@ -341,8 +349,10 @@ var allColumns = [
return `<div class="d-flex justify-content-center align-items-center" data-toggle="modal" data-target="#modal-material" style="min-width:100%;height:100%;">
${html}
</div>`
} },
{ name: "expenses", label: "Overhead", align: "center", min_width: 150, resize: true, template: function (text) {
}
},
{
name: "expenses", label: "Overhead", align: "center", min_width: 150, resize: true, template: function (text) {
if (text.type == "project" || text.type == "milestone" || text.type == "header") {
return;
}
@ -359,8 +369,10 @@ var allColumns = [
return `<div class="d-flex justify-content-center align-items-center" data-toggle="modal" data-target="#modal-expense" style="min-width:100%;height:100%;">
${html}
</div>`
} },
{ name: "tools", label: "Tools", align: "center", min_width: 150, resize: true, template: function (text) {
}
},
{
name: "tools", label: "Tools", align: "center", min_width: 150, resize: true, template: function (text) {
if (text.type == "project" || text.type == "milestone" || text.type == "header") {
return;
}
@ -377,9 +389,11 @@ var allColumns = [
return `<div class="d-flex justify-content-center align-items-center" data-toggle="modal" data-target="#modal-tools" style="min-width:100%;height:100%;">
${html}
</div>`
} },
}
},
// { name: "status", label: "Status", align: "center", editor: editor.status, resize: true },
{ name: "bobot_planning", label: "Bobot Activity (%)", align: "center", editor: editor.bobot_planning, resize: true, min_width: 115, template: function (text) {
{
name: "bobot_planning", label: "Bobot Activity (%)", align: "center", editor: editor.bobot_planning, resize: true, min_width: 115, template: function (text) {
let bobot = parseFloat(text.bobot_planning);
if (bobot.toFixed(2) > 100) {
gantt.alert("Bobot tidak boleh lebih dari 100%!");
@ -390,13 +404,17 @@ var allColumns = [
}
let bobot_planning = parseFloat(text.bobot_planning);
return roundToTwo(bobot_planning);
} },
{ name: "progress", label: "Actual Progress (%)", align: "center", editor: progressEditor ,min_width: 125, template: function (text) {
}
},
{
name: "progress", label: "Actual Progress (%)", align: "center", editor: progressEditor, min_width: 125, template: function (text) {
let progress = text.progress
progress = progress * 100
return roundToTwo(progress);
}, resize: true },
{ name:"progress_actual", label: "Total Actual Progress (%)", align: "center", min_width: 150, template: function (text) {
}, resize: true
},
{
name: "progress_actual", label: "Total Actual Progress (%)", align: "center", min_width: 150, template: function (text) {
let progress = text.progress
progress = progress * 100
if (progress.toFixed(2) > 100) {
@ -406,9 +424,11 @@ var allColumns = [
let bobot = text.bobot_planning
let actual = (progress * bobot) / 100
return roundToTwo(actual);
}, resize: true },
}, resize: true
},
{ name: "jumlah_pekerjaan", label: "Volume Plan", align: "center", min_width: 100, resize: true, editor: editor.job_count },
{ name: "jobs_done", label: "Report", align: "center", min_width: 100, resize: true, template: function (text) {
{
name: "jobs_done", label: "Report", align: "center", min_width: 100, resize: true, template: function (text) {
if (text.type == "project" || text.type == "milestone" || text.type == "header") {
return;
}
@ -421,7 +441,8 @@ var allColumns = [
return `<div class="d-flex justify-content-center align-items-center" data-toggle="modal" data-target="#modal_report_activity" style="min-width:100%;height:100%;">
${html}
</div>`
} },
}
},
{ name: "satuan", label: "UOM", align: "center", min_width: 100, resize: true, editor: editor.satuan, template: satuanLabel },
{
name: "predecessor", label: "Predecessor", align: "center", min_width: 100, template: function (text) {
@ -613,13 +634,15 @@ var zoomConfig = {
scale_height: 50,
min_column_width: 50,
scales: [
{unit: "week", step: 1, format: function (date) {
{
unit: "week", step: 1, format: function (date) {
var dateToStr = gantt.date.date_to_str("%d %M");
var endDate = gantt.date.add(date, -6, "day");
var weekNum = gantt.date.date_to_str("%W")(date);
var year = gantt.date.date_to_str("%Y")(date);
return "W#" + weekNum + ", " + dateToStr(date) + " - " + dateToStr(endDate) + " " + year;
}},
}
},
{ unit: "day", step: 1, format: "%d %M" }
]
},
@ -635,10 +658,12 @@ var zoomConfig = {
// var year = gantt.date.date_to_str("%Y")(date);
// return "#" + weekNum + ", " + dateToStr(date) + " - " + dateToStr(endDate) + " " + year;
// }},
{unit: "week", step: 1, format: function (date) {
{
unit: "week", step: 1, format: function (date) {
var weekNum = gantt.date.date_to_str("%W")(date);
return "W#" + weekNum;
}},
}
},
{ unit: "month", format: "%F, %Y" },
// {unit: "day", step: 1, format: "%j %D"}
]
@ -705,14 +730,18 @@ for (var i = 0; i < radios.length; i++) {
// GANTT PERFORMANCE CONFIG RECOMMENDATION
gantt.config.scales = [
{ unit: "month", step: 1, format: "%F, %Y" },
{unit: "week", step: 1, format: function (date) {
{
unit: "week", step: 1, format: function (date) {
return "Week #" + gantt.date.getWeek(date);
}},
{unit: "day", step: 1, format: "%D", css: function(date) {
}
},
{
unit: "day", step: 1, format: "%D", css: function (date) {
if (!gantt.isWorkTime({ date: date, unit: "day" })) {
return "weekend"
}
}}
}
}
];
gantt.config.show_task_cells = false;
gantt.config.static_background = true;

Loading…
Cancel
Save