Browse Source

Merge pull request 'fix date range' (#40) from dev-wahyu into staging

Reviewed-on: ordo/adw-gantt#40
pull/1/head
ibnu 1 year ago
parent
commit
5890d25e92
  1. 22
      edit-mode/function/function.js
  2. 2
      edit-mode/function/ganttConfig.js
  3. 12
      edit-mode/function/ganttEvent.js
  4. 8
      edit-mode/function/ganttSettings.js
  5. 8
      edit-mode/function/humanResource.js
  6. 15
      edit-mode/function/restActivityLink.js
  7. 18
      edit-mode/index.html

22
edit-mode/function/function.js

@ -718,6 +718,7 @@ function batchUpdate(){
$("body").removeClass("loading"); $("body").removeClass("loading");
localStorage.setItem('batchEntity', ''); localStorage.setItem('batchEntity', '');
$("#save-activity").hide(); $("#save-activity").hide();
$("#save-separator").hide();
sendStorage(); sendStorage();
refresData(); refresData();
}).catch(function (error) { }).catch(function (error) {
@ -731,6 +732,27 @@ function batchUpdate(){
}); });
} }
function updateSchedule() {
$("body").addClass("loading");
return gantt.ajax.get({
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
url: base_url + "activity/update-schedule/" + ganttId
}).then(function (response) {
$("body").removeClass("loading");
refresData();
}).catch(function (error) {
$("body").removeClass("loading")
gantt.alert({
title: "Peringatan",
type: "alert-error",
text: "Update activity gagal"
});
});
}
$(window).on('beforeunload', function(event) { $(window).on('beforeunload', function(event) {
let batchEntity = localStorage.getItem('batchEntity'); let batchEntity = localStorage.getItem('batchEntity');
sendStorage(); sendStorage();

2
edit-mode/function/ganttConfig.js

@ -661,7 +661,7 @@ gantt.templates.rightside_text = function (start, end, task) {
end_date: end, end_date: end,
task: task task: task
}, 'day'); }, 'day');
var text = "<b>Overdue: " + overdue + " days</b>"; var text = "<b style='color: red;'>Overdue: " + overdue + " days</b>";
return text; return text;
} }
} }

12
edit-mode/function/ganttEvent.js

@ -10,6 +10,7 @@ gantt.attachEvent("onAfterTaskAdd", function (id, item) {
gantt.updateTask(parentId); gantt.updateTask(parentId);
} }
} }
updateRange();
}); });
gantt.attachEvent("onTaskRowClick", function (id, row) { gantt.attachEvent("onTaskRowClick", function (id, row) {
@ -40,7 +41,16 @@ gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function (state) {
} }
return true return true
}); });
function updateRange(){
var range = gantt.getSubtaskDates();
var chart = gantt.getState();
if(range.start_date.valueOf() <= chart.min_date.valueOf() || range.end_date.valueOf() >= chart.max_date.valueOf()){
gantt.config.start_date = gantt.date.add(range.start_date, -1, "day");
gantt.config.end_date = gantt.date.add(range.end_date, 2, "day");
gantt.render();
}
}
gantt.attachEvent("onAfterTaskUpdate", updateRange);
gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) { gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) {
// format progress // format progress
let progress = new_item.progress; let progress = new_item.progress;

8
edit-mode/function/ganttSettings.js

@ -143,6 +143,14 @@ $(document).ready(function () {
setSynchronize(); setSynchronize();
}); });
$("#compare-data").on('click', function (event) {
compareData(ganttTask);
});
$("#update-schedule").on('click', function (event) {
updateSchedule();
});
initHolidays(); initHolidays();
initGanttSettings(); initGanttSettings();
}); });

8
edit-mode/function/humanResource.js

@ -7,6 +7,8 @@ function resetFormAssign() {
$('#select-hr').val(null).trigger("change"); $('#select-hr').val(null).trigger("change");
$('#select-hr').find('option').remove(); $('#select-hr').find('option').remove();
$('#select-hr').val(""); $('#select-hr').val("");
$("#hr-start-date").val("");
$("#hr-end-date").val("");
$("#hr_role").val(""); $("#hr_role").val("");
// $("#hide-form-hr").hide(); // $("#hide-form-hr").hide();
// $("#show-form-hr").show(); // $("#show-form-hr").show();
@ -29,6 +31,8 @@ $(document).ready(function () {
"columns": [ "columns": [
{ data: 'user_name', name: 'user_name' }, { data: 'user_name', name: 'user_name' },
{ data: 'role_name', name: 'role_name' }, { data: 'role_name', name: 'role_name' },
{ data: 'start_date', name: 'start_date' },
{ data: 'end_date', name: 'end_date' },
{ {
data: 'action', data: 'action',
name: 'action', name: 'action',
@ -158,6 +162,8 @@ $(document).ready(function () {
// var formData = new FormData(this); // var formData = new FormData(this);
let users = $("#select-hr").val(); let users = $("#select-hr").val();
let start_date = $("#hr-start-date").val();
let end_date = $("#hr-end-date").val();
let user_id = []; let user_id = [];
let user_role = []; let user_role = [];
users.map((item)=>{ users.map((item)=>{
@ -175,6 +181,8 @@ $(document).ready(function () {
let payload = { let payload = {
user_id: user_id, user_id: user_id,
start_date: start_date,
end_date: end_date,
role_proyek_id: user_role, role_proyek_id: user_role,
version_gantt_id: ganttId, version_gantt_id: ganttId,
proyek_id: proyekId, proyek_id: proyekId,

15
edit-mode/function/restActivityLink.js

@ -1,6 +1,7 @@
let geom = []; let geom = [];
let latest; let latest;
let earliest; let earliest;
let ganttTask;
$("body").addClass("loading"); $("body").addClass("loading");
gantt.ajax.get({ gantt.ajax.get({
url: `${base_url}activity/${ganttId}/${proyekId}/get`, url: `${base_url}activity/${ganttId}/${proyekId}/get`,
@ -13,8 +14,10 @@ gantt.ajax.get({
let batchEntity = localStorage.getItem('batchEntity'); let batchEntity = localStorage.getItem('batchEntity');
if (!batchEntity || batchEntity == '') { if (!batchEntity || batchEntity == '') {
$("#save-activity").hide(); $("#save-activity").hide();
$("#save-separator").hide();
} else { } else {
$("#save-activity").show(); $("#save-activity").show();
$("#save-separator").show();
} }
let data = {}; let data = {};
let response = xhr.responseText; let response = xhr.responseText;
@ -39,8 +42,8 @@ gantt.ajax.get({
}); });
gantt.silent(function () { gantt.silent(function () {
// updateLinksLag(data); // updateLinksLag(data);
ganttTask = data;
gantt.parse(data); gantt.parse(data);
compareData(data);
getGanttOpen(); getGanttOpen();
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate(); earliest = getEarliestTaskDate();
@ -75,8 +78,10 @@ function refresData(id) {
let batchEntity = localStorage.getItem('batchEntity'); let batchEntity = localStorage.getItem('batchEntity');
if (!batchEntity || batchEntity == '') { if (!batchEntity || batchEntity == '') {
$("#save-activity").hide(); $("#save-activity").hide();
$("#save-separator").hide();
} else { } else {
$("#save-activity").show(); $("#save-activity").show();
$("#save-separator").show();
} }
gantt.clearAll(); gantt.clearAll();
let data = {}; let data = {};
@ -93,8 +98,8 @@ function refresData(id) {
}); });
gantt.silent(function () { gantt.silent(function () {
// updateLinksLag(data); // updateLinksLag(data);
ganttTask = data;
gantt.parse(data); gantt.parse(data);
compareData(data);
getGanttOpen(); getGanttOpen();
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate(); earliest = getEarliestTaskDate();
@ -176,6 +181,11 @@ var dp = gantt.createDataProcessor(function (entity, action, data, id) {
// data['start_date'] = startDate.format("YYYY-MM-DD")+" 00:00:00+07"; // data['start_date'] = startDate.format("YYYY-MM-DD")+" 00:00:00+07";
let endDate = moment(data.end_date, "YYYY-MM-DD"); let endDate = moment(data.end_date, "YYYY-MM-DD");
let configStart = moment(gantt.config.start_date);
let configEnd = moment(gantt.config.end_date);
if (startDate >= configEnd || startDate <= configStart || endDate >= configEnd || endDate <= configStart) {
// location.reload();
}
if (startDate > endDate) { if (startDate > endDate) {
gantt.alert({ gantt.alert({
title: "Peringatan", title: "Peringatan",
@ -215,6 +225,7 @@ var dp = gantt.createDataProcessor(function (entity, action, data, id) {
} }
localStorage.setItem('batchEntity', JSON.stringify(toBeSet)); localStorage.setItem('batchEntity', JSON.stringify(toBeSet));
$("#save-activity").show(); $("#save-activity").show();
$("#save-separator").show();
sendStorage(); sendStorage();
// $("body").addClass("loading"); // $("body").addClass("loading");
// return gantt.ajax.put({ // return gantt.ajax.put({

18
edit-mode/index.html

@ -89,16 +89,22 @@
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
<button title="Save" class="btn btn-sm btn-icon-toolbar" id="save-activity"><i <button title="Save" class="btn btn-sm btn-icon-toolbar" id="save-activity"><i
class="fa fa-save icon-toolbar"></i></button> class="fa fa-save icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator"id="save-separator">|</span>
<button title="Synchronize to Report Activity" class="btn btn-sm btn-icon-toolbar" id="gantt-synchronize"><i <button title="Synchronize to Report Activity" class="btn btn-sm btn-icon-toolbar" id="gantt-synchronize"><i
class="fa fa-sync icon-toolbar"></i></button> class="fa fa-sync icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
<button title="Update Schedule" class="btn btn-sm btn-icon-toolbar" id="update-schedule"><i
class="fa fa-upload icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span>
<button title="Set Baseline" class="btn btn-sm btn-icon-toolbar" id="gantt-baseline"><i <button title="Set Baseline" class="btn btn-sm btn-icon-toolbar" id="gantt-baseline"><i
class="fa fa-grip-lines icon-toolbar"></i></button> class="fa fa-grip-lines icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
<button title="Show / Hide Columns" class="btn btn-sm btn-icon-toolbar" id="gantt_toggle_columns_btn" <button title="Show / Hide Columns" class="btn btn-sm btn-icon-toolbar" id="gantt_toggle_columns_btn"
onclick="gantt.$showDropdown(this)"><i class="fa fa-columns icon-toolbar"></i></button> onclick="gantt.$showDropdown(this)"><i class="fa fa-columns icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
<button title="Gantt Compare" class="btn btn-sm btn-icon-toolbar" id="compare-data"><i
class="fa fa-columns icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span>
<button title="Gantt Settings" class="btn btn-sm btn-icon-toolbar" id="gantt_setting_btn"><i <button title="Gantt Settings" class="btn btn-sm btn-icon-toolbar" id="gantt_setting_btn"><i
class="fa fa-cog icon-toolbar"></i></button> class="fa fa-cog icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
@ -136,6 +142,14 @@
<label>Human Resource</label> <label>Human Resource</label>
<select id="select-hr" name="user_id[]" multiple="multiple" class="form-control form-control-sm" style="width:100%;"></select> <select id="select-hr" name="user_id[]" multiple="multiple" class="form-control form-control-sm" style="width:100%;"></select>
</div> </div>
<div class="col-md-2 form-group">
<label>Start Date</label>
<input type="date" id="hr-start-date" class="form-control form-control-sm" />
</div>
<div class="col-md-2 form-group">
<label>End Date</label>
<input type="date" id="hr-end-date" class="form-control form-control-sm" />
</div>
<div class="col-md-2 form-group"> <div class="col-md-2 form-group">
<button style="margin-top: 31px;" id="btn-assign-hr" type="submit" <button style="margin-top: 31px;" id="btn-assign-hr" type="submit"
class="btn btn-sm btn-primary">Assign</button> class="btn btn-sm btn-primary">Assign</button>
@ -156,6 +170,8 @@
<tr> <tr>
<th scope="col">User</th> <th scope="col">User</th>
<th scope="col">Role</th> <th scope="col">Role</th>
<th scope="col">Start Date</th>
<th scope="col">End Date</th>
<th scope="col">Actions</th> <th scope="col">Actions</th>
</tr> </tr>
</thead> </thead>

Loading…
Cancel
Save