Browse Source

feat(form): manual input & default value and fix bug when null user add

pull/1/head
farhantock 7 months ago
parent
commit
7c01c07845
  1. 30
      edit-mode/function/humanResource.js

30
edit-mode/function/humanResource.js

@ -31,11 +31,13 @@ $(document).ready(function () {
"columns": [
{ data: 'user_name', name: 'user_name' },
{ data: 'role_name', name: 'role_name' },
{ data: 'start_date', name: 'start_date', render: function (data, type) {
{
data: 'start_date', name: 'start_date', render: function (data, type) {
return data ? formatDate(data) : '-'
}
},
{ data: 'end_date', name: 'end_date', render: function (data, type) {
{
data: 'end_date', name: 'end_date', render: function (data, type) {
return data ? formatDate(data) : '-'
}
},
@ -78,6 +80,8 @@ $(document).ready(function () {
$('#modal-hr').on('show.bs.modal', function (event) {
$('#modal-hr-title').html("Human Resource " + activityName);
$('#modal-hr-sub-title').html(`<p style="font-size: 12px; color: #747474">Plan Date ${moment(activityEarlyStart).format('MM-DD-YYYY')} - ${moment(activityEarlyFinish).format('MM-DD-YYYY')}</p>`);
$("#hr-start-date").val(moment(activityEarlyStart).format('YYYY-MM-DD'));
$("#hr-end-date").val(moment(activityEarlyFinish).format('YYYY-MM-DD'));
$('#modal-hr-time-startDate').html("Minimum from " + moment(activityEarlyStart).format('MM-DD-YYYY'));
$('#modal-hr-time-endDate').html("Maximum from " + moment(activityEarlyFinish).format('MM-DD-YYYY'));
tableHr.draw();
@ -153,7 +157,6 @@ $(document).ready(function () {
});
$('#select-hr').on('select2:select', function (e) {
console.log('select event', e.params.data);
let param_data = e.params.data;
if (param_data && param_data.proyek_role) {
let proyek_role = param_data.proyek_role
@ -162,20 +165,24 @@ $(document).ready(function () {
});
$("#hr-start-date").on('change', (e) => {
let start_date = new Date($("#hr-start-date").val());
if (start_date < activityEarlyStart || start_date > activityEarlyFinish) {
$("#hr-start-date").on('input', (e) => {
let inputDate = moment($("#hr-start-date").val());
if (moment(inputDate).format('YYYY') >= moment(activityEarlyStart).format('YYYY')) {
if (inputDate.isBefore(moment(activityEarlyStart).format('YYYY-MM-DD')) || inputDate.isAfter(moment(activityEarlyFinish).format('YYYY-MM-DD'))) {
gantt.alert("Start date should be inside activity date range !");
$("#hr-start-date").val("");
}
})
}
});
$("#hr-end-date").on('change', (e) => {
let end_date = new Date($("#hr-end-date").val());
if (end_date < activityEarlyStart || end_date > activityEarlyFinish) {
let inputDate = moment($("#hr-end-date").val());
if (moment(inputDate).format('YYYY') >= moment(activityEarlyStart).format('YYYY')) {
if (inputDate.isBefore(moment(activityEarlyStart).format('YYYY-MM-DD')) || inputDate.isAfter(moment(activityEarlyFinish).format('YYYY-MM-DD'))) {
gantt.alert("End date should be inside activity date range !");
$("#hr-end-date").val("");
}
}
})
$("#form-assign-hr").on('submit', function (e) {
@ -190,12 +197,13 @@ $(document).ready(function () {
let end_date = $("#hr-end-date").val();
let user_id = [];
let user_role = [];
users.map((item)=>{
users.map((item) => {
let text = item.split('|');
user_id.push(text[0]);
user_role.push(text[1]);
})
if (!users || users < 0) {
if (!users || users.length === 0) {
gantt.alert("Please choose user to assign!");
$('#btn-assign-hr').html('Assign');
$('#btn-assign-hr').prop("disabled", false);

Loading…
Cancel
Save