Skip to content

Commit 5ecc81e

Browse files
authored
Merge pull request #2538 from CCAFS/aiccra-dev-A2-597-General-Message-PROGRESS
Aiccra dev a2 597 general message progress
2 parents b1a4e00 + e0f1001 commit 5ecc81e

File tree

3 files changed

+126
-4
lines changed

3 files changed

+126
-4
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*****************************************************************
2+
* This file is part of Managing Agricultural Research for Learning &
3+
* Outcomes Platform (MARLO).
4+
* MARLO is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* at your option) any later version.
8+
* MARLO is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
* You should have received a copy of the GNU General Public License
13+
* along with MARLO. If not, see <http://www.gnu.org/licenses/>.
14+
*****************************************************************/
15+
16+
package org.cgiar.ccafs.marlo.action.json.global;
17+
18+
import org.cgiar.ccafs.marlo.action.BaseAction;
19+
import org.cgiar.ccafs.marlo.utils.APConfig;
20+
21+
import java.util.HashMap;
22+
import java.util.Map;
23+
24+
import javax.inject.Inject;
25+
26+
import org.apache.struts2.dispatcher.Parameter;
27+
28+
29+
public class ProgressActiveValidationAction extends BaseAction {
30+
31+
32+
/**
33+
*
34+
*/
35+
private static final long serialVersionUID = 8027160696406597679L;
36+
/**
37+
*
38+
*/
39+
private Map<String, String> status;
40+
41+
@Inject
42+
public ProgressActiveValidationAction(APConfig config) {
43+
super(config);
44+
}
45+
46+
@Override
47+
public String execute() throws Exception {
48+
49+
status = new HashMap<>();
50+
51+
if (this.isUpKeepActive()) {
52+
status.put("isProgress", "true");
53+
} else {
54+
status.put("isProgress", "false");
55+
}
56+
57+
return SUCCESS;
58+
}
59+
60+
public Map<String, String> getStatus() {
61+
return status;
62+
}
63+
64+
@Override
65+
public void prepare() throws Exception {
66+
Map<String, Parameter> parameters = this.getParameters();
67+
}
68+
69+
70+
public void setStatus(Map<String, String> keyOutputs) {
71+
this.status = keyOutputs;
72+
}
73+
}
74+

marlo-web/src/main/resources/struts-json.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
<param name="excludeNullProperties">true</param>
2727
</result>
2828
</action>
29+
30+
<action name="isProgressActive"
31+
class="org.cgiar.ccafs.marlo.action.json.global.ProgressActiveValidationAction">
32+
<result type="json">
33+
<param name="noCache">true</param>
34+
<param name="excludeNullProperties">true</param>
35+
</result>
36+
</action>
2937

3038
<action name="uploadFundingSource"
3139
class="org.cgiar.ccafs.marlo.action.json.project.UploadFundingSourceFileAction">

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

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $.widget.bridge('uitooltip', $.ui.tooltip);
44

55
// Global Vars
66
var yesnoEvent;
7+
var isProgress;
78
var notyDefaultOptions = {
89
text: '',
910
layout: 'bottomRight',
@@ -20,13 +21,17 @@ var notyDefaultOptions = {
2021
]
2122
};
2223

24+
2325
/**
2426
* Global javascript must be here.
2527
*/
2628
$(document).ready(function () {
2729

28-
showNotificationMessages();
30+
2931
showHelpText();
32+
validatePhase().then(function(isProgress){
33+
showNotificationMessages();
34+
}).catch(function(error){});
3035

3136
// Set elementsListComponent
3237
setElementsListComponent();
@@ -176,6 +181,22 @@ $(document).ready(function () {
176181
$buttons.find('.buttons-content').removeClass('positionFixedBot animated flipInX');
177182
}
178183
}
184+
185+
function validatePhase() {
186+
return new Promise(function(resolve, reject) {
187+
// Ajax
188+
$.ajax({
189+
url: baseURL + '/isProgressActive.do',
190+
success: function(data) {
191+
isProgress = data.status.isProgress;
192+
resolve();
193+
},
194+
error: function(xhr, status, error) {
195+
reject(error);
196+
}
197+
});
198+
});
199+
}
179200

180201
// Animate help text
181202
function showHelpText() {
@@ -200,8 +221,11 @@ $(document).ready(function () {
200221
} else if (messageSelector.length >= 1 && messageSelector.html().split(":")[0] != "message" && messageSelector.html().split(":")[1] === " deliverable.status.remaining") {
201222
// SHOW CLUSTER SUBMITTED BASED ON THE DISABLED INPUT
202223
var $clusterSubmitted = $(`.clusterSubmitted`);
224+
var $clusterSubmittedFilter = $clusterSubmitted.filter((index, ele) => $(ele).attr("issubmit") === "true").get();
203225
var message = "";
204-
if ($clusterSubmitted.length > 0) {
226+
console.log("ClusterSubmitted Lenght",$clusterSubmitted.length);
227+
console.log("ClusterSubmitted", $clusterSubmitted);
228+
if ($clusterSubmittedFilter.length > 0) {
205229
// $clusterSubmitted exists, do something
206230
const $mapClusterSubmit = $clusterSubmitted.filter((index, ele) => $(ele).attr("issubmit") === "true").get();
207231
const $stringClusterSubmit = $mapClusterSubmit.reduce((prev,curr) => prev +$(curr).attr("name")+",","");
@@ -223,9 +247,17 @@ $(document).ready(function () {
223247
} else if (messageSelector.length >= 1 && messageSelector.html().split(":")[0] != "message") {
224248
// WARNING MESSAGE
225249
var message = ""
226-
message += "The Information was correctly saved. <br> ";
227-
message += "Please keep in mind that the fields highlighted below are missing or incorrect.";
228250
var messageType = "warning";
251+
if(isProgress == 'true'){
252+
message += "The Information was correctly saved. <br> ";
253+
message += "Some of the fields could be missing or incorrect. <br>";
254+
message += "Don't worry! Some information is not necessary at this phase, but it will be required in the next phase.";
255+
messageType = "info";
256+
}else{
257+
message += "The Information was correctly saved. <br> ";
258+
message += "Please keep in mind that the fields highlighted below are missing or incorrect.";
259+
}
260+
229261
notifyErrorMessage(messageType, message);
230262
}
231263
} else if ($(messageSelector).hasClass("error")) {
@@ -262,6 +294,14 @@ $(document).ready(function () {
262294
$(containerIcon).addClass("alertColorWarning");
263295
$(messages).removeClass("displayNone");
264296
break;
297+
case "info":
298+
$(element).find('.alertText').html(message);
299+
$(iconAlert).attr("src", baseURL + '/global/images/icon-info.png');
300+
$(containerAlert).addClass("alertColorBackgroundInfo");
301+
$(containerLine).addClass("alertColorInfo");
302+
$(containerIcon).addClass("alertColorInfo");
303+
$(messages).removeClass("displayNone");
304+
break;
265305
case "error":
266306
//Declaraciones ejecutadas cuando el resultado de expresión coincide con valorN
267307
break;

0 commit comments

Comments
 (0)