Browse Source

feat: fixed bug

pull/3/head
wahyun 5 months ago
parent
commit
285b8aa8cd
  1. 35
      edit-mode/function/expenseResource.js
  2. 3
      edit-mode/function/function.js
  3. 16
      edit-mode/function/ganttConfig.js
  4. 8
      edit-mode/function/ganttSettings.js
  5. 2
      edit-mode/index.html

35
edit-mode/function/expenseResource.js

@ -1,10 +1,11 @@
var expenseModal = $('#modal-expense > .modal-dialog > .modal-content'); var expenseModal = $('#modal-expense > .modal-dialog > .modal-content');
function resetFormAssignexpense() { function resetFormAssignexpense() {
$('#select-expense').val(null).trigger("change"); // $('#select-expense').val(null).trigger("change");
$('#select-expense').find('option').remove(); // $('#select-expense').find('option').remove();
$('#select-expense').val(""); // $('#select-expense').val("");
$('#uom-req-expense').val(null).trigger('change'); $("#desc-expense").val("");
$('#uom-req-expense').val("").trigger('change');
$('#form-assign-expense').trigger("reset"); $('#form-assign-expense').trigger("reset");
$('#btn-assign-expense').html('Assign'); $('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false); $('#btn-assign-expense').prop("disabled", false);
@ -88,18 +89,18 @@ $(document).ready(function () {
}); });
$('#modal-expense').on('show.bs.modal', function (event) { $('#modal-expense').on('show.bs.modal', function (event) {
$("#desc-expense").val(activityName); resetFormAssignexpense();
$('#modal-expense-title').html("Overhead " + activityName); $('#modal-expense-title').html("Overhead " + activityName);
$('#modal-expense-sub-title').html(`<p style="font-size: 12px; color: #747474">Plan Date: ${moment(activityEarlyStart).format('DD MMMM YYYY')} - ${moment(activityEarlyFinish).format('DD MMMM YYYY')}</p>`); $('#modal-expense-sub-title').html(`<p style="font-size: 12px; color: #747474">Plan Date: ${moment(activityEarlyStart).format('DD MMMM YYYY')} - ${moment(activityEarlyFinish).format('DD MMMM YYYY')}</p>`);
tableexpense.draw(); tableexpense.draw();
}); });
$('#modal-expense').on('hide.bs.modal', function (event) { $('#modal-expense').on('hide.bs.modal', function (event) {
resetFormAssignexpense();
$("#show-form-expense").show(); $("#show-form-expense").show();
if (actionHappen) { if (actionHappen) {
updateActivity(activityId); updateActivity(activityId);
} }
resetFormAssignexpense();
}); });
$('#select-expense').select2({ $('#select-expense').select2({
@ -160,7 +161,7 @@ $(document).ready(function () {
type: "expense", type: "expense",
fom_date: required_date, fom_date: required_date,
required_date: required_date, required_date: required_date,
proyek_id: proyekId, proyek_id: parseInt(proyekId),
uom: uom, uom: uom,
qty: formatReplaceTitikRibuan(qty_planning), qty: formatReplaceTitikRibuan(qty_planning),
price: formatReplaceTitikRibuan(price) price: formatReplaceTitikRibuan(price)
@ -175,7 +176,6 @@ $(document).ready(function () {
if (data && data.code === 200) { if (data && data.code === 200) {
material_id = data.data.id; material_id = data.data.id;
resetFormAssignexpense(); resetFormAssignexpense();
let payloadAssign = { let payloadAssign = {
proyek_id: proyekId, proyek_id: proyekId,
activity_id: activityId, activity_id: activityId,
@ -192,35 +192,34 @@ $(document).ready(function () {
contentType: false, contentType: false,
success: function (data) { success: function (data) {
if (data && data.code === 200) { if (data && data.code === 200) {
resetFormAssignexpense();
actionHappen = true; actionHappen = true;
gantt.alert("Data added!"); gantt.alert("Data added!");
tableexpense.draw(); tableexpense.draw();
resetFormAssignexpense(); } else {
}
else {
gantt.alert({ type: "error", text: data.message });
$('#btn-assign-expense').html('Assign'); $('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false); $('#btn-assign-expense').prop("disabled", false);
gantt.alert({ type: "error", text: data.message });
} }
}, },
error: function (data) { error: function (data) {
$('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false);
gantt.alert("Assign Failed, try again later!"); gantt.alert("Assign Failed, try again later!");
resetFormAssignexpense();
} }
}); });
} } else {
else {
gantt.alert({ type: "error", text: data.message });
$('#btn-assign-expense').html('Assign'); $('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false); $('#btn-assign-expense').prop("disabled", false);
gantt.alert({ type: "error", text: data.message });
} }
}, },
error: function (data) { error: function (data) {
$('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false);
gantt.alert("Overhead request Failed, try again later!"); gantt.alert("Overhead request Failed, try again later!");
resetFormAssignexpense();
} }
}); });
}); });
// delete from row // delete from row

3
edit-mode/function/function.js

@ -196,6 +196,7 @@ function getSatuan() {
] ]
} }
} }
$.ajax({ $.ajax({
data: JSON.stringify(payload), data: JSON.stringify(payload),
url: `${base_url}satuan/search`, url: `${base_url}satuan/search`,
@ -223,7 +224,7 @@ function getSatuan() {
let newOption = new Option(option.label, option.label); let newOption = new Option(option.label, option.label);
$('#uom-req-material').append(newOption); $('#uom-req-material').append(newOption);
}); });
$('#uom-req-expense').append(new Option('', '', true, true));
satuanList.forEach((option) => { satuanList.forEach((option) => {
let newOption = new Option(option.label, option.label); let newOption = new Option(option.label, option.label);
$('#uom-req-expense').append(newOption); $('#uom-req-expense').append(newOption);

16
edit-mode/function/ganttConfig.js

@ -294,14 +294,14 @@ var allColumns = [
editor: editor.text, editor: editor.text,
resize: true, resize: true,
template: function (text) { template: function (text) {
function truncateText(text, maxLength) { // function truncateText(text, maxLength) {
if (text.length > maxLength) { // if (text.length > maxLength) {
return text.substring(0, maxLength) + '...'; // return text.substring(0, maxLength) + '...';
} // }
return text; // return text;
} // }
const truncatedText = truncateText(text.text, 30); // const truncatedText = truncateText(text.text, 30);
return `<span title="${text.text}">${truncatedText}</span>`; return `<span title="${text.text}">${text.text}</span>`;
} }
}, },
{ {

8
edit-mode/function/ganttSettings.js

@ -65,6 +65,7 @@ $(document).ready(function () {
if (result && result.status == 200) { if (result && result.status == 200) {
if (result.data && result.data.data) { if (result.data && result.data.data) {
var config_dayoff = null; var config_dayoff = null;
if (result.data.data.config_dayoff !== null) { if (result.data.data.config_dayoff !== null) {
config_dayoff = result.data.data.config_dayoff; config_dayoff = result.data.data.config_dayoff;
@ -130,8 +131,8 @@ $(document).ready(function () {
}); });
$("#dashboard-project").on('click', function (event) { $("#dashboard-project").on('click', function (event) {
// window.location.href = `https://si.ospro.id/#/dashboard-project/${projectId}/${ganttId}false-header`; window.location.href = `https://si.ospro.id/#/dashboard-project/${projectId}/${ganttId}?dashboardGantt=${true}`;
window.location.href = `http://localhost:3000/#/dashboard-project/${projectId}/${ganttId}/false-header`; // window.location.href = `http://localhost:3000/#/dashboard-project/${projectId}/${ganttId}?dashboardGantt=${true}`;
}); });
$("#gantt-baseline").on('click', function (event) { $("#gantt-baseline").on('click', function (event) {
@ -203,6 +204,9 @@ async function initGanttSettings() {
if (result && result.status == 200) { if (result && result.status == 200) {
var config_dayoff = result.data.data.config_dayoff; var config_dayoff = result.data.data.config_dayoff;
var type_gantt = result.data.data.calculation_type; var type_gantt = result.data.data.calculation_type;
const ganttName = result.data.data.name_version;
document.getElementById("project-name-header").textContent = ganttName;
reRenderColumns(type_gantt); reRenderColumns(type_gantt);
var dayoff = []; var dayoff = [];
if (config_dayoff && config_dayoff.length > 0) { if (config_dayoff && config_dayoff.length > 0) {

2
edit-mode/index.html

@ -67,7 +67,7 @@
<div class="loading-overlay"></div> <div class="loading-overlay"></div>
<div class="container-header"> <div class="container-header">
<div class="container-project"> <div class="container-project">
<h6 id="project-name-header"></h6> <h6 id="project-name-header" style="margin-left: 10px;"></h6>
</div> </div>
<div class="container-action"> <div class="container-action">
<div class="btn-icon-toolbar btn-sm"><span class="icon-toolbar-separator">Zoom: </span></div> <div class="btn-icon-toolbar btn-sm"><span class="icon-toolbar-separator">Zoom: </span></div>

Loading…
Cancel
Save