Skip to content

Commit efe468d

Browse files
authored
Merge pull request #2512 from CCAFS/aiccra-dev-A2-392-IPI-2.3
Aiccra dev a2 392 ipi 2.3
2 parents 4fc8b21 + f42f4c6 commit efe468d

File tree

4 files changed

+99
-6
lines changed

4 files changed

+99
-6
lines changed

marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101

102102
<section class="container">
103103

104-
<div class="modal-evidences" style="display: none">
104+
<div class="modal-deliverable modal-evidences" style="display: none">
105105
<div class="content-modal">
106106
<div class="button-exit close-modal-evidences">
107107
<div class="x-close-modal" ></div>
@@ -124,6 +124,24 @@
124124
</div>
125125
</div>
126126

127+
<div class=" modal-deliverable modal-indicator" style="display: none">
128+
<div class="content-modal">
129+
<div class="button-exit close-modal-indicator">
130+
<div class="x-close-modal" ></div>
131+
</div>
132+
<p class="title-modal-evidences title-modal-indicator">Remove Indicator</p>
133+
<div class="text-modal-evidences text-modal-indicator">
134+
<p>It is not possible to remove the indicator from the list, since this deliverable has shared clusters that have already been submitted and have related trainees.</p>
135+
136+
</div>
137+
<div class="container-buttons-evidences">
138+
<div class="button-close-modal close-modal-indicator">
139+
<p>Close</p>
140+
</div>
141+
</div>
142+
</div>
143+
</div>
144+
127145
<div class="row">
128146
[#-- Project Menu --]
129147
<div class="col-md-3">

marlo-web/src/main/webapp/crp/css/projects/projectDeliverable.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ div.fieldFocus-deliverable {
981981
font-weight: 620;
982982
}
983983

984-
.modal-evidences{
984+
.modal-deliverable{
985985
display: flex;
986986
background-color: #50505070;
987987
align-items: center;

marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableDissemination.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,37 @@ $('.listindicators .setSelect2').select2().on('change', function() {
9191
});
9292

9393
// Validate indicator removed in select2
94-
$(".listindicators .removeElement").on("click", function () {
94+
$(".listindicators .removeElement").on("click",async function () {
9595

96-
// detects when an element is removed and checks if the IPI 2.3 flag is still in the list
97-
$(this).closest("li").remove();
98-
searchIndicator();
96+
//These is validation for the IPI 2.3 indicator is selected and is able to be removed
97+
if($(this).siblings('.elementRelationID').val() === "7505"){
98+
99+
const inputs = document.querySelectorAll("div.form-group.row[clusteridparticipant] .participantsNumbers input");
100+
101+
const values = [];
102+
inputs.forEach(input => {
103+
values.push(parseInt(input.value));
104+
});
105+
var sumData = values.reduce((a, b) => a + b, 0);
106+
if (sumData > 0) {
107+
// If the flag is still in the list, the user is notified that the element is related to the IPI 2.3 indicator
108+
try {
109+
await alertRemoveIndicatorIPI2_3();
110+
} catch (error) {
111+
return;
112+
}
113+
} else {
114+
$(this).closest("li").remove();
115+
searchIndicator();
116+
return
117+
}
118+
119+
} else {
120+
// detects when an element is removed and checks if the IPI 2.3 flag is still in the list
121+
$(this).closest("li").remove();
122+
searchIndicator();
123+
return
124+
}
99125
});
100126

101127
// Validate which cluster is sectioned in select2
@@ -125,6 +151,9 @@ $('.listindicators .setSelect2').select2().on('change', function() {
125151
// close modal evidences
126152
$('.close-modal-evidences').on('click', closeModalEvidences);
127153

154+
// close modal indicator
155+
$('.close-modal-indicator').on('click', closeModalIndicator);
156+
128157
initialTotals();
129158
initialRemaining();
130159
reviewSharedclusters();
@@ -421,6 +450,12 @@ function closeModalEvidences(){
421450

422451
}
423452

453+
function closeModalIndicator(){
454+
let modal = $('.modal-indicator');
455+
console.log("close modal indicator");
456+
modal.hide();
457+
}
458+
424459
function validateRequiredTagToCategory() {
425460
var statusID = $('select[name="deliverable.deliverableInfo.status"]').val();
426461
if (statusID != '7' && statusID != '5') {

marlo-web/src/main/webapp/global/js/global.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,33 @@ async function onClickRemoveElement() {
867867
return;
868868
}
869869

870+
// check if the indicator IPI2.3 has information, to avoid removing, it in the Performance Indicator
871+
if (id === "7505" || name.includes("IPI 2.3")) {
870872

873+
//Represents a collection of input elements that contain the information of the total participants for each shared clusters.
874+
875+
const inputs = document.querySelectorAll("div.form-group.row[clusteridparticipant] .participantsNumbers input");
876+
877+
const values = [];
878+
inputs.forEach(input => {
879+
values.push(parseInt(input.value));
880+
});
881+
var sumData = values.reduce((a, b) => a + b, 0);
882+
if (sumData > 0) {
883+
884+
try {
885+
// Wait for the user to click on the modal
886+
await alertRemoveIndicatorIPI2_3();
887+
} catch (error) {
888+
// User clicked on the close button instead of the remove button
889+
console.log("Not removed");
890+
return;
891+
}
892+
}
893+
removeCluster(id);
894+
}
895+
896+
// check if the shared cluster has information, to avoid removing it, in the listClustersDM
871897
if (hasListClusters) {
872898
const inputs = document.querySelectorAll("div.form-group.row[clusteridparticipant='" + id + "'] input");
873899
const values = [];
@@ -889,6 +915,8 @@ async function onClickRemoveElement() {
889915

890916
}
891917

918+
919+
892920
$parent.slideUp(300, function () {
893921
$parent.remove();
894922

@@ -944,6 +972,18 @@ function alertRemoveCluster() {
944972
});
945973
}
946974

975+
function alertRemoveIndicatorIPI2_3() {
976+
return new Promise(function (resolve, reject) {
977+
let modal = $('.modal-indicator');
978+
modal.show();
979+
980+
$('.close-modal-indicator').on('click', function () {
981+
modal.hide();
982+
reject(true);
983+
});
984+
});
985+
}
986+
947987
function removeCluster(idCluster) {
948988
var spanText = $("#existCurrentCluster").text();
949989
if ($('.listClusters ul.list li').length == 1 && spanText == "false") { //existCurrentCluster

0 commit comments

Comments
 (0)