Browse Source

Merge pull request 'dev-wahyu' (#3) from dev-wahyu into staging

Reviewed-on: ordo/adw-gantt#3
pull/1/head
ibnu 1 year ago
parent
commit
2e5eadf58d
  1. 6
      edit-mode/function/function.js
  2. 34
      edit-mode/function/reportActivity.js
  3. 30
      view-mode/function/function.js
  4. 30
      view-mode/function/ganttEvent.js
  5. 25
      view-mode/function/overlaySCurve.js
  6. 6
      view-mode/function/restActivityLink.js

6
edit-mode/function/function.js

@ -212,6 +212,7 @@ function updateActivity(id) {
gantt.getTask(id).assign_hr = data.assign_hr; gantt.getTask(id).assign_hr = data.assign_hr;
gantt.getTask(id).assign_material = data.assign_material; gantt.getTask(id).assign_material = data.assign_material;
gantt.getTask(id).assign_tools = data.assign_tools; gantt.getTask(id).assign_tools = data.assign_tools;
gantt.getTask(id).assign_expense = data.assign_expense;
gantt.getTask(id).bobot_planning = data.bobot_planning; gantt.getTask(id).bobot_planning = data.bobot_planning;
gantt.getTask(id).rencana_biaya = data.rencana_biaya; gantt.getTask(id).rencana_biaya = data.rencana_biaya;
gantt.getTask(id).biaya_actual = data.biaya_actual; gantt.getTask(id).biaya_actual = data.biaya_actual;
@ -339,7 +340,7 @@ function initializationColumn() {
if (data.status == "not yet have") { if (data.status == "not yet have") {
addShowHideColumn(); addShowHideColumn();
} else if (data.status == "not have access") { } else if (data.status == "not have access") {
gantt.config.columns = createColumnsConfig(columnShows);
} else { } else {
setUpForShowHideColumn(data); setUpForShowHideColumn(data);
} }
@ -513,7 +514,7 @@ function submitShowHideColumn(allColumn) {
version_gantt_id: ganttId, version_gantt_id: ganttId,
columns: allColumn columns: allColumn
} }
gantt.config.columns = createColumnsConfig(allColumn);
$.ajax({ $.ajax({
data: JSON.stringify(payload), data: JSON.stringify(payload),
url: `${base_url}gantt-show-hide/add`, url: `${base_url}gantt-show-hide/add`,
@ -676,6 +677,7 @@ function batchUpdate(){
}).then(function (response) { }).then(function (response) {
$("body").removeClass("loading"); $("body").removeClass("loading");
localStorage.setItem('batchEntity', ''); localStorage.setItem('batchEntity', '');
refresData();
}).catch(function (error) { }).catch(function (error) {
$("body").removeClass("loading") $("body").removeClass("loading")

34
edit-mode/function/reportActivity.js

@ -425,20 +425,26 @@ $(document).ready(function () {
.post(`${base_url}report-activity-material/add`, formData); .post(`${base_url}report-activity-material/add`, formData);
const reportId = result.data.data.report_id; const reportId = result.data.data.report_id;
const image = formData.get("files"); try {
const imageFormData = new FormData(); const image = formData.get("files");
imageFormData.append("ref_id", reportId); const imageFormData = new FormData();
imageFormData.append("category", "report_activity"); imageFormData.append("ref_id", reportId);
imageFormData.append("files", image, image.name); imageFormData.append("category", "report_activity");
imageFormData.append("files", image, image.name);
const resultImage = await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData);
if (image.name && image.size) {
const resultImage = await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData);
}
if (result.status === 200 && resultImage.status === 200) { if (result.status === 200) {
gantt.alert("Add report activity material Success!"); gantt.alert("Add report activity material Success!");
resetFormAddRaMaterial(); resetFormAddRaMaterial();
tableRaMaterialActual.draw(); tableRaMaterialActual.draw();
} else { } else {
throw new Error("Add report activity material failed."); throw new Error("Add report activity material failed.");
}
} catch (error) {
throw new Error("Image upload failed.");
} }
} catch (error) { } catch (error) {
resetFormAddRaMaterial(); resetFormAddRaMaterial();
@ -512,7 +518,7 @@ $(document).ready(function () {
// kalo gambarnya banyak belum di handle... // kalo gambarnya banyak belum di handle...
}, },
error: function (data) { error: function (data) {
gantt.alert({ type: "error", text: "Failed to get report image" }); gantt.alert({ type: "error", text: "Image not found !" });
} }
}); });
}); });

30
view-mode/function/function.js

@ -522,3 +522,33 @@ function replaceAll(str, find, replace) {
} }
return str return str
} }
// Function to get the earliest planned start date among all tasks
function getEarliestTaskDate() {
var earliestDate = null;
gantt.eachTask(function (task) {
var taskStartDate = task.planned_start || task.start_date;
if (!earliestDate || task.planned_start < earliestDate) {
earliestDate = taskStartDate;
if (task.start_date < earliestDate) {
earliestDate = task.start_date;
}
}
});
return earliestDate;
}
// Function to get the latest planned end date among all tasks
function getLatestTaskDate() {
var latestDate = null;
gantt.eachTask(function (task) {
var taskEndDate = task.planned_end || task.end_date;
if (!latestDate || task.planned_end > latestDate) {
latestDate = taskEndDate;
if (task.end_date > latestDate) {
latestDate = task.end_date;
}
}
});
return latestDate;
}

30
view-mode/function/ganttEvent.js

@ -98,3 +98,33 @@ gantt.attachEvent("onGanttRender", function(){
gantt.config.readonly = true; gantt.config.readonly = true;
} }
}); });
gantt.attachEvent("onGanttScroll", function (left, top){
var left_date = gantt.dateFromPos(left)
var right_date = gantt.dateFromPos(left + gantt.$task.offsetWidth)
let taskCount = gantt.getTaskCount();
if (taskCount > 0) {
gantt.config.start_date = gantt.config.start_date || gantt.getState().min_date;
gantt.config.end_date = gantt.config.end_date || gantt.getState().max_date;
var min_allowed_date = gantt.date.add(gantt.config.start_date, 1, "day");
var max_allowed_date = gantt.date.add(gantt.config.end_date, -1, "day");
var repaint = false;
if (earliest && +left_date <= +min_allowed_date && +left_date >= +earliest){
gantt.config.start_date = gantt.date.add(gantt.config.start_date, -1, "day");
repaint = true;
}
if (latest && +right_date >= +max_allowed_date && +right_date <= +latest){
gantt.config.end_date = gantt.date.add(gantt.config.end_date, 1, "day");
repaint = true;
}
if (repaint) {
setTimeout(function(){
gantt.render()
},20)
}
}
});

25
view-mode/function/overlaySCurve.js

@ -121,9 +121,26 @@ function getProgressLine(){
function getScalePaddings(){ function getScalePaddings(){
var scale = gantt.getScale(); var scale = gantt.getScale();
var dataRange = gantt.getSubtaskDates(); var dataRange = gantt.getSubtaskDates();
let minDate = new Date();
let maxDate = new Date();
gantt.eachTask(function(task){
let plannedEarlier = task.planned_start < task.start_date;
let plannedLater = task.planned_end > task.end_date;
if (plannedEarlier) {
minDate = new Date(Math.min(minDate.getTime(), task.planned_start.getTime()));
} else {
minDate = new Date(Math.min(minDate.getTime(), task.start_date.getTime()));
}
if (plannedLater) {
maxDate = new Date(Math.max(maxDate.getTime(), task.planned_end.getTime()));
} else {
maxDate = new Date(Math.max(maxDate.getTime(), task.end_date.getTime()));
}
})
var chartScale = getChartScaleRange();
var newWidth = scale.col_width;
var padding = { var padding = {
left:0, left:0,
right:0 right:0
@ -132,8 +149,8 @@ function getScalePaddings(){
if(dataRange.start_date){ if(dataRange.start_date){
var yScaleLabelsWidth = 48; var yScaleLabelsWidth = 48;
// fine tune values in order to align chart with the scale range // fine tune values in order to align chart with the scale range
padding.left = gantt.posFromDate(dataRange.start_date) - yScaleLabelsWidth; padding.left = gantt.posFromDate(minDate) - yScaleLabelsWidth;
padding.right = scale.full_width - gantt.posFromDate(dataRange.end_date) - yScaleLabelsWidth; padding.right = scale.full_width - gantt.posFromDate(maxDate) - yScaleLabelsWidth;
padding.top = gantt.config.row_height - 12; padding.top = gantt.config.row_height - 12;
padding.bottom = gantt.config.row_height - 12; padding.bottom = gantt.config.row_height - 12;
} }

6
view-mode/function/restActivityLink.js

@ -1,4 +1,6 @@
var parts = []; var parts = [];
let latest;
let earliest;
window.parent.postMessage({ action: 'getUrl' }, '*'); window.parent.postMessage({ action: 'getUrl' }, '*');
window.addEventListener('message', function(event) { window.addEventListener('message', function(event) {
if (event.data && event.data.action === 'sendUrl') { if (event.data && event.data.action === 'sendUrl') {
@ -40,6 +42,8 @@ gantt.ajax.get({
if(!parts[2]){ if(!parts[2]){
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate();
latest = getLatestTaskDate();
}); });
} }
}); });
@ -62,6 +66,8 @@ function refresData(id){
if(!parts[2]){ if(!parts[2]){
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate();
latest = getLatestTaskDate();
}); });
} }
if(id){ if(id){

Loading…
Cancel
Save