From ca92a8f7584d86d130bb67ea678a0c767afcccf7 Mon Sep 17 00:00:00 2001 From: JhonSGIzquierdo Date: Thu, 9 May 2024 16:24:30 -0500 Subject: [PATCH 1/4] :recycle: refactor(Status Rules): status rules disabled ongoing --- .../projects/deliverables/deliverableInfo.js | 70 ++++++++++++------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js index 9f1a815a4d..6a68d59ac3 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js @@ -557,10 +557,15 @@ function validateCurrentDate() { } function justificationByStatus(statusId) { - var $yearOverlay = $('#deliverableYear .overlay'); + + const $expectedYearBlock = $('#deliverableYear'); + const $expectedYearSelect = $expectedYearBlock.find('select'); + const expectedYear = $expectedYearSelect.val(); + var $newExpectedYearBlock = $('#newExpectedYear'); var $newExpectedYearSelect = $newExpectedYearBlock.find('select'); var newExpectedYear = $newExpectedYearSelect.val(); + var hasExpectedYear = ((newExpectedYear != "") && newExpectedYear != "-1") && (typeof newExpectedYear !== 'undefined'); var isCompletedWithoutExpectedYear = ((!reportingActive) && isStatusComplete(statusId) && hasExpectedYear); @@ -572,41 +577,36 @@ function justificationByStatus(statusId) { } else { $statusDescription.slideUp(400); } - - if (true) { - // Validate the new extended year - if (isDeliverableNew) { - showNewExpectedComponent(isStatusExtended(statusId) && upKeepActive); + // Validate the new extended year + if (isDeliverableNew) { + showNewExpectedComponent(isStatusExtended(statusId) && upKeepActive); + } else { + console.log("hasExpectedYear", hasExpectedYear); + if (isStatusOnGoing(statusId)) { + console.log("if"); + showNewExpectedComponent(false); } else { - console.log("hasExpectedYear", hasExpectedYear); - if (isStatusOnGoing(statusId)) { - console.log("if"); - showNewExpectedComponent(false); - } else { - console.log("else"); - if (statusId == 4) { + console.log("else"); + if (statusId == 4) { + showNewExpectedComponent(true); + $('.expectedDisabled').hide("slow"); + } else if (statusId == 2 || statusId == 3 || statusId == 5 || statusId == 6) { + + if (($('.yearNewExpected').val() != '-1') && ($('.yearNewExpected').val() != $('.yearExpected').val())) { showNewExpectedComponent(true); - $('.expectedDisabled').hide("slow"); - } else if (statusId == 2 || statusId == 3 || statusId == 5 || statusId == 6) { - - if (($('.yearNewExpected').val() != '-1') && ($('.yearNewExpected').val() != $('.yearExpected').val())) { - showNewExpectedComponent(true); - } else { - showNewExpectedComponent(false); - } - $('.expectedDisabled').show("slow"); } else { showNewExpectedComponent(false); } + $('.expectedDisabled').show("slow"); + } else { + showNewExpectedComponent(false); } } - - } else { - } } +//Display the overlay thaty block the possibility to change the expected year function showNewExpectedComponent(state) { var $newExpectedYearBlock = $('#newExpectedYear'); var $yearOverlay = $('#deliverableYear .overlay'); @@ -623,6 +623,17 @@ function showNewExpectedComponent(state) { } function validateDeliverableStatus(canChangeStatus) { + + const $expectedYearBlock = $('#deliverableYear'); + const $expectedYearSelect = $expectedYearBlock.find('select'); + const expectedYear = $expectedYearSelect.val(); + + var $newExpectedYearBlock = $('#newExpectedYear'); + var $newExpectedYearSelect = $newExpectedYearBlock.find('select'); + var newExpectedYear = $newExpectedYearSelect.val(); + + var isAdmin = document.getElementById("adminRole").value; + // New Expected year should be greater than current reporting cycle year if (reportingActive) { if (isDeliverableNew) { @@ -640,7 +651,7 @@ function validateDeliverableStatus(canChangeStatus) { // Validation when the deliverable has shared submitted clusters related with trainees information if(canChangeStatus === false){ - var isAdmin = document.getElementById("adminRole").value; + if(isAdmin){ $statuses.find('option[value="4"]').prop("disabled", false); // Enable Extended $statuses.find('option[value="5"]').prop("disabled", false); // Enable Cancelled @@ -649,6 +660,13 @@ function validateDeliverableStatus(canChangeStatus) { $statuses.find('option[value="5"]').prop("disabled", true); // Disable Cancelled } } + + // Validate if the current cycle year is different or equal to the year expected to active On going status + if((expectedYear != currentCycleYear) && (newExpectedYear != "-1") && (isAdmin !== true) ){ + $statuses.find('option[value="2"]').prop("disabled", true); // Disable On-going + } else { + $statuses.find('option[value="2"]').prop("disabled", false); // Enable On-going + } } function checkActivityItems(block) { From 4f587efbb94ed29fccf445b59c2c14c3ef0323d4 Mon Sep 17 00:00:00 2001 From: JhonSGIzquierdo Date: Fri, 10 May 2024 12:04:39 -0500 Subject: [PATCH 2/4] :recycle: refactor(Status Rules): unncesary validation remove --- .../webapp/crp/js/projects/deliverables/deliverableInfo.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js index 6a68d59ac3..3bc1584ecd 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js @@ -661,8 +661,9 @@ function validateDeliverableStatus(canChangeStatus) { } } + //console.log("newExpectedYearCondition", newExpectedYear != "-1"); // Validate if the current cycle year is different or equal to the year expected to active On going status - if((expectedYear != currentCycleYear) && (newExpectedYear != "-1") && (isAdmin !== true) ){ + if((expectedYear != currentCycleYear) && (isAdmin !== true) ){ $statuses.find('option[value="2"]').prop("disabled", true); // Disable On-going } else { $statuses.find('option[value="2"]').prop("disabled", false); // Enable On-going From 41aa052f0ab6aa50d1eb16e1fd15a03bd1fc0ff9 Mon Sep 17 00:00:00 2001 From: JhonSGIzquierdo Date: Fri, 10 May 2024 16:12:57 -0500 Subject: [PATCH 3/4] :sparkles: feat(Status Rules): remove justification if on going is select and available --- .../crp/js/projects/deliverables/deliverableInfo.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js index 3bc1584ecd..16de81f59a 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js @@ -558,10 +558,6 @@ function validateCurrentDate() { function justificationByStatus(statusId) { - const $expectedYearBlock = $('#deliverableYear'); - const $expectedYearSelect = $expectedYearBlock.find('select'); - const expectedYear = $expectedYearSelect.val(); - var $newExpectedYearBlock = $('#newExpectedYear'); var $newExpectedYearSelect = $newExpectedYearBlock.find('select'); var newExpectedYear = $newExpectedYearSelect.val(); @@ -585,6 +581,8 @@ function justificationByStatus(statusId) { if (isStatusOnGoing(statusId)) { console.log("if"); showNewExpectedComponent(false); + $newExpectedYearSelect.val("-1").trigger("change.select2"); + $statusDescription.find('textarea').val(""); } else { console.log("else"); if (statusId == 4) { @@ -606,7 +604,7 @@ function justificationByStatus(statusId) { } -//Display the overlay thaty block the possibility to change the expected year +//Display the overlay that block the possibility to change the expected year function showNewExpectedComponent(state) { var $newExpectedYearBlock = $('#newExpectedYear'); var $yearOverlay = $('#deliverableYear .overlay'); @@ -628,10 +626,6 @@ function validateDeliverableStatus(canChangeStatus) { const $expectedYearSelect = $expectedYearBlock.find('select'); const expectedYear = $expectedYearSelect.val(); - var $newExpectedYearBlock = $('#newExpectedYear'); - var $newExpectedYearSelect = $newExpectedYearBlock.find('select'); - var newExpectedYear = $newExpectedYearSelect.val(); - var isAdmin = document.getElementById("adminRole").value; // New Expected year should be greater than current reporting cycle year From 193a15b11068bbe3926d22d957b44b2041270573 Mon Sep 17 00:00:00 2001 From: JhonSGIzquierdo Date: Fri, 10 May 2024 17:39:42 -0500 Subject: [PATCH 4/4] :recycle: refactor(Status Rules): validation update based on previous methods --- .../crp/js/projects/deliverables/deliverableInfo.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js index 16de81f59a..9827df487b 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js @@ -562,9 +562,7 @@ function justificationByStatus(statusId) { var $newExpectedYearSelect = $newExpectedYearBlock.find('select'); var newExpectedYear = $newExpectedYearSelect.val(); - var hasExpectedYear = - ((newExpectedYear != "") && newExpectedYear != "-1") && (typeof newExpectedYear !== 'undefined'); - var isCompletedWithoutExpectedYear = ((!reportingActive) && isStatusComplete(statusId) && hasExpectedYear); + var hasExpectedYear = ((newExpectedYear != "") && newExpectedYear != "-1") && (typeof newExpectedYear !== 'undefined'); // Validate the justification if (isStatusCancelled(statusId) || isStatusExtended(statusId)) { @@ -573,6 +571,7 @@ function justificationByStatus(statusId) { } else { $statusDescription.slideUp(400); } + // Validate the new extended year if (isDeliverableNew) { showNewExpectedComponent(isStatusExtended(statusId) && upKeepActive); @@ -585,11 +584,10 @@ function justificationByStatus(statusId) { $statusDescription.find('textarea').val(""); } else { console.log("else"); - if (statusId == 4) { + if (isStatusExtended(statusId)) { showNewExpectedComponent(true); $('.expectedDisabled').hide("slow"); - } else if (statusId == 2 || statusId == 3 || statusId == 5 || statusId == 6) { - + } else if ( isStatusComplete(statusId) || isStatusComplete(statusId) || statusId == 6) { if (($('.yearNewExpected').val() != '-1') && ($('.yearNewExpected').val() != $('.yearExpected').val())) { showNewExpectedComponent(true); } else { @@ -601,7 +599,6 @@ function justificationByStatus(statusId) { } } } - } //Display the overlay that block the possibility to change the expected year