Browse Source

Merge pull request 'fix bug set baseline gantt chart & add company_id param' (#3) from dev-wahyun into master

Reviewed-on: ibnu/generic-ospro-gantt#3
pull/1/head
farhantock 10 months ago
parent
commit
2a346a076e
  1. 18
      edit-mode/function/ganttActivityUploadDoc.js
  2. 24
      edit-mode/function/ganttConfig.js
  3. 8
      edit-mode/function/ganttSettings.js
  4. 19
      view-mode/function/ganttActivityUploadDoc.js
  5. 2
      view-mode/function/ganttSettings.js

18
edit-mode/function/ganttActivityUploadDoc.js

@ -1,8 +1,8 @@
// Upload Document Activity // Upload Document Activity
const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`; const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`;
const DOCUMENT_DOWNLOAD_URL = (id) => `${base_url}document-activity/download/${id}`; const DOCUMENT_DOWNLOAD_URL = (id) => `${base_url}document-activity/download/${id}/${company_id}`;
const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`; const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`;
const DOCUMENT_DELETE_URL = (id) => `${base_url}document-activity/delete/${id}`; const DOCUMENT_DELETE_URL = (id, company_id) => `${base_url}document-activity/delete/${id}/${company_id}`;
var fileToUpload = null; var fileToUpload = null;
@ -100,35 +100,27 @@ async function submitDocuments() {
var formData = new FormData; var formData = new FormData;
formData.append('activity_id', activity_id); formData.append('activity_id', activity_id);
formData.append('dokumen', files); formData.append('dokumen', files);
formData.append('company_id',company_id);
if (activity_id !== '' && dokumen !== '') { if (activity_id !== '' && dokumen !== '') {
const result = await axiosInstance const result = await axiosInstance
.post(DOCUMENT_UPLOAD_URL, formData) .post(DOCUMENT_UPLOAD_URL, formData)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log("result", result)
if(result && result.status==200){ if(result && result.status==200){
console.log('done upload doc', result) console.log('done upload doc', result)
// gantt.message("Upload success");
gantt.alert("Upload Success"); gantt.alert("Upload Success");
$("#add_doc_form").trigger("reset"); $("#add_doc_form").trigger("reset");
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
$('#btn_doc_submit').prop("disabled",false); $('#btn_doc_submit').prop("disabled",false);
searchDocuments(activity_id); // reload the contents searchDocuments(activity_id); // reload the contents
}else{ }else{
// closeDialog('failed upload')
console.log('failed upload'); console.log('failed upload');
// alert('Upload failed');
// gantt.message({type:"error", text:"Upload Failed"});
gantt.alert({type: "error", text: "Upload Failed"}); gantt.alert({type: "error", text: "Upload Failed"});
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
$('#btn_doc_submit').prop("disabled",false); $('#btn_doc_submit').prop("disabled",false);
} }
} }
else { else {
// alert('Please input the comment');
gantt.alert("Please insert the document file"); gantt.alert("Please insert the document file");
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
$('#btn_doc_submit').prop("disabled",false); $('#btn_doc_submit').prop("disabled",false);
@ -209,7 +201,7 @@ function searchDocuments(activity_id) {
async function downloadDocument(id, name) { async function downloadDocument(id, name) {
let result; let result;
await fetch(DOCUMENT_DOWNLOAD_URL(id), { await fetch(DOCUMENT_DOWNLOAD_URL(id, company_id), {
headers: new Headers({ headers: new Headers({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': `Bearer ${token}` 'Authorization': `Bearer ${token}`
@ -253,7 +245,7 @@ async function deleteDocument(id, activity_id) {
if (result) { if (result) {
console.log('download document', id); console.log('download document', id);
const result = await axiosInstance const result = await axiosInstance
.delete(DOCUMENT_DELETE_URL(id)) .delete(DOCUMENT_DELETE_URL(id, company_id))
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

24
edit-mode/function/ganttConfig.js

@ -114,13 +114,13 @@ var colHeader = '<div class="gantt_grid_head_cell"><i style="margin-right:5px;"
colContent = function (task) { colContent = function (task) {
var hasChild = gantt.hasChild(task.id); var hasChild = gantt.hasChild(task.id);
var optionsContent = '<div class="align-left">'; var optionsContent = '<div class="align-left">';
optionsContent += '<i title="Add Activity" class="fa gantt_button_grid gantt_grid_add fa-plus icon-action f-blue-sky" onclick="clickGridButton(' + task.id + ', \'add\')"></i> '; optionsContent += '<i title="Add Activity ' + task.name + '" class="fa gantt_button_grid gantt_grid_add fa-plus icon-action f-blue-sky" onclick="clickGridButton(' + task.id + ', \'' + task.name + '\', \'add\')"></i> ';
optionsContent += '<i title="Delete Activity" class="fa gantt_button_grid gantt_grid_delete fa-times icon-action f-red" onclick="clickGridButton(' + task.id + ', \'delete\')"></i> '; optionsContent += '<i title="Delete Activity ' + task.name + '" class="fa gantt_button_grid gantt_grid_delete fa-times icon-action f-red" onclick="clickGridButton(' + task.id + ', \'' + task.name + '\', \'delete\')"></i> ';
optionsContent += '<i title="Set Baseline Activity" class="fa gantt_button_grid gantt_grid_delete fa-grip-lines icon-action f-blue-sky" onclick="clickGridButton(' + task.id + ', \'set-baseline-activity\')"></i> '; optionsContent += '<i title="Set Baseline Activity ' + task.name + '" class="fa gantt_button_grid gantt_grid_delete fa-grip-lines icon-action f-blue-sky" onclick="clickGridButton(' + task.id + ', \'' + task.name + '\', \'set-baseline-activity\')"></i> ';
optionsContent += '<i title="Add Milestone" class="fa gantt_button_grid gantt_grid_add fab fa-jira icon-action f-black" onclick="addMilestone(' + task.id + ')"></i> '; optionsContent += '<i title="Add Milestone ' + task.name + '" class="fa gantt_button_grid gantt_grid_add fab fa-jira icon-action f-black" onclick="addMilestone(' + task.id + ')"></i> ';
optionsContent += !hasChild ? '<i title="Upload Document" class="fa gantt_button_grid gantt_grid_delete fa-file icon-action f-orange" onclick="clickGridButton(' + task.id + ', \'upload\')"></i> ' : ''; optionsContent += !hasChild ? '<i title="Upload Document ' + task.name + '" class="fa gantt_button_grid gantt_grid_delete fa-file icon-action f-orange" onclick="clickGridButton(' + task.id + ', \'' + task.name + '\', \'upload\')"></i> ' : '';
optionsContent += !hasChild ? '<i title="Show Comments" class="fa gantt_button_grid gantt_grid_delete fa-comment icon-action f-black" onclick="clickGridButton(' + task.id + ', \'comment\')"></i> ' : ''; optionsContent += !hasChild ? '<i title="Show Comments ' + task.name + '" class="fa gantt_button_grid gantt_grid_delete fa-comment icon-action f-black" onclick="clickGridButton(' + task.id + ', \'' + task.name + '\', \'comment\')"></i> ' : '';
optionsContent += !hasChild ? '<i title="Activity Location" class="fa fas gantt_button_grid gantt_grid_delete fa-map-marked icon-action f-green" onclick="openActivityMap(' + task.id + ')"></i> ' : ''; optionsContent += !hasChild ? '<i title="Activity Location ' + task.name + '" class="fa fas gantt_button_grid gantt_grid_delete fa-map-marked icon-action f-green" onclick="openActivityMap(' + task.id + ')"></i> ' : '';
optionsContent += '</div>'; optionsContent += '</div>';
return (optionsContent); return (optionsContent);
}; };
@ -238,7 +238,7 @@ function addWithParent(id) {
no = no + 1; no = no + 1;
} }
function clickGridButton(id, action) { function clickGridButton(id, name, action) {
switch (action) { switch (action) {
case "edit": case "edit":
gantt.showLightbox(id); gantt.showLightbox(id);
@ -257,7 +257,7 @@ function clickGridButton(id, action) {
}); });
break; break;
case "set-baseline-activity": case "set-baseline-activity":
setBaselineActivity(id); setBaselineActivity(id, name);
break; break;
case "upload": case "upload":
showDocuments(id); showDocuments(id);
@ -347,10 +347,7 @@ var allColumns = [
{ {
name: "bobot_planning", label: "Bobot (%)", align: "center", editor: editor.bobot_planning, resize: true, min_width: 115, template: function (text) { name: "bobot_planning", label: "Bobot (%)", align: "center", editor: editor.bobot_planning, resize: true, min_width: 115, template: function (text) {
let bobot = parseFloat(text.bobot_planning); let bobot = parseFloat(text.bobot_planning);
console.log("bobot roundToTwo ", roundToTwo(bobot));
console.log("bobot toFixed ", bobot.toFixed(2));
if (bobot.toFixed(2) > 100) { if (bobot.toFixed(2) > 100) {
gantt.alert("Bobot tidak boleh lebih dari 100%!"); gantt.alert("Bobot tidak boleh lebih dari 100%!");
return; return;
} }
@ -512,9 +509,6 @@ var allColumns = [
name: "progress_actual", label: "Total Actual Progress (%)", align: "center", min_width: 150, template: function (text) { name: "progress_actual", label: "Total Actual Progress (%)", align: "center", min_width: 150, template: function (text) {
let progress = text.progress let progress = text.progress
progress = progress * 100 progress = progress * 100
console.log("progress roundToTwo ", roundToTwo(progress));
console.log("progress toFixed ", progress.toFixed(2));
if (progress.toFixed(2) > 100) { if (progress.toFixed(2) > 100) {
gantt.alert("Progress tidak boleh lebih dari 100%!"); gantt.alert("Progress tidak boleh lebih dari 100%!");
return; return;

8
edit-mode/function/ganttSettings.js

@ -347,7 +347,7 @@ window.addEventListener("click", function (event) {
// Set Baseline // Set Baseline
function setBaseline() { function setBaseline() {
var box = gantt.confirm({ var box = gantt.confirm({
text: "Set Baseline?", text: "Set Baseline for this gantt chart?",
ok: "Yes", ok: "Yes",
cancel: "No", cancel: "No",
callback: async function (result) { callback: async function (result) {
@ -363,9 +363,9 @@ function setBaseline() {
} }
// Set Baseline Activity // Set Baseline Activity
function setBaselineActivity(activity_id) { function setBaselineActivity(activity_id, name) {
var box = gantt.confirm({ var box = gantt.confirm({
text: "Set Baseline Activity?", text: `Set Baseline for this activity <b>${name}</b>?`,
ok: "Yes", ok: "Yes",
cancel: "No", cancel: "No",
callback: async function (result) { callback: async function (result) {
@ -428,7 +428,7 @@ async function setBaselineActivityAPI(activity_id) {
async function setBaselineAPI() { async function setBaselineAPI() {
await importUpdate(); await importUpdate();
const res = await axiosInstance const res = await axiosInstance
.get(ACTIVITY_SET_BASELINE_URL(activity_id), HEADER) .get(ACTIVITY_SET_BASELINE_URL, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('set baseline res', res); console.log('set baseline res', res);

19
view-mode/function/ganttActivityUploadDoc.js

@ -1,8 +1,8 @@
// Upload Document Activity // Upload Document Activity
const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`; const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`;
const DOCUMENT_DOWNLOAD_URL = (id) => `${base_url}document-activity/download/${id}`; const DOCUMENT_DOWNLOAD_URL = (id) => `${base_url}document-activity/download/${id}/${company_id}`;
const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`; const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`;
const DOCUMENT_DELETE_URL = (id) => `${base_url}document-activity/delete/${id}`; const DOCUMENT_DELETE_URL = (id, company_id) => `${base_url}document-activity/delete/${id}/${company_id}`;
var fileToUpload = null; var fileToUpload = null;
@ -100,35 +100,26 @@ async function submitDocuments() {
var formData = new FormData; var formData = new FormData;
formData.append('activity_id', activity_id); formData.append('activity_id', activity_id);
formData.append('dokumen', files); formData.append('dokumen', files);
formData.append('company_id',company_id);
if (activity_id !== '' && dokumen !== '') { if (activity_id !== '' && dokumen !== '') {
const result = await axiosInstance const result = await axiosInstance
.post(DOCUMENT_UPLOAD_URL, formData) .post(DOCUMENT_UPLOAD_URL, formData)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log("result", result)
if(result && result.status==200){ if(result && result.status==200){
console.log('done upload doc', result) console.log('done upload doc', result)
// gantt.message("Upload success");
gantt.alert("Upload Success"); gantt.alert("Upload Success");
$("#add_doc_form").trigger("reset"); $("#add_doc_form").trigger("reset");
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
$('#btn_doc_submit').prop("disabled",false); $('#btn_doc_submit').prop("disabled",false);
searchDocuments(activity_id); // reload the contents searchDocuments(activity_id); // reload the contents
}else{ }else{
// closeDialog('failed upload')
console.log('failed upload');
// alert('Upload failed');
// gantt.message({type:"error", text:"Upload Failed"});
gantt.alert({type: "error", text: "Upload Failed"}); gantt.alert({type: "error", text: "Upload Failed"});
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
$('#btn_doc_submit').prop("disabled",false); $('#btn_doc_submit').prop("disabled",false);
} }
} }
else { else {
// alert('Please input the comment');
gantt.alert("Please insert the document file"); gantt.alert("Please insert the document file");
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
$('#btn_doc_submit').prop("disabled",false); $('#btn_doc_submit').prop("disabled",false);
@ -209,7 +200,7 @@ function searchDocuments(activity_id) {
async function downloadDocument(id, name) { async function downloadDocument(id, name) {
let result; let result;
await fetch(DOCUMENT_DOWNLOAD_URL(id), { await fetch(DOCUMENT_DOWNLOAD_URL(id, company_id), {
headers: new Headers({ headers: new Headers({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': `Bearer ${token}` 'Authorization': `Bearer ${token}`
@ -253,7 +244,7 @@ async function deleteDocument(id, activity_id) {
if (result) { if (result) {
console.log('download document', id); console.log('download document', id);
const result = await axiosInstance const result = await axiosInstance
.delete(DOCUMENT_DELETE_URL(id)) .delete(DOCUMENT_DELETE_URL(id, company_id))
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

2
view-mode/function/ganttSettings.js

@ -384,7 +384,7 @@ window.addEventListener("click", function(event){
// Set Baseline // Set Baseline
function setBaseline() { function setBaseline() {
var box = gantt.confirm({ var box = gantt.confirm({
text: "Set Baseline?", text: "Set Baseline for this gantt chart?",
ok:"Yes", ok:"Yes",
cancel:"No", cancel:"No",
callback: async function(result){ callback: async function(result){

Loading…
Cancel
Save