Browse Source

remove unused codes

pull/1/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
63901b3c8e
  1. 1
      edit-mode/function/function.js
  2. 68
      edit-mode/function/ganttConfig.js
  3. 6
      edit-mode/function/ganttEvent.js
  4. 12
      edit-mode/function/restActivityLink.js

1
edit-mode/function/function.js

@ -124,7 +124,6 @@ function initializationProject(){
success: function (result) { success: function (result) {
let data = result.data; let data = result.data;
let projectName = data.nama; let projectName = data.nama;
// $("#project-name-header").html(projectName);
}, },
error: function (data) { error: function (data) {
actionHappen = false; actionHappen = false;

68
edit-mode/function/ganttConfig.js

@ -75,14 +75,7 @@ gantt.plugins({
auto_scheduling: true 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 = "%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.auto_scheduling = true;
gantt.config.fit_tasks = true; gantt.config.fit_tasks = true;
if (!base_url) { if (!base_url) {
@ -150,7 +143,7 @@ const editor = {
kode_sortname: { type: "text", map_to: "kode_sortname" }, kode_sortname: { type: "text", map_to: "kode_sortname" },
start_date: { type: "date", map_to: "start_date", min: new Date(2018, 0, 1) }, 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) }, 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 }, cost: { type: "number", map_to: "rencana_biaya", min: 0 },
costActual: { type: "number", map_to: "biaya_actual", min: 0 }, costActual: { type: "number", map_to: "biaya_actual", min: 0 },
status: { type: "text", map_to: "status" }, status: { type: "text", map_to: "status" },
@ -177,7 +170,7 @@ function addWithoutParent() {
text: `New Activity`, text: `New Activity`,
start_date: start_date, start_date: start_date,
biaya: 10000, biaya: 10000,
duration: 7 duration: 1
}); });
gantt.selectTask(taskId); gantt.selectTask(taskId);
@ -198,7 +191,7 @@ function addWithParent(id) {
id: no, id: no,
text: `New Activity`, text: `New Activity`,
start_date: start_date, start_date: start_date,
duration: 7 duration: 1
}, id); }, id);
no = no + 1; no = no + 1;
@ -234,13 +227,8 @@ function clickGridButton(id, action) {
function createColumnsConfig(selectedColumns){ function createColumnsConfig(selectedColumns){
var newColumns = []; var newColumns = [];
allColumns.forEach(function(column){ allColumns.forEach(function(column){
// restore the action
if(selectedColumns[column.name]){ if(selectedColumns[column.name]){
// if (column.name === 'action') {
// newColumns.push(column);
// }
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: "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: "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: "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: "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) { { name: "rencana_biaya", label: "Cost Planning", align: "center", min_width: 100, resize: true, template: function (text) {
if(!text.rencana_biaya){ if(!text.rencana_biaya){
return return
@ -387,8 +384,6 @@ gantt.config.columns = createColumnsConfig({
action: true, action: true,
kode_sortname: true, kode_sortname: true,
text: true, text: true,
// planned_start: true,
// planned_end: true,
start_date: true, start_date: true,
end_date: true, end_date: true,
duration: true, duration: true,
@ -409,34 +404,16 @@ gantt.config.columns = createColumnsConfig({
gantt.config.reorder_grid_columns = true; gantt.config.reorder_grid_columns = true;
gantt.config.resize_rows = 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.min_column_width = 50;
gantt.config.scale_height = 20; gantt.config.scale_height = 20;
// gantt.config.row_height = 30;
gantt.config.order_branch = "marker"; gantt.config.order_branch = "marker";
gantt.config.order_branch_free = true; gantt.config.order_branch_free = true;
gantt.config.open_tree_initially = 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.row_height = 30;
gantt.config.task_height = 20; 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 // adding baseline display
gantt.addTaskLayer({ gantt.addTaskLayer({
renderer: { renderer: {
@ -445,19 +422,14 @@ gantt.addTaskLayer({
var sizes = gantt.getTaskPosition(task, task.planned_start, task.planned_end); var sizes = gantt.getTaskPosition(task, task.planned_start, task.planned_end);
var el = document.createElement('div'); var el = document.createElement('div');
el.className = 'baseline'; 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.left = sizes.left - 6 + 'px';
el.style.width = sizes.width + 10+ 'px'; el.style.width = sizes.width + 10+ 'px';
el.style.height= sizes.height + 'px'; el.style.height= sizes.height + 'px';
// el.style.top = sizes.top + 1 + 'px';
el.style.top = sizes.top + 2 + 'px'; el.style.top = sizes.top + 2 + 'px';
return el; return el;
} }
return false; return false;
}, },
// define getRectangle in order to hook layer with the smart rendering
getRectangle: function(task, view){ getRectangle: function(task, view){
if (task.planned_start && task.planned_end) { if (task.planned_start && task.planned_end) {
return gantt.getTaskPosition(task, 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) { gantt.templates.rightside_text = function (start, end, task) {
if (task.planned_end) { if (task.planned_end) {
if (end.getTime() > task.planned_end.getTime()) { 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) { gantt.templates.grid_folder = function (item) {
// return "<div class='gantt_tree_icon gantt_folder_" + (item.$open ? "open" : "closed") + "'></div>";
return ""; return "";
}; };
gantt.templates.grid_file = function (item) { gantt.templates.grid_file = function (item) {
// return "<div class='gantt_tree_icon gantt_file'></div>";
return ""; return "";
}; };
@ -636,8 +609,7 @@ for (var i = 0; i < radios.length; i++) {
}; };
} }
// end Zoom Scale function // end Zoom Scale function
//
//
// GANTT PERFORMANCE CONFIG RECOMMENDATION // GANTT PERFORMANCE CONFIG RECOMMENDATION
gantt.config.scales = [ gantt.config.scales = [
{unit: "month", step: 1, format: "%F, %Y"}, {unit: "month", step: 1, format: "%F, %Y"},
@ -654,7 +626,7 @@ gantt.config.show_task_cells = false;
gantt.config.static_background = true; gantt.config.static_background = true;
gantt.config.branch_loading = true; gantt.config.branch_loading = true;
gantt.config.smart_scales = true; gantt.config.smart_scales = true;
// gantt.config.smart_rendering = true; gantt.config.smart_rendering = true;
// gantt initialization // gantt initialization
$(document).ready(function () { $(document).ready(function () {

6
edit-mode/function/ganttEvent.js

@ -3,14 +3,10 @@ gantt.attachEvent("onTaskDblClick", function(id,e){
}); });
gantt.attachEvent("onAfterTaskAdd", function(id,item){ gantt.attachEvent("onAfterTaskAdd", function(id,item){
if(item.parent > 0 && gantt.hasChild()) { if(item.parent && gantt.hasChild()) {
let parentId = item.parent; let parentId = item.parent;
gantt.getTask(parentId).type = "project"; gantt.getTask(parentId).type = "project";
gantt.updateTask(parentId); gantt.updateTask(parentId);
} else if (item.parent && gantt.hasChild()) {
let parentId = item.parent;
gantt.getTask(parentId).type = "task";
gantt.updateTask(parentId);
} }
}); });

12
edit-mode/function/restActivityLink.js

@ -56,13 +56,10 @@ function refresData(id){
var dp = gantt.createDataProcessor(function(entity, action, data, id) { var dp = gantt.createDataProcessor(function(entity, action, data, id) {
switch(action) { switch(action) {
case "create": case "create":
if(entity=="task"){ if(entity=="task"){
data['proyek_id'] = proyekId; data['proyek_id'] = proyekId;
data['start_date'] = `${data.start_date}+07`; data['start_date'] = `${data.start_date}+07`;
data['end_date'] = `${data.start_date}`; 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){ if(data && data.parent){
data['parent_id'] = data.parent; data['parent_id'] = data.parent;
@ -84,15 +81,12 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
}else if(entity=="task"){ }else if(entity=="task"){
gantt.changeTaskId(id, res.tid); gantt.changeTaskId(id, res.tid);
} }
// refresData();
}); });
break; break;
case "update": case "update":
if(entity=="task"){ if(entity=="task"){
data['start_date'] = moment(data.start_date).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 HH:mm:ss+07"); data['end_date'] = moment(data.end_date).format("YYYY-MM-DD")+" 17:00:00+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");
if(data && data.parent){ if(data && data.parent){
data['parent_id'] = 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({ return gantt.ajax.put({
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",

Loading…
Cancel
Save