Skip to content

Aiccra dev a2 304 status rules #2531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,12 @@ function validateCurrentDate() {
}

function justificationByStatus(statusId) {
var $yearOverlay = $('#deliverableYear .overlay');

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);

var hasExpectedYear = ((newExpectedYear != "") && newExpectedYear != "-1") && (typeof newExpectedYear !== 'undefined');

// Validate the justification
if (isStatusCancelled(statusId) || isStatusExtended(statusId)) {
Expand All @@ -573,40 +572,36 @@ function justificationByStatus(statusId) {
$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);
$newExpectedYearSelect.val("-1").trigger("change.select2");
$statusDescription.find('textarea').val("");
} else {
console.log("hasExpectedYear", hasExpectedYear);
if (isStatusOnGoing(statusId)) {
console.log("if");
showNewExpectedComponent(false);
} else {
console.log("else");
if (statusId == 4) {
console.log("else");
if (isStatusExtended(statusId)) {
showNewExpectedComponent(true);
$('.expectedDisabled').hide("slow");
} else if ( isStatusComplete(statusId) || isStatusComplete(statusId) || 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 that block the possibility to change the expected year
function showNewExpectedComponent(state) {
var $newExpectedYearBlock = $('#newExpectedYear');
var $yearOverlay = $('#deliverableYear .overlay');
Expand All @@ -623,6 +618,13 @@ function showNewExpectedComponent(state) {
}

function validateDeliverableStatus(canChangeStatus) {

const $expectedYearBlock = $('#deliverableYear');
const $expectedYearSelect = $expectedYearBlock.find('select');
const expectedYear = $expectedYearSelect.val();

var isAdmin = document.getElementById("adminRole").value;

// New Expected year should be greater than current reporting cycle year
if (reportingActive) {
if (isDeliverableNew) {
Expand All @@ -640,7 +642,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
Expand All @@ -649,6 +651,14 @@ function validateDeliverableStatus(canChangeStatus) {
$statuses.find('option[value="5"]').prop("disabled", true); // Disable Cancelled
}
}

//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) && (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) {
Expand Down