From 63901b3c8ea1fccf11017eab4ca77cfa282e44bd Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Thu, 17 Nov 2022 16:28:44 +0700 Subject: [PATCH] remove unused codes --- edit-mode/function/function.js | 1 - edit-mode/function/ganttConfig.js | 68 ++++++++------------------ edit-mode/function/ganttEvent.js | 6 +-- edit-mode/function/restActivityLink.js | 12 +---- 4 files changed, 23 insertions(+), 64 deletions(-) diff --git a/edit-mode/function/function.js b/edit-mode/function/function.js index 35f4d40..1e10fd7 100644 --- a/edit-mode/function/function.js +++ b/edit-mode/function/function.js @@ -124,7 +124,6 @@ function initializationProject(){ success: function (result) { let data = result.data; let projectName = data.nama; - // $("#project-name-header").html(projectName); }, error: function (data) { actionHappen = false; diff --git a/edit-mode/function/ganttConfig.js b/edit-mode/function/ganttConfig.js index 0f037c4..9c31277 100644 --- a/edit-mode/function/ganttConfig.js +++ b/edit-mode/function/ganttConfig.js @@ -75,14 +75,7 @@ gantt.plugins({ auto_scheduling: true }); -// gantt.templates.parse_date = function (date) { -// return new Date(2019,01,01); -// }; - -// gantt.config.highlight_critical_path = true; gantt.config.date_format = "%Y-%m-%d %H:%i:%s"; -// gantt.config.date_format="%d-%m-%Y %H:%i:%s"; -// gantt.config.date_grid="%d-%m-%Y %H:%i:%s"; gantt.config.auto_scheduling = true; gantt.config.fit_tasks = true; if (!base_url) { @@ -150,7 +143,7 @@ const editor = { kode_sortname: { type: "text", map_to: "kode_sortname" }, start_date: { type: "date", map_to: "start_date", min: new Date(2018, 0, 1) }, end_date: { type: "date", map_to: "end_date", min: new Date(2018, 0, 1) }, - duration: { type: "duration", map_to: "duration", min: 0, max: 365, formatter: formatter }, + duration: { type: "duration", map_to: "duration", min: 1, max: 365, formatter: formatter }, cost: { type: "number", map_to: "rencana_biaya", min: 0 }, costActual: { type: "number", map_to: "biaya_actual", min: 0 }, status: { type: "text", map_to: "status" }, @@ -177,7 +170,7 @@ function addWithoutParent() { text: `New Activity`, start_date: start_date, biaya: 10000, - duration: 7 + duration: 1 }); gantt.selectTask(taskId); @@ -198,7 +191,7 @@ function addWithParent(id) { id: no, text: `New Activity`, start_date: start_date, - duration: 7 + duration: 1 }, id); no = no + 1; @@ -234,13 +227,8 @@ function clickGridButton(id, action) { function createColumnsConfig(selectedColumns){ var newColumns = []; - allColumns.forEach(function(column){ - // restore the action if(selectedColumns[column.name]){ - // if (column.name === 'action') { - // newColumns.push(column); - // } newColumns.push(column); } }); @@ -253,8 +241,17 @@ var allColumns = [ { name: "kode_sortname", label: "Kode / Sortname",align: "center", min_width: 120, editor: editor.kode_sortname, resize: true }, { 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, template: function(task){ + // var gridDateToStr = gantt.date.date_to_str("%Y-%m-%d"); + // if (task.type == gantt.config.types.milestone) { + // return '' + // } + // else { + // return gridDateToStr(new Date(task.end_date.valueOf() - 1)); + // } + // }}, { name: "end_date", label: "Finish Date", align: "center", min_width: 80, editor: editor.end_date, resize: true }, - { name: "duration", label: "Duration", align: "center", min_width: 50, editor: editor.duration, resize: true }, + { name: "duration", label: "Duration", align: "center", min_width: 50, resize: true }, { name: "rencana_biaya", label: "Cost Planning", align: "center", min_width: 100, resize: true, template: function (text) { if(!text.rencana_biaya){ return @@ -387,8 +384,6 @@ gantt.config.columns = createColumnsConfig({ action: true, kode_sortname: true, text: true, - // planned_start: true, - // planned_end: true, start_date: true, end_date: true, duration: true, @@ -409,34 +404,16 @@ gantt.config.columns = createColumnsConfig({ gantt.config.reorder_grid_columns = true; gantt.config.resize_rows = true; -gantt.config.grid_resize = true; // pro edition +gantt.config.grid_resize = true; gantt.config.min_column_width = 50; gantt.config.scale_height = 20; -// gantt.config.row_height = 30; gantt.config.order_branch = "marker"; gantt.config.order_branch_free = true; gantt.config.open_tree_initially = true; -// adding baseline -// gantt.config.bar_height = 16; -// gantt.config.row_height = 40; - gantt.config.row_height = 30; gantt.config.task_height = 20; -// gantt.locale.labels.baseline_enable_button = 'Set'; -// gantt.locale.labels.baseline_disable_button = 'Remove'; -// gantt.config.lightbox.sections = [ -// {name: "Activity", height: 70, map_to: "text", type: "textarea", focus: true}, -// {name: "time", map_to: "auto", type: "duration"}, -// { -// name: "baseline", -// map_to: {start_date: "planned_start", end_date: "planned_end"}, -// button: true, -// type: "duration_optional" -// } -// ]; -// gantt.locale.labels.section_baseline = "Planned"; // adding baseline display gantt.addTaskLayer({ renderer: { @@ -445,19 +422,14 @@ gantt.addTaskLayer({ var sizes = gantt.getTaskPosition(task, task.planned_start, task.planned_end); var el = document.createElement('div'); el.className = 'baseline'; - // el.style.left = sizes.left + 'px'; - // el.style.width = sizes.width + 'px'; - // el.style.top = sizes.top + gantt.config.bar_height + 13 + 'px'; el.style.left = sizes.left - 6 + 'px'; el.style.width = sizes.width + 10+ 'px'; el.style.height= sizes.height + 'px'; - // el.style.top = sizes.top + 1 + 'px'; el.style.top = sizes.top + 2 + 'px'; return el; } return false; }, - // define getRectangle in order to hook layer with the smart rendering getRectangle: function(task, view){ if (task.planned_start && task.planned_end) { return gantt.getTaskPosition(task, task.planned_start, task.planned_end); @@ -477,6 +449,10 @@ gantt.templates.task_class = function (start, end, task) { } }; +// gantt.templates.task_end_date = function(date){ +// return gantt.templates.task_date(new Date(date.valueOf() - 1)); +// }; + gantt.templates.rightside_text = function (start, end, task) { if (task.planned_end) { if (end.getTime() > task.planned_end.getTime()) { @@ -519,13 +495,10 @@ gantt.config.layout = { }; -// custom folder, file, collapse icons on activity gantt.templates.grid_folder = function (item) { - // return "
"; return ""; }; gantt.templates.grid_file = function (item) { - // return "
"; return ""; }; @@ -636,8 +609,7 @@ for (var i = 0; i < radios.length; i++) { }; } // end Zoom Scale function -// -// + // GANTT PERFORMANCE CONFIG RECOMMENDATION gantt.config.scales = [ {unit: "month", step: 1, format: "%F, %Y"}, @@ -654,7 +626,7 @@ gantt.config.show_task_cells = false; gantt.config.static_background = true; gantt.config.branch_loading = true; gantt.config.smart_scales = true; -// gantt.config.smart_rendering = true; +gantt.config.smart_rendering = true; // gantt initialization $(document).ready(function () { diff --git a/edit-mode/function/ganttEvent.js b/edit-mode/function/ganttEvent.js index fba50f6..ef17cac 100644 --- a/edit-mode/function/ganttEvent.js +++ b/edit-mode/function/ganttEvent.js @@ -3,14 +3,10 @@ gantt.attachEvent("onTaskDblClick", function(id,e){ }); gantt.attachEvent("onAfterTaskAdd", function(id,item){ - if(item.parent > 0 && gantt.hasChild()) { + if(item.parent && gantt.hasChild()) { let parentId = item.parent; gantt.getTask(parentId).type = "project"; gantt.updateTask(parentId); - } else if (item.parent && gantt.hasChild()) { - let parentId = item.parent; - gantt.getTask(parentId).type = "task"; - gantt.updateTask(parentId); } }); diff --git a/edit-mode/function/restActivityLink.js b/edit-mode/function/restActivityLink.js index e3908ac..4865531 100644 --- a/edit-mode/function/restActivityLink.js +++ b/edit-mode/function/restActivityLink.js @@ -56,13 +56,10 @@ function refresData(id){ var dp = gantt.createDataProcessor(function(entity, action, data, id) { switch(action) { case "create": - if(entity=="task"){ data['proyek_id'] = proyekId; data['start_date'] = `${data.start_date}+07`; data['end_date'] = `${data.start_date}`; - // data['start_date'] = moment(data.start_date).format("DD-MM-YYYY HH:mm:ss+07"); - // data['end_date'] = moment(data.end_date).format("DD-MM-YYYY HH:mm:ss+07"); if(data && data.parent){ data['parent_id'] = data.parent; @@ -84,15 +81,12 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) { }else if(entity=="task"){ gantt.changeTaskId(id, res.tid); } - // refresData(); }); break; case "update": if(entity=="task"){ - data['start_date'] = moment(data.start_date).format("YYYY-MM-DD HH:mm:ss+07"); - data['end_date'] = moment(data.end_date).format("YYYY-MM-DD HH:mm:ss+07"); - // data['planned_start'] = moment(data.planned_start).format("YYYY-MM-DD HH:mm:ss+07"); - // data['planned_end'] = moment(data.planned_end).format("YYYY-MM-DD HH:mm:ss+07"); + data['start_date'] = moment(data.start_date).format("YYYY-MM-DD")+" 00:00:00+07"; + data['end_date'] = moment(data.end_date).format("YYYY-MM-DD")+" 17:00:00+07"; if(data && data.parent){ data['parent_id'] = data.parent; @@ -104,8 +98,6 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) { } }); } - // let dataProgress = parseInt(data.progress) - // dataProgress = dataProgress/100 return gantt.ajax.put({ headers: { "Content-Type": "application/json",