From 51d5c4ddda1a259bbb72b345fcb46b7389a9f6c9 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 29 Jan 2024 08:41:04 -0500 Subject: [PATCH 01/65] :wrench: fix(safeguard): Update safeguard feedback functionality --- .../action/projects/SafeguardAction.java | 57 ++++++++++++++++--- .../WEB-INF/crp/views/projects/safeguard.ftl | 11 +++- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/SafeguardAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/SafeguardAction.java index 59ac03ae1b..15abfcd7ea 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/SafeguardAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/SafeguardAction.java @@ -18,6 +18,8 @@ import org.cgiar.ccafs.marlo.action.BaseAction; import org.cgiar.ccafs.marlo.config.APConstants; import org.cgiar.ccafs.marlo.data.manager.AuditLogManager; +import org.cgiar.ccafs.marlo.data.manager.FeedbackQACommentManager; +import org.cgiar.ccafs.marlo.data.manager.FeedbackQACommentableFieldsManager; import org.cgiar.ccafs.marlo.data.manager.FileDBManager; import org.cgiar.ccafs.marlo.data.manager.ProjectInfoManager; import org.cgiar.ccafs.marlo.data.manager.ProjectManager; @@ -25,6 +27,8 @@ import org.cgiar.ccafs.marlo.data.manager.SectionStatusManager; import org.cgiar.ccafs.marlo.data.manager.UserManager; import org.cgiar.ccafs.marlo.data.model.CrpProgram; +import org.cgiar.ccafs.marlo.data.model.FeedbackQAComment; +import org.cgiar.ccafs.marlo.data.model.FeedbackQACommentableFields; import org.cgiar.ccafs.marlo.data.model.GlobalUnit; import org.cgiar.ccafs.marlo.data.model.Project; import org.cgiar.ccafs.marlo.data.model.ProjectInfo; @@ -87,12 +91,16 @@ public class SafeguardAction extends BaseAction { private String fileReportingFileName; private SafeguardValidator validator; private Safeguards safeguard; + private List feedbackComments; + private FeedbackQACommentManager feedbackQACommentManager; + private FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager; @Inject public SafeguardAction(APConfig config, ProjectManager projectManager, UserManager userManager, SectionStatusManager sectionStatusManager, FileDBManager fileDBManager, AuditLogManager auditLogManager, SafeguardValidator validator, HistoryComparator historyComparator, ProjectInfoManager projectInfoManagerManager, - SafeguardsManager safeguardsManager) { + SafeguardsManager safeguardsManager, FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager, + FeedbackQACommentManager feedbackQACommentManager) { super(config); this.projectManager = projectManager; this.projectInfoManagerManager = projectInfoManagerManager; @@ -102,6 +110,8 @@ public SafeguardAction(APConfig config, ProjectManager projectManager, UserManag this.fileDBManager = fileDBManager; this.historyComparator = historyComparator; this.safeguardsManager = safeguardsManager; + this.feedbackQACommentableFieldsManager = feedbackQACommentableFieldsManager; + this.feedbackQACommentManager = feedbackQACommentManager; } /** @@ -202,6 +212,10 @@ private String getBilateralProposalRelativePath() { + "safeguard" + File.separator; } + public List getFeedbackComments() { + return feedbackComments; + } + public File getFile() { return file; } @@ -245,6 +259,7 @@ public GlobalUnit getLoggedCrp() { return loggedCrp; } + public Project getProject() { return project; } @@ -279,7 +294,6 @@ public long getSafeguardID() { return safeguardID; } - public String getTransaction() { return transaction; } @@ -290,11 +304,11 @@ private String getWorkplanRelativePath() { + config.getProjectWorkplanFolder() + File.separator; } + public String getWorkplanURL() { return config.getDownloadURL() + "/" + this.getWorkplanRelativePath().replace('\\', '/'); } - /** * Return the absolute path where the work plan is or should be located. * @@ -305,6 +319,7 @@ private String getWorplansAbsolutePath() { return config.getUploadsBaseFolder() + File.separator + this.getWorkplanRelativePath() + File.separator; } + public void loadFile() { if (safeguard.getFile() != null) { if (safeguard.getFile().getId() != null) { @@ -315,7 +330,6 @@ public void loadFile() { } } - @Override public void prepare() throws Exception { @@ -445,6 +459,30 @@ public void prepare() throws Exception { projectDB = projectManager.getProjectById(projectID); + /* + * get feedback comments + */ + try { + + feedbackComments = new ArrayList<>(); + feedbackComments = feedbackQACommentableFieldsManager.findAll().stream() + .filter(f -> f.getSectionName() != null && f.getSectionName().equals("innovation")) + .collect(Collectors.toList()); + if (feedbackComments != null) { + for (FeedbackQACommentableFields field : feedbackComments) { + List comments = new ArrayList(); + comments = feedbackQACommentManager.findAll().stream() + .filter(f -> f != null && f.getPhase() != null && f.getPhase().getId() != null + && f.getPhase().getId().equals(this.getActualPhase().getId()) && f.getParentId() == safeguard.getId() + && f.getField() != null && f.getField().getId() != null && f.getField().getId().equals(field.getId())) + .collect(Collectors.toList()); + field.setQaComments(comments); + } + } + + } catch (Exception e) { + } + // The base permission is established for the current section String params[] = {loggedCrp.getAcronym(), project.getId() + ""}; @@ -490,6 +528,7 @@ public String save() { } + public void saveSafeguard() { Safeguards safeguardDB = new Safeguards(); if (safeguard != null && safeguard.getId() != null) { @@ -506,6 +545,10 @@ public void saveSafeguard() { } + public void setFeedbackComments(List feedbackComments) { + this.feedbackComments = feedbackComments; + } + public void setFile(File file) { this.file = file; } @@ -515,16 +558,15 @@ public void setFileContentType(String fileContentType) { this.fileContentType = fileContentType; } + public void setFileFileName(String fileFileName) { this.fileFileName = fileFileName; } - public void setFileReporting(File fileReporting) { this.fileReporting = fileReporting; } - public void setFileReportingFileName(String fileReportingFileName) { this.fileReportingFileName = fileReportingFileName; } @@ -537,6 +579,7 @@ public void setProject(Project project) { this.project = project; } + public void setProjectID(long projectID) { this.projectID = projectID; } @@ -545,7 +588,6 @@ public void setSafeguard(Safeguards safeguard) { this.safeguard = safeguard; } - public void setSafeguardID(long safeguardID) { this.safeguardID = safeguardID; } @@ -554,7 +596,6 @@ public void setTransaction(String transaction) { this.transaction = transaction; } - @Override public void validate() { this.setInvalidFields(new HashMap<>()); diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/safeguard.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/safeguard.ftl index 1f837d562e..0bc07c11b6 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/safeguard.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/safeguard.ftl @@ -38,10 +38,15 @@ [#include "/WEB-INF/crp/views/projects/availability-projects.ftl" /] [#else] -[@customForm.qaPopUp /] - [#if action.hasSpecificities('feedback_active') ] - + [#if feedbackComments?has_content] + [#list feedbackComments as feedback] + [@customForm.qaPopUpMultiple fields=feedback.qaComments name=feedback.fieldDescription index=feedback_index canLeaveComments=(action.canLeaveComments()!false)/] + [/#list] + + [/#if] [/#if]
From 783aad05f73d071d6cd7282c54fe690bb5f0ba18 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 29 Jan 2024 08:46:36 -0500 Subject: [PATCH 02/65] :wrench: chore(migrations): Creation of shfrm contribution database model migration --- ...0126_1508__UpdateDeliverablesInfoTable.sql | 2 ++ ..._1509__CreateShfrmPriorityActionsTable.sql | 15 ++++++++++++++ ...40126_1510__CreateShfrmSubActionsTable.sql | 17 ++++++++++++++++ ...teDeliverableShfrmPriorityActionsTable.sql | 20 +++++++++++++++++++ ..._CreateDeliverableShfrmSubActionsTable.sql | 20 +++++++++++++++++++ 5 files changed, 74 insertions(+) create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1508__UpdateDeliverablesInfoTable.sql create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1509__CreateShfrmPriorityActionsTable.sql create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1510__CreateShfrmSubActionsTable.sql create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1511__CreateDeliverableShfrmPriorityActionsTable.sql create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1512__CreateDeliverableShfrmSubActionsTable.sql diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1508__UpdateDeliverablesInfoTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1508__UpdateDeliverablesInfoTable.sql new file mode 100644 index 0000000000..b27a22a659 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1508__UpdateDeliverablesInfoTable.sql @@ -0,0 +1,2 @@ +ALTER TABLE deliverables_info ADD is_contributing_shfrm tinyint(1) DEFAULT 0 NULL; +ALTER TABLE deliverables_info ADD shfrm_contribution_narrative varchar(200) NULL; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1509__CreateShfrmPriorityActionsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1509__CreateShfrmPriorityActionsTable.sql new file mode 100644 index 0000000000..d0fcff5e67 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1509__CreateShfrmPriorityActionsTable.sql @@ -0,0 +1,15 @@ +CREATE TABLE shfrm_priority_actions ( + id bigint(20) auto_increment NOT NULL, + name varchar(100) NULL, + is_active tinyint(1) NULL, + description varchar(300) NULL, + modified_by bigint(20) NULL, + modification_justification text NULL, + created_by bigint(20) NULL, + active_since timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP NULL, + CONSTRAINT shfrm_priority_action_pk PRIMARY KEY (id), + CONSTRAINT shfrm_priority_actions_users_FK FOREIGN KEY (modified_by) REFERENCES users(id) ON DELETE RESTRICT ON UPDATE RESTRICT +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_general_ci; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1510__CreateShfrmSubActionsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1510__CreateShfrmSubActionsTable.sql new file mode 100644 index 0000000000..d11df3f67e --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1510__CreateShfrmSubActionsTable.sql @@ -0,0 +1,17 @@ +CREATE TABLE shfrm_sub_actions ( + id bigint(20) auto_increment NOT NULL, + name varchar(100) NULL, + description varchar(300) NULL, + shfrm_priority_action_id bigint(20) NOT NULL, + is_active tinyint(1) NULL, + modified_by bigint(20) NULL, + modification_justification text NULL, + created_by bigint(20) NULL, + active_since timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP NULL, + CONSTRAINT shfrm_sub_action_pk PRIMARY KEY (id), + CONSTRAINT shfrm_sub_action_users_FK FOREIGN KEY (modified_by) REFERENCES users(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT shfrm_sub_actions_FK FOREIGN KEY (shfrm_priority_action_id) REFERENCES shfrm_priority_actions(id) ON DELETE RESTRICT ON UPDATE RESTRICT +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_czech_ci; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1511__CreateDeliverableShfrmPriorityActionsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1511__CreateDeliverableShfrmPriorityActionsTable.sql new file mode 100644 index 0000000000..a01fb1e7f2 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1511__CreateDeliverableShfrmPriorityActionsTable.sql @@ -0,0 +1,20 @@ +CREATE TABLE deliverable_shfrm_priority_action ( + id bigint(20) auto_increment NOT NULL, + deliverable_id bigint(20) NOT NULL, + shfrm_priority_action_id bigint(20) NOT NULL, + is_active tinyint(1) NULL, + id_phase bigint(20) NOT NULL, + modified_by bigint(20) NULL, + modification_justification text NULL, + created_by bigint(20) NULL, + active_since timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP NULL, + CONSTRAINT deliverable_shfrm_priority_action_pk PRIMARY KEY (id), + CONSTRAINT deliverable_shfrm_priority_action_deliverables_FK FOREIGN KEY (deliverable_id) REFERENCES deliverables(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfrm_priority_action_phases_FK FOREIGN KEY (id_phase) REFERENCES phases(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfrm_priority_action_shfrm_priority_actions_FK FOREIGN KEY (shfrm_priority_action_id) REFERENCES shfrm_priority_actions(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfmr_priority_action_users_FK FOREIGN KEY (modified_by) REFERENCES users(id) ON DELETE RESTRICT ON UPDATE RESTRICT + +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_general_ci; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1512__CreateDeliverableShfrmSubActionsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1512__CreateDeliverableShfrmSubActionsTable.sql new file mode 100644 index 0000000000..50ba5b0aa8 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1512__CreateDeliverableShfrmSubActionsTable.sql @@ -0,0 +1,20 @@ +CREATE TABLE deliverable_shfmr_sub_action ( + id bigint(20) auto_increment NOT NULL, + deliverable_shfrm_priority_action_id bigint(20) NOT NULL, + shfrm_sub_action_id bigint(20) NULL, + is_active tinyint(1) NULL, + id_phase bigint(20) NOT NULL, + modified_by bigint(20) NULL, + modification_justification text NULL, + created_by bigint(20) NULL, + active_since timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP NULL, + CONSTRAINT deliverable_shfmr_sub_action_pk PRIMARY KEY (id), + CONSTRAINT deliverable_shfmr_sub_action_phases_FK FOREIGN KEY (id_phase) REFERENCES phases(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfmr_sub_action_users_FK FOREIGN KEY (modified_by) REFERENCES users(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfmr_sub_action_shfrm_sub_actions_FK FOREIGN KEY (shfrm_sub_action_id) REFERENCES shfrm_sub_actions(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfmr_sub_action_deliverable_FK FOREIGN KEY (deliverable_shfrm_priority_action_id) REFERENCES deliverable_shfrm_priority_action(id) ON DELETE RESTRICT ON UPDATE RESTRICT +) + +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_general_ci; \ No newline at end of file From 42fd934689f0d393cd9cd651f97790802851eca4 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 29 Jan 2024 16:11:37 -0500 Subject: [PATCH 03/65] :wrench: chore(shfrm Contribution): Update deliverable info model --- .../marlo/data/model/DeliverableInfo.java | 33 ++++++++++++------- .../resources/xmls/DeliverablesInfo.hbm.xml | 6 ++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java index d3dceffe12..92abd509db 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java @@ -47,6 +47,10 @@ public class DeliverableInfo extends MarloAuditableEntity implements java.io.Ser private Boolean duplicated; @Expose private Boolean remainingPending; + @Expose + private Boolean contributingShfrm; + @Expose + private Boolean shfrmContributionNarrative; public DeliverableInfo() { } @@ -55,11 +59,14 @@ public Boolean getAdoptedLicense() { return adoptedLicense; } + public Boolean getContributingShfrm() { + return contributingShfrm; + } + public CrpClusterKeyOutput getCrpClusterKeyOutput() { return crpClusterKeyOutput; } - public CrpProgramOutcome getCrpProgramOutcome() { return crpProgramOutcome; } @@ -68,7 +75,6 @@ public Deliverable getDeliverable() { return deliverable; } - public DeliverableType getDeliverableType() { return deliverableType; } @@ -77,12 +83,10 @@ public String getDescription() { return description; } - public Boolean getDuplicated() { return duplicated; } - public RepIndGeographicScope getGeographicScope() { return geographicScope; } @@ -91,7 +95,6 @@ public Boolean getIsLocationGlobal() { return isLocationGlobal; } - @Override public String getLogDeatil() { StringBuilder sb = new StringBuilder(); @@ -104,7 +107,6 @@ public Integer getNewExpectedYear() { return newExpectedYear; } - public Phase getPhase() { return phase; } @@ -119,16 +121,18 @@ public Boolean getRemainingPending() { } + public Boolean getShfrmContributionNarrative() { + return shfrmContributionNarrative; + } + public Integer getStatus() { return status; } - public String getStatusDescription() { return statusDescription; } - public String getStatusName(Phase phase) { @@ -372,6 +376,10 @@ public void setAdoptedLicense(Boolean adoptedLicense) { } + public void setContributingShfrm(Boolean contributingShfrm) { + this.contributingShfrm = contributingShfrm; + } + public void setCrpClusterKeyOutput(CrpClusterKeyOutput crpClusterKeyOutput) { this.crpClusterKeyOutput = crpClusterKeyOutput; } @@ -381,7 +389,6 @@ public void setCrpProgramOutcome(CrpProgramOutcome crpProgramOutcome) { this.crpProgramOutcome = crpProgramOutcome; } - public void setDeliverable(Deliverable deliverable) { this.deliverable = deliverable; } @@ -391,7 +398,6 @@ public void setDeliverableType(DeliverableType deliverableType) { this.deliverableType = deliverableType; } - public void setDescription(String description) { this.description = description; } @@ -400,7 +406,6 @@ public void setDuplicated(Boolean duplicated) { this.duplicated = duplicated; } - public void setGeographicScope(RepIndGeographicScope geographicScope) { this.geographicScope = geographicScope; } @@ -425,6 +430,10 @@ public void setRemainingPending(Boolean remainingPending) { this.remainingPending = remainingPending; } + public void setShfrmContributionNarrative(Boolean shfrmContributionNarrative) { + this.shfrmContributionNarrative = shfrmContributionNarrative; + } + public void setStatus(Integer status) { this.status = status; } @@ -460,6 +469,8 @@ public void updateDeliverableInfo(DeliverableInfo update) { this.setStatusDescription(update.getStatusDescription()); this.setGeographicScope(update.getGeographicScope()); this.setRegion(update.getRegion()); + this.setContributingShfrm(update.getContributingShfrm()); + this.setShfrmContributionNarrative(update.getShfrmContributionNarrative()); } } diff --git a/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml index 18bf38c1eb..abcc2c7770 100644 --- a/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml +++ b/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml @@ -81,6 +81,12 @@ + + + + + + From 7c4d4223fb2a49156f10712dcd0a2b09349f4d74 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 29 Jan 2024 16:41:35 -0500 Subject: [PATCH 04/65] :wrench: chore(shfrm Contribution): Create shfrm priority actions model --- .../marlo/data/model/ShfrmPriorityAction.java | 57 +++++++++++++++++++ .../src/main/resources/hibernate.cfg.xml | 1 + .../xmls/ShfrmPriorityActions.hbm.xml | 33 +++++++++++ 3 files changed, 91 insertions(+) create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java create mode 100644 marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java new file mode 100644 index 0000000000..e71ecf1a59 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java @@ -0,0 +1,57 @@ +package org.cgiar.ccafs.marlo.data.model; +// Generated Jun 27, 2017 2:55:00 PM by Hibernate Tools 4.3.1.Final + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import com.google.gson.annotations.Expose; + +/** + * ProjectInfo generated by hbm2java + */ +public class ShfrmPriorityAction extends MarloAuditableEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -3820243690705823369L; + + @Expose + private String name; + @Expose + private String description; + + public ShfrmPriorityAction() { + } + + public String getDescription() { + return description; + } + + @Override + public String getLogDeatil() { + StringBuilder sb = new StringBuilder(); + sb.append("Id : ").append(this.getId()); + return sb.toString(); + } + + public String getName() { + return name; + } + + @Override + public boolean isActive() { + return true; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setName(String name) { + this.name = name; + } + + public void updateProjectInfo(ShfrmPriorityAction update) { + this.setName(update.getName()); + this.setDescription(update.getDescription()); + this.setActiveSince(update.getActiveSince()); + } + +} diff --git a/marlo-data/src/main/resources/hibernate.cfg.xml b/marlo-data/src/main/resources/hibernate.cfg.xml index 958b3e3732..ceca97bcfc 100644 --- a/marlo-data/src/main/resources/hibernate.cfg.xml +++ b/marlo-data/src/main/resources/hibernate.cfg.xml @@ -429,6 +429,7 @@ + diff --git a/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml b/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml new file mode 100644 index 0000000000..1c1b75ea6a --- /dev/null +++ b/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 53d527cf57c654daa952ce7cc3f241581f9a4825 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Tue, 30 Jan 2024 08:54:07 -0500 Subject: [PATCH 05/65] :wrench: chore(shfrm Contribution): Create shfrm priority actions java model --- .../data/dao/ShfrmPriorityActionDAO.java | 67 +++++++++++++++ .../mysql/ShfrmPriorityActionMySQLDAO.java | 85 +++++++++++++++++++ .../manager/ShfrmPriorityActionManager.java | 74 ++++++++++++++++ .../impl/ShfrmPriorityActionManagerImpl.java | 77 +++++++++++++++++ 4 files changed, 303 insertions(+) create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmPriorityActionDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmPriorityActionManager.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmPriorityActionManagerImpl.java diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmPriorityActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmPriorityActionDAO.java new file mode 100644 index 0000000000..5f03fe1b24 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmPriorityActionDAO.java @@ -0,0 +1,67 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; + +import java.util.List; + + +public interface ShfrmPriorityActionDAO { + + /** + * This method removes a specific shfrmPriorityAction value from the database. + * + * @param shfrmPriorityActionId is the shfrmPriorityAction identifier. + * @return true if the shfrmPriorityAction was successfully deleted, false otherwise. + */ + public void deleteShfrmPriorityAction(long shfrmPriorityActionId); + + /** + * This method validate if the shfrmPriorityAction identify with the given id exists in the system. + * + * @param shfrmPriorityActionID is a shfrmPriorityAction identifier. + * @return true if the shfrmPriorityAction exists, false otherwise. + */ + public boolean existShfrmPriorityAction(long shfrmPriorityActionID); + + /** + * This method gets a shfrmPriorityAction object by a given shfrmPriorityAction identifier. + * + * @param shfrmPriorityActionID is the shfrmPriorityAction identifier. + * @return a ShfrmPriorityAction object. + */ + public ShfrmPriorityAction find(long id); + + /** + * This method gets a list of shfrmPriorityAction that are active + * + * @return a list from ShfrmPriorityAction null if no exist records + */ + public List findAll(); + + + /** + * This method saves the information of the given shfrmPriorityAction + * + * @param shfrmPriorityAction - is the shfrmPriorityAction object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the shfrmPriorityAction was + * updated + * or -1 is some error occurred. + */ + public ShfrmPriorityAction save(ShfrmPriorityAction shfrmPriorityAction); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java new file mode 100644 index 0000000000..d842049574 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java @@ -0,0 +1,85 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.ShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class ShfrmPriorityActionMySQLDAO extends AbstractMarloDAO implements ShfrmPriorityActionDAO { + + + @Inject + public ShfrmPriorityActionMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteShfrmPriorityAction(long shfrmPriorityActionId) { + ShfrmPriorityAction shfrmPriorityAction = this.find(shfrmPriorityActionId); + shfrmPriorityAction.setActive(false); + this.update(shfrmPriorityAction); + } + + @Override + public boolean existShfrmPriorityAction(long shfrmPriorityActionID) { + ShfrmPriorityAction shfrmPriorityAction = this.find(shfrmPriorityActionID); + if (shfrmPriorityAction == null) { + return false; + } + return true; + + } + + @Override + public ShfrmPriorityAction find(long id) { + return super.find(ShfrmPriorityAction.class, id); + + } + + @Override + public List findAll() { + String query = "from " + ShfrmPriorityAction.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public ShfrmPriorityAction save(ShfrmPriorityAction shfrmPriorityAction) { + if (shfrmPriorityAction.getId() == null) { + super.saveEntity(shfrmPriorityAction); + } else { + shfrmPriorityAction = super.update(shfrmPriorityAction); + } + + + return shfrmPriorityAction; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmPriorityActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmPriorityActionManager.java new file mode 100644 index 0000000000..d66307f022 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmPriorityActionManager.java @@ -0,0 +1,74 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface ShfrmPriorityActionManager { + + + /** + * This method removes a specific shfrmPriorityAction value from the database. + * + * @param shfrmPriorityActionId is the shfrmPriorityAction identifier. + * @return true if the shfrmPriorityAction was successfully deleted, false otherwise. + */ + public void deleteShfrmPriorityAction(long shfrmPriorityActionId); + + + /** + * This method validate if the shfrmPriorityAction identify with the given id exists in the system. + * + * @param shfrmPriorityActionID is a shfrmPriorityAction identifier. + * @return true if the shfrmPriorityAction exists, false otherwise. + */ + public boolean existShfrmPriorityAction(long shfrmPriorityActionID); + + + /** + * This method gets a list of shfrmPriorityAction that are active + * + * @return a list from ShfrmPriorityAction null if no exist records + */ + public List findAll(); + + + /** + * This method gets a shfrmPriorityAction object by a given shfrmPriorityAction identifier. + * + * @param shfrmPriorityActionID is the shfrmPriorityAction identifier. + * @return a ShfrmPriorityAction object. + */ + public ShfrmPriorityAction getShfrmPriorityActionById(long shfrmPriorityActionID); + + /** + * This method saves the information of the given shfrmPriorityAction + * + * @param shfrmPriorityAction - is the shfrmPriorityAction object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the shfrmPriorityAction was + * updated + * or -1 is some error occurred. + */ + public ShfrmPriorityAction saveShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmPriorityActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmPriorityActionManagerImpl.java new file mode 100644 index 0000000000..f0d833da7a --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmPriorityActionManagerImpl.java @@ -0,0 +1,77 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.ShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author CCAFS + */ +@Named +public class ShfrmPriorityActionManagerImpl implements ShfrmPriorityActionManager { + + + private ShfrmPriorityActionDAO shfrmPriorityActionDAO; + // Managers + + + @Inject + public ShfrmPriorityActionManagerImpl(ShfrmPriorityActionDAO shfrmPriorityActionDAO) { + this.shfrmPriorityActionDAO = shfrmPriorityActionDAO; + + + } + + @Override + public void deleteShfrmPriorityAction(long shfrmPriorityActionId) { + + shfrmPriorityActionDAO.deleteShfrmPriorityAction(shfrmPriorityActionId); + } + + @Override + public boolean existShfrmPriorityAction(long shfrmPriorityActionID) { + + return shfrmPriorityActionDAO.existShfrmPriorityAction(shfrmPriorityActionID); + } + + @Override + public List findAll() { + + return shfrmPriorityActionDAO.findAll(); + + } + + @Override + public ShfrmPriorityAction getShfrmPriorityActionById(long shfrmPriorityActionID) { + + return shfrmPriorityActionDAO.find(shfrmPriorityActionID); + } + + @Override + public ShfrmPriorityAction saveShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { + + return shfrmPriorityActionDAO.save(shfrmPriorityAction); + } + + +} From 69d4465ca4aefe19519512c058e879e306f5977c Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Tue, 30 Jan 2024 10:30:39 -0500 Subject: [PATCH 06/65] :wrench: chore(shfrm Contribution): Create sub actions java model --- .../marlo/data/dao/ShfrmSubActionDAO.java | 67 +++++++++++++++ .../dao/mysql/ShfrmSubActionMySQLDAO.java | 85 +++++++++++++++++++ .../data/manager/ShfrmSubActionManager.java | 74 ++++++++++++++++ .../impl/ShfrmSubActionManagerImpl.java | 77 +++++++++++++++++ .../marlo/data/model/ShfrmSubAction.java | 61 +++++++++++++ .../src/main/resources/hibernate.cfg.xml | 1 + .../resources/xmls/ShfrmSubActions.hbm.xml | 36 ++++++++ 7 files changed, 401 insertions(+) create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmSubActionDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmSubActionManager.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmSubActionManagerImpl.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java create mode 100644 marlo-data/src/main/resources/xmls/ShfrmSubActions.hbm.xml diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmSubActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmSubActionDAO.java new file mode 100644 index 0000000000..b1713c1bd6 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmSubActionDAO.java @@ -0,0 +1,67 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; + +import java.util.List; + + +public interface ShfrmSubActionDAO { + + /** + * This method removes a specific shfrmSubAction value from the database. + * + * @param shfrmSubActionId is the shfrmSubAction identifier. + * @return true if the shfrmSubAction was successfully deleted, false otherwise. + */ + public void deleteShfrmSubAction(long shfrmSubActionId); + + /** + * This method validate if the shfrmSubAction identify with the given id exists in the system. + * + * @param shfrmSubActionID is a shfrmSubAction identifier. + * @return true if the shfrmSubAction exists, false otherwise. + */ + public boolean existShfrmSubAction(long shfrmSubActionID); + + /** + * This method gets a shfrmSubAction object by a given shfrmSubAction identifier. + * + * @param shfrmSubActionID is the shfrmSubAction identifier. + * @return a ShfrmSubAction object. + */ + public ShfrmSubAction find(long id); + + /** + * This method gets a list of shfrmSubAction that are active + * + * @return a list from ShfrmSubAction null if no exist records + */ + public List findAll(); + + + /** + * This method saves the information of the given shfrmSubAction + * + * @param shfrmSubAction - is the shfrmSubAction object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the shfrmSubAction was + * updated + * or -1 is some error occurred. + */ + public ShfrmSubAction save(ShfrmSubAction shfrmSubAction); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java new file mode 100644 index 0000000000..e6f03e7103 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java @@ -0,0 +1,85 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.ShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class ShfrmSubActionMySQLDAO extends AbstractMarloDAO implements ShfrmSubActionDAO { + + + @Inject + public ShfrmSubActionMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteShfrmSubAction(long shfrmSubActionId) { + ShfrmSubAction shfrmSubAction = this.find(shfrmSubActionId); + shfrmSubAction.setActive(false); + this.update(shfrmSubAction); + } + + @Override + public boolean existShfrmSubAction(long shfrmSubActionID) { + ShfrmSubAction shfrmSubAction = this.find(shfrmSubActionID); + if (shfrmSubAction == null) { + return false; + } + return true; + + } + + @Override + public ShfrmSubAction find(long id) { + return super.find(ShfrmSubAction.class, id); + + } + + @Override + public List findAll() { + String query = "from " + ShfrmSubAction.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public ShfrmSubAction save(ShfrmSubAction shfrmSubAction) { + if (shfrmSubAction.getId() == null) { + super.saveEntity(shfrmSubAction); + } else { + shfrmSubAction = super.update(shfrmSubAction); + } + + + return shfrmSubAction; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmSubActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmSubActionManager.java new file mode 100644 index 0000000000..e9817bd989 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmSubActionManager.java @@ -0,0 +1,74 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface ShfrmSubActionManager { + + + /** + * This method removes a specific shfrmSubAction value from the database. + * + * @param shfrmSubActionId is the shfrmSubAction identifier. + * @return true if the shfrmSubAction was successfully deleted, false otherwise. + */ + public void deleteShfrmSubAction(long shfrmSubActionId); + + + /** + * This method validate if the shfrmSubAction identify with the given id exists in the system. + * + * @param shfrmSubActionID is a shfrmSubAction identifier. + * @return true if the shfrmSubAction exists, false otherwise. + */ + public boolean existShfrmSubAction(long shfrmSubActionID); + + + /** + * This method gets a list of shfrmSubAction that are active + * + * @return a list from ShfrmSubAction null if no exist records + */ + public List findAll(); + + + /** + * This method gets a shfrmSubAction object by a given shfrmSubAction identifier. + * + * @param shfrmSubActionID is the shfrmSubAction identifier. + * @return a ShfrmSubAction object. + */ + public ShfrmSubAction getShfrmSubActionById(long shfrmSubActionID); + + /** + * This method saves the information of the given shfrmSubAction + * + * @param shfrmSubAction - is the shfrmSubAction object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the shfrmSubAction was + * updated + * or -1 is some error occurred. + */ + public ShfrmSubAction saveShfrmSubAction(ShfrmSubAction shfrmSubAction); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmSubActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmSubActionManagerImpl.java new file mode 100644 index 0000000000..f1e5e9e89d --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmSubActionManagerImpl.java @@ -0,0 +1,77 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.ShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author CCAFS + */ +@Named +public class ShfrmSubActionManagerImpl implements ShfrmSubActionManager { + + + private ShfrmSubActionDAO shfrmSubActionDAO; + // Managers + + + @Inject + public ShfrmSubActionManagerImpl(ShfrmSubActionDAO shfrmSubActionDAO) { + this.shfrmSubActionDAO = shfrmSubActionDAO; + + + } + + @Override + public void deleteShfrmSubAction(long shfrmSubActionId) { + + shfrmSubActionDAO.deleteShfrmSubAction(shfrmSubActionId); + } + + @Override + public boolean existShfrmSubAction(long shfrmSubActionID) { + + return shfrmSubActionDAO.existShfrmSubAction(shfrmSubActionID); + } + + @Override + public List findAll() { + + return shfrmSubActionDAO.findAll(); + + } + + @Override + public ShfrmSubAction getShfrmSubActionById(long shfrmSubActionID) { + + return shfrmSubActionDAO.find(shfrmSubActionID); + } + + @Override + public ShfrmSubAction saveShfrmSubAction(ShfrmSubAction shfrmSubAction) { + + return shfrmSubActionDAO.save(shfrmSubAction); + } + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java new file mode 100644 index 0000000000..acd84e31d3 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java @@ -0,0 +1,61 @@ +package org.cgiar.ccafs.marlo.data.model; +// Generated Jun 27, 2017 2:55:00 PM by Hibernate Tools 4.3.1.Final + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import com.google.gson.annotations.Expose; + +/** + * ProjectInfo generated by hbm2java + */ +public class ShfrmSubAction extends MarloAuditableEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -3820243690705823369L; + + @Expose + private String name; + @Expose + private String description; + @Expose + private ShfrmPriorityAction shfrmPriorityAction; + + public ShfrmSubAction() { + } + + public String getDescription() { + return description; + } + + @Override + public String getLogDeatil() { + StringBuilder sb = new StringBuilder(); + sb.append("Id : ").append(this.getId()); + return sb.toString(); + } + + public String getName() { + return name; + } + + public ShfrmPriorityAction getShfrmPriorityAction() { + return shfrmPriorityAction; + } + + @Override + public boolean isActive() { + return true; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setName(String name) { + this.name = name; + } + + public void setShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { + this.shfrmPriorityAction = shfrmPriorityAction; + } + +} diff --git a/marlo-data/src/main/resources/hibernate.cfg.xml b/marlo-data/src/main/resources/hibernate.cfg.xml index ceca97bcfc..dce695d4c1 100644 --- a/marlo-data/src/main/resources/hibernate.cfg.xml +++ b/marlo-data/src/main/resources/hibernate.cfg.xml @@ -430,6 +430,7 @@ + diff --git a/marlo-data/src/main/resources/xmls/ShfrmSubActions.hbm.xml b/marlo-data/src/main/resources/xmls/ShfrmSubActions.hbm.xml new file mode 100644 index 0000000000..ed6bf768e9 --- /dev/null +++ b/marlo-data/src/main/resources/xmls/ShfrmSubActions.hbm.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 06942dda556354bb1a07b32db490bb26a947a5ac Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Tue, 30 Jan 2024 11:57:26 -0500 Subject: [PATCH 07/65] chore(shfrm Contribution): Create reverse priority actions model and mapping --- .../marlo/data/model/ShfrmPriorityAction.java | 26 ++++++++++++++++--- .../xmls/ShfrmPriorityActions.hbm.xml | 8 ++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java index e71ecf1a59..669e7269dc 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java @@ -3,6 +3,11 @@ import org.cgiar.ccafs.marlo.data.IAuditLog; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import com.google.gson.annotations.Expose; /** @@ -17,6 +22,9 @@ public class ShfrmPriorityAction extends MarloAuditableEntity implements java.io @Expose private String description; + private Set shfrmSubAction = new HashSet(0); + private List shfrmSubActions = new ArrayList(); + public ShfrmPriorityAction() { } @@ -35,6 +43,14 @@ public String getName() { return name; } + public Set getShfrmSubAction() { + return shfrmSubAction; + } + + public List getShfrmSubActions() { + return shfrmSubActions; + } + @Override public boolean isActive() { return true; @@ -48,10 +64,12 @@ public void setName(String name) { this.name = name; } - public void updateProjectInfo(ShfrmPriorityAction update) { - this.setName(update.getName()); - this.setDescription(update.getDescription()); - this.setActiveSince(update.getActiveSince()); + public void setShfrmSubAction(Set shfrmSubAction) { + this.shfrmSubAction = shfrmSubAction; + } + + public void setShfrmSubActions(List shfrmSubActions) { + this.shfrmSubActions = shfrmSubActions; } } diff --git a/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml b/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml index 1c1b75ea6a..fcca635a46 100644 --- a/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml +++ b/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml @@ -29,5 +29,13 @@ + + + + + + \ No newline at end of file From e9982c115801b15b4d0e0556fcef49ae4a4be568 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Tue, 30 Jan 2024 14:12:04 -0500 Subject: [PATCH 08/65] chore(shfrm Contribution): Create deliverable priority action model --- .../ccafs/marlo/data/model/Deliverable.java | 59 +++++++++++------- .../model/DeliverableShfrmPriorityAction.java | 60 +++++++++++++++++++ .../cgiar/ccafs/marlo/data/model/Phase.java | 33 ++++------ .../src/main/resources/hibernate.cfg.xml | 1 + .../DeliverableShfrmPriorityActions.hbm.xml | 36 +++++++++++ .../main/resources/xmls/Deliverables.hbm.xml | 8 +++ 6 files changed, 155 insertions(+), 42 deletions(-) create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java create mode 100644 marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java index c2a70348cb..be2180dbd3 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java @@ -134,6 +134,10 @@ public class Deliverable extends MarloAuditableEntity implements java.io.Seriali private List crpOutcomes; private Set deliverableCrpOutcomes = new HashSet(0); + private Set deliverableShfrmPriorityAction = + new HashSet(0); + private List shfrmPriorityActions; + private String sharedWithProjects; private String sharedWithMe; private String owner; @@ -490,6 +494,10 @@ public List getDeliverableRegions() { return deliverableRegions; } + public Set getDeliverableShfrmPriorityAction() { + return deliverableShfrmPriorityAction; + } + public Set getDeliverableUserPartnerships() { return deliverableUserPartnerships; } @@ -498,11 +506,11 @@ public Set getDeliverableUsers() { return deliverableUsers; } + public DeliverableDissemination getDissemination() { return dissemination; } - public DeliverableDissemination getDissemination(Phase phase) { List deliverableDisseminations = this.getDeliverableDisseminations().stream() .filter(dd -> dd.isActive() && dd.getPhase().equals(phase)).collect(Collectors.toList()); @@ -535,11 +543,11 @@ public DeliverableMetadataExternalSources getExternalSource(Phase phase) { return externalSourceFound; } + public List getFiles() { return files; } - public String getFlagshipValue() { return flagshipValue; } @@ -588,15 +596,16 @@ public Boolean getIsInteroperable() { return isInteroperable; } + public Boolean getIsPublication() { return isPublication; } - public Boolean getIsReusable() { return isReusable; } + public List getLeaders() { return leaders; } @@ -609,7 +618,6 @@ public String getLogDeatil() { return sb.toString(); } - public long getMElementID(int metadataID) { if (metadataElements != null) { for (DeliverableMetadataElement dmetadata : metadataElements) { @@ -629,6 +637,7 @@ public List getMetadata() { return metadata; } + public DeliverableMetadataElement getMetadata(long metadataID) { String value = ""; if (metadataElements != null) { @@ -647,7 +656,6 @@ public DeliverableMetadataElement getMetadata(long metadataID) { return null; } - public List getMetadataElements() { return metadataElements; } @@ -797,11 +805,11 @@ public String getRegionsValue() { return regionsValue; } + public String getResponsible() { return responsible; } - public List getResponsiblePartnership() { return responsiblePartnership; } @@ -810,6 +818,7 @@ public Set getSectionStatuses() { return sectionStatuses; } + public List getSelectedFlahsgips() { return selectedFlahsgips; } @@ -830,11 +839,15 @@ public String getSharedWithProjects() { } + public List getShfrmPriorityActions() { + return shfrmPriorityActions; + } + + public String getTagTitle() { return tagTitle; } - public List getUsers() { return users; } @@ -845,6 +858,7 @@ public List getUsers(Phase phase) { .filter(du -> du.isActive() && du.getPhase().equals(phase)).collect(Collectors.toList())); } + @Override public int hashCode() { final int prime = 31; @@ -858,12 +872,10 @@ public void setActivities(List activities) { this.activities = activities; } - public void setAltmetricInfos(List altmetricInfos) { this.altmetricInfos = altmetricInfos; } - public void setClusterParticipant(List clusterParticipant) { this.clusterParticipant = clusterParticipant; } @@ -872,15 +884,16 @@ public void setCommentStatus(String commentStatus) { this.commentStatus = commentStatus; } + public void setContribution(Boolean contribution) { this.contribution = contribution; } + public void setCountries(List countries) { this.countries = countries; } - public void setCountriesIds(List countriesIds) { this.countriesIds = countriesIds; } @@ -890,6 +903,7 @@ public void setCountriesIdsText(String countriesIdsText) { this.countriesIdsText = countriesIdsText; } + public void setCreateDate(Date createDate) { this.createDate = createDate; } @@ -899,12 +913,10 @@ public void setCrossCuttingMarkers(List crossCutt this.crossCuttingMarkers = crossCuttingMarkers; } - public void setCrp(GlobalUnit crp) { this.crp = crp; } - public void setCrpOutcomes(List crpOutcomes) { this.crpOutcomes = crpOutcomes; } @@ -937,6 +949,7 @@ public void setDeliverableClusterParticipants(Set this.deliverableClusterParticipants = deliverableClusterParticipants; } + public void setDeliverableCrossCuttingMarkers(Set deliverableCrossCuttingMarkers) { this.deliverableCrossCuttingMarkers = deliverableCrossCuttingMarkers; } @@ -945,7 +958,6 @@ public void setDeliverableCrpOutcomes(Set deliverableCrpO this.deliverableCrpOutcomes = deliverableCrpOutcomes; } - public void setDeliverableCrps(Set deliverableCrps) { this.deliverableCrps = deliverableCrps; } @@ -986,6 +998,7 @@ public void setDeliverableInfos(Set deliverableInfos) { this.deliverableInfos = deliverableInfos; } + public void setDeliverableIntellectualAssets(Set deliverableIntellectualAssets) { this.deliverableIntellectualAssets = deliverableIntellectualAssets; } @@ -994,11 +1007,11 @@ public void setDeliverableLeaders(Set deliverableLeaders) { this.deliverableLeaders = deliverableLeaders; } - public void setDeliverableLocations(Set deliverableLocations) { this.deliverableLocations = deliverableLocations; } + public void setDeliverableLp6s(Set deliverableLp6s) { this.deliverableLp6s = deliverableLp6s; } @@ -1007,7 +1020,6 @@ public void setDeliverableMetadataElements(Set deliv this.deliverableMetadataElements = deliverableMetadataElements; } - public void setDeliverableMetadataExternalSources(Set deliverableMetadataExternalSources) { this.deliverableMetadataExternalSources = deliverableMetadataExternalSources; @@ -1041,6 +1053,10 @@ public void setDeliverableRegions(List deliverableR this.deliverableRegions = deliverableRegions; } + public void setDeliverableShfrmPriorityAction(Set deliverableShfrmPriorityAction) { + this.deliverableShfrmPriorityAction = deliverableShfrmPriorityAction; + } + public void setDeliverableUserPartnerships(Set deliverableUserPartnerships) { this.deliverableUserPartnerships = deliverableUserPartnerships; } @@ -1073,14 +1089,17 @@ public void setFundingSources(List fundingSources) { this.fundingSources = fundingSources; } + public void setGenderLevels(List genderLevels) { this.genderLevels = genderLevels; } + public void setGeographicScopes(List geographicScopes) { this.geographicScopes = geographicScopes; } + public void setIsAccesible(Boolean isAccesible) { this.isAccesible = isAccesible; } @@ -1115,7 +1134,6 @@ public void setMetadata(List metadata) { this.metadata = metadata; } - public void setMetadataElements(List metadataElements) { this.metadataElements = metadataElements; } @@ -1144,6 +1162,7 @@ public void setPrograms(List programs) { this.programs = programs; } + public void setProject(Project project) { this.project = project; } @@ -1153,17 +1172,14 @@ public void setProjectDeliverableShareds(Set projectDe this.projectDeliverableShareds = projectDeliverableShareds; } - public void setProjectOutcomes(List projectOutcomes) { this.projectOutcomes = projectOutcomes; } - public void setPublication(DeliverablePublicationMetadata publication) { this.publication = publication; } - public void setPublicationMetadatas(List publicationMetadatas) { this.publicationMetadatas = publicationMetadatas; } @@ -1208,6 +1224,10 @@ public void setSharedWithProjects(String sharedWithProjects) { this.sharedWithProjects = sharedWithProjects; } + public void setShfrmPriorityActions(List shfrmPriorityActions) { + this.shfrmPriorityActions = shfrmPriorityActions; + } + public void setTagTitle(String tagTitle) { this.tagTitle = tagTitle; } @@ -1221,5 +1241,4 @@ public String toString() { return "Deliverable [id=" + this.getId() + ", project=" + project + ", active=" + this.isActive() + ", phase=" + phase + ", isPublication=" + isPublication + ", deliverableInfo=" + deliverableInfo + "]"; } - } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java new file mode 100644 index 0000000000..a1a4b641fd --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java @@ -0,0 +1,60 @@ +package org.cgiar.ccafs.marlo.data.model; +// Generated Jun 27, 2017 2:55:00 PM by Hibernate Tools 4.3.1.Final + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import com.google.gson.annotations.Expose; + +/** + * ProjectInfo generated by hbm2java + */ +public class DeliverableShfrmPriorityAction extends MarloAuditableEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -3820243690705823369L; + + @Expose + private Deliverable deliverable; + @Expose + private ShfrmPriorityAction shfrmPriorityAction; + @Expose + private Phase phase; + + public DeliverableShfrmPriorityAction() { + } + + public Deliverable getDeliverable() { + return deliverable; + } + + @Override + public String getLogDeatil() { + StringBuilder sb = new StringBuilder(); + sb.append("Id : ").append(this.getId()); + return sb.toString(); + } + + public Phase getPhase() { + return phase; + } + + public ShfrmPriorityAction getShfrmPriorityAction() { + return shfrmPriorityAction; + } + + @Override + public boolean isActive() { + return true; + } + + public void setDeliverable(Deliverable deliverable) { + this.deliverable = deliverable; + } + + public void setPhase(Phase phase) { + this.phase = phase; + } + + public void setShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { + this.shfrmPriorityAction = shfrmPriorityAction; + } +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java index 87bef972e7..a724c33096 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java @@ -44,6 +44,8 @@ public class Phase extends MarloBaseEntity implements java.io.Serializable, IAud private Set projectPhases = new HashSet(0); private Set projectInfos = new HashSet(0); + private Set deliverableShfrmPriorityActions = + new HashSet(0); private Set projectFocuses = new HashSet(0); @@ -226,7 +228,6 @@ public Set getDeliverableGeographicScopes() { return deliverableGeographicScopes; } - public Set getDeliverableInfos() { return deliverableInfos; } @@ -235,42 +236,38 @@ public Set getDeliverableIntellectualAssets() { return deliverableIntellectualAssets; } - public Set getDeliverableLocations() { return deliverableLocations; } + public Set getDeliverableShfrmPriorityActions() { + return deliverableShfrmPriorityActions; + } public Set getDeliverableUserPartnerships() { return deliverableUserPartnerships; } - public Set getDeliverableUsers() { return deliverableUsers; } - public String getDescription() { return this.description; } - public Boolean getEditable() { return editable; } - public Date getEndDate() { return endDate; } - public Set getExpectedStudyProjects() { return expectedStudyProjects; } - public Set getFeedbackQAComments() { return feedbackQAComments; } @@ -358,7 +355,6 @@ public Set getProjectBudgets() { return projectBudgets; } - public Set getProjectBudgetsFlagships() { return projectBudgetsFlagships; } @@ -367,7 +363,6 @@ public Set getProjectClusters() { return projectClusters; } - public Set getProjectDeliverableShareds() { return projectDeliverableShareds; } @@ -388,7 +383,6 @@ public Set getProjectExpectedStudyFlagships() { return projectExpectedStudyFlagships; } - public Set getProjectExpectedStudyGeographicScopes() { return projectExpectedStudyGeographicScopes; } @@ -469,7 +463,6 @@ public Set getProjectInnovationGeographicScope return projectInnovationGeographicScopes; } - public Set getProjectInnovationInfos() { return projectInnovationInfos; } @@ -494,11 +487,11 @@ public Set getProjectLocations() { return projectLocations; } + public Set getProjectLp6ContributionDeliverables() { return projectLp6ContributionDeliverables; } - public Set getProjectLp6Contributions() { return projectLp6Contributions; } @@ -588,11 +581,11 @@ public boolean isActive() { return true; } + public Boolean isReporting() { return description.equals(APConstants.REPORTING); } - public void setClusters(Set clusters) { this.clusters = clusters; } @@ -641,11 +634,14 @@ public void setDeliverableLocations(Set deliverableLocation this.deliverableLocations = deliverableLocations; } + public void setDeliverableShfrmPriorityActions(Set deliverableShfrmPriorityActions) { + this.deliverableShfrmPriorityActions = deliverableShfrmPriorityActions; + } + public void setDeliverableUserPartnerships(Set deliverableUserPartnerships) { this.deliverableUserPartnerships = deliverableUserPartnerships; } - public void setDeliverableUsers(Set deliverableUsers) { this.deliverableUsers = deliverableUsers; } @@ -719,7 +715,6 @@ public void setPowbSynthesis(Set powbSynthesis) { this.powbSynthesis = powbSynthesis; } - public void setProgramOutcomeIndicators(Set programOutcomeIndicators) { this.programOutcomeIndicators = programOutcomeIndicators; } @@ -795,7 +790,6 @@ public void setProjectExpectedStudyQuantifications( this.projectExpectedStudyQuantifications = projectExpectedStudyQuantifications; } - public void setProjectExpectedStudyRegions(Set projectExpectedStudyRegions) { this.projectExpectedStudyRegions = projectExpectedStudyRegions; } @@ -816,12 +810,10 @@ public void setProjectHighlightCountries(Set projectHig this.projectHighlightCountries = projectHighlightCountries; } - public void setProjectHighlightInfos(Set projectHighlightInfos) { this.projectHighlightInfos = projectHighlightInfos; } - public void setProjectHighligthsTypes(Set projectHighligthsTypes) { this.projectHighligthsTypes = projectHighligthsTypes; } @@ -847,13 +839,11 @@ public void setProjectInnovationDeliverables(Set p this.projectInnovationDeliverables = projectInnovationDeliverables; } - public void setProjectInnovationGeographicScopes(Set projectInnovationGeographicScopes) { this.projectInnovationGeographicScopes = projectInnovationGeographicScopes; } - public void setProjectInnovationInfos(Set projectInnovationInfos) { this.projectInnovationInfos = projectInnovationInfos; } @@ -920,7 +910,6 @@ public void setProjectPolicyGeographicScopes(Set p this.projectPolicyGeographicScopes = projectPolicyGeographicScopes; } - public void setProjectPolicyInfos(Set projectPolicyInfos) { this.projectPolicyInfos = projectPolicyInfos; } diff --git a/marlo-data/src/main/resources/hibernate.cfg.xml b/marlo-data/src/main/resources/hibernate.cfg.xml index dce695d4c1..5a9735b184 100644 --- a/marlo-data/src/main/resources/hibernate.cfg.xml +++ b/marlo-data/src/main/resources/hibernate.cfg.xml @@ -431,6 +431,7 @@ + diff --git a/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml new file mode 100644 index 0000000000..f03d90b386 --- /dev/null +++ b/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml b/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml index ff853db886..f7b7f8998f 100644 --- a/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml +++ b/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml @@ -278,6 +278,14 @@ + + + + + + From b3d2d096bf4524c70786edbe889c671004696e18 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Tue, 30 Jan 2024 14:51:14 -0500 Subject: [PATCH 09/65] :wrench: chore(shfrm Contribution): Create deliverable action and sub actions mappings models --- .../ccafs/marlo/data/model/Deliverable.java | 56 +++++++++++------ .../data/model/DeliverableShfrmSubAction.java | 60 +++++++++++++++++++ .../cgiar/ccafs/marlo/data/model/Phase.java | 15 ++++- .../src/main/resources/hibernate.cfg.xml | 1 + .../xmls/DeliverableShfrmSubActions.hbm.xml | 36 +++++++++++ .../main/resources/xmls/Deliverables.hbm.xml | 8 +++ .../src/main/resources/xmls/Phases.hbm.xml | 16 +++++ 7 files changed, 170 insertions(+), 22 deletions(-) create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java create mode 100644 marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java index be2180dbd3..71540e959a 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java @@ -137,6 +137,8 @@ public class Deliverable extends MarloAuditableEntity implements java.io.Seriali private Set deliverableShfrmPriorityAction = new HashSet(0); private List shfrmPriorityActions; + private Set deliverableShfrmSubAction = new HashSet(0); + private List shfrmSubActions; private String sharedWithProjects; private String sharedWithMe; @@ -498,15 +500,19 @@ public Set getDeliverableShfrmPriorityAction() { return deliverableShfrmPriorityAction; } + public Set getDeliverableShfrmSubAction() { + return deliverableShfrmSubAction; + } + public Set getDeliverableUserPartnerships() { return deliverableUserPartnerships; } + public Set getDeliverableUsers() { return deliverableUsers; } - public DeliverableDissemination getDissemination() { return dissemination; } @@ -528,6 +534,7 @@ public DeliverableMetadataExternalSources getExternalSource() { return externalSource; } + public DeliverableMetadataExternalSources getExternalSource(Phase phase) { DeliverableMetadataExternalSources externalSourceFound = this.getExternalSource(); if (externalSourceFound == null) { @@ -543,7 +550,6 @@ public DeliverableMetadataExternalSources getExternalSource(Phase phase) { return externalSourceFound; } - public List getFiles() { return files; } @@ -592,15 +598,16 @@ public Boolean getIsFindable() { return isFindable; } + public Boolean getIsInteroperable() { return isInteroperable; } - public Boolean getIsPublication() { return isPublication; } + public Boolean getIsReusable() { return isReusable; } @@ -610,7 +617,6 @@ public List getLeaders() { return leaders; } - @Override public String getLogDeatil() { StringBuilder sb = new StringBuilder(); @@ -633,11 +639,11 @@ public long getMElementID(int metadataID) { return -1; } + public List getMetadata() { return metadata; } - public DeliverableMetadataElement getMetadata(long metadataID) { String value = ""; if (metadataElements != null) { @@ -801,11 +807,11 @@ public List getRegions() { return regions; } + public String getRegionsValue() { return regionsValue; } - public String getResponsible() { return responsible; } @@ -814,6 +820,7 @@ public List getResponsiblePartnership() { return responsiblePartnership; } + public Set getSectionStatuses() { return sectionStatuses; } @@ -843,11 +850,16 @@ public List getShfrmPriorityActions() { return shfrmPriorityActions; } + public List getShfrmSubActions() { + return shfrmSubActions; + } + public String getTagTitle() { return tagTitle; } + public List getUsers() { return users; } @@ -858,7 +870,6 @@ public List getUsers(Phase phase) { .filter(du -> du.isActive() && du.getPhase().equals(phase)).collect(Collectors.toList())); } - @Override public int hashCode() { final int prime = 31; @@ -867,7 +878,6 @@ public int hashCode() { return result; } - public void setActivities(List activities) { this.activities = activities; } @@ -876,15 +886,16 @@ public void setAltmetricInfos(List altmetricInfos) { this.altmetricInfos = altmetricInfos; } + public void setClusterParticipant(List clusterParticipant) { this.clusterParticipant = clusterParticipant; } + public void setCommentStatus(String commentStatus) { this.commentStatus = commentStatus; } - public void setContribution(Boolean contribution) { this.contribution = contribution; } @@ -894,6 +905,7 @@ public void setCountries(List countries) { this.countries = countries; } + public void setCountriesIds(List countriesIds) { this.countriesIds = countriesIds; } @@ -903,12 +915,10 @@ public void setCountriesIdsText(String countriesIdsText) { this.countriesIdsText = countriesIdsText; } - public void setCreateDate(Date createDate) { this.createDate = createDate; } - public void setCrossCuttingMarkers(List crossCuttingMarkers) { this.crossCuttingMarkers = crossCuttingMarkers; } @@ -941,6 +951,7 @@ public void setDeliverableAltmetricInfo(DeliverableAltmetricInfo deliverableAltm this.deliverableAltmetricInfo = deliverableAltmetricInfo; } + public void setDeliverableAltmetricInfos(Set deliverableAltmetricInfos) { this.deliverableAltmetricInfos = deliverableAltmetricInfos; } @@ -949,7 +960,6 @@ public void setDeliverableClusterParticipants(Set this.deliverableClusterParticipants = deliverableClusterParticipants; } - public void setDeliverableCrossCuttingMarkers(Set deliverableCrossCuttingMarkers) { this.deliverableCrossCuttingMarkers = deliverableCrossCuttingMarkers; } @@ -990,6 +1000,7 @@ public void setDeliverableGeographicScopes(Set deliv this.deliverableGeographicScopes = deliverableGeographicScopes; } + public void setDeliverableInfo(DeliverableInfo deliverableInfo) { this.deliverableInfo = deliverableInfo; } @@ -998,11 +1009,11 @@ public void setDeliverableInfos(Set deliverableInfos) { this.deliverableInfos = deliverableInfos; } - public void setDeliverableIntellectualAssets(Set deliverableIntellectualAssets) { this.deliverableIntellectualAssets = deliverableIntellectualAssets; } + public void setDeliverableLeaders(Set deliverableLeaders) { this.deliverableLeaders = deliverableLeaders; } @@ -1011,7 +1022,6 @@ public void setDeliverableLocations(Set deliverableLocation this.deliverableLocations = deliverableLocations; } - public void setDeliverableLp6s(Set deliverableLp6s) { this.deliverableLp6s = deliverableLp6s; } @@ -1057,6 +1067,10 @@ public void setDeliverableShfrmPriorityAction(Set deliverableShfrmSubAction) { + this.deliverableShfrmSubAction = deliverableShfrmSubAction; + } + public void setDeliverableUserPartnerships(Set deliverableUserPartnerships) { this.deliverableUserPartnerships = deliverableUserPartnerships; } @@ -1077,14 +1091,17 @@ public void setExternalSource(DeliverableMetadataExternalSources externalSource) this.externalSource = externalSource; } + public void setFiles(List files) { this.files = files; } + public void setFlagshipValue(String flagshipValue) { this.flagshipValue = flagshipValue; } + public void setFundingSources(List fundingSources) { this.fundingSources = fundingSources; } @@ -1119,7 +1136,6 @@ public void setIsPublication(Boolean isPublication) { this.isPublication = isPublication; } - public void setIsReusable(Boolean isReusable) { this.isReusable = isReusable; } @@ -1148,6 +1164,7 @@ public void setOtherPartnerships(List otherPartnersh this.otherPartnerships = otherPartnerships; } + public void setOwner(String owner) { this.owner = owner; } @@ -1157,17 +1174,14 @@ public void setPhase(Phase phase) { this.phase = phase; } - public void setPrograms(List programs) { this.programs = programs; } - public void setProject(Project project) { this.project = project; } - public void setProjectDeliverableShareds(Set projectDeliverableShareds) { this.projectDeliverableShareds = projectDeliverableShareds; } @@ -1228,6 +1242,10 @@ public void setShfrmPriorityActions(List shfrmPr this.shfrmPriorityActions = shfrmPriorityActions; } + public void setShfrmSubActions(List shfrmSubActions) { + this.shfrmSubActions = shfrmSubActions; + } + public void setTagTitle(String tagTitle) { this.tagTitle = tagTitle; } @@ -1241,4 +1259,4 @@ public String toString() { return "Deliverable [id=" + this.getId() + ", project=" + project + ", active=" + this.isActive() + ", phase=" + phase + ", isPublication=" + isPublication + ", deliverableInfo=" + deliverableInfo + "]"; } -} +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java new file mode 100644 index 0000000000..02e4a9f22c --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java @@ -0,0 +1,60 @@ +package org.cgiar.ccafs.marlo.data.model; +// Generated Jun 27, 2017 2:55:00 PM by Hibernate Tools 4.3.1.Final + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import com.google.gson.annotations.Expose; + +/** + * ProjectInfo generated by hbm2java + */ +public class DeliverableShfrmSubAction extends MarloAuditableEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -3820243690705823369L; + + @Expose + private ShfrmPriorityAction shfrmPriorityAction; + @Expose + private ShfrmSubAction shfrmSubAction; + @Expose + private Phase phase; + + public DeliverableShfrmSubAction() { + } + + @Override + public String getLogDeatil() { + StringBuilder sb = new StringBuilder(); + sb.append("Id : ").append(this.getId()); + return sb.toString(); + } + + public Phase getPhase() { + return phase; + } + + public ShfrmPriorityAction getShfrmPriorityAction() { + return shfrmPriorityAction; + } + + public ShfrmSubAction getShfrmSubAction() { + return shfrmSubAction; + } + + @Override + public boolean isActive() { + return true; + } + + public void setPhase(Phase phase) { + this.phase = phase; + } + + public void setShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { + this.shfrmPriorityAction = shfrmPriorityAction; + } + + public void setShfrmSubAction(ShfrmSubAction shfrmSubAction) { + this.shfrmSubAction = shfrmSubAction; + } +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java index a724c33096..470a6cdc3c 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java @@ -46,6 +46,7 @@ public class Phase extends MarloBaseEntity implements java.io.Serializable, IAud private Set projectInfos = new HashSet(0); private Set deliverableShfrmPriorityActions = new HashSet(0); + private Set deliverableShfrmSubActions = new HashSet(0); private Set projectFocuses = new HashSet(0); @@ -244,6 +245,10 @@ public Set getDeliverableShfrmPriorityActions() return deliverableShfrmPriorityActions; } + public Set getDeliverableShfrmSubActions() { + return deliverableShfrmSubActions; + } + public Set getDeliverableUserPartnerships() { return deliverableUserPartnerships; } @@ -336,6 +341,7 @@ public Set getPowbSynthesis() { return powbSynthesis; } + public Set getProgramOutcomeIndicators() { return programOutcomeIndicators; } @@ -350,7 +356,6 @@ public Set getProjectBudgetExecutions() { return projectBudgetExecutions; } - public Set getProjectBudgets() { return projectBudgets; } @@ -483,11 +488,11 @@ public Set getProjectLeverages() { return projectLeverages; } + public Set getProjectLocations() { return projectLocations; } - public Set getProjectLp6ContributionDeliverables() { return projectLp6ContributionDeliverables; } @@ -576,12 +581,12 @@ public int hashCode() { return result; } + @Override public boolean isActive() { return true; } - public Boolean isReporting() { return description.equals(APConstants.REPORTING); } @@ -638,6 +643,10 @@ public void setDeliverableShfrmPriorityActions(Set deliverableShfrmSubActions) { + this.deliverableShfrmSubActions = deliverableShfrmSubActions; + } + public void setDeliverableUserPartnerships(Set deliverableUserPartnerships) { this.deliverableUserPartnerships = deliverableUserPartnerships; } diff --git a/marlo-data/src/main/resources/hibernate.cfg.xml b/marlo-data/src/main/resources/hibernate.cfg.xml index 5a9735b184..84c8dddd60 100644 --- a/marlo-data/src/main/resources/hibernate.cfg.xml +++ b/marlo-data/src/main/resources/hibernate.cfg.xml @@ -432,6 +432,7 @@ + diff --git a/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml new file mode 100644 index 0000000000..1124a2be0d --- /dev/null +++ b/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml b/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml index f7b7f8998f..26ca95e681 100644 --- a/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml +++ b/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml @@ -286,6 +286,14 @@ + + + + + + diff --git a/marlo-data/src/main/resources/xmls/Phases.hbm.xml b/marlo-data/src/main/resources/xmls/Phases.hbm.xml index 51d4fe4c9b..035ad9c8ac 100644 --- a/marlo-data/src/main/resources/xmls/Phases.hbm.xml +++ b/marlo-data/src/main/resources/xmls/Phases.hbm.xml @@ -106,6 +106,22 @@ + + + + + + + + + + + + From dd134f45c053b6f53034975aa3e9b52de06d22d7 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Tue, 30 Jan 2024 16:32:31 -0500 Subject: [PATCH 10/65] :wrench: chore(shfrm Contribution): Update global labels and implement priority actions list in deliverable action class --- .../action/projects/DeliverableAction.java | 18 +++++++++++++++++- marlo-web/src/main/resources/global.properties | 8 ++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index a1f5737094..4cde55b14d 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -77,6 +77,7 @@ import org.cgiar.ccafs.marlo.data.manager.RepIndTypeActivityManager; import org.cgiar.ccafs.marlo.data.manager.RepIndTypeParticipantManager; import org.cgiar.ccafs.marlo.data.manager.RepositoryChannelManager; +import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; import org.cgiar.ccafs.marlo.data.manager.UserManager; import org.cgiar.ccafs.marlo.data.model.Activity; import org.cgiar.ccafs.marlo.data.model.CgiarCrossCuttingMarker; @@ -139,6 +140,7 @@ import org.cgiar.ccafs.marlo.data.model.RepIndTypeActivity; import org.cgiar.ccafs.marlo.data.model.RepIndTypeParticipant; import org.cgiar.ccafs.marlo.data.model.RepositoryChannel; +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; import org.cgiar.ccafs.marlo.data.model.User; import org.cgiar.ccafs.marlo.security.Permission; import org.cgiar.ccafs.marlo.utils.APConfig; @@ -248,6 +250,7 @@ public class DeliverableAction extends BaseAction { private FeedbackQACommentManager feedbackQACommentManager; private FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager; private DeliverableTraineesIndicatorManager deliverableTraineesIndicatorManager; + private ShfrmPriorityActionManager shfrmPriorityActionManager; // Variables @@ -262,6 +265,7 @@ public class DeliverableAction extends BaseAction { private Boolean has_specific_management_deliverables; private Boolean isManagingPartnerPersonRequerid; private List deliverableTypeParent; + private List shfrmPriorityActions; private DeliverableValidator deliverableValidator; private List fundingSources; private List activities; @@ -346,7 +350,8 @@ public DeliverableAction(APConfig config, DeliverableTypeManager deliverableType FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager, FeedbackQACommentManager feedbackQACommentManager, DeliverableClusterParticipantManager deliverableClusterParticipantManager, - DeliverableTraineesIndicatorManager deliverableTraineesIndicatorManager) { + DeliverableTraineesIndicatorManager deliverableTraineesIndicatorManager, + ShfrmPriorityActionManager shfrmPriorityActionManager) { super(config); this.activityManager = activityManager; this.deliverableManager = deliverableManager; @@ -408,6 +413,7 @@ public DeliverableAction(APConfig config, DeliverableTypeManager deliverableType this.feedbackQACommentableFieldsManager = feedbackQACommentableFieldsManager; this.feedbackQACommentManager = feedbackQACommentManager; this.deliverableTraineesIndicatorManager = deliverableTraineesIndicatorManager; + this.shfrmPriorityActionManager = shfrmPriorityActionManager; } /** @@ -899,6 +905,10 @@ public List getResponsibleUsers() { return responsibleUsers; } + public List getShfrmPriorityActions() { + return shfrmPriorityActions; + } + public Map getStatus() { return status; } @@ -1815,6 +1825,8 @@ public void prepare() throws Exception { .filter(dt -> dt.isActive() && dt.getDeliverableCategory() == null && dt.getCrp() != null && dt.getCrp().getId().longValue() == loggedCrp.getId().longValue() && dt.getAdminType().booleanValue()) .collect(Collectors.toList()))); + + shfrmPriorityActions = shfrmPriorityActionManager.findAll(); } if (deliverable.getDeliverableInfo(this.getActualPhase()).getDeliverableType() != null @@ -3988,6 +4000,10 @@ public void setResponsibleUsers(List responsibleUsers) { this.responsibleUsers = responsibleUsers; } + public void setShfrmPriorityActions(List shfrmPriorityActions) { + this.shfrmPriorityActions = shfrmPriorityActions; + } + public void setStatus(Map status) { this.status = status; } diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index 03245abf08..1dafaa79b2 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -928,6 +928,14 @@ deliverable.typeOfActivity.trials.description=This includes participants in lab deliverable.typeOfActivity.other=Other deliverable.typeOfActivity.other.description= +deliverable.shfrmContribution.question.reporting=Is this deliverable contributing to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: +deliverable.shfrmContribution.question.planning=Is this deliverable expected to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: +deliverable.shfrmContribution.question.help=If you select yes, please make sure to select the SHFRM indicator in the next question +deliverable.shfrmContribution.narrative=Provide a short narrative on how this deliverable is expecting to contribute to the SHFRM +deliverable.shfrmContribution.priorityAction=To which priority action of the SHFRM is this deliverable contributing to? +deliverable.shfrmContribution.priorityAction.help=Select a priority action +deliverable.shfrmContribution.subAction=To which specific sub-action of the SHFRM is this deliverable contributing to? + intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status intellectualAsset.patentType=Patent Type From cc770421261a70fd915f97fd4bb54314eadea246 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Tue, 30 Jan 2024 16:34:19 -0500 Subject: [PATCH 11/65] :wrench: chore(shfrm Contribution): Create shfrm question components in deliverable section --- .../crp/views/projects/deliverableInfo.ftl | 8 +++ .../global/macros/deliverableMacros.ftl | 58 ++++++++++++++++++- .../projects/deliverables/deliverableInfo.js | 31 ++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl index 7993e83b17..63e95de067 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl @@ -1,4 +1,6 @@ [#ftl] +[#import "/WEB-INF/global/macros/deliverableMacros.ftl" as deliverableMacros /] +
@@ -135,6 +137,12 @@ There are required fields still incompleted [/#if]
+ + [#-- Shfmr Sub Actions Template --] + [@deliverableMacros.shfmrSubActionMacro element={} name="feedbackFields[-1]" index=-1 isTemplate=true /] + + [#-- SHRFM contribution --] + [@deliverableMacros.shfmrContributionMacro /] [#-- Key Outputs select --] [#if !project.projectInfo.administrative && !phaseOne && !isCenterProject ] diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 50bdb14d98..2ecf0674b8 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -572,12 +572,68 @@ [/#macro] +[#macro shfmrContributionMacro ] + [#local name = "deliverable.deliverableinfo" /] +
+
+ + +

[@s.text name="deliverable.shfrmContribution.question.help" /]

+
+
+ [@customForm.yesNoInputDeliverable name="${name}.contributingShfrm" editable=editable inverse=false cssClass="type-findable text-center" /] +
+
+ [#local isContributingShfrm = (deliverable.deliverableinfo.contributingShfrm?string)!""] +
+
+ + [#-- Shfrm Contribution Narrative --] +
+ [@customForm.textArea name="deliverable.deliverableInfo.shfrmContributionNarrative" value="${(deliverable.deliverableInfo.shfrmContributionNarrative)!}" i18nkey="deliverable.shfrmContribution.narrative" placeholder="" className="limitWords-200" required=true editable=editable /] +
+ + [#-- Shfrm Priority Action --] +
+ [@customForm.select name="deliverable.deliverableInfo.deliverableType.deliverableCategory.id" label="deliverable.shfrmContribution.priorityAction.help" i18nkey="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="name" multiple=false required=true className=" form-control input-sm typeSelect addSlo" editable=editable/] +
+ +
+
+[/#macro] + +[#macro shfmrSubActionMacro element name index isTemplate=false] +
+ [#-- Remove Button --] +
+ + [#-- Sub Action ID --] +
+ shfmr Sub Action ${index+1}: ${(element.sectionDescription)!''} - ${(element.fieldName[0..*200])!'shfmr SubAction Fields'} +
+ + +
+[/#macro] + [#macro findableOptions ] [#local isSynced = (deliverable.dissemination.synced)!false ] [#local customName = "deliverable.dissemination" /]
- [#-- Note --] + [#-- Note
[@s.text name="project.deliverable.dissemination.channelInfo" /]
+ --]
[#if editable] 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 92a2fd2baa..9a6fb97c56 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 @@ -690,6 +690,37 @@ var deliverablePartnersModule = (function() { $('.removePartnerItem').on('click', removePartnerItem); // On add a new deliverable partner Item $('.addPartnerItem').on('click', addPartnerItem); + // On add a shrfm sub action + $('.addSlo').on('click', addIdo); + + } + + function addIdo() { + console.log("add sub action"); + var $itemsList = $(this).parent().find('.slos-list'); + var $item = $("#srfSlo-template").clone(true).removeAttr("id"); + $item.find('.blockTitle').trigger('click'); + $itemsList.append($item); + $item.slideDown('slow'); + updateSubActionIndexes(); + $item.trigger('addComponent'); + } + + function updateSubActionIndexes() { + $('.slos-list .srfSlo').each(function(i,slo) { + // Updating indexes + $(slo).setNameIndexes(1, i); + $(slo).find('.srfSloIndicator').each(function(subIdoIndex,subIdo) { + // Updating indexes + $(subIdo).setNameIndexes(2, subIdoIndex); + }); + }); + + $('.issues-list .srfCCIssue').each(function(i,crossCutting) { + // Updating indexes + $(crossCutting).setNameIndexes(1, i); + + }); } function addPartnerItem() { From dcdfaa56fb1ff101dbaec72887b134dc3a5e9b7a Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 31 Jan 2024 08:03:50 -0500 Subject: [PATCH 12/65] chore(shfrm Contribution): Update system labels for shfrm management module --- .../main/resources/custom/aicrra.properties | 20 +++++++++++++++++++ .../src/main/resources/global.properties | 13 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index aeab0b95a6..3ddd2f55ab 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -330,6 +330,7 @@ breadCrumb.menu.timelineManagement=Timeline Management breadCrumb.menu.feedbackManagement=Feedback Management breadCrumb.menu.buttonGuideManagement=Button Guide Management breadCrumb.menu.messageManagement=MARLO Message Management +breadCrumb.menu.shfrmManagement=Soil Health and Fertility Road Map # Message section message.title=MARLO Message Management @@ -926,6 +927,14 @@ deliverable.typeOfActivity.other=Other deliverable.typeOfActivity.other.description= deliverable.missing.activity.alert=There are {0} deliverable(s) in this cluster not mapped to any activity
*Please keep in mind that without full fill this task the green-check mark validator will not be reflected
+deliverable.shfrmContribution.question.reporting=Is this deliverable contributing to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: +deliverable.shfrmContribution.question.planning=Is this deliverable expected to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: +deliverable.shfrmContribution.question.help=If you select yes, please make sure to select the SHFRM indicator in the next question +deliverable.shfrmContribution.narrative=Provide a short narrative on how this deliverable is expecting to contribute to the SHFRM +deliverable.shfrmContribution.priorityAction=To which priority action of the SHFRM is this deliverable contributing to? +deliverable.shfrmContribution.priorityAction.help=Select a priority action +deliverable.shfrmContribution.subAction=To which specific sub-action of the SHFRM is this deliverable contributing to? + intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status intellectualAsset.patentType=Patent Type @@ -1802,6 +1811,7 @@ CRPAdmin.menu.guestUsers=Guest Users CRPAdmin.menu.users=List of users CRPAdmin.menu.deliverables=Deliverables Management CRPAdmin.menu.crpPhases=Planning/Reporting Cycles +CRPAdmin.menu.shfrmManagement=Soil Health and Fertility Road Map # # Program Management Section programManagement.title=Project Management Committee @@ -1899,6 +1909,16 @@ projectPhases.help= projectPhases.visible=Display on timeline projectPhases.editable=Status +# Soil Health and Fertility Road Map Management +shfrmManagement.title=Manage the Soil Health and Fertility Road Map (SHFRM) +shfrmManagement.priorityActions.set=Set the control list for Priority Actions: +shfrmManagement.priorityActions.title=Title +shfrmManagement.priorityActions.add=Add new priority action +shfrmManagement.subActions.add=Add new sub-action +shfrmManagement.subActions.title=Title +shfrmManagement.subActions.description=Description +shfrmManagement.deliverables.info=See {0} deliverables attached + # # Super Admin marloSLOs.sloTitle=System Level Outcomes diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index 1dafaa79b2..445a16087d 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -333,6 +333,7 @@ breadCrumb.menu.timelineManagement=Timeline Management breadCrumb.menu.feedbackManagement=Feedback Management breadCrumb.menu.buttonGuideManagement=Button Guide Management breadCrumb.menu.messageManagement=MARLO Message Management +breadCrumb.menu.shfrmManagement=Soil Health and Fertility Road Map # Message section message.title=MARLO Message Management @@ -927,6 +928,7 @@ deliverable.typeOfActivity.trials=Trials and studies deliverable.typeOfActivity.trials.description=This includes participants in lab and field trials (including on-farm trials), and direct participants in nutrition studies, impact evaluations and other research studies (soil research, integrated pest management, etc.). deliverable.typeOfActivity.other=Other deliverable.typeOfActivity.other.description= +deliverable.missing.activity.alert=There are {0} deliverable(s) in this cluster not mapped to any activity
*Please keep in mind that without full fill this task the green-check mark validator will not be reflected
deliverable.shfrmContribution.question.reporting=Is this deliverable contributing to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: deliverable.shfrmContribution.question.planning=Is this deliverable expected to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: @@ -1888,6 +1890,7 @@ CRPAdmin.menu.guestUsers=Guest Users CRPAdmin.menu.users=List of users CRPAdmin.menu.deliverables=Deliverables Management CRPAdmin.menu.crpPhases=Planning/Reporting Cycles +CRPAdmin.menu.shfrmManagement=Soil Health and Fertility Road Map # # Program Management Section programManagement.title=Program Management Unit Team @@ -1982,6 +1985,16 @@ projectPhases.help= projectPhases.visible=Display on timeline projectPhases.editable=Status +# Soil Health and Fertility Road Map Management +shfrmManagement.title=Manage the Soil Health and Fertility Road Map (SHFRM) +shfrmManagement.priorityActions.set=Set the control list for Priority Actions: +shfrmManagement.priorityActions.title=Title +shfrmManagement.priorityActions.add=Add new priority action +shfrmManagement.subActions.add=Add new sub-action +shfrmManagement.subActions.title=Title +shfrmManagement.subActions.description=Description +shfrmManagement.deliverables.info=See {0} deliverables attached + # # Super Admin marloSLOs.sloTitle=System Level Outcomes From c00b3f9f205091497907aa21de5e891c3789e0a7 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 31 Jan 2024 10:33:55 -0500 Subject: [PATCH 13/65] :wrench: chore(shfrm Contribution): Create priority actions management module --- .../marlo/data/model/ShfrmPriorityAction.java | 26 +-- .../xmls/ShfrmPriorityActions.hbm.xml | 8 - .../crp/admin/ShfrmManagementAction.java | 116 ++++++++++++ marlo-web/src/main/resources/struts-admin.xml | 13 ++ .../WEB-INF/crp/views/admin/menu-admin.ftl | 3 +- .../crp/views/admin/shfrmManagement.ftl | 113 ++++++++++++ .../webapp/crp/js/admin/shfrmManagement.js | 171 ++++++++++++++++++ 7 files changed, 417 insertions(+), 33 deletions(-) create mode 100644 marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java create mode 100644 marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl create mode 100644 marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java index 669e7269dc..dca5759fcb 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java @@ -3,11 +3,6 @@ import org.cgiar.ccafs.marlo.data.IAuditLog; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import com.google.gson.annotations.Expose; /** @@ -22,8 +17,8 @@ public class ShfrmPriorityAction extends MarloAuditableEntity implements java.io @Expose private String description; - private Set shfrmSubAction = new HashSet(0); - private List shfrmSubActions = new ArrayList(); + // private Set shfrmSubAction = new HashSet(0); + // private List shfrmSubActions = new ArrayList(); public ShfrmPriorityAction() { } @@ -43,14 +38,6 @@ public String getName() { return name; } - public Set getShfrmSubAction() { - return shfrmSubAction; - } - - public List getShfrmSubActions() { - return shfrmSubActions; - } - @Override public boolean isActive() { return true; @@ -63,13 +50,4 @@ public void setDescription(String description) { public void setName(String name) { this.name = name; } - - public void setShfrmSubAction(Set shfrmSubAction) { - this.shfrmSubAction = shfrmSubAction; - } - - public void setShfrmSubActions(List shfrmSubActions) { - this.shfrmSubActions = shfrmSubActions; - } - } diff --git a/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml b/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml index fcca635a46..1c1b75ea6a 100644 --- a/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml +++ b/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml @@ -29,13 +29,5 @@ - - - - - - \ No newline at end of file diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java new file mode 100644 index 0000000000..cffc3433f9 --- /dev/null +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java @@ -0,0 +1,116 @@ +/* + * This file is part of Managing Agricultural Research for Learning&*Outcomes Platform(MARLO). + ** MARLO is free software:you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation,either version 3 of the License,or*at your option)any later version. + ** MARLO is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY;without even the implied warranty of*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See + * the + ** GNU General Public License for more details. + ** You should have received a copy of the GNU General Public License + ** along with MARLO.If not,see. + *****************************************************************/ + +package org.cgiar.ccafs.marlo.action.crp.admin; + +import org.cgiar.ccafs.marlo.action.BaseAction; +import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; +import org.cgiar.ccafs.marlo.utils.APConfig; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.inject.Inject; + + +public class ShfrmManagementAction extends BaseAction { + + private static final long serialVersionUID = -793652591843623397L; + private List priorityActions; + private final ShfrmPriorityActionManager shfrmPriorityActionManager; + private final ShfrmSubActionManager shfrmSubActionManager; + + @Inject + public ShfrmManagementAction(APConfig config, ShfrmPriorityActionManager shfrmPriorityActionManager, + ShfrmSubActionManager shfrmSubActionManager) { + super(config); + this.shfrmPriorityActionManager = shfrmPriorityActionManager; + this.shfrmSubActionManager = shfrmSubActionManager; + } + + public List getPriorityActions() { + return priorityActions; + } + + @Override + public void prepare() throws Exception { + priorityActions = new ArrayList<>(); + priorityActions = shfrmPriorityActionManager.findAll(); + + if (this.isHttpPost()) { + } + } + + @Override + public String save() { + if (this.canAcessCrpAdmin()) { + if (priorityActions != null && !priorityActions.isEmpty()) { + + for (ShfrmPriorityAction action : priorityActions) { + ShfrmPriorityAction actionSave = new ShfrmPriorityAction(); + if (action.getId() != null) { + actionSave = shfrmPriorityActionManager.getShfrmPriorityActionById(action.getId()); + } + if (action.getName() != null) { + actionSave.setName(action.getName()); + } + if (action.getDescription() != null) { + actionSave.setDescription(action.getDescription()); + } + shfrmPriorityActionManager.saveShfrmPriorityAction(actionSave); + } + } + + if (this.getUrl() == null || this.getUrl().isEmpty()) { + Collection messages = this.getActionMessages(); + /* + * if (!this.getInvalidFields().isEmpty()) { + * this.setActionMessages(null); + * // this.addActionMessage(Map.toString(this.getInvalidFields().toArray())); + * List keys = new ArrayList(this.getInvalidFields().keySet()); + * for (String key : keys) { + * this.addActionMessage(key + ": " + this.getInvalidFields().get(key)); + * } + * } else { + * this.addActionMessage("message:" + this.getText("saving.saved")); + * } + */ + this.addActionMessage("message:" + this.getText("saving.saved")); + + return SUCCESS; + } else { + this.addActionMessage(""); + this.setActionMessages(null); + return REDIRECT; + } + + } else { + return NOT_AUTHORIZED; + } + } + + public void setPriorityActions(List priorityActions) { + this.priorityActions = priorityActions; + } + + + @Override + public void validate() { + if (save) { + // validator.validate(this, feedbackFields); + } + } +} \ No newline at end of file diff --git a/marlo-web/src/main/resources/struts-admin.xml b/marlo-web/src/main/resources/struts-admin.xml index 55ffc0b0e6..497320f75d 100644 --- a/marlo-web/src/main/resources/struts-admin.xml +++ b/marlo-web/src/main/resources/struts-admin.xml @@ -109,6 +109,19 @@ ${phaseID} + + + + + /WEB-INF/crp/views/admin/shfrmManagement.ftl + + + ${crpSession}/shfrmManagement + true + ${phaseID} + + diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl index 3a3fc7fc3f..fced38788f 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl @@ -29,7 +29,8 @@ [#-- { 'slug': 'guestUsers', 'name': 'CRPAdmin.menu.guestUsers', 'action': 'guestUser', 'active': !config.production }, --] { 'slug': 'targetUnits', 'name': 'CRPAdmin.menu.hrefTargetUnits', 'action': 'targetUnits', 'active': true }, <#-- { 'slug': 'institutions', 'name': 'menu.superadmin.institutions', 'action': 'marloInstitutions', 'active': true }, --> - { 'slug': 'crpPhases', 'name': 'CRPAdmin.menu.crpPhases', 'action': 'crpPhases', 'active': true } + { 'slug': 'crpPhases', 'name': 'CRPAdmin.menu.crpPhases', 'action': 'crpPhases', 'active': true }, + { 'slug': 'shfrmManagement', 'name': 'CRPAdmin.menu.shfrmManagement', 'action': 'shfrmManagement', 'active': true } ]/] [/#if] diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl new file mode 100644 index 0000000000..f6245d7267 --- /dev/null +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -0,0 +1,113 @@ +[#ftl] +[#assign title = "SHFRM Management" /] +[#assign currentSectionString = "${actionName?replace('/','-')}-phase-${(actualPhase.id)!}" /] +[#assign pageLibs = [] /] +[#assign customJS = [ + "${baseUrlMedia}/js/admin/shfrmManagement.js", + "${baseUrlCdn}/global/js/fieldsValidation.js" + ] +/] +[#assign customCSS = [ "${baseUrlMedia}/css/admin/crpPhases.css" ] /] +[#assign currentSection = "admin" /] +[#assign currentStage = "shfrmManagement" /] + +[#assign breadCrumb = [ + {"label":"superadmin", "nameSpace":"", "action":"adminManagement"}, + {"label":"shfrmManagement", "nameSpace":"", "action":""} +]/] + +[#include "/WEB-INF/global/pages/header.ftl" /] +
+ +
+ [#include "/WEB-INF/global/pages/breadcrumb.ftl" /] +
+[#include "/WEB-INF/global/pages/generalMessages.ftl" /] + +[#-- +
+
+
+
+
+ +
+
+
+

+ [@s.text name="Please note that activities are displayed on the homepage timeline component in the order they are entered or in the order defined by the 'order' field, if its filled. By default, the dates of the activities do not determine their order." /] +

+
+
+
+
+ --] + +
+
+
+
+ [#include "/WEB-INF/crp/views/admin/menu-admin.ftl" /] +
+
+ [@s.form action=actionName enctype="multipart/form-data" ] + + [#-- System Level Outcomes --] +

[@s.text name="shfrmManagement.title" /]

+
+ [#if priorityActions?has_content] + [#list priorityActions as slo] + [@srfSloMacro element=slo name="priorityActions[${slo_index}]" index=slo_index /] + [/#list] + [/#if] +
+ [#-- Add Outcome Button --] +
[@s.text name="shfrmManagement.priorityActions.add"/]
+ + [#-- Section Buttons--] +
+
+ [@s.submit type="button" name="save" cssClass="button-save"] [@s.text name="form.buttons.save" /][/@s.submit] +
+
+ + [/@s.form] + +
+
+
+
+ +[#-- SLO Template --] +[@srfSloMacro element={} name="priorityActions[-1]" index=-1 isTemplate=true /] + +[#include "/WEB-INF/global/pages/footer.ftl" /] + +[#macro srfSloMacro element name index isTemplate=false] +
+ [#-- Remove Button --] +
+ + [#-- SLO Title --] +
+ ${(element.name)!'Shfrm Priority Action'} ${index+1}: ${(element.description)!'Shfrm Priority Action'} +
+ + +
+[/#macro] diff --git a/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js b/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js new file mode 100644 index 0000000000..edcfadae0d --- /dev/null +++ b/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js @@ -0,0 +1,171 @@ +$(document).ready(init); + +function init() { + + /* Declaring Events */ + attachEvents(); + + datePickerConfig({ + "startDate": ".startDate", + "endDate": ".endDate", + defaultMinDateValue: $("#minDateValue").val(), + defaultMaxDateValue: $("#maxDateValue").val() + }); + +} + +function attachEvents() { + $('.addSlo').on('click', addIdo); + + $('.addIndicator').on('click', addIndicator); + + $('.addTargets').on('click', addTargets); + + $('.addCrossCuttingIssue').on('click', addCrossCuttingIssue); + + $('.remove-element').on('click', removeElement); + + $('.blockTitle.closed').on('click', function() { + if($(this).hasClass('closed')) { + $('.blockContent').slideUp(); + $('.blockTitle').removeClass('opened').addClass('closed'); + $(this).removeClass('closed').addClass('opened'); + } else { + $(this).removeClass('opened').addClass('closed'); + } + $(this).next().slideToggle('slow', function() { + $(this).find('textarea').autoGrow(); + }); + }); + +} + +function addIdo() { + console.log("add ido"); + var $itemsList = $(this).parent().find('.slos-list'); + var $item = $("#srfSlo-template").clone(true).removeAttr("id"); + $item.find('.blockTitle').trigger('click'); + $itemsList.append($item); + $item.slideDown('slow'); + updateIndexes(); + $item.trigger('addComponent'); +} + +function addIndicator() { + console.log("addIndicator"); + var $itemsList = $(this).parent().parent().find('.srfIndicators-list'); + var $item = $("#srfSloIndicator-template").clone(true).removeAttr("id"); + + $itemsList.append($item); + $item.slideDown('slow'); + updateIndexes(); + $item.trigger('addComponent'); +} + +function addTargets() { + console.log("addTargets"); + var $itemsList = $(this).parent().parent().find('.targetsList'); + var $item = $("#targetIndicator-template").clone(true).removeAttr("id"); + $itemsList.append($item); + $item.show('slow'); + updateIndexes(); + $item.trigger('addComponent'); +} + +function addCrossCuttingIssue() { + console.log("addCrossCuttingIssue"); + var $itemsList = $(this).parent().find('.issues-list'); + var $item = $("#srfCCIssue-template").clone(true).removeAttr("id"); + + $itemsList.append($item); + $item.slideDown('slow'); + updateIndexes(); + $item.trigger('addComponent'); +} + +function removeElement() { + $item = $(this).parent(); + $item.hide('slow', function() { + $item.remove(); + updateIndexes(); + $(document).trigger('removeComponent'); + }); +} + +function updateIndexes() { + $('.slos-list .srfSlo').each(function(i,slo) { + // Updating indexes + $(slo).setNameIndexes(1, i); + $(slo).find('.srfSloIndicator').each(function(subIdoIndex,subIdo) { + // Updating indexes + $(subIdo).setNameIndexes(2, subIdoIndex); + }); + }); + + $('.issues-list .srfCCIssue').each(function(i,crossCutting) { + // Updating indexes + $(crossCutting).setNameIndexes(1, i); + + }); +} + +/** + * Attach to the date fields the datepicker plugin + */ +function datePickerConfig(element) { + date($(element.startDate), $(element.endDate)); +} + +function date(start,end) { + var dateFormat = "yy-mm-dd"; + var from = $(start).datepicker({ + dateFormat: dateFormat, + minDate: '2023-01-01', + maxDate: '2026-12-31', + changeMonth: true, + numberOfMonths: 2, + changeYear: true, + onChangeMonthYear: function(year,month,inst) { + var selectedDate = new Date(inst.selectedYear, inst.selectedMonth, 1); + $(this).datepicker('setDate', selectedDate); + if(selectedDate != "") { + $(end).datepicker("option", "minDate", selectedDate); + } + } + }).on("click", function() { + if(!$(this).val()) { + $(this).datepicker('setDate', new Date()); + } + }); + + var to = $(end).datepicker({ + dateFormat: dateFormat, + minDate: '2023-01-01', + maxDate: '2026-12-31', + changeMonth: true, + numberOfMonths: 2, + changeYear: true, + onChangeMonthYear: function(year,month,inst) { + var selectedDate = new Date(inst.selectedYear, inst.selectedMonth + 1, 0); + $(this).datepicker('setDate', selectedDate); + if(selectedDate != "") { + $(start).datepicker("option", "maxDate", selectedDate); + } + } + }).on("click", function() { + if(!$(this).val()) { + $(this).datepicker('setDate', new Date()); + } + }); + + function getDate(element) { + var date; + try { + date = $.datepicker.parseDate(dateFormat, element.value); + } catch(error) { + date = null; + } + + return date; + } +} From 3240b471974a43df12815249857a8fb9eaa6fe98 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Thu, 1 Feb 2024 13:23:38 -0500 Subject: [PATCH 14/65] chore(shfrm Contribution): Update priority actions management action front end files and backend logic --- .../marlo/data/model/ShfrmPriorityAction.java | 13 +- .../crp/admin/ShfrmManagementAction.java | 77 +- .../main/resources/custom/aicrra.properties | 3 + .../src/main/resources/global.properties | 4 + .../crp/views/admin/shfrmManagement.ftl | 284 +++- .../webapp/crp/js/admin/shfrmManagement.js | 1201 +++++++++++++++-- .../webapp/crp/js/projects/projectPartners.js | 1 - 7 files changed, 1393 insertions(+), 190 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java index dca5759fcb..9124d127de 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java @@ -3,6 +3,9 @@ import org.cgiar.ccafs.marlo.data.IAuditLog; +import java.util.ArrayList; +import java.util.List; + import com.google.gson.annotations.Expose; /** @@ -18,7 +21,7 @@ public class ShfrmPriorityAction extends MarloAuditableEntity implements java.io private String description; // private Set shfrmSubAction = new HashSet(0); - // private List shfrmSubActions = new ArrayList(); + private List shfrmSubActions = new ArrayList(); public ShfrmPriorityAction() { } @@ -38,6 +41,10 @@ public String getName() { return name; } + public List getShfrmSubActions() { + return shfrmSubActions; + } + @Override public boolean isActive() { return true; @@ -50,4 +57,8 @@ public void setDescription(String description) { public void setName(String name) { this.name = name; } + + public void setShfrmSubActions(List shfrmSubActions) { + this.shfrmSubActions = shfrmSubActions; + } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java index cffc3433f9..285962a39a 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java @@ -17,17 +17,23 @@ import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; import org.cgiar.ccafs.marlo.utils.APConfig; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; import javax.inject.Inject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class ShfrmManagementAction extends BaseAction { + private static Logger logger = LoggerFactory.getLogger(ShfrmManagementAction.class); private static final long serialVersionUID = -793652591843623397L; private List priorityActions; private final ShfrmPriorityActionManager shfrmPriorityActionManager; @@ -41,6 +47,33 @@ public ShfrmManagementAction(APConfig config, ShfrmPriorityActionManager shfrmPr this.shfrmSubActionManager = shfrmSubActionManager; } + /** + * Fill Priority actions with sub actions list + */ + public void fillSubActions() { + if (priorityActions != null && !priorityActions.isEmpty()) { + try { + List subActions = shfrmSubActionManager.findAll(); + + if (subActions != null && !subActions.isEmpty()) { + priorityActions.forEach(action -> { + List subActionsAdd = subActions.stream() + .filter(subaction -> action != null && action.getId() != null && subaction != null + && subaction.getShfrmPriorityAction() != null && subaction.getShfrmPriorityAction().getId() != null + && subaction.getShfrmPriorityAction().getId().equals(action.getId())) + .collect(Collectors.toList()); + + if (!subActionsAdd.isEmpty()) { + action.setShfrmSubActions(subActionsAdd); + } + }); + } + } catch (Exception e) { + logger.info(e + "no sub actions added yet"); + } + } + } + public List getPriorityActions() { return priorityActions; } @@ -49,7 +82,7 @@ public List getPriorityActions() { public void prepare() throws Exception { priorityActions = new ArrayList<>(); priorityActions = shfrmPriorityActionManager.findAll(); - + this.fillSubActions(); if (this.isHttpPost()) { } } @@ -57,9 +90,19 @@ public void prepare() throws Exception { @Override public String save() { if (this.canAcessCrpAdmin()) { - if (priorityActions != null && !priorityActions.isEmpty()) { + if (this.priorityActions != null && !this.priorityActions.isEmpty()) { + + List priorityActionsDB = null; + List subActionsDB = null; + try { + priorityActionsDB = shfrmPriorityActionManager.findAll(); + subActionsDB = shfrmSubActionManager.findAll(); + } catch (Exception e) { + logger.info(e + "no sub actions added yet"); + } + - for (ShfrmPriorityAction action : priorityActions) { + for (ShfrmPriorityAction action : this.priorityActions) { ShfrmPriorityAction actionSave = new ShfrmPriorityAction(); if (action.getId() != null) { actionSave = shfrmPriorityActionManager.getShfrmPriorityActionById(action.getId()); @@ -70,10 +113,38 @@ public String save() { if (action.getDescription() != null) { actionSave.setDescription(action.getDescription()); } + shfrmPriorityActionManager.saveShfrmPriorityAction(actionSave); + if (priorityActionsDB != null && !priorityActionsDB.isEmpty() && !priorityActionsDB.contains(action)) { + shfrmPriorityActionManager.deleteShfrmPriorityAction(action.getId()); + } + + // Save sub-actions + if (action.getShfrmSubActions() != null && !action.getShfrmSubActions().isEmpty()) { + for (ShfrmSubAction subAction : action.getShfrmSubActions()) { + ShfrmSubAction subActionSave = new ShfrmSubAction(); + + if (subAction.getId() != null) { + subActionSave.setId(subAction.getId()); + } + if (subAction.getName() != null) { + subActionSave.setName(subAction.getName()); + } + if (subAction.getDescription() != null) { + subActionSave.setDescription(subAction.getDescription()); + } + subActionSave.setShfrmPriorityAction(action); + + shfrmSubActionManager.saveShfrmSubAction(subActionSave); + if (subActionsDB != null && !subActionsDB.isEmpty() && !subActionsDB.contains(subAction)) { + shfrmSubActionManager.deleteShfrmSubAction(subAction.getId()); + } + } + } } } + if (this.getUrl() == null || this.getUrl().isEmpty()) { Collection messages = this.getActionMessages(); /* diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 3ddd2f55ab..05a50d775a 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -1913,11 +1913,14 @@ projectPhases.editable=Status shfrmManagement.title=Manage the Soil Health and Fertility Road Map (SHFRM) shfrmManagement.priorityActions.set=Set the control list for Priority Actions: shfrmManagement.priorityActions.title=Title +shfrmManagement.priorityActions.description=description shfrmManagement.priorityActions.add=Add new priority action shfrmManagement.subActions.add=Add new sub-action shfrmManagement.subActions.title=Title shfrmManagement.subActions.description=Description shfrmManagement.deliverables.info=See {0} deliverables attached +shfrmManagement.subActionsEmpty=No sub-Action(s) added yet +shfrmManagement.actionsEmpty=No action(s) added yet # # Super Admin diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index 445a16087d..26e0b15dea 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -1989,11 +1989,15 @@ projectPhases.editable=Status shfrmManagement.title=Manage the Soil Health and Fertility Road Map (SHFRM) shfrmManagement.priorityActions.set=Set the control list for Priority Actions: shfrmManagement.priorityActions.title=Title +shfrmManagement.priorityActions.description=description shfrmManagement.priorityActions.add=Add new priority action shfrmManagement.subActions.add=Add new sub-action shfrmManagement.subActions.title=Title shfrmManagement.subActions.description=Description shfrmManagement.deliverables.info=See {0} deliverables attached +shfrmManagement.subActionsEmpty=No sub-Action(s) added yet +shfrmManagement.actionsEmpty=No action(s) added yet + # # Super Admin diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index f6245d7267..356c8c9d12 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -1,15 +1,17 @@ [#ftl] [#assign title = "SHFRM Management" /] [#assign currentSectionString = "${actionName?replace('/','-')}-phase-${(actualPhase.id)!}" /] -[#assign pageLibs = [] /] +[#assign pageLibs = ["select2", "flag-icon-css"] /] [#assign customJS = [ "${baseUrlMedia}/js/admin/shfrmManagement.js", - "${baseUrlCdn}/global/js/fieldsValidation.js" + "${baseUrlCdn}/global/js/fieldsValidation.js", + "${baseUrlCdn}/global/js/usersManagement.js?20230927" ] /] [#assign customCSS = [ "${baseUrlMedia}/css/admin/crpPhases.css" ] /] [#assign currentSection = "admin" /] [#assign currentStage = "shfrmManagement" /] +[#assign hideJustification = true /] [#assign breadCrumb = [ {"label":"superadmin", "nameSpace":"", "action":"adminManagement"}, @@ -17,97 +19,237 @@ ]/] [#include "/WEB-INF/global/pages/header.ftl" /] -
-
- [#include "/WEB-INF/global/pages/breadcrumb.ftl" /] -
-[#include "/WEB-INF/global/pages/generalMessages.ftl" /] - -[#-- -
-
-
-
-
- -
-
-
-

- [@s.text name="Please note that activities are displayed on the homepage timeline component in the order they are entered or in the order defined by the 'order' field, if its filled. By default, the dates of the activities do not determine their order." /] -

-
-
-
-
- --] - -
-
+[#include "/WEB-INF/global/pages/main-menu.ftl" /] +[#import "/WEB-INF/crp/macros/relationsPopupMacro.ftl" as popUps /] + + +[#if (!availabePhase)!false] + [#include "/WEB-INF/crp/views/projects/availability-projects.ftl" /] +[#else] +
+
[#include "/WEB-INF/crp/views/admin/menu-admin.ftl" /]
+ [#-- Project Section Content --]
- [@s.form action=actionName enctype="multipart/form-data" ] - - [#-- System Level Outcomes --] -

[@s.text name="shfrmManagement.title" /]

-
- [#if priorityActions?has_content] - [#list priorityActions as slo] - [@srfSloMacro element=slo name="priorityActions[${slo_index}]" index=slo_index /] - [/#list] - [/#if] -
- [#-- Add Outcome Button --] -
[@s.text name="shfrmManagement.priorityActions.add"/]
- - [#-- Section Buttons--] -
-
- [@s.submit type="button" name="save" cssClass="button-save"] [@s.text name="form.buttons.save" /][/@s.submit] + [#-- Section Messages --] + [@s.form action=actionName method="POST" enctype="multipart/form-data" cssClass=""] +
+

[@s.text name="shfrmManagement.title" /]

-
- - [/@s.form] - + [#-- Listing Partners --] + + [#-- Partners list --] +
+ [#if priorityActions?has_content] + [#list priorityActions as priorityAction] + [@projectPartnerMacro element=priorityAction!{} name="priorityActions[${priorityAction_index}]" index=priorityAction_index opened=(priorityActions?size = 1)/] + [/#list] + [#else] + [@projectPartnerMacro element={} name="priorityActions[0]" index=0 opened=true defaultPerson=true /] + + [/#if] +
[@s.text name="shfrmManagement.priorityActions.add" /]
+
+ + [#-- Section Buttons--] +
+
+ [@s.submit type="button" name="save" cssClass="button-save"] [@s.text name="form.buttons.save" /][/@s.submit] +
+
+ + + [/@s.form]
-
-
+
+[/#if] + +[#-- Single partner TEMPLATE from partnersTemplate.ftl --] +[@projectPartnerMacro element={} name="priorityActions[-1]" isTemplate=true /] -[#-- SLO Template --] -[@srfSloMacro element={} name="priorityActions[-1]" index=-1 isTemplate=true /] +[#-- Contact person TEMPLATE from partnersTemplate.ftl --] +[@contactPersonMacro element={} name="priorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] -[#include "/WEB-INF/global/pages/footer.ftl" /] +[#-- PPA list Template --] +
    +
  • + + + + + [#if editable][@s.text name="form.buttons.remove" /][/#if] +
  • +
-[#macro srfSloMacro element name index isTemplate=false] -
- [#-- Remove Button --] -
+[#-- Project roles descriptions --] + + + + +[#-- allPPAInstitutions --] + + +[#-- Remove Partner Dialog --] + + +[#-- Remove partner person leader dialog --] + + +[#-- Change partner person email dialog --] + + +[#-- Change partner person type dialog --] + + +[#-- Partner person relations dialog --] + + + +[#include "/WEB-INF/global/pages/footer.ftl"] + +[#------------------------------------------------------ ------------------------------------------------------] +[#---------------------------------------------------- MACROS ----------------------------------------------------] +[#------------------------------------------------------ ------------------------------------------------------] + +[#macro projectPartnerMacro element name index=-1 opened=false defaultPerson=false isTemplate=false] + [#local isLeader = (element.leader)!false/] + [#local isCoordinator = (element.coordinator)!false/] + [#local isPPA = (action.isPPA(element.institution))!false /] + [#local allowSubDep = ((element.subDepartment?has_content)!false) || ((element.institution.institutionType.subDepartmentActive)!false) ] + +
+ [#-- Loading --] + + [#-- TODO: Please improve this validation at backend side --] + + [#-- Remove link for all partners --] + [#if editable ] [#--&& (isTemplate) --] + + [/#if] - [#-- SLO Title --] -
- ${(element.name)!'Shfrm Priority Action'} ${index+1}: ${(element.description)!'Shfrm Priority Action'} + [#-- Partner Title --] +
+ [#-- Title --] + ${index+1}. ${(element.shfrmPriorityAction.title)!'Priority Action'} + + [#-- Tags --] +
+ Leader + Coordinator + ${isPPA?string('Managing Partner','Partner')} +
+ + [#-- Contacts --] + [#if (element.partnerPersons)?? ]
+ [#list element.partnerPersons as partnerPerson] + [#if partnerPerson.user?? && partnerPerson.user.firstName??] + [${(partnerPerson.user.composedCompleteName)!}] + [/#if] + [/#list] + [/#if] +
- +[/#macro] + +[#macro contactPersonMacro element name index=-1 partnerIndex=-1 isTemplate=false institutionID=-1] +
+ [#-- Remove link for all partners --] + [#if editable && action.canBeDeleted((element.id)!-1,(element.class.name)!)] +
+ [/#if] +
+ +
+ + [#local isPPA = (action.isPPA(element.projectPartner.institution))!false /] + + [#if customForm.changedField('${name}.id') != ''] + Added/Updated + [/#if] +
+
+ [#-- Sub action name --] +
+ [@customForm.input name="${name}.name" className="partnerPersonType" editable=editable i18nkey="shfrmManagement.subActions.title" value="${(element.name)!}" /] +
+ [#-- Sub action description --] +
+ + [@customForm.input name="${name}.description" value="${(element.description)!}" type="text" i18nkey="shfrmManagement.subActions.description" required=true editable=editable /] + +
+
+ +
+
[/#macro] diff --git a/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js b/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js index edcfadae0d..406ad84334 100644 --- a/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js +++ b/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js @@ -1,31 +1,84 @@ +var $removePartnerDialog, $projectPPAPartners; +var canUpdatePPAPartners, allPPAInstitutions, partnerPersonTypes, leaderType, coordinatorType, defaultType, partnerRespRequired; +var projectLeader; +var lWordsResp = 100; + $(document).ready(init); function init() { - /* Declaring Events */ + // Setting global variables + $removePartnerDialog = $('#partnerRemove-dialog'); + $partnersBlock = $('#projectPartnersBlock'); + $projectPPAPartners = $('#projectPPAPartners'); + allPPAInstitutions = JSON.parse($('#allPPAInstitutions').val()); + canUpdatePPAPartners = ($("#canUpdatePPAPartners").val() === "true"); + partnerRespRequired = ($("#partnerRespRequired").val() === "true"); + leaderType = 'PL'; + coordinatorType = 'PC'; + defaultType = 'CP'; + partnerPersonTypes = [ + coordinatorType, leaderType, defaultType, '-1' + ]; + + if(editable) { + // Getting the actual project leader + projectLeader = jQuery.extend({}, getProjectLeader()); + // Remove PPA institutions from partner institution list when there is not privileges to update PPA Partners + if(!canUpdatePPAPartners) { + removePPAPartnersFromList('#projectPartner-template .institutionsList'); + } + // Update initial project CCAFS partners list for each partner + updateProjectPPAPartnersLists(); + + } + // Activate the chosen to the existing partners + addSelect2(); + + addUser = function(composedName,userId) { + var $contact = $elementSelected.parents('.contactsPerson ').find('input[value="' + userId + '"]'); + + if(!$contact.exists()) { + $elementSelected.parents('.userField ').find("input.userName").val(composedName).addClass('animated flash'); + $elementSelected.parents('.userField ').find("input.userId").val(userId); + } else { + var notyOptions = jQuery.extend({}, notyDefaultOptions); + notyOptions.text = 'Contact person cannot be repeated'; + noty(notyOptions); + } + dialog.dialog("close"); + } + + // This function enables launch the pop up window + popups(); + // Attaching listeners attachEvents(); - - datePickerConfig({ - "startDate": ".startDate", - "endDate": ".endDate", - defaultMinDateValue: $("#minDateValue").val(), - defaultMaxDateValue: $("#maxDateValue").val() + + // Set the unique person as leader + /* + * if(editable){ var contactPeople = $partnersBlock.find('.projectPartner'); if ((contactPeople.length == 1)){ var + * person = new PartnerPersonObject(contactPeople); person.setPartnerType(leaderType); person.changeType(); } } + */ + + $('.loadingBlock').hide().next().fadeIn(500, function() { + // Missing fields in parter person + $("form .projectPartner ").each(function(i,e) { + verifyMissingFields(e); + }); + showHelpText(); + setViewMore(); }); + $("textarea[id!='justification']").autoGrow(); } function attachEvents() { - $('.addSlo').on('click', addIdo); - $('.addIndicator').on('click', addIndicator); + /** + * General + */ - $('.addTargets').on('click', addTargets); - - $('.addCrossCuttingIssue').on('click', addCrossCuttingIssue); - - $('.remove-element').on('click', removeElement); - - $('.blockTitle.closed').on('click', function() { + $('.blockTitle').on('click', function() { if($(this).hasClass('closed')) { $('.blockContent').slideUp(); $('.blockTitle').removeClass('opened').addClass('closed'); @@ -33,139 +86,1059 @@ function attachEvents() { } else { $(this).removeClass('opened').addClass('closed'); } - $(this).next().slideToggle('slow', function() { + + $(this).next().slideToggle(500, function() { $(this).find('textarea').autoGrow(); + $(this).find(".errorTag").hide(); + $(this).find(".errorTag").css("left", $(this).outerWidth()); + $(this).find(".errorTag").fadeIn(1000); + + // Scroll to selected partner + $('html, body').animate({scrollTop: $(this).offset().top - 100}, 500); + }); + }); + + $('.button-save').on('click', function(e) { + var missingFields = 0 + $('form select.institutionsList').each(function(i,e){ + if(!e.value){ + missingFields++; + } + }); + + // Validate if there are missing fields + if(missingFields) { + e.preventDefault(); + var notyOptions = jQuery.extend({}, notyDefaultOptions); + notyOptions.text = "You must select a partner organization"; + noty(notyOptions); + // Turn off the saving button state + turnSavingStateOff(this); + return + } + }); + + /** + * Project partner Events + */ + // Add a project partner Event + $(".addProjectPartner").on('click', addPartnerEvent); + // Remove a project partner Event + $(".removePartner").on('click', removePartnerEvent); + // When Partner Type change + $("select.partnerTypes, select.countryList").change(updateOrganizationsList); + // When name change + $("input.name").on("change", function(e) { + find('.priorityActionTitle').text(this.name); + }); + // When organization change + $("select.institutionsList").on("change", function(e) { + var partner = new PartnerObject($(this).parents('.projectPartner')); + // Update Partner Title + partner.updateBlockContent(); + + // Get Countries from Institution ID + $.ajax({ + url: baseURL + "/institutionBranchList.do", + data: { + institutionID: $(this).val(), + phaseID: phaseID + }, + beforeSend: function() { + partner.startLoader(); + }, + success: function(data) { + partner.clearCountries(); + + $(partner.countriesSelect).empty(); + $(partner.countriesSelect).addOption(-1, "Select a country..."); + + // Validate if the current partner is not selected, then add the countries + if(!($('input.institutionsList[value=' + partner.institutionId + ']').exists())) { + $.each(data.branches, function(index,branch) { + + if((branch.name).indexOf("HQ") != "-1") { + partner.addCountry({ + iso: branch.iso, + name: branch.name + }); + } else { + $(partner.countriesSelect).addOption(branch.iso, branch.name); + } + }); + } + + $(partner.countriesSelect).trigger("change.select2"); + }, + complete: function() { + partner.stopLoader(); + } + }); + + // Update PPA Partners List + updateProjectPPAPartnersLists(e); + }); + // Partnership Geographic Scope + $(".geographicScopeSelect").on('change', function(){ + var $partner = $(this).parents('.projectPartner'); + var $regionalBlock = $partner.find('.regionalBlock'); + var $nationalBlock = $partner.find('.nationalBlock'); + + var isRegional = this.value == 2; + var isMultiNational = this.value == 3; + var isNational = this.value == 4; + var isSubNational = this.value == 5; + + // Regions + if(isRegional){ + $regionalBlock.show(); + }else{ + $regionalBlock.hide(); + } + + // Countries + $nationalBlock.find("select").val(null).trigger('change'); + if(isMultiNational || isNational || isSubNational){ + if (isMultiNational){ + $nationalBlock.find("select").select2({ + maximumSelectionLength: 0, + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' + }); + }else{ + $nationalBlock.find("select").select2({ + maximumSelectionLength: 1, + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' + }); + } + $nationalBlock.show(); + }else{ + $nationalBlock.hide(); + } + + }); + // Partners filters + $(".filters-link span").on("click", filterInstitutions); + + // Location Elements events + $(".countriesList").on('change', addLocElementCountry); + $('.removeLocElement').on('click', removeLocElement); + + // Request country office + $('#requestModal').on( + 'show.bs.modal', + function(event) { + $.noty.closeAll(); + var partner = new PartnerObject($(event.relatedTarget).parents('.projectPartner')); + + var $modal = $(this); + // Show Form & button + $modal.find('form, .requestButton').show(); + $modal.find('.messageBlock').hide(); + $modal.find('input.institution_id').val(partner.institutionId); + $modal.find('select.countriesRequest').val(null).trigger('select2:change'); + $modal.find('select.countriesRequest').trigger('change'); + $modal.find('.modal-title').html( + 'Request Country office(s)
(' + partner.institutionName + ')'); + }); + $('#requestModal button.requestButton').on('click', function() { + var $modal = $(this).parents('.modal'); + if($modal.find('select.countriesRequest').val() == null) { + return + + } + + $.ajax({ + url: baseURL + '/requestCountryOffice.do', + data: $('#requestModal form').serialize(), + beforeSend: function(data) { + $modal.find('.loading').fadeIn(); + }, + success: function(data) { + console.log(data); + if(data.sucess.result == "1") { + // Hide Form & button + $modal.find('form, .requestButton').hide(); + $modal.find('.messageBlock').show(); + + // Noty Message + /* + * var message = $modal.find('.messageBlock .notyMessage').html(); var notyOptions = jQuery.extend({}, + * notyDefaultOptions); notyOptions.text = message; notyOptions.type = 'info'; notyOptions.timeout = 5000; + * notyOptions.animation = { open: 'animated fadeIn', // Animate.css class names close: 'animated fadeOut', // + * Animate.css class names easing: 'swing', // unavailable - no need speed: 400 // unavailable - no need }; + * notyOptions.callback = { onClose : function(){ $modal.modal('hide'); } }; $modal.find('.messageBlock + * .notyMessage').noty(notyOptions); + */ + } + }, + complete: function() { + $modal.find('.loading').fadeOut(); + } }); }); + /** + * CCAFS Partners list events + */ + $('.ppaPartnersList select').on('change', function(e) { + addItemList($(this).find('option:selected')); + }); + $('ul li .remove').on('click', function(e) { + removeItemList($(this).parents('li')); + }); + + /** + * Partner Person Events + */ + // Add partner Person Event + // $(".addContact a.addLink").on('click', addContactEvent); + $(".addContact").on('click', addContactEvent); + // Remove partner person event + $(".removePerson").on('click', removePersonEvent); + // When partnerPersonType change + $("select.partnerPersonType").on("change", changePartnerPersonType); + // Event when click in a relation tag of partner person + $(".tag").on("click", showPersonRelations); + } -function addIdo() { - console.log("add ido"); - var $itemsList = $(this).parent().find('.slos-list'); - var $item = $("#srfSlo-template").clone(true).removeAttr("id"); - $item.find('.blockTitle').trigger('click'); - $itemsList.append($item); - $item.slideDown('slow'); - updateIndexes(); - $item.trigger('addComponent'); +function showHelpText() { + $('.helpMessage').show(); + $('.helpMessage').addClass('animated flipInX'); } -function addIndicator() { - console.log("addIndicator"); - var $itemsList = $(this).parent().parent().find('.srfIndicators-list'); - var $item = $("#srfSloIndicator-template").clone(true).removeAttr("id"); +function getProjectLeader() { + var contactLeader = {}; + $partnersBlock.find('.contactPerson').each(function(i,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + if(contact.isLeader()) { + contactLeader = jQuery.extend({}, contact); + } + }); + return contactLeader; +} - $itemsList.append($item); - $item.slideDown('slow'); - updateIndexes(); - $item.trigger('addComponent'); +function setProjectLeader(obj) { + projectLeader = jQuery.extend({}, obj); } -function addTargets() { - console.log("addTargets"); - var $itemsList = $(this).parent().parent().find('.targetsList'); - var $item = $("#targetIndicator-template").clone(true).removeAttr("id"); - $itemsList.append($item); - $item.show('slow'); - updateIndexes(); - $item.trigger('addComponent'); +function filterInstitutions(e) { + var $filterContent = $(e.target).parent().next(); + if($filterContent.is(":visible")) { + updateOrganizationsList(e); + } + $filterContent.slideToggle(); } -function addCrossCuttingIssue() { - console.log("addCrossCuttingIssue"); - var $itemsList = $(this).parent().find('.issues-list'); - var $item = $("#srfCCIssue-template").clone(true).removeAttr("id"); +function showPersonRelations(e) { + var $relations = $(this).next().html(); + $('#relations-dialog').dialog({ + modal: true, + closeText: "", + width: 500, + buttons: { + Close: function() { + $(this).dialog("close"); + } + }, + open: function() { + $(this).html($relations); + }, + close: function() { + $(this).empty(); + } + }); +} - $itemsList.append($item); - $item.slideDown('slow'); - updateIndexes(); - $item.trigger('addComponent'); +function changePartnerPersonType(e) { + var $contactPerson = $(e.target).parents('.contactPerson'); + var contact = new PartnerPersonObject($contactPerson); + // Set as unique contact type in the project + if((contact.type == leaderType)) { + setPartnerTypeToDefault(contact.type); + } + // Change partner person type + contact.changeType(); + // Change parent partner type + var partner = new PartnerObject($contactPerson.parents('.projectPartner')); + partner.changeType(); + console.log(contact.type); + // If the contact type selected is PL + if(contact.type == leaderType) { + // If there is a PL previous selected + if(!jQuery.isEmptyObject(projectLeader)) { + var previousLeaderName = projectLeader.contactInfo; + var messages = '
  • Please note that there can only be one project leader per project.
    '; + messages += + 'Therefore ' + previousLeaderName + + ' was assigned a Project collaborator/partner role.
  • '; + // Show a pop up with the message + $("#contactChangeType-dialog").find('.messages').append(messages); + $("#contactChangeType-dialog").dialog({ + modal: true, + closeText: "", + width: 500, + buttons: { + Close: function() { + $(this).dialog("close"); + } + }, + close: function() { + $(this).find('.messages').empty(); + } + }); + } + } + // Update project leader contact person + setProjectLeader(getProjectLeader()); } -function removeElement() { - $item = $(this).parent(); - $item.hide('slow', function() { - $item.remove(); - updateIndexes(); - $(document).trigger('removeComponent'); +function updateOrganizationsList(e) { + var $parent = $(e.target).parents('.projectPartner'); + var partner = new PartnerObject($parent); + var $selectInstitutions = $parent.find("select.institutionsList"); // Institutions list + var optionSelected = $selectInstitutions.find('option:selected').val(); // Institution selected + var source = baseURL + "/institutionsByTypeAndCountry.do"; + + if($(e.target).parent().attr("class") != "filters-link") { + var partnerTypes = $parent.find("select.partnerTypes").find('option:selected').val() || -1; // Type value + var countryList = $parent.find("select.countryList").find('option:selected').val() || -1; // Value value + source += "?institutionTypeID=" + partnerTypes + "&countryID=" + countryList; + } else { + source += "?institutionTypeID=-1&countryID=-1"; + } + $.ajax({ + url: source, + beforeSend: function() { + partner.startLoader(); + $selectInstitutions.empty().append(setOption(-1, "Select an option")); + }, + success: function(data) { + $.each(data.institutions, function(index,institution) { + $selectInstitutions.append(setOption(institution.id, institution.name)); + }); + if(!canUpdatePPAPartners) { + removePPAPartnersFromList($selectInstitutions); + } + }, + complete: function() { + partner.stopLoader(); + $selectInstitutions.val(optionSelected); + $selectInstitutions.trigger("change.select2"); + } }); } -function updateIndexes() { - $('.slos-list .srfSlo').each(function(i,slo) { - // Updating indexes - $(slo).setNameIndexes(1, i); - $(slo).find('.srfSloIndicator').each(function(subIdoIndex,subIdo) { - // Updating indexes - $(subIdo).setNameIndexes(2, subIdoIndex); +function removePPAPartnersFromList(list) { + for(var i = 0, len = allPPAInstitutions.length; i < len; i++) { + $(list).find('option[value=' + allPPAInstitutions[i] + ']').remove(); + } + $(list).trigger("change.select2"); +} + +function updateProjectPPAPartnersLists(e) { + var projectInstitutions = []; + // Clean PPA partners from hidden select + $projectPPAPartners.empty(); + // Loop for all projects partners + $partnersBlock.find('.projectPartner').each(function(i,projectPartner) { + var partner = new PartnerObject($(projectPartner)); + // Collecting partners institutions + projectInstitutions.push(parseInt(partner.institutionId)); + // Validating if the partners is PPA Partner + if(partner.isPPA()) { + partner.hidePPAs(); + // Collecting list CCAFS partners from all project partners + $projectPPAPartners.append(setOption(partner.institutionId, partner.institutionName)); + } else { + if(partner.institutionId == -1) { + partner.hidePPAs(); + } else { + partner.showPPAs(); + } + } + }); + $projectPPAPartners.trigger("change.select2"); + + // Validating if the institution chosen is already selected + if(e) { + var $fieldError = $(e.target).parents('.partnerName').find('p.fieldErrorInstitutions'); + $fieldError.text(''); + var count = 0; + // Verify if the partner is already selected + for(var i = 0; i < projectInstitutions.length; ++i) { + if(projectInstitutions[i] == e.target.value) { + count++; + } + } + // If there is one selected , show an error message + if(count > 1) { + var institutionName = $(e.target).find('option[value="' + e.target.value + '"]').text(); + var institutionName_saved = + $('input.institutionsList[value=' + e.target.value + ']').parents('.projectPartner').find('.partnerTitle') + .text(); + $fieldError.html('"' + (institutionName || institutionName_saved) + '" is already selected').animateCss( + 'flipInX'); + e.target.value = -1; + } + } + + // Filling CCAFS partners lists for each project partner cooment + $partnersBlock.find('.projectPartner').each(function(i,partner) { + var $select = $(partner).find('select.ppaPartnersSelect'); + $select.empty().append(setOption(-1, "Select an option")); + $select.append($projectPPAPartners.html()); + // Removing of the list CCAFS partners previously selected by project partner + $(partner).find('li input.id').each(function(i_id,id) { + $select.find('option[value=' + $(id).val() + ']').remove(); }); + $select.trigger("change.select2"); }); - $('.issues-list .srfCCIssue').each(function(i,crossCutting) { - // Updating indexes - $(crossCutting).setNameIndexes(1, i); +} +function setPartnerTypeToDefault(type) { + $partnersBlock.find('.projectPartner').each(function(i,partner) { + var projectPartner = new PartnerObject($(partner)); + $(partner).find('.contactPerson').each(function(i,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + if(contact.type == type) { + $(partnerPerson).removeClass(partnerPersonTypes.join(' ')).addClass(defaultType); + contact.setPartnerType(defaultType); + } + }); + projectPartner.changeType(); }); } -/** - * Attach to the date fields the datepicker plugin - */ -function datePickerConfig(element) { - date($(element.startDate), $(element.endDate)); -} - -function date(start,end) { - var dateFormat = "yy-mm-dd"; - var from = $(start).datepicker({ - dateFormat: dateFormat, - minDate: '2023-01-01', - maxDate: '2026-12-31', - changeMonth: true, - numberOfMonths: 2, - changeYear: true, - onChangeMonthYear: function(year,month,inst) { - var selectedDate = new Date(inst.selectedYear, inst.selectedMonth, 1); - $(this).datepicker('setDate', selectedDate); - if(selectedDate != "") { - $(end).datepicker("option", "minDate", selectedDate); - } +function removePartnerEvent(e) { + e.preventDefault(); + var partner = new PartnerObject($(e.target).parent().parent()); + var messages = ""; + var activities = partner.getRelationsNumber('activities'); + var deliverables = partner.getRelationsNumber('deliverables'); + var partnerContributions = partner.hasPartnerContributions(); + var removeDialogOptions = { + modal: true, + width: 500, + buttons: {}, + closeText: "", + close: function() { + $(this).find('.messages').empty(); } - }).on("click", function() { - if(!$(this).val()) { - $(this).datepicker('setDate', new Date()); + }; + // The budget related with this partner will be deleted + if(partner.id != -1) { + // messages += '
  • Note that the budget affected to this partner will also be deleted.
  • '; + removeDialogOptions.buttons = { + "Remove partner": function() { + partner.remove(); + $(this).dialog("close"); + }, + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if there are any deliverables linked to any contact persons from this partner + if(deliverables > 0) { + messages += + '
  • Please bear in mind that if you delete this partner, ' + deliverables + + ' deliverables relations will be deleted
  • '; + removeDialogOptions.buttons = { + "Remove partner": function() { + partner.remove(); + $(this).dialog("close"); + }, + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if the CCAFS partner is currently contributing has any contributions to another partner + if(partner.isPPA() && (partnerContributions.length > 0)) { + messages += '
  • ' + partner.institutionName + ' is currently allocating budget to the following partner(s):'; + messages += '
      '; + for(var i = 0, len = partnerContributions.length; i < len; i++) { + messages += '
    • ' + partnerContributions[i] + '
    • '; } + messages += '
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if the project partner has any project leader assigned + if(partner.hasLeader()) { + messages += + '
  • Please indicate another project leader from a different partner before deleting this partner.
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if the user has privileges to remove CCAFS Partners + if(partner.isPPA() && !canUpdatePPAPartners) { + messages += '
  • You don\'t have enough privileges to delete CCAFS Partners.
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if there are any activity linked to any contact person of this partner + if(activities > 0) { + messages += + '
  • This partner cannot be deleted because at least one or more contact persons is leading ' + activities + + ' activity(ies)
  • '; + messages += + '
  • If you want to proceed with the deletion, please go to the activities and change the activity leader
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + + if(messages === "") { + // Remove partner if there is not any problem + partner.remove(); + } else { + // Show pop up if there are any message + $("#partnerRemove-dialog").find('.messages').append(messages); + $("#partnerRemove-dialog").dialog(removeDialogOptions); + } +} + +function addPartnerEvent(e) { + console.log("addPartnerEvent"); + var $newElement = $("#projectPartner-template").clone(true).removeAttr("id"); + $(this).before($newElement); + $newElement.find('.blockTitle').trigger('click'); + $newElement.show("slow", function() { + // Update component + $(document).trigger('updateComponent'); }); - var to = $(end).datepicker({ - dateFormat: dateFormat, - minDate: '2023-01-01', - maxDate: '2026-12-31', - changeMonth: true, - numberOfMonths: 2, - changeYear: true, - onChangeMonthYear: function(year,month,inst) { - var selectedDate = new Date(inst.selectedYear, inst.selectedMonth + 1, 0); - $(this).datepicker('setDate', selectedDate); - if(selectedDate != "") { - $(start).datepicker("option", "maxDate", selectedDate); + // Activate the select2 plugin for new partners created + // Organization + $newElement.find("select.institutionsList").select2(searchInstitutionsOptions(canUpdatePPAPartners)); + $newElement.find("select.institutionsList").parent().find("span.select2-selection__placeholder") + .text(placeholderText); + + // Role Selection + $newElement.find("select.partnerPersonType").select2({ + templateResult: formatState, + width: "100%" + }); + + // Research Phase + $newElement.find("select.researchPhasesSelect ").select2({ + placeholder: "Select here...", + width: '100%' + }); + + // Countries + $newElement.find('select.countriesList, select.countriesSelect').select2({ + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' + }); + + // Other Selects + $newElement.find('select.setSelect2').select2({ + width: '100%' + }); + + // Update indexes + setProjectPartnersIndexes(); +} + +function addContactEvent(e) { + e.preventDefault(); + var $newElement = $("#contactPerson-template").clone(true).removeAttr("id"); + var contact = new PartnerPersonObject($newElement); + var partner = new PartnerObject($(this).parents('.projectPartner')); + $(e.target).parent().before($newElement); + $newElement.show("slow"); + // Activate the select2 plugin for new partners created + $newElement.find("select").select2({ + templateResult: formatState, + width: '100%' + }); + + // IFPRI Division + if(partner.institutionId == 89){ + $newElement.find('.divisionBlock.division-IFPRI').show(); + } + + // Remove "No contact person added" message + $(e.target).parents('.contactsPerson').find('.noContactMessage').hide(); + + // Update PPA partners requirements + updateProjectPPAPartnersLists(); + + // Update indexes + setProjectPartnersIndexes(); +} + +function removePersonEvent(e) { + e.preventDefault(); + var person = new PartnerPersonObject($(e.target).parent()); + var messages = ""; + var activities = person.getRelationsNumber('activities'); + var deliverables = person.getRelationsNumber('deliverables'); + var removeDialogOptions = { + modal: true, + closeText: "", + width: 500, + buttons: {}, + close: function() { + $(this).find('.messages').empty(); + } + }; + // Validate if there are any deliverable linked to this person + if(deliverables > 0) { + messages += + '
  • Please bear in mind that if you delete this contact, ' + deliverables + + ' deliverables relations will be deleted.
  • '; + removeDialogOptions.buttons = { + "Remove Person": function() { + person.remove(); + $(this).dialog("close"); + }, + Close: function() { + $(this).dialog("close"); } + }; + } + // Validate if the person type is PL + if(person.isLeader()) { + messages += + '
  • There must be one project leader per project. Please select another project leader before deleting this contact.
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); } - }).on("click", function() { - if(!$(this).val()) { - $(this).datepicker('setDate', new Date()); - } + }; + } + // Validate if there are any activity linked to this person + if(activities > 0) { + messages += '
  • This contact person cannot be deleted because he/she is leading activity(ies)'; + messages += + '
  • If you want to proceed with the deletion, please go to the following activities and change the activity leader
  • '; + messages += '
      '; + messages += person.getRelations('activities'); + messages += '
    '; + messages += ''; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + if(messages === "") { + // Remove person if there is not any message + person.remove(); + } else { + // Show a pop up with the message + $("#contactRemove-dialog").find('.messages').append(messages); + $("#contactRemove-dialog").dialog(removeDialogOptions); + } +} + +function setProjectPartnersIndexes() { + $partnersBlock.find(".projectPartner").each(function(index,element) { + var partner = new PartnerObject($(element)); + partner.setIndex(index); + }); +} + +/** + * Items list functions + */ + +function removeItemList($item) { + // Adding option to the select + var $select = $item.parents('.panel').find('select'); + $select.append(setOption($item.find('.id').val(), $item.find('.name').text())); + $select.trigger("change.select2"); + // Removing from list + $item.hide("slow", function() { + $item.remove(); + setProjectPartnersIndexes(); + }); +} + +function addItemList($option) { + var $select = $option.parent(); + var $list = $option.parents('.panel').find('ul.list'); + // Adding element to the list + var $li = $("#ppaListTemplate").clone(true).removeAttr("id"); + $li.find('.id').val($option.val()); + $li.find('.name').html($option.text()); + $li.appendTo($list).hide().show('slow'); + // Removing option from select + $option.remove(); + $select.trigger("change.select2"); + setProjectPartnersIndexes(); +} + +// Activate the chosen plugin to the countries, partner types and partners lists. +function addSelect2() { + + // Organization / institution + $("form select.institutionsList").select2(searchInstitutionsOptions(canUpdatePPAPartners)); + $("form select.institutionsList").parent().find("span.select2-selection__placeholder").text(placeholderText); + + // Role Selection + $("form select.partnerPersonType").select2({ + templateResult: formatState, + width: "100%" + }); + + // Research Phase + $("form select.researchPhasesSelect ").select2({ + placeholder: "Select here...", + width: '100%' }); - function getDate(element) { - var date; - try { - date = $.datepicker.parseDate(dateFormat, element.value); - } catch(error) { - date = null; + + + $('form select.countriesList, select.countriesRequest, form select.countriesSelect').select2({ + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' + }); + + // Other selects + $("form select.setSelect2 ").select2({ + width: '100%' + }); + +} + +/** + * PartnerObject + * + * @param {DOM} Project partner + */ + +function PartnerObject(partner) { + + var types = []; + this.id = parseInt($(partner).find('.partnerId').val()); + this.institutionId = parseInt($(partner).find('.institutionsList').val()); + this.institutionName = + $('#instID-' + this.institutionId + ' .composedName').text() || $(partner).find('.partnerTitle').text(); + this.allowSubDepart = ($('#instID-' + this.institutionId + ' .allowSubDepart').text() === "true") || false; + this.subDepartments = $('#instID-' + this.institutionId + ' .subDepartments option'); + this.ppaPartnersList = $(partner).find('.ppaPartnersList'); + this.persons = $(partner).find('.contactsPerson .contactPerson'); + this.countriesSelect = $(partner).find('.countriesList'); + this.setIndex = function(index) { + + // Updating indexes + $(partner).setNameIndexes(1, index); + // Update index for project Partner + $(partner).find("> .blockTitle .index_number").html(index + 1); + // Update index for CCAFS Partners + $(partner).find('.ppaPartnersList ul.list li').each(function(li_index,li) { + $(li).setNameIndexes(2, li_index); + }); + + // Update radio buttons labels and for + $(partner).find('input.hasPartnerships-yes').attr('id', "hasPartnerships-yes-"+ index).next().attr('for',"hasPartnerships-yes-"+ index); + $(partner).find('input.hasPartnerships-no').attr('id', "hasPartnerships-no-"+ index).next().attr('for',"hasPartnerships-no-"+ index); + + // Update index for partner persons + $(partner).find('.contactPerson').each(function(person_index,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + contact.setIndex(index, person_index); + }); + + // Update index for locations + $(partner).find('.locElement').each(function(i,element) { + $(element).setNameIndexes(2, i); + }); + }; + this.validateGovernmentType = function() { + if(this.allowSubDepart) { + $(partner).find('.subDepartment').slideDown(); + } else { + $(partner).find('.subDepartment').slideUp(); + } + }; + this.updateBlockContent = function() { + $(partner).find('.partnerTitle').text(this.institutionName); + this.validateGovernmentType(); + }; + this.hasPartnerContributions = function() { + var partners = []; + var institutionId = this.institutionId; + $partnersBlock.find(".projectPartner").each(function(index,element) { + var projectPartner = new PartnerObject($(element)); + $(element).find('.ppaPartnersList ul.list li input.id').each(function(i_id,id) { + if($(id).val() == institutionId) { + partners.push(projectPartner.institutionName); + } + }); + }); + return partners; + }; + this.hasLeader = function() { + var result = false; + $(partner).find('.contactPerson').each(function(i,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + if(contact.isLeader()) { + result = true; + } + }); + return result; + }; + this.isPPA = function() { + var instID = parseInt($(partner).find('.institutionsList').val()); + if(instID == -1) { + $(partner).find("> .blockTitle .index").removeClass('ppa').text('Partner'); + return false; + } + if(allPPAInstitutions.indexOf(instID) != -1) { + $(partner).find("> .blockTitle .index").addClass('ppa').text('Managing Partner'); + return true; + } else { + $(partner).find("> .blockTitle .index").removeClass('ppa').text('Partner'); + return false; } + }; + this.getRelationsNumber = function(relation) { + var count = 0; + $(partner).find('.contactPerson').each(function(i,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + count += contact.getRelationsNumber(relation); + }); + return count; + }; + this.checkLeader = function() { + if($(partner).find('.contactPerson.PL').length == 0) { + $(partner).removeClass('leader'); + $(partner).find('.type-leader').hide(); + } else { + $(partner).find('.type-leader').show(); + $(partner).addClass('leader'); + types.push('Leader'); + } + }; + this.checkCoordinator = function() { + if($(partner).find('.contactPerson.PC').length == 0) { + $(partner).removeClass('coordinator'); + $(partner).find('.type-coordinator').hide(); + } else { + $(partner).addClass('coordinator'); + $(partner).find('.type-coordinator').show(); + types.push('Coordinator'); + } + }; + this.changeType = function() { + types = []; + this.checkLeader(); + this.checkCoordinator(); + if(types.length != 0) { + $(partner).find('strong.type').text(' (' + types.join(", ") + ')'); + } else { + $(partner).find('strong.type').text(''); + } + }; + this.remove = function() { + $(partner).hide("slow", function() { + $(partner).remove(); + updateProjectPPAPartnersLists(); + setProjectPartnersIndexes(); + }); + }; + this.clearCountries = function() { + var $list = $(partner).find(".countries-list.items-list ul"); + $list.empty(); + }; + this.addCountry = function(country) { + var contryISO = country.iso; + var countryName = country.name; + if(contryISO == "-1") { + return + + } + + var $list = $(partner).find(".items-list ul"); - return date; + var selectedCountries = $list.find('.locElement').map(function() { + return $(this).find('input.locElementCountry').val(); + }).get(); + + if(selectedCountries.indexOf(contryISO) != -1) { + var notyOptions = jQuery.extend({}, notyDefaultOptions); + notyOptions.text = 'Countries office cannot be repeated'; + noty(notyOptions); + return + + } + + var $item = $('#locElement-template').clone(true).removeAttr('id'); + + // Fill item values + $item.find('span.name').text(countryName); + $item.find('span.coordinates').text(""); + $item.find('input.locElementName').val(countryName); + $item.find('input.locElementCountry').val(contryISO); + + // Add Flag + var $flag = $item.find('.flag-icon'); + var flag = ''; + $flag.html(flag); + // Remove coordinates span + $item.find('.coordinates').remove(); + // Adding item to the list + $list.append($item); + // Update Locations Indexes + setProjectPartnersIndexes(); + // Show item + $item.show('slow'); + // Remove message + $list.parent().find('p.message').hide(); + + // Reset select + $(this.countriesSelect).removeOption(contryISO) + $(this.countriesSelect).val('-1'); + $(this.countriesSelect).trigger('select2:change'); + }; + this.showPPAs = function() { + $(this.ppaPartnersList).slideDown(); + // $(partner).find('.partnerResponsabilities .requiredTag').hide(); + $(partner).find('.contactsPerson .requiredTag').hide(); + }; + this.hidePPAs = function() { + $(this.ppaPartnersList).slideUp(); + + // Add a contact person by default + if($(this.persons).length <= 0) { + console.log('asdfasdf'); + $(partner).find('.addContact .addLink').trigger('click'); + } + + // $(partner).find('.partnerResponsabilities .requiredTag').show(); + $(partner).find('.contactsPerson .requiredTag').show(); + + }; + + this.startLoader = function() { + $(partner).find('.loading').fadeIn(); + }; + this.stopLoader = function() { + $(partner).find('.loading').fadeOut(); + }; +} + +/** + * PartnerPersonObject + * + * @param {DOM} Partner person + */ +function PartnerPersonObject(partnerPerson) { + this.id = parseInt($(partnerPerson).find('.partnerPersonId').val()); + this.type = $(partnerPerson).find('.partnerPersonType').val(); + this.contactInfo = $(partnerPerson).find('.userName').val(); + this.canEditEmail = ($(partnerPerson).find('input.canEditEmail').val() === "true"); + this.setPartnerType = function(type) { + this.type = type; + $(partnerPerson).find('.partnerPersonType').val(type).trigger('change.select2'); + }; + this.getPartnerType = function() { + return $(partnerPerson).find('.partnerPersonType').val(); + }; + this.changeType = function() { + $(partnerPerson).removeClass(partnerPersonTypes.join(' ')).addClass(this.type); + this.setPartnerType(this.type); + }; + this.getRelationsNumber = function(relation) { + return parseInt($(partnerPerson).find('.tag.' + relation + ' span').text()) || 0; + }; + this.getRelations = function(relation) { + return $(partnerPerson).find('.tag.' + relation).next().find('ul').html(); + }; + this.setIndex = function(partnerIndex,index) { + // Update Indexes + $(partnerPerson).setNameIndexes(2, index); + + // Update name & id for unused input + $(partnerPerson).find(".userName").attr("name", "partner-" + partnerIndex + "-person-" + index); + $(partnerPerson).find(".userName").attr("id", "partner-" + partnerIndex + "-person-" + index); + + }; + this.isLeader = function() { + return(this.type == leaderType); + }; + this.remove = function() { + var partner = new PartnerObject($(partnerPerson).parents('.projectPartner')); + $(partnerPerson).hide("slow", function() { + $(partnerPerson).remove(); + partner.changeType(this.type); + setProjectPartnersIndexes(); + }); + }; +} + +function formatState(state) { + var $state = + $("" + + state.text + + "
    " + + $('span.contactPersonRole-' + state.id).text() + "
    "); + return $state; + +}; + +function formatStateCountries(state) { + if(!state.id) { + return state.text; + } + var flag = ' '; + var $state; + if(state.id != -1) { + $state = $('' + flag + state.text + ''); + } else { + $state = $('' + state.text + ''); } + return $state; +}; + +// Locations (Country Offices) +function addLocElementCountry() { + var $partner = $(this).parents('.projectPartner'); + var partner = new PartnerObject($partner); + + var $countrySelected = $(this).find("option:selected"); + partner.addCountry({ + iso: $countrySelected.val(), + name: $countrySelected.text() + }); +} + +function removeLocElement() { + var $parent = $(this).parent(); + var $select = $parent.parents('.countries-list ').find('select.countriesList'); + // Add removed item to the selection list + $select.addOption($parent.find('input.locElementCountry').val(), $parent.find('span.name').text()); + // Removing item + $parent.hide('slow', function() { + $parent.remove(); + setProjectPartnersIndexes(); + }); } diff --git a/marlo-web/src/main/webapp/crp/js/projects/projectPartners.js b/marlo-web/src/main/webapp/crp/js/projects/projectPartners.js index 8d73a830de..e5752871fc 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/projectPartners.js +++ b/marlo-web/src/main/webapp/crp/js/projects/projectPartners.js @@ -1057,7 +1057,6 @@ function PartnerObject(partner) { // Add a contact person by default if($(this.persons).length <= 0) { - console.log('asdfasdf'); $(partner).find('.addContact .addLink').trigger('click'); } From d89d26410d1c2a7d1304d61985da80fa5dba0167 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Thu, 1 Feb 2024 17:00:00 -0500 Subject: [PATCH 15/65] :wrench: chore(shfrm Contribution): Update management module backend and frontend files --- .../crp/admin/ShfrmManagementAction.java | 28 +++++++++++++++---- .../src/main/resources/global.properties | 2 +- .../crp/views/admin/shfrmManagement.ftl | 4 +-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java index 285962a39a..e2a9f97e16 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java @@ -97,6 +97,15 @@ public String save() { try { priorityActionsDB = shfrmPriorityActionManager.findAll(); subActionsDB = shfrmSubActionManager.findAll(); + + if (priorityActions != null && !priorityActions.isEmpty()) { + for (ShfrmPriorityAction priorityAction : priorityActions) { + if (!priorityActionsDB.contains(priorityAction)) { + shfrmPriorityActionManager.deleteShfrmPriorityAction(priorityAction.getId()); + } + } + } + } catch (Exception e) { logger.info(e + "no sub actions added yet"); } @@ -115,9 +124,7 @@ public String save() { } shfrmPriorityActionManager.saveShfrmPriorityAction(actionSave); - if (priorityActionsDB != null && !priorityActionsDB.isEmpty() && !priorityActionsDB.contains(action)) { - shfrmPriorityActionManager.deleteShfrmPriorityAction(action.getId()); - } + // Save sub-actions if (action.getShfrmSubActions() != null && !action.getShfrmSubActions().isEmpty()) { @@ -134,10 +141,19 @@ public String save() { subActionSave.setDescription(subAction.getDescription()); } subActionSave.setShfrmPriorityAction(action); + try { + shfrmSubActionManager.saveShfrmSubAction(subActionSave); + } catch (Exception e) { + logger.info(e + " error saving sub action"); + } - shfrmSubActionManager.saveShfrmSubAction(subActionSave); - if (subActionsDB != null && !subActionsDB.isEmpty() && !subActionsDB.contains(subAction)) { - shfrmSubActionManager.deleteShfrmSubAction(subAction.getId()); + try { + if (subAction != null && subAction.getId() != null && subActionsDB != null && !subActionsDB.isEmpty() + && !subActionsDB.contains(subAction)) { + shfrmSubActionManager.deleteShfrmSubAction(subAction.getId()); + } + } catch (Exception e) { + logger.info(e + " error deleting sub action"); } } } diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index 26e0b15dea..8fe6347983 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -1989,7 +1989,7 @@ projectPhases.editable=Status shfrmManagement.title=Manage the Soil Health and Fertility Road Map (SHFRM) shfrmManagement.priorityActions.set=Set the control list for Priority Actions: shfrmManagement.priorityActions.title=Title -shfrmManagement.priorityActions.description=description +shfrmManagement.priorityActions.description=Description shfrmManagement.priorityActions.add=Add new priority action shfrmManagement.subActions.add=Add new sub-action shfrmManagement.subActions.title=Title diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index 356c8c9d12..90e0e87928 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -169,9 +169,9 @@

    - [#-- Action name -- + [#-- Action name --] -] +
    [@customForm.input name="${name}.name" i18nkey="shfrmManagement.priorityActions.title" className="name limitWords-100" required=true /]
    From 6ceeca9daf92d2892805c6d94f903ec2670b78aa Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Thu, 1 Feb 2024 23:23:40 -0500 Subject: [PATCH 16/65] :wrench: chore(shfrm Contribution): Update save process adding new priority action --- .../crp/admin/ShfrmManagementAction.java | 3 + .../crp/views/admin/shfrmManagement.ftl | 68 ++++--------------- 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java index e2a9f97e16..6d509e35d3 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java @@ -84,6 +84,9 @@ public void prepare() throws Exception { priorityActions = shfrmPriorityActionManager.findAll(); this.fillSubActions(); if (this.isHttpPost()) { + if (priorityActions != null) { + priorityActions.clear();; + } } } diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index 90e0e87928..4bbfa9a221 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -42,7 +42,7 @@
    [#-- Listing Partners --] - [#-- Partners list --] + [#-- Priority actions list --]
    [#if priorityActions?has_content] [#list priorityActions as priorityAction] @@ -128,12 +128,8 @@ [#------------------------------------------------------ ------------------------------------------------------] [#macro projectPartnerMacro element name index=-1 opened=false defaultPerson=false isTemplate=false] - [#local isLeader = (element.leader)!false/] - [#local isCoordinator = (element.coordinator)!false/] - [#local isPPA = (action.isPPA(element.institution))!false /] - [#local allowSubDep = ((element.subDepartment?has_content)!false) || ((element.institution.institutionType.subDepartmentActive)!false) ] -
    +
    [#-- Loading --] [#-- TODO: Please improve this validation at backend side --] @@ -146,24 +142,7 @@ [#-- Partner Title --]
    [#-- Title --] - ${index+1}. ${(element.shfrmPriorityAction.title)!'Priority Action'} - - [#-- Tags --] -
    - Leader - Coordinator - ${isPPA?string('Managing Partner','Partner')} -
    - - [#-- Contacts --] - [#if (element.partnerPersons)?? ]
    - [#list element.partnerPersons as partnerPerson] - [#if partnerPerson.user?? && partnerPerson.user.firstName??] - [${(partnerPerson.user.composedCompleteName)!}] - [/#if] - [/#list] - [/#if] -
    + ${index+1}. ${(element.name)!'Priority Action'}
    @@ -187,36 +166,22 @@
    [@s.text name="shfrmManagement.subActions.add" /] [@customForm.req required=true /]
    - [#if element.shfrmSubActions?has_content] - [#list element.shfrmSubActions as subAction] - [@contactPersonMacro element=subAction name="${name}.subActions[$subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] - [/#list] - [#else] - [#if isPPA || defaultPerson] - [@contactPersonMacro element={} name="${name}subActions[0]" index=0 partnerIndex=index institutionID=(element.institution.id)!-1 /] - [#else] -

    [@s.text name="shfrmManagement.subActionsEmpty" /]

    + [#if element.shfrmSubActions?has_content] + [#list element.shfrmSubActions as subAction] + [@contactPersonMacro element=subAction name="${name}.subActions[${subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] + [/#list] + [#else] +

    [@s.text name="shfrmManagement.subActionsEmpty" /]

    + [/#if] + [#if (editable && canEdit)] +
    [@s.text name="shfrmManagement.subActions.add"/]
    [/#if] - [/#if] - [#if (editable && canEdit)] -
    [@s.text name="shfrmManagement.subActions.add"/]
    - [/#if] - [#-- -
    -
    [@s.text name="shfrmManagement.priorityActions.add" /]
    ---] +
    - - [#-- Deliverables --] - [#if !isTemplate] -
    - [@popUps.relationsMacro element=element /] -
    - [/#if] - +
    [/#macro] @@ -230,7 +195,6 @@
    - [#local isPPA = (action.isPPA(element.projectPartner.institution))!false /] [#if customForm.changedField('${name}.id') != ''] Added/Updated @@ -242,10 +206,8 @@ [@customForm.input name="${name}.name" className="partnerPersonType" editable=editable i18nkey="shfrmManagement.subActions.title" value="${(element.name)!}" /]
    [#-- Sub action description --] -
    - +
    [@customForm.input name="${name}.description" value="${(element.description)!}" type="text" i18nkey="shfrmManagement.subActions.description" required=true editable=editable /] -
    From ac7cfcac4092996de81d48d36bafefbd6871a78e Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 09:19:19 -0500 Subject: [PATCH 17/65] :wrench: chore(shfrm Contribution): Create specificity for shfrm modules --- .../cgiar/ccafs/marlo/config/APConstants.java | 1 + .../org/cgiar/ccafs/marlo/action/BaseAction.java | 9 +++++++++ .../cgiar/ccafs/marlo/config/APConstants.java | 1 + ...240202_0840__AddSpecifityForShfrmFunction.sql | 6 ++++++ .../WEB-INF/crp/views/admin/menu-admin.ftl | 2 +- .../crp/views/projects/deliverableInfo.ftl | 16 ++++++++++------ .../WEB-INF/global/macros/deliverableMacros.ftl | 6 +++++- 7 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0840__AddSpecifityForShfrmFunction.sql diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index 642892b1a2..c5899d044f 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -150,6 +150,7 @@ public final class APConstants { public static final String DELIVERABLE_SHARED_CLUSTERS_TRAINEES_ACTIVE = "deliverable_shared_clusters_trainees_active"; public static final String HIGHLIGHT_COMMENTS_ACTIVE = "highlight_comments_active"; + public static final String SHFRM_CONTRIBUTION_ACTIVE = "shfrm_contribution_active"; public static final String IS_EXPECTED_DELIVERABLE_REPORT_All_YEARS_VISIBLE = "is_expected_deliverable_report_all_years_visible"; diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java index 9c2543c9d5..6c8668c3d0 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java @@ -137,6 +137,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.formula.functions.T; import org.apache.struts2.ServletActionContext; import org.apache.struts2.dispatcher.Parameter; import org.apache.struts2.interceptor.ServletRequestAware; @@ -7288,6 +7289,14 @@ public boolean isSaveable() { return this.saveable; } + public boolean isShfrmSpecificityActive() { + try { + return Boolean.parseBoolean(this.getSession().get(APConstants.SHFRM_CONTRIBUTION_ACTIVE).toString()); + } catch (Exception e) { + return false; + } + } + public boolean isSubmit(long projectID) { Project project = this.projectManager.getProjectById(projectID); int year = this.getCurrentCycleYear(); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index 0bd041b306..0d6868713e 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -160,6 +160,7 @@ public final class APConstants { public static final String DELIVERABLE_SHARED_CLUSTERS_TRAINEES_ACTIVE = "deliverable_shared_clusters_trainees_active"; public static final String HIGHLIGHT_COMMENTS_ACTIVE = "highlight_comments_active"; + public static final String SHFRM_CONTRIBUTION_ACTIVE = "shfrm_contribution_active"; public static final String IS_EXPECTED_DELIVERABLE_REPORT_All_YEARS_VISIBLE = diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0840__AddSpecifityForShfrmFunction.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0840__AddSpecifityForShfrmFunction.sql new file mode 100644 index 0000000000..eeeac93d5f --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0840__AddSpecifityForShfrmFunction.sql @@ -0,0 +1,6 @@ +INSERT INTO parameters (global_unit_type_id, `key`, `description`, `format`, default_value, category) +VALUES ( '1', 'shfrm_contribution_active', 'Enable shfrm deliverables contribution functionality)', '1', 'false', '2'); +INSERT INTO parameters (global_unit_type_id, `key`, `description`, `format`, default_value, category) +VALUES ( '3', 'shfrm_contribution_active', 'Enable shfrm deliverables contribution functionality', '1', 'false', '2'); +INSERT INTO parameters (global_unit_type_id, `key`, `description`, `format`, default_value, category) +VALUES ( '4', 'shfrm_contribution_active', 'Enable shfrm deliverables contribution functionality', '1', 'false', '2'); \ No newline at end of file diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl index fced38788f..1bd75f651f 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl @@ -30,7 +30,7 @@ { 'slug': 'targetUnits', 'name': 'CRPAdmin.menu.hrefTargetUnits', 'action': 'targetUnits', 'active': true }, <#-- { 'slug': 'institutions', 'name': 'menu.superadmin.institutions', 'action': 'marloInstitutions', 'active': true }, --> { 'slug': 'crpPhases', 'name': 'CRPAdmin.menu.crpPhases', 'action': 'crpPhases', 'active': true }, - { 'slug': 'shfrmManagement', 'name': 'CRPAdmin.menu.shfrmManagement', 'action': 'shfrmManagement', 'active': true } + { 'slug': 'shfrmManagement', 'name': 'CRPAdmin.menu.shfrmManagement', 'action': 'shfrmManagement', 'active': action.isShfrmSpecificityActive()} ]/] [/#if] diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl index 63e95de067..5e8b6880fb 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl @@ -137,13 +137,17 @@ There are required fields still incompleted [/#if]
    - - [#-- Shfmr Sub Actions Template --] - [@deliverableMacros.shfmrSubActionMacro element={} name="feedbackFields[-1]" index=-1 isTemplate=true /] - - [#-- SHRFM contribution --] - [@deliverableMacros.shfmrContributionMacro /] + + [#if action.hasSpecificities('shfrm_contribution_active') ] + [#-- SHRFM contribution --] + [@deliverableMacros.shfmrContributionMacro /] + + [#-- Shfmr Sub Actions Template + [@deliverableMacros.shfmrSubActionMacro element={} name="feedbackFields[-1]" index=-1 isTemplate=true /] + --] + [/#if] + [#-- Key Outputs select --] [#if !project.projectInfo.administrative && !phaseOne && !isCenterProject ]
    diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 2ecf0674b8..03d7f3e4a9 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -577,7 +577,11 @@
    - + [#if reportingActive] + + [#else] + + [/#if]

    [@s.text name="deliverable.shfrmContribution.question.help" /]

    From 668f0ce69c5e18703885c6eaff4ef75ba3511d07 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 09:20:12 -0500 Subject: [PATCH 18/65] :wrench: chore(shfrm Contribution): Update shfrm tables --- .../V2_6_0_20240202_0728__UpdateShfrmTables.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0728__UpdateShfrmTables.sql diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0728__UpdateShfrmTables.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0728__UpdateShfrmTables.sql new file mode 100644 index 0000000000..cc6d618c46 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0728__UpdateShfrmTables.sql @@ -0,0 +1,10 @@ +ALTER TABLE shfrm_priority_actions MODIFY COLUMN is_active tinyint(1) DEFAULT 1 NOT NULL; + +ALTER TABLE shfrm_sub_actions MODIFY COLUMN is_active tinyint(1) DEFAULT 1 NOT NULL; + +ALTER TABLE deliverable_shfrm_priority_action MODIFY COLUMN is_active tinyint(1) DEFAULT 1 NOT NULL; + +ALTER TABLE deliverable_shfmr_sub_action MODIFY COLUMN is_active tinyint(1) DEFAULT 1 NOT NULL; + + + From f5cbcf4353463fdd5dcce46b5d6c76534b9675fe Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 09:51:39 -0500 Subject: [PATCH 19/65] :wrench: chore(shfrm Contribution): Create soil indicators table migration --- ..._20240202_0841__CreateShfrmSoilIndicatorsTable.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0841__CreateShfrmSoilIndicatorsTable.sql diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0841__CreateShfrmSoilIndicatorsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0841__CreateShfrmSoilIndicatorsTable.sql new file mode 100644 index 0000000000..48be03b98a --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0841__CreateShfrmSoilIndicatorsTable.sql @@ -0,0 +1,11 @@ +CREATE TABLE soil_indicators ( + id bigint(20) auto_increment NOT NULL, + indicator_name varchar(100) NOT NULL, + indicador_id bigint(20) NULL, + id_phase bigint(20) NOT NULL, + CONSTRAINT soil_indicators_pk PRIMARY KEY (id), + CONSTRAINT soil_indicators_phases_FK FOREIGN KEY (id_phase) REFERENCES phases(id) ON DELETE RESTRICT ON UPDATE RESTRICT +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_general_ci; \ No newline at end of file From 4cd96604778c36183b6bdea3f5236a595436fd31 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 09:52:28 -0500 Subject: [PATCH 20/65] :wrench: chore(shfrm Contribution): Create soil indicators DB mapping and java models --- .../marlo/data/dao/SoilIndicatorDAO.java | 67 +++++++++++++++ .../data/dao/mysql/SoilIndicatorMySQLDAO.java | 84 ++++++++++++++++++ .../data/manager/SoilIndicatorManager.java | 74 ++++++++++++++++ .../impl/SoilIndicatorManagerImpl.java | 77 +++++++++++++++++ .../ccafs/marlo/data/model/SoilIndicator.java | 86 +++++++++++++++++++ .../src/main/resources/hibernate.cfg.xml | 1 + .../resources/xmls/SoilIndicators.hbm.xml | 21 +++++ 7 files changed, 410 insertions(+) create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/SoilIndicatorDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/SoilIndicatorManager.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/SoilIndicatorManagerImpl.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/SoilIndicator.java create mode 100644 marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/SoilIndicatorDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/SoilIndicatorDAO.java new file mode 100644 index 0000000000..f6e8bc75fd --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/SoilIndicatorDAO.java @@ -0,0 +1,67 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; + +import java.util.List; + + +public interface SoilIndicatorDAO { + + /** + * This method removes a specific soilIndicator value from the database. + * + * @param soilIndicatorId is the soilIndicator identifier. + * @return true if the soilIndicator was successfully deleted, false otherwise. + */ + public void deleteSoilIndicator(long soilIndicatorId); + + /** + * This method validate if the soilIndicator identify with the given id exists in the system. + * + * @param soilIndicatorID is a soilIndicator identifier. + * @return true if the soilIndicator exists, false otherwise. + */ + public boolean existSoilIndicator(long soilIndicatorID); + + /** + * This method gets a soilIndicator object by a given soilIndicator identifier. + * + * @param soilIndicatorID is the soilIndicator identifier. + * @return a SoilIndicator object. + */ + public SoilIndicator find(long id); + + /** + * This method gets a list of soilIndicator that are active + * + * @return a list from SoilIndicator null if no exist records + */ + public List findAll(); + + + /** + * This method saves the information of the given soilIndicator + * + * @param soilIndicator - is the soilIndicator object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the soilIndicator was + * updated + * or -1 is some error occurred. + */ + public SoilIndicator save(SoilIndicator soilIndicator); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java new file mode 100644 index 0000000000..e9dde2912d --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java @@ -0,0 +1,84 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.SoilIndicatorDAO; +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class SoilIndicatorMySQLDAO extends AbstractMarloDAO implements SoilIndicatorDAO { + + + @Inject + public SoilIndicatorMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteSoilIndicator(long soilIndicatorId) { + SoilIndicator soilIndicator = this.find(soilIndicatorId); + this.delete(soilIndicator); + } + + @Override + public boolean existSoilIndicator(long soilIndicatorID) { + SoilIndicator soilIndicator = this.find(soilIndicatorID); + if (soilIndicator == null) { + return false; + } + return true; + + } + + @Override + public SoilIndicator find(long id) { + return super.find(SoilIndicator.class, id); + + } + + @Override + public List findAll() { + String query = "from " + SoilIndicator.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public SoilIndicator save(SoilIndicator soilIndicator) { + if (soilIndicator.getId() == null) { + super.saveEntity(soilIndicator); + } else { + soilIndicator = super.update(soilIndicator); + } + + + return soilIndicator; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/SoilIndicatorManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/SoilIndicatorManager.java new file mode 100644 index 0000000000..64000356a1 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/SoilIndicatorManager.java @@ -0,0 +1,74 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface SoilIndicatorManager { + + + /** + * This method removes a specific soilIndicator value from the database. + * + * @param soilIndicatorId is the soilIndicator identifier. + * @return true if the soilIndicator was successfully deleted, false otherwise. + */ + public void deleteSoilIndicator(long soilIndicatorId); + + + /** + * This method validate if the soilIndicator identify with the given id exists in the system. + * + * @param soilIndicatorID is a soilIndicator identifier. + * @return true if the soilIndicator exists, false otherwise. + */ + public boolean existSoilIndicator(long soilIndicatorID); + + + /** + * This method gets a list of soilIndicator that are active + * + * @return a list from SoilIndicator null if no exist records + */ + public List findAll(); + + + /** + * This method gets a soilIndicator object by a given soilIndicator identifier. + * + * @param soilIndicatorID is the soilIndicator identifier. + * @return a SoilIndicator object. + */ + public SoilIndicator getSoilIndicatorById(long soilIndicatorID); + + /** + * This method saves the information of the given soilIndicator + * + * @param soilIndicator - is the soilIndicator object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the soilIndicator was + * updated + * or -1 is some error occurred. + */ + public SoilIndicator saveSoilIndicator(SoilIndicator soilIndicator); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/SoilIndicatorManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/SoilIndicatorManagerImpl.java new file mode 100644 index 0000000000..f1508bc6b0 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/SoilIndicatorManagerImpl.java @@ -0,0 +1,77 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.SoilIndicatorDAO; +import org.cgiar.ccafs.marlo.data.manager.SoilIndicatorManager; +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author CCAFS + */ +@Named +public class SoilIndicatorManagerImpl implements SoilIndicatorManager { + + + private SoilIndicatorDAO soilIndicatorDAO; + // Managers + + + @Inject + public SoilIndicatorManagerImpl(SoilIndicatorDAO soilIndicatorDAO) { + this.soilIndicatorDAO = soilIndicatorDAO; + + + } + + @Override + public void deleteSoilIndicator(long soilIndicatorId) { + + soilIndicatorDAO.deleteSoilIndicator(soilIndicatorId); + } + + @Override + public boolean existSoilIndicator(long soilIndicatorID) { + + return soilIndicatorDAO.existSoilIndicator(soilIndicatorID); + } + + @Override + public List findAll() { + + return soilIndicatorDAO.findAll(); + + } + + @Override + public SoilIndicator getSoilIndicatorById(long soilIndicatorID) { + + return soilIndicatorDAO.find(soilIndicatorID); + } + + @Override + public SoilIndicator saveSoilIndicator(SoilIndicator soilIndicator) { + + return soilIndicatorDAO.save(soilIndicator); + } + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/SoilIndicator.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/SoilIndicator.java new file mode 100644 index 0000000000..2f6b39452e --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/SoilIndicator.java @@ -0,0 +1,86 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + +package org.cgiar.ccafs.marlo.data.model; + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import com.google.gson.annotations.Expose; + +public class SoilIndicator extends MarloBaseEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -963914989396761020L; + + @Expose + private String indicatorName; + @Expose + private long indicatorId; + @Expose + private Phase phase; + + public long getIndicatorId() { + return indicatorId; + } + + public String getIndicatorName() { + return indicatorName; + } + + @Override + public String getLogDeatil() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getModificationJustification() { + // TODO Auto-generated method stub + return null; + } + + @Override + public User getModifiedBy() { + // TODO Auto-generated method stub + return null; + } + + public Phase getPhase() { + return phase; + } + + @Override + public boolean isActive() { + // TODO Auto-generated method stub + return false; + } + + public void setIndicatorId(long indicatorId) { + this.indicatorId = indicatorId; + } + + public void setIndicatorName(String indicatorName) { + this.indicatorName = indicatorName; + } + + @Override + public void setModifiedBy(User modifiedBy) { + // TODO Auto-generated method stub + } + + public void setPhase(Phase phase) { + this.phase = phase; + } +} + diff --git a/marlo-data/src/main/resources/hibernate.cfg.xml b/marlo-data/src/main/resources/hibernate.cfg.xml index 84c8dddd60..0e11e5f8a7 100644 --- a/marlo-data/src/main/resources/hibernate.cfg.xml +++ b/marlo-data/src/main/resources/hibernate.cfg.xml @@ -433,6 +433,7 @@ + diff --git a/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml b/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml new file mode 100644 index 0000000000..24091dd12f --- /dev/null +++ b/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 4f816b889a55d6d92cf56ebbf2bee9ff7fe293d2 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 09:53:41 -0500 Subject: [PATCH 21/65] :wrench: chore(shfrm Contribution): Creation of save process in shfrm priority actions and sub actions --- .../crp/admin/ShfrmManagementAction.java | 82 ++++++++++++++----- .../crp/views/admin/shfrmManagement.ftl | 13 +-- 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java index 6d509e35d3..4d50a33c43 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java @@ -23,6 +23,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import javax.inject.Inject; @@ -93,21 +95,55 @@ public void prepare() throws Exception { @Override public String save() { if (this.canAcessCrpAdmin()) { - if (this.priorityActions != null && !this.priorityActions.isEmpty()) { + List subActionstoDelete = new ArrayList<>(); + try { List priorityActionsDB = null; List subActionsDB = null; - try { - priorityActionsDB = shfrmPriorityActionManager.findAll(); - subActionsDB = shfrmSubActionManager.findAll(); + priorityActionsDB = shfrmPriorityActionManager.findAll(); + subActionsDB = shfrmSubActionManager.findAll(); + if (this.priorityActions != null && !this.priorityActions.isEmpty()) { + for (ShfrmPriorityAction action : this.priorityActions) { + + // Remove Sub actions + if (action.getShfrmSubActions() != null && !action.getShfrmSubActions().isEmpty()) { + // Obtener los IDs de las subacciones en action.getShfrmSubActions() + Set subActionIdsInFrontend = action.getShfrmSubActions().stream().filter(Objects::nonNull) + .map(ShfrmSubAction::getId).collect(Collectors.toSet()); + + // Filter subActionsDB to retain only the subactions present in action.getShfrmSubActions() + subActionsDB = subActionsDB.stream() + .filter(subActionDB -> subActionDB.getShfrmPriorityAction() != null + && subActionDB.getShfrmPriorityAction().getId() != null + && subActionDB.getShfrmPriorityAction().getId().equals(action.getId()) + && !subActionIdsInFrontend.contains(subActionDB.getId())) + .collect(Collectors.toList()); + + // Delete subactions from subActionsDB that are not in action.getShfrmSubActions() + subActionsDB.forEach(subActionDB -> { + shfrmSubActionManager.deleteShfrmSubAction(subActionDB.getId()); + action.getShfrmSubActions().removeIf(sa -> sa.getId().equals(subActionDB.getId())); + subActionstoDelete.add(subActionDB); + }); - if (priorityActions != null && !priorityActions.isEmpty()) { - for (ShfrmPriorityAction priorityAction : priorityActions) { - if (!priorityActionsDB.contains(priorityAction)) { - shfrmPriorityActionManager.deleteShfrmPriorityAction(priorityAction.getId()); - } } + + } + } + + } catch (Exception e) { + logger.info(e + " error deleting sub action"); + } + + + if (this.priorityActions != null && !this.priorityActions.isEmpty()) { + + // List priorityActionsDB = null; + // List subActionsDB = null; + try { + // priorityActionsDB = shfrmPriorityActionManager.findAll(); + // subActionsDB = shfrmSubActionManager.findAll(); } catch (Exception e) { logger.info(e + "no sub actions added yet"); @@ -119,15 +155,26 @@ public String save() { if (action.getId() != null) { actionSave = shfrmPriorityActionManager.getShfrmPriorityActionById(action.getId()); } + + if (subActionstoDelete != null && !subActionstoDelete.isEmpty()) { + for (ShfrmSubAction subActiontoDelete : subActionstoDelete) { + actionSave.getShfrmSubActions().remove(subActiontoDelete); + } + } + if (action.getName() != null) { actionSave.setName(action.getName()); } if (action.getDescription() != null) { actionSave.setDescription(action.getDescription()); } + List subActionsTemp = new ArrayList<>(); + if (action.getShfrmSubActions() != null && !action.getShfrmSubActions().isEmpty()) { + subActionsTemp = action.getShfrmSubActions(); + } - shfrmPriorityActionManager.saveShfrmPriorityAction(actionSave); - + action = shfrmPriorityActionManager.saveShfrmPriorityAction(actionSave); + action.setShfrmSubActions(subActionsTemp); // Save sub-actions if (action.getShfrmSubActions() != null && !action.getShfrmSubActions().isEmpty()) { @@ -143,21 +190,14 @@ public String save() { if (subAction.getDescription() != null) { subActionSave.setDescription(subAction.getDescription()); } - subActionSave.setShfrmPriorityAction(action); + if (action.getId() != null) { + subActionSave.setShfrmPriorityAction(action); + } try { shfrmSubActionManager.saveShfrmSubAction(subActionSave); } catch (Exception e) { logger.info(e + " error saving sub action"); } - - try { - if (subAction != null && subAction.getId() != null && subActionsDB != null && !subActionsDB.isEmpty() - && !subActionsDB.contains(subAction)) { - shfrmSubActionManager.deleteShfrmSubAction(subAction.getId()); - } - } catch (Exception e) { - logger.info(e + " error deleting sub action"); - } } } } diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index 4bbfa9a221..5949cce2a4 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -75,17 +75,6 @@ [#-- Contact person TEMPLATE from partnersTemplate.ftl --] [@contactPersonMacro element={} name="priorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] -[#-- PPA list Template --] -
      -
    • - - - - - [#if editable][@s.text name="form.buttons.remove" /][/#if] -
    • -
    - [#-- Project roles descriptions --] @@ -168,7 +157,7 @@
    [#if element.shfrmSubActions?has_content] [#list element.shfrmSubActions as subAction] - [@contactPersonMacro element=subAction name="${name}.subActions[${subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] + [@contactPersonMacro element=subAction name="${name}.shfrmSubActions[${subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] [/#list] [#else]

    [@s.text name="shfrmManagement.subActionsEmpty" /]

    From 56f92cb04b1a573b072c4517dd2ecf08c6de30c5 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 14:57:03 -0500 Subject: [PATCH 22/65] :wrench: chore(shfrm Contribution): Create migration to update soil indicators table field --- .../V2_6_0_20240202_1445__UpdateShfrmSoilIndicatorsField.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1445__UpdateShfrmSoilIndicatorsField.sql diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1445__UpdateShfrmSoilIndicatorsField.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1445__UpdateShfrmSoilIndicatorsField.sql new file mode 100644 index 0000000000..c5807f8b8c --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1445__UpdateShfrmSoilIndicatorsField.sql @@ -0,0 +1 @@ +ALTER TABLE soil_indicators CHANGE indicador_id indicator_id bigint(20) NULL; From e4b740f8d765f23eb9e2a4f9858511aaaec9bb8e Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 14:57:47 -0500 Subject: [PATCH 23/65] :wrench: chore(shfrm Contribution): Update soil indicator table model --- .../cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java | 2 +- marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java index e9dde2912d..04f9275ac2 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java @@ -59,7 +59,7 @@ public SoilIndicator find(long id) { @Override public List findAll() { - String query = "from " + SoilIndicator.class.getName() + " where is_active=1"; + String query = "from " + SoilIndicator.class.getName(); List list = super.findAll(query); if (list.size() > 0) { return list; diff --git a/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml b/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml index 24091dd12f..ff77d7c3dd 100644 --- a/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml +++ b/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml @@ -9,7 +9,7 @@ - + From 17f3dcd88a2262dae1855279dcb9f39187801c37 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 15:01:16 -0500 Subject: [PATCH 24/65] :wrench: chore(shfrm Contribution): Create shfrm question and narrative save in deliverable section --- .../marlo/data/model/DeliverableInfo.java | 13 +++--- .../projects/DeliverableValidator.java | 45 ++++++++++++++++++- .../crp/views/projects/deliverableInfo.ftl | 5 --- .../global/macros/deliverableMacros.ftl | 32 ++----------- 4 files changed, 54 insertions(+), 41 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java index 92abd509db..3bb1db091c 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java @@ -50,7 +50,7 @@ public class DeliverableInfo extends MarloAuditableEntity implements java.io.Ser @Expose private Boolean contributingShfrm; @Expose - private Boolean shfrmContributionNarrative; + private String shfrmContributionNarrative; public DeliverableInfo() { } @@ -121,7 +121,7 @@ public Boolean getRemainingPending() { } - public Boolean getShfrmContributionNarrative() { + public String getShfrmContributionNarrative() { return shfrmContributionNarrative; } @@ -232,6 +232,7 @@ public Boolean isPrevious() { return false; } + public Boolean isRequiredToBeReported() { if (this.getStatus() == null) { return true; @@ -375,25 +376,24 @@ public void setAdoptedLicense(Boolean adoptedLicense) { this.adoptedLicense = adoptedLicense; } - public void setContributingShfrm(Boolean contributingShfrm) { this.contributingShfrm = contributingShfrm; } + public void setCrpClusterKeyOutput(CrpClusterKeyOutput crpClusterKeyOutput) { this.crpClusterKeyOutput = crpClusterKeyOutput; } - public void setCrpProgramOutcome(CrpProgramOutcome crpProgramOutcome) { this.crpProgramOutcome = crpProgramOutcome; } + public void setDeliverable(Deliverable deliverable) { this.deliverable = deliverable; } - public void setDeliverableType(DeliverableType deliverableType) { this.deliverableType = deliverableType; } @@ -430,7 +430,7 @@ public void setRemainingPending(Boolean remainingPending) { this.remainingPending = remainingPending; } - public void setShfrmContributionNarrative(Boolean shfrmContributionNarrative) { + public void setShfrmContributionNarrative(String shfrmContributionNarrative) { this.shfrmContributionNarrative = shfrmContributionNarrative; } @@ -472,6 +472,5 @@ public void updateDeliverableInfo(DeliverableInfo update) { this.setContributingShfrm(update.getContributingShfrm()); this.setShfrmContributionNarrative(update.getShfrmContributionNarrative()); } - } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java index 765e29bb68..d5b03680ed 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java @@ -24,9 +24,11 @@ import org.cgiar.ccafs.marlo.data.manager.ProjectManager; import org.cgiar.ccafs.marlo.data.manager.ProjectPartnerPersonManager; import org.cgiar.ccafs.marlo.data.manager.RepIndTypeActivityManager; +import org.cgiar.ccafs.marlo.data.manager.SoilIndicatorManager; import org.cgiar.ccafs.marlo.data.model.CgiarCrossCuttingMarker; import org.cgiar.ccafs.marlo.data.model.Deliverable; import org.cgiar.ccafs.marlo.data.model.DeliverableCrossCuttingMarker; +import org.cgiar.ccafs.marlo.data.model.DeliverableCrpOutcome; import org.cgiar.ccafs.marlo.data.model.DeliverableDissemination; import org.cgiar.ccafs.marlo.data.model.DeliverableGeographicScope; import org.cgiar.ccafs.marlo.data.model.DeliverableInfo; @@ -38,12 +40,14 @@ import org.cgiar.ccafs.marlo.data.model.ProjectSectionStatusEnum; import org.cgiar.ccafs.marlo.data.model.ProjectStatusEnum; import org.cgiar.ccafs.marlo.data.model.RepIndTypeActivity; +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; import org.cgiar.ccafs.marlo.utils.InvalidFieldsMessages; import org.cgiar.ccafs.marlo.utils.doi.DOIService; import org.cgiar.ccafs.marlo.validation.BaseValidator; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -69,6 +73,7 @@ public class DeliverableValidator extends BaseValidator { private DeliverableUserManager deliverableUserManager; private CgiarCrossCuttingMarkerManager cgiarCrossCuttingMarkerManager; private RepIndTypeActivityManager repIndTypeActivityManager; + private SoilIndicatorManager soilIndicatorManager; Boolean doesNotHaveDOI; @@ -76,13 +81,14 @@ public class DeliverableValidator extends BaseValidator { public DeliverableValidator(GlobalUnitManager crpManager, ProjectManager projectManager, ProjectPartnerPersonManager projectPartnerPersonManager, CgiarCrossCuttingMarkerManager cgiarCrossCuttingMarkerManager, RepIndTypeActivityManager repIndTypeActivityManager, - DeliverableUserManager deliverableUserManager) { + DeliverableUserManager deliverableUserManager, SoilIndicatorManager soilIndicatorManager) { this.crpManager = crpManager; this.projectManager = projectManager; this.projectPartnerPersonManager = projectPartnerPersonManager; this.cgiarCrossCuttingMarkerManager = cgiarCrossCuttingMarkerManager; this.deliverableUserManager = deliverableUserManager; this.repIndTypeActivityManager = repIndTypeActivityManager; + this.soilIndicatorManager = soilIndicatorManager; } private Path getAutoSaveFilePath(Deliverable deliverable, long crpID, BaseAction action) { @@ -525,6 +531,43 @@ public void validate(BaseAction action, Deliverable deliverable, boolean saving) } } + // SHFRM contribution validations + + if (action.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE) && dInfo != null + && dInfo.getContributingShfrm() != null && dInfo.getContributingShfrm() == true) { + + // Validate Soil indicators + if (deliverable.getCrpOutcomes() == null || !deliverable.getCrpOutcomes().isEmpty()) { + List soilIndicators = new ArrayList<>(); + soilIndicators = soilIndicatorManager.findAll(); + + for (DeliverableCrpOutcome indicator : deliverable.getCrpOutcomes()) { + if (soilIndicators != null && !soilIndicators.isEmpty()) { + for (SoilIndicator soilIndicator : soilIndicators) { + if (soilIndicator != null && soilIndicator.getIndicatorName() != null && indicator != null + && indicator.getCrpProgramOutcome() != null && indicator.getCrpProgramOutcome().getAcronym() != null + && !indicator.getCrpProgramOutcome().getAcronym().contains(soilIndicator.getIndicatorName())) { + action.addMessage(action.getText("deliverable.crpOutcomes")); + action.addMissingField("deliverable.crpOutcomes"); + action.getInvalidFields().put("list-deliverable.crpOutcomes", InvalidFieldsMessages.EMPTYFIELD); + } + } + } + } + } + + // Validate contribution narrative + if (!(this + .isValidString(deliverable.getDeliverableInfo(action.getActualPhase()).getShfrmContributionNarrative()) + && this.wordCount( + deliverable.getDeliverableInfo(action.getActualPhase()).getShfrmContributionNarrative()) <= 200)) { + action.addMessage(action.getText("deliverable.deliverableInfo.shfrmContributionNarrative")); + action.addMissingField("deliverable.deliverableInfo.shfrmContributionNarrative"); + action.getInvalidFields().put("input-deliverable.deliverableInfo.shfrmContributionNarrative", + InvalidFieldsMessages.EMPTYFIELD); + } + } + } this.saveMissingFields(deliverable, action.getActualPhase().getDescription(), action.getActualPhase().getYear(), action.getActualPhase().getUpkeep(), ProjectSectionStatusEnum.DELIVERABLES.getStatus(), action); diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl index 5e8b6880fb..869700a3cc 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl @@ -141,11 +141,6 @@ [#if action.hasSpecificities('shfrm_contribution_active') ] [#-- SHRFM contribution --] [@deliverableMacros.shfmrContributionMacro /] - - [#-- Shfmr Sub Actions Template - [@deliverableMacros.shfmrSubActionMacro element={} name="feedbackFields[-1]" index=-1 isTemplate=true /] - --] - [/#if] [#-- Key Outputs select --] diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 03d7f3e4a9..e4461d5c4b 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -589,6 +589,7 @@
    [#local isContributingShfrm = (deliverable.deliverableinfo.contributingShfrm?string)!""] + [#--

    Contributing: ${isContributingShfrm}

    --]

    @@ -597,36 +598,11 @@ [@customForm.textArea name="deliverable.deliverableInfo.shfrmContributionNarrative" value="${(deliverable.deliverableInfo.shfrmContributionNarrative)!}" i18nkey="deliverable.shfrmContribution.narrative" placeholder="" className="limitWords-200" required=true editable=editable /]
    - [#-- Shfrm Priority Action --] + [#-- Shfrm Priority Action
    - [@customForm.select name="deliverable.deliverableInfo.deliverableType.deliverableCategory.id" label="deliverable.shfrmContribution.priorityAction.help" i18nkey="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="name" multiple=false required=true className=" form-control input-sm typeSelect addSlo" editable=editable/] + [@customForm.select name="deliverable.shfrmPriorityActions" label="deliverable.shfrmContribution.priorityAction.help" i18nkey="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="name" multiple=false required=true className=" form-control input-sm typeSelect addSlo" editable=editable/]
    - -
    -
    -[/#macro] - -[#macro shfmrSubActionMacro element name index isTemplate=false] -
    - [#-- Remove Button --] -
    - - [#-- Sub Action ID --] -
    - shfmr Sub Action ${index+1}: ${(element.sectionDescription)!''} - ${(element.fieldName[0..*200])!'shfmr SubAction Fields'} -
    - -
    [/#macro] From b072909bda06a04974a3dd49d58bd36fce6e49df Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 16:32:20 -0500 Subject: [PATCH 25/65] :wrench: chore(shfrm Contribution): Update shfrm deliverables tables --- .../V2_6_0_20240202_1625__UpdateShfrmDeliverablesTables.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1625__UpdateShfrmDeliverablesTables.sql diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1625__UpdateShfrmDeliverablesTables.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1625__UpdateShfrmDeliverablesTables.sql new file mode 100644 index 0000000000..26f8849fa5 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1625__UpdateShfrmDeliverablesTables.sql @@ -0,0 +1,2 @@ +RENAME TABLE deliverable_shfmr_sub_action TO deliverable_shfmr_sub_actions; +RENAME TABLE deliverable_shfrm_priority_action TO deliverable_shfrm_priority_actions; \ No newline at end of file From 014c78f15855d3f223910ffed73e161e9abcbe38 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 16:33:07 -0500 Subject: [PATCH 26/65] :wrench: chore(shfrm Contribution): Create shfrm deliverables models for priority actions and sub actions --- .../DeliverableShfrmPriorityActionDAO.java | 67 +++++++++++++++ .../dao/DeliverableShfrmSubActionDAO.java | 67 +++++++++++++++ ...eliverableShfrmPriorityActionMySQLDAO.java | 85 +++++++++++++++++++ .../DeliverableShfrmSubActionMySQLDAO.java | 85 +++++++++++++++++++ ...DeliverableShfrmPriorityActionManager.java | 74 ++++++++++++++++ .../DeliverableShfrmSubActionManager.java | 74 ++++++++++++++++ ...verableShfrmPriorityActionManagerImpl.java | 77 +++++++++++++++++ .../DeliverableShfrmSubActionManagerImpl.java | 77 +++++++++++++++++ 8 files changed, 606 insertions(+) create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java new file mode 100644 index 0000000000..4c413a69aa --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java @@ -0,0 +1,67 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; + +import java.util.List; + + +public interface DeliverableShfrmPriorityActionDAO { + + /** + * This method removes a specific deliverableShfrmPriorityAction value from the database. + * + * @param deliverableShfrmPriorityActionId is the deliverableShfrmPriorityAction identifier. + * @return true if the deliverableShfrmPriorityAction was successfully deleted, false otherwise. + */ + public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId); + + /** + * This method validate if the deliverableShfrmPriorityAction identify with the given id exists in the system. + * + * @param deliverableShfrmPriorityActionID is a deliverableShfrmPriorityAction identifier. + * @return true if the deliverableShfrmPriorityAction exists, false otherwise. + */ + public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID); + + /** + * This method gets a deliverableShfrmPriorityAction object by a given deliverableShfrmPriorityAction identifier. + * + * @param deliverableShfrmPriorityActionID is the deliverableShfrmPriorityAction identifier. + * @return a DeliverableShfrmPriorityAction object. + */ + public DeliverableShfrmPriorityAction find(long id); + + /** + * This method gets a list of deliverableShfrmPriorityAction that are active + * + * @return a list from DeliverableShfrmPriorityAction null if no exist records + */ + public List findAll(); + + + /** + * This method saves the information of the given deliverableShfrmPriorityAction + * + * @param deliverableShfrmPriorityAction - is the deliverableShfrmPriorityAction object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the deliverableShfrmPriorityAction was + * updated + * or -1 is some error occurred. + */ + public DeliverableShfrmPriorityAction save(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java new file mode 100644 index 0000000000..bf5b4b4334 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java @@ -0,0 +1,67 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; + +import java.util.List; + + +public interface DeliverableShfrmSubActionDAO { + + /** + * This method removes a specific deliverableShfrmSubAction value from the database. + * + * @param deliverableShfrmSubActionId is the deliverableShfrmSubAction identifier. + * @return true if the deliverableShfrmSubAction was successfully deleted, false otherwise. + */ + public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId); + + /** + * This method validate if the deliverableShfrmSubAction identify with the given id exists in the system. + * + * @param deliverableShfrmSubActionID is a deliverableShfrmSubAction identifier. + * @return true if the deliverableShfrmSubAction exists, false otherwise. + */ + public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID); + + /** + * This method gets a deliverableShfrmSubAction object by a given deliverableShfrmSubAction identifier. + * + * @param deliverableShfrmSubActionID is the deliverableShfrmSubAction identifier. + * @return a DeliverableShfrmSubAction object. + */ + public DeliverableShfrmSubAction find(long id); + + /** + * This method gets a list of deliverableShfrmSubAction that are active + * + * @return a list from DeliverableShfrmSubAction null if no exist records + */ + public List findAll(); + + + /** + * This method saves the information of the given deliverableShfrmSubAction + * + * @param deliverableShfrmSubAction - is the deliverableShfrmSubAction object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the deliverableShfrmSubAction was + * updated + * or -1 is some error occurred. + */ + public DeliverableShfrmSubAction save(DeliverableShfrmSubAction deliverableShfrmSubAction); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java new file mode 100644 index 0000000000..a52c0b3e9d --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java @@ -0,0 +1,85 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class DeliverableShfrmPriorityActionMySQLDAO extends AbstractMarloDAO implements DeliverableShfrmPriorityActionDAO { + + + @Inject + public DeliverableShfrmPriorityActionMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId) { + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction = this.find(deliverableShfrmPriorityActionId); + deliverableShfrmPriorityAction.setActive(false); + this.update(deliverableShfrmPriorityAction); + } + + @Override + public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID) { + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction = this.find(deliverableShfrmPriorityActionID); + if (deliverableShfrmPriorityAction == null) { + return false; + } + return true; + + } + + @Override + public DeliverableShfrmPriorityAction find(long id) { + return super.find(DeliverableShfrmPriorityAction.class, id); + + } + + @Override + public List findAll() { + String query = "from " + DeliverableShfrmPriorityAction.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public DeliverableShfrmPriorityAction save(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + if (deliverableShfrmPriorityAction.getId() == null) { + super.saveEntity(deliverableShfrmPriorityAction); + } else { + deliverableShfrmPriorityAction = super.update(deliverableShfrmPriorityAction); + } + + + return deliverableShfrmPriorityAction; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java new file mode 100644 index 0000000000..bc59c8ebf1 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java @@ -0,0 +1,85 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class DeliverableShfrmSubActionMySQLDAO extends AbstractMarloDAO implements DeliverableShfrmSubActionDAO { + + + @Inject + public DeliverableShfrmSubActionMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId) { + DeliverableShfrmSubAction deliverableShfrmSubAction = this.find(deliverableShfrmSubActionId); + deliverableShfrmSubAction.setActive(false); + this.update(deliverableShfrmSubAction); + } + + @Override + public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID) { + DeliverableShfrmSubAction deliverableShfrmSubAction = this.find(deliverableShfrmSubActionID); + if (deliverableShfrmSubAction == null) { + return false; + } + return true; + + } + + @Override + public DeliverableShfrmSubAction find(long id) { + return super.find(DeliverableShfrmSubAction.class, id); + + } + + @Override + public List findAll() { + String query = "from " + DeliverableShfrmSubAction.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public DeliverableShfrmSubAction save(DeliverableShfrmSubAction deliverableShfrmSubAction) { + if (deliverableShfrmSubAction.getId() == null) { + super.saveEntity(deliverableShfrmSubAction); + } else { + deliverableShfrmSubAction = super.update(deliverableShfrmSubAction); + } + + + return deliverableShfrmSubAction; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java new file mode 100644 index 0000000000..633ade7824 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java @@ -0,0 +1,74 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface DeliverableShfrmPriorityActionManager { + + + /** + * This method removes a specific deliverableShfrmPriorityAction value from the database. + * + * @param deliverableShfrmPriorityActionId is the deliverableShfrmPriorityAction identifier. + * @return true if the deliverableShfrmPriorityAction was successfully deleted, false otherwise. + */ + public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId); + + + /** + * This method validate if the deliverableShfrmPriorityAction identify with the given id exists in the system. + * + * @param deliverableShfrmPriorityActionID is a deliverableShfrmPriorityAction identifier. + * @return true if the deliverableShfrmPriorityAction exists, false otherwise. + */ + public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID); + + + /** + * This method gets a list of deliverableShfrmPriorityAction that are active + * + * @return a list from DeliverableShfrmPriorityAction null if no exist records + */ + public List findAll(); + + + /** + * This method gets a deliverableShfrmPriorityAction object by a given deliverableShfrmPriorityAction identifier. + * + * @param deliverableShfrmPriorityActionID is the deliverableShfrmPriorityAction identifier. + * @return a DeliverableShfrmPriorityAction object. + */ + public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long deliverableShfrmPriorityActionID); + + /** + * This method saves the information of the given deliverableShfrmPriorityAction + * + * @param deliverableShfrmPriorityAction - is the deliverableShfrmPriorityAction object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the deliverableShfrmPriorityAction was + * updated + * or -1 is some error occurred. + */ + public DeliverableShfrmPriorityAction saveDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java new file mode 100644 index 0000000000..214057057d --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java @@ -0,0 +1,74 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface DeliverableShfrmSubActionManager { + + + /** + * This method removes a specific deliverableShfrmSubAction value from the database. + * + * @param deliverableShfrmSubActionId is the deliverableShfrmSubAction identifier. + * @return true if the deliverableShfrmSubAction was successfully deleted, false otherwise. + */ + public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId); + + + /** + * This method validate if the deliverableShfrmSubAction identify with the given id exists in the system. + * + * @param deliverableShfrmSubActionID is a deliverableShfrmSubAction identifier. + * @return true if the deliverableShfrmSubAction exists, false otherwise. + */ + public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID); + + + /** + * This method gets a list of deliverableShfrmSubAction that are active + * + * @return a list from DeliverableShfrmSubAction null if no exist records + */ + public List findAll(); + + + /** + * This method gets a deliverableShfrmSubAction object by a given deliverableShfrmSubAction identifier. + * + * @param deliverableShfrmSubActionID is the deliverableShfrmSubAction identifier. + * @return a DeliverableShfrmSubAction object. + */ + public DeliverableShfrmSubAction getDeliverableShfrmSubActionById(long deliverableShfrmSubActionID); + + /** + * This method saves the information of the given deliverableShfrmSubAction + * + * @param deliverableShfrmSubAction - is the deliverableShfrmSubAction object with the new information to be added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the deliverableShfrmSubAction was + * updated + * or -1 is some error occurred. + */ + public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmSubAction deliverableShfrmSubAction); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java new file mode 100644 index 0000000000..52cc27ccba --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java @@ -0,0 +1,77 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author CCAFS + */ +@Named +public class DeliverableShfrmPriorityActionManagerImpl implements DeliverableShfrmPriorityActionManager { + + + private DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO; + // Managers + + + @Inject + public DeliverableShfrmPriorityActionManagerImpl(DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO) { + this.deliverableShfrmPriorityActionDAO = deliverableShfrmPriorityActionDAO; + + + } + + @Override + public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId) { + + deliverableShfrmPriorityActionDAO.deleteDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionId); + } + + @Override + public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID) { + + return deliverableShfrmPriorityActionDAO.existDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionID); + } + + @Override + public List findAll() { + + return deliverableShfrmPriorityActionDAO.findAll(); + + } + + @Override + public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long deliverableShfrmPriorityActionID) { + + return deliverableShfrmPriorityActionDAO.find(deliverableShfrmPriorityActionID); + } + + @Override + public DeliverableShfrmPriorityAction saveDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + + return deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityAction); + } + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java new file mode 100644 index 0000000000..2bc15dd651 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java @@ -0,0 +1,77 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmSubActionManager; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author CCAFS + */ +@Named +public class DeliverableShfrmSubActionManagerImpl implements DeliverableShfrmSubActionManager { + + + private DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO; + // Managers + + + @Inject + public DeliverableShfrmSubActionManagerImpl(DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO) { + this.deliverableShfrmSubActionDAO = deliverableShfrmSubActionDAO; + + + } + + @Override + public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId) { + + deliverableShfrmSubActionDAO.deleteDeliverableShfrmSubAction(deliverableShfrmSubActionId); + } + + @Override + public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID) { + + return deliverableShfrmSubActionDAO.existDeliverableShfrmSubAction(deliverableShfrmSubActionID); + } + + @Override + public List findAll() { + + return deliverableShfrmSubActionDAO.findAll(); + + } + + @Override + public DeliverableShfrmSubAction getDeliverableShfrmSubActionById(long deliverableShfrmSubActionID) { + + return deliverableShfrmSubActionDAO.find(deliverableShfrmSubActionID); + } + + @Override + public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmSubAction deliverableShfrmSubAction) { + + return deliverableShfrmSubActionDAO.save(deliverableShfrmSubAction); + } + + +} From ed0fc4624deee743397eed523c8bf681752b6fc7 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 2 Feb 2024 17:04:43 -0500 Subject: [PATCH 27/65] :wrench: chore(shfrm Contribution): Create shfrm deliverables priority actions backend save process --- .../action/projects/DeliverableAction.java | 117 +++++++++++++++++- .../main/resources/custom/aicrra.properties | 2 +- .../global/macros/deliverableMacros.ftl | 13 +- 3 files changed, 119 insertions(+), 13 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 4cde55b14d..3f701cdb35 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -47,6 +47,8 @@ import org.cgiar.ccafs.marlo.data.manager.DeliverablePublicationMetadataManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableQualityAnswerManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableQualityCheckManager; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmSubActionManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTraineesIndicatorManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTypeManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableUserManager; @@ -78,6 +80,7 @@ import org.cgiar.ccafs.marlo.data.manager.RepIndTypeParticipantManager; import org.cgiar.ccafs.marlo.data.manager.RepositoryChannelManager; import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; import org.cgiar.ccafs.marlo.data.manager.UserManager; import org.cgiar.ccafs.marlo.data.model.Activity; import org.cgiar.ccafs.marlo.data.model.CgiarCrossCuttingMarker; @@ -105,6 +108,7 @@ import org.cgiar.ccafs.marlo.data.model.DeliverableProjectOutcome; import org.cgiar.ccafs.marlo.data.model.DeliverableQualityAnswer; import org.cgiar.ccafs.marlo.data.model.DeliverableQualityCheck; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; import org.cgiar.ccafs.marlo.data.model.DeliverableTraineesIndicator; import org.cgiar.ccafs.marlo.data.model.DeliverableType; import org.cgiar.ccafs.marlo.data.model.DeliverableUser; @@ -251,7 +255,9 @@ public class DeliverableAction extends BaseAction { private FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager; private DeliverableTraineesIndicatorManager deliverableTraineesIndicatorManager; private ShfrmPriorityActionManager shfrmPriorityActionManager; - + private ShfrmSubActionManager shfrmSubActionManager; + private DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager; + private DeliverableShfrmSubActionManager deliverableShfrmSubActionManager; // Variables private List answers; @@ -266,6 +272,7 @@ public class DeliverableAction extends BaseAction { private Boolean isManagingPartnerPersonRequerid; private List deliverableTypeParent; private List shfrmPriorityActions; + private List deliverableShfrmPriorityActions; private DeliverableValidator deliverableValidator; private List fundingSources; private List activities; @@ -351,7 +358,9 @@ public DeliverableAction(APConfig config, DeliverableTypeManager deliverableType FeedbackQACommentManager feedbackQACommentManager, DeliverableClusterParticipantManager deliverableClusterParticipantManager, DeliverableTraineesIndicatorManager deliverableTraineesIndicatorManager, - ShfrmPriorityActionManager shfrmPriorityActionManager) { + ShfrmPriorityActionManager shfrmPriorityActionManager, ShfrmSubActionManager shfrmSubActionManager, + DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager, + DeliverableShfrmSubActionManager deliverableShfrmSubActionManager) { super(config); this.activityManager = activityManager; this.deliverableManager = deliverableManager; @@ -414,6 +423,9 @@ public DeliverableAction(APConfig config, DeliverableTypeManager deliverableType this.feedbackQACommentManager = feedbackQACommentManager; this.deliverableTraineesIndicatorManager = deliverableTraineesIndicatorManager; this.shfrmPriorityActionManager = shfrmPriorityActionManager; + this.shfrmSubActionManager = shfrmSubActionManager; + this.deliverableShfrmPriorityActionManager = deliverableShfrmPriorityActionManager; + this.deliverableShfrmSubActionManager = deliverableShfrmSubActionManager; } /** @@ -730,6 +742,10 @@ public long getDeliverableID() { return deliverableID; } + public List getDeliverableShfrmPriorityActions() { + return deliverableShfrmPriorityActions; + } + public List> getDeliverablesSubTypes(long deliverableTypeID) { List> subTypes = new ArrayList<>(); Map keyOutput; @@ -809,6 +825,7 @@ public List getPartnerInstitutions() { return partnerInstitutions; } + public List getPartnerPersons() { return partnerPersons; } @@ -818,7 +835,6 @@ public List getPartners() { return partners; } - /** * @return an array of integers. */ @@ -1418,6 +1434,18 @@ public void prepare() throws Exception { .filter(o -> o.getPhase().getId().equals(this.getActualPhase().getId())).collect(Collectors.toList()))); } + // SHFRM contribution + if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) { + shfrmPriorityActions = shfrmPriorityActionManager.findAll(); + + + if (deliverable.getDeliverableShfrmPriorityAction() != null) { + deliverable.setShfrmPriorityActions(new ArrayList<>(deliverable.getDeliverableShfrmPriorityAction().stream() + .filter(o -> o.isActive() && o.getPhase().getId().equals(this.getActualPhase().getId())) + .collect(Collectors.toList()))); + } + } + // Expected Study Geographic Regions List if (deliverable.getDeliverableGeographicRegions() != null && !deliverable.getDeliverableGeographicRegions().isEmpty()) { @@ -1825,8 +1853,6 @@ public void prepare() throws Exception { .filter(dt -> dt.isActive() && dt.getDeliverableCategory() == null && dt.getCrp() != null && dt.getCrp().getId().longValue() == loggedCrp.getId().longValue() && dt.getAdminType().booleanValue()) .collect(Collectors.toList()))); - - shfrmPriorityActions = shfrmPriorityActionManager.findAll(); } if (deliverable.getDeliverableInfo(this.getActualPhase()).getDeliverableType() != null @@ -2178,6 +2204,10 @@ public void prepare() throws Exception { if (deliverable.getCrpOutcomes() != null) { deliverable.getCrpOutcomes().clear(); } + + if (deliverable.getShfrmPriorityActions() != null) { + deliverable.getShfrmPriorityActions().clear(); + } } try { @@ -2244,6 +2274,7 @@ public String save() { // this.saveProjectOutcomes(deliverableDB, this.getActualPhase()); this.saveCrpOutcomes(deliverableDB, this.getActualPhase()); + this.savePriorityActions(deliverableDB, this.getActualPhase()); boolean haveRegions = false; boolean haveCountries = false; @@ -3539,6 +3570,78 @@ private void saveParticipant() { } } + /** + * Save Deliverable SHFRM priority action Information + * + * @param deliverable + * @param phase + */ + public void savePriorityActions(Deliverable deliverable, Phase phase) { + + // Search and deleted form Information + try { + if (deliverable.getDeliverableShfrmPriorityAction() != null + && !deliverable.getDeliverableShfrmPriorityAction().isEmpty()) { + + List priorityActionPrev = + new ArrayList<>(deliverable.getDeliverableShfrmPriorityAction().stream() + .filter(nu -> nu.isActive() && nu.getPhase().getId().equals(phase.getId())).collect(Collectors.toList())); + + for (DeliverableShfrmPriorityAction priorityAction : priorityActionPrev) { + if (this.deliverable.getShfrmPriorityActions() == null + || !this.deliverable.getShfrmPriorityActions().contains(priorityAction)) { + this.deliverableCrpOutcomeManager.deleteDeliverableCrpOutcome(priorityAction.getId(), + this.getActualPhase().getId()); + } + } + } + } catch (Exception e) { + logger.error("unable to delete priority action", e); + } + + // Save form Information + if (this.deliverable.getShfrmPriorityActions() != null) { + + for (DeliverableShfrmPriorityAction deliverablePriorityActions : this.deliverable.getShfrmPriorityActions()) { + DeliverableShfrmPriorityAction deliverablePriorityActionsSave = new DeliverableShfrmPriorityAction(); + + if (deliverablePriorityActions != null) { + // For new deliverable Priority Actions + if (deliverablePriorityActions.getId() == null) { + deliverablePriorityActionsSave.setDeliverable(deliverable); + deliverablePriorityActionsSave.setPhase(phase); + } else { + // For old deliverable Priority Actions + try { + if (deliverablePriorityActions.getId() != null) { + deliverablePriorityActionsSave = deliverableShfrmPriorityActionManager + .getDeliverableShfrmPriorityActionById(deliverablePriorityActions.getId()); + } + } catch (Exception e) { + logger.error("unable to get old deliverable Priority Actions", e); + } + } + + if (deliverablePriorityActions.getShfrmPriorityAction() != null + && deliverablePriorityActions.getShfrmPriorityAction().getId() != null) { + ShfrmPriorityAction priorityAction = shfrmPriorityActionManager + .getShfrmPriorityActionById(deliverablePriorityActions.getShfrmPriorityAction().getId()); + if (priorityAction != null) { + deliverablePriorityActionsSave.setShfrmPriorityAction(priorityAction); + } + + this.deliverableShfrmPriorityActionManager + .saveDeliverableShfrmPriorityAction(deliverablePriorityActionsSave); + // This is to add deliverablePriorityActions to generate correct auditlog. + if (!this.deliverable.getDeliverableShfrmPriorityAction().contains(deliverablePriorityActionsSave)) { + this.deliverable.getDeliverableShfrmPriorityAction().add(deliverablePriorityActionsSave); + } + } + } + } + } + } + /** * All we are doing here is setting the modification justification. */ @@ -3872,6 +3975,10 @@ public void setDeliverableID(long deliverableID) { this.deliverableID = deliverableID; } + public void setDeliverableShfrmPriorityActions(List deliverableShfrmPriorityActions) { + this.deliverableShfrmPriorityActions = deliverableShfrmPriorityActions; + } + public void setDeliverableSubTypes(List deliverableSubTypes) { this.deliverableSubTypes = deliverableSubTypes; } diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 05a50d775a..8d391e42a2 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -1913,7 +1913,7 @@ projectPhases.editable=Status shfrmManagement.title=Manage the Soil Health and Fertility Road Map (SHFRM) shfrmManagement.priorityActions.set=Set the control list for Priority Actions: shfrmManagement.priorityActions.title=Title -shfrmManagement.priorityActions.description=description +shfrmManagement.priorityActions.description=Description shfrmManagement.priorityActions.add=Add new priority action shfrmManagement.subActions.add=Add new sub-action shfrmManagement.subActions.title=Title diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index e4461d5c4b..47974c2fb7 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -573,7 +573,7 @@ [/#macro] [#macro shfmrContributionMacro ] - [#local name = "deliverable.deliverableinfo" /] + [#local name = "deliverable.deliverableInfo" /]
    @@ -588,8 +588,7 @@ [@customForm.yesNoInputDeliverable name="${name}.contributingShfrm" editable=editable inverse=false cssClass="type-findable text-center" /]
    - [#local isContributingShfrm = (deliverable.deliverableinfo.contributingShfrm?string)!""] - [#--

    Contributing: ${isContributingShfrm}

    --] + [#local isContributingShfrm = (deliverable.deliverableInfo.contributingShfrm?string)!""]

    @@ -597,12 +596,12 @@
    [@customForm.textArea name="deliverable.deliverableInfo.shfrmContributionNarrative" value="${(deliverable.deliverableInfo.shfrmContributionNarrative)!}" i18nkey="deliverable.shfrmContribution.narrative" placeholder="" className="limitWords-200" required=true editable=editable /]
    - - [#-- Shfrm Priority Action +
    + [#-- Shfrm Priority Action --]
    - [@customForm.select name="deliverable.shfrmPriorityActions" label="deliverable.shfrmContribution.priorityAction.help" i18nkey="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="name" multiple=false required=true className=" form-control input-sm typeSelect addSlo" editable=editable/] + [@customForm.elementsListComponent name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="name" required=true /]
    - --] +
    [/#macro] From 60c2f7190f5d99316a514126f70a44042b69f1f0 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Sat, 3 Feb 2024 12:13:26 -0500 Subject: [PATCH 28/65] :wrench: chore(shfrm Contribution): Create shfrm deliverable replication process --- .../DeliverableShfrmPriorityActionDAO.java | 9 +++- .../dao/DeliverableShfrmSubActionDAO.java | 9 +++- ...eliverableShfrmPriorityActionMySQLDAO.java | 14 +++++- .../DeliverableShfrmSubActionMySQLDAO.java | 16 +++++- ...DeliverableShfrmPriorityActionManager.java | 11 ++-- .../DeliverableShfrmSubActionManager.java | 9 ++-- ...verableShfrmPriorityActionManagerImpl.java | 50 ++++++++++++++++--- .../DeliverableShfrmSubActionManagerImpl.java | 49 +++++++++++++++--- .../action/projects/DeliverableAction.java | 11 ++-- 9 files changed, 149 insertions(+), 29 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java index 4c413a69aa..59e77d918d 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java @@ -55,11 +55,16 @@ public interface DeliverableShfrmPriorityActionDAO { public List findAll(); + public List findByDeliverableAndPhase(long deliverableId, long phaseId); + + /** * This method saves the information of the given deliverableShfrmPriorityAction * - * @param deliverableShfrmPriorityAction - is the deliverableShfrmPriorityAction object with the new information to be added/updated. - * @return a number greater than 0 representing the new ID assigned by the database, 0 if the deliverableShfrmPriorityAction was + * @param deliverableShfrmPriorityAction - is the deliverableShfrmPriorityAction object with the new information to be + * added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the + * deliverableShfrmPriorityAction was * updated * or -1 is some error occurred. */ diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java index bf5b4b4334..2d0869d63d 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java @@ -55,11 +55,16 @@ public interface DeliverableShfrmSubActionDAO { public List findAll(); + public List findByPriorityActionAndPhase(long priorityActionId, long phaseId); + + /** * This method saves the information of the given deliverableShfrmSubAction * - * @param deliverableShfrmSubAction - is the deliverableShfrmSubAction object with the new information to be added/updated. - * @return a number greater than 0 representing the new ID assigned by the database, 0 if the deliverableShfrmSubAction was + * @param deliverableShfrmSubAction - is the deliverableShfrmSubAction object with the new information to be + * added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the + * deliverableShfrmSubAction was * updated * or -1 is some error occurred. */ diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java index a52c0b3e9d..937ad260c5 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java @@ -27,7 +27,8 @@ import org.hibernate.SessionFactory; @Named -public class DeliverableShfrmPriorityActionMySQLDAO extends AbstractMarloDAO implements DeliverableShfrmPriorityActionDAO { +public class DeliverableShfrmPriorityActionMySQLDAO extends AbstractMarloDAO + implements DeliverableShfrmPriorityActionDAO { @Inject @@ -69,6 +70,17 @@ public List findAll() { } + @Override + public List findByDeliverableAndPhase(long deliverableId, long phaseId) { + String query = "from " + DeliverableShfrmPriorityAction.class.getName() + " where is_active=1 and deliverable_id=" + + deliverableId + " and id_phase=" + phaseId; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + } + @Override public DeliverableShfrmPriorityAction save(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { if (deliverableShfrmPriorityAction.getId() == null) { diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java index bc59c8ebf1..29fb739859 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java @@ -27,7 +27,8 @@ import org.hibernate.SessionFactory; @Named -public class DeliverableShfrmSubActionMySQLDAO extends AbstractMarloDAO implements DeliverableShfrmSubActionDAO { +public class DeliverableShfrmSubActionMySQLDAO extends AbstractMarloDAO + implements DeliverableShfrmSubActionDAO { @Inject @@ -69,6 +70,19 @@ public List findAll() { } + + @Override + public List findByPriorityActionAndPhase(long priorityActionId, long phaseId) { + String query = "from " + DeliverableShfrmSubAction.class.getName() + + " where is_active=1 and shfrm_priority_action_id=" + priorityActionId + " and id_phase=" + phaseId; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + @Override public DeliverableShfrmSubAction save(DeliverableShfrmSubAction deliverableShfrmSubAction) { if (deliverableShfrmSubAction.getId() == null) { diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java index 633ade7824..217e982ac2 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java @@ -51,6 +51,8 @@ public interface DeliverableShfrmPriorityActionManager { */ public List findAll(); + public List findByDeliverableAndPhase(long deliverableId, long phaseId); + /** * This method gets a deliverableShfrmPriorityAction object by a given deliverableShfrmPriorityAction identifier. @@ -63,12 +65,15 @@ public interface DeliverableShfrmPriorityActionManager { /** * This method saves the information of the given deliverableShfrmPriorityAction * - * @param deliverableShfrmPriorityAction - is the deliverableShfrmPriorityAction object with the new information to be added/updated. - * @return a number greater than 0 representing the new ID assigned by the database, 0 if the deliverableShfrmPriorityAction was + * @param deliverableShfrmPriorityAction - is the deliverableShfrmPriorityAction object with the new information to be + * added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the + * deliverableShfrmPriorityAction was * updated * or -1 is some error occurred. */ - public DeliverableShfrmPriorityAction saveDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction); + public DeliverableShfrmPriorityAction + saveDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction); } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java index 214057057d..a04b6d3915 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java @@ -52,6 +52,8 @@ public interface DeliverableShfrmSubActionManager { public List findAll(); + public List findByPriorityActionAndPhase(long priorityActionId, long phaseId); + /** * This method gets a deliverableShfrmSubAction object by a given deliverableShfrmSubAction identifier. * @@ -63,12 +65,13 @@ public interface DeliverableShfrmSubActionManager { /** * This method saves the information of the given deliverableShfrmSubAction * - * @param deliverableShfrmSubAction - is the deliverableShfrmSubAction object with the new information to be added/updated. - * @return a number greater than 0 representing the new ID assigned by the database, 0 if the deliverableShfrmSubAction was + * @param deliverableShfrmSubAction - is the deliverableShfrmSubAction object with the new information to be + * added/updated. + * @return a number greater than 0 representing the new ID assigned by the database, 0 if the + * deliverableShfrmSubAction was * updated * or -1 is some error occurred. */ public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmSubAction deliverableShfrmSubAction); - } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java index 52cc27ccba..7e5a43141d 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java @@ -16,30 +16,37 @@ import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.dao.PhaseDAO; import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager; import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; +import org.cgiar.ccafs.marlo.data.model.Phase; import java.util.List; import javax.inject.Inject; import javax.inject.Named; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * @author CCAFS */ @Named public class DeliverableShfrmPriorityActionManagerImpl implements DeliverableShfrmPriorityActionManager { + private final Logger logger = LoggerFactory.getLogger(DeliverableShfrmPriorityActionManagerImpl.class); - private DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO; // Managers + private DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO; + private PhaseDAO phaseDAO; @Inject - public DeliverableShfrmPriorityActionManagerImpl(DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO) { + public DeliverableShfrmPriorityActionManagerImpl(DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO, + PhaseDAO phaseDAO) { this.deliverableShfrmPriorityActionDAO = deliverableShfrmPriorityActionDAO; - - + this.phaseDAO = phaseDAO; } @Override @@ -61,6 +68,13 @@ public List findAll() { } + @Override + public List findByDeliverableAndPhase(long deliverableId, long phaseId) { + + return deliverableShfrmPriorityActionDAO.findByDeliverableAndPhase(deliverableId, phaseId); + + } + @Override public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long deliverableShfrmPriorityActionID) { @@ -68,10 +82,34 @@ public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long } @Override - public DeliverableShfrmPriorityAction saveDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + public DeliverableShfrmPriorityAction + saveDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionResult = + deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityAction); + Phase currentPhase = phaseDAO.find(deliverableShfrmPriorityActionResult.getPhase().getId()); + + if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { - return deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityAction); + this.saveDeliverableShfrmPriorityActionPhase(currentPhase.getNext(), + deliverableShfrmPriorityActionResult.getDeliverable().getId(), deliverableShfrmPriorityActionResult); + } + return deliverableShfrmPriorityActionResult; } + public void saveDeliverableShfrmPriorityActionPhase(Phase next, long deliverableId, + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + Phase phase = phaseDAO.find(next.getId()); + + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionAdd = new DeliverableShfrmPriorityAction(); + deliverableShfrmPriorityActionAdd.setDeliverable(deliverableShfrmPriorityAction.getDeliverable()); + deliverableShfrmPriorityActionAdd.setPhase(phase); + deliverableShfrmPriorityActionAdd.setShfrmPriorityAction(deliverableShfrmPriorityAction.getShfrmPriorityAction()); + deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityActionAdd); + + if (phase.getNext() != null) { + this.saveDeliverableShfrmPriorityActionPhase(phase.getNext(), deliverableId, deliverableShfrmPriorityAction); + } + } } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java index 2bc15dd651..2b939cc3ca 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java @@ -16,30 +16,36 @@ import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.dao.PhaseDAO; import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmSubActionManager; import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; +import org.cgiar.ccafs.marlo.data.model.Phase; import java.util.List; import javax.inject.Inject; import javax.inject.Named; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * @author CCAFS */ @Named public class DeliverableShfrmSubActionManagerImpl implements DeliverableShfrmSubActionManager { + private final Logger logger = LoggerFactory.getLogger(DeliverableShfrmSubActionManagerImpl.class); - private DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO; // Managers - + private DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO; + private PhaseDAO phaseDAO; @Inject - public DeliverableShfrmSubActionManagerImpl(DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO) { + public DeliverableShfrmSubActionManagerImpl(DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO, + PhaseDAO phaseDAO) { this.deliverableShfrmSubActionDAO = deliverableShfrmSubActionDAO; - - + this.phaseDAO = phaseDAO; } @Override @@ -61,6 +67,13 @@ public List findAll() { } + @Override + public List findByPriorityActionAndPhase(long priorityActionId, long phaseId) { + + return deliverableShfrmSubActionDAO.findByPriorityActionAndPhase(priorityActionId, phaseId); + + } + @Override public DeliverableShfrmSubAction getDeliverableShfrmSubActionById(long deliverableShfrmSubActionID) { @@ -70,7 +83,31 @@ public DeliverableShfrmSubAction getDeliverableShfrmSubActionById(long deliverab @Override public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmSubAction deliverableShfrmSubAction) { - return deliverableShfrmSubActionDAO.save(deliverableShfrmSubAction); + DeliverableShfrmSubAction deliverableShfrmSubActionResult = + deliverableShfrmSubActionDAO.save(deliverableShfrmSubAction); + Phase currentPhase = phaseDAO.find(deliverableShfrmSubActionResult.getPhase().getId()); + + if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { + + this.saveDeliverableShfrmSubActionPhase(currentPhase.getNext(), + deliverableShfrmSubActionResult.getShfrmPriorityAction().getId(), deliverableShfrmSubActionResult); + } + return deliverableShfrmSubActionResult; + } + + public void saveDeliverableShfrmSubActionPhase(Phase next, long priorityActionId, + DeliverableShfrmSubAction deliverableShfrmSubAction) { + Phase phase = phaseDAO.find(next.getId()); + + DeliverableShfrmSubAction deliverableShfrmSubActionAdd = new DeliverableShfrmSubAction(); + deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd.setShfrmPriorityAction(deliverableShfrmSubAction.getShfrmPriorityAction()); + deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); + + if (phase.getNext() != null) { + this.saveDeliverableShfrmSubActionPhase(phase.getNext(), + deliverableShfrmSubAction.getShfrmPriorityAction().getId(), deliverableShfrmSubAction); + } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 3f701cdb35..2890449ec9 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -3588,10 +3588,9 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { .filter(nu -> nu.isActive() && nu.getPhase().getId().equals(phase.getId())).collect(Collectors.toList())); for (DeliverableShfrmPriorityAction priorityAction : priorityActionPrev) { - if (this.deliverable.getShfrmPriorityActions() == null + if (priorityAction != null && this.deliverable.getShfrmPriorityActions() == null || !this.deliverable.getShfrmPriorityActions().contains(priorityAction)) { - this.deliverableCrpOutcomeManager.deleteDeliverableCrpOutcome(priorityAction.getId(), - this.getActualPhase().getId()); + this.deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); } } } @@ -3601,9 +3600,9 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { // Save form Information if (this.deliverable.getShfrmPriorityActions() != null) { - + DeliverableShfrmPriorityAction deliverablePriorityActionsSave; for (DeliverableShfrmPriorityAction deliverablePriorityActions : this.deliverable.getShfrmPriorityActions()) { - DeliverableShfrmPriorityAction deliverablePriorityActionsSave = new DeliverableShfrmPriorityAction(); + deliverablePriorityActionsSave = new DeliverableShfrmPriorityAction(); if (deliverablePriorityActions != null) { // For new deliverable Priority Actions @@ -3627,7 +3626,9 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { ShfrmPriorityAction priorityAction = shfrmPriorityActionManager .getShfrmPriorityActionById(deliverablePriorityActions.getShfrmPriorityAction().getId()); if (priorityAction != null) { + deliverablePriorityActionsSave.setDeliverable(deliverable); deliverablePriorityActionsSave.setShfrmPriorityAction(priorityAction); + deliverablePriorityActionsSave.setPhase(phase); } this.deliverableShfrmPriorityActionManager From 5bf0c8bcc7e186a92c19ced8de5e0b2f49428d48 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Sun, 4 Feb 2024 08:52:52 -0500 Subject: [PATCH 29/65] :wrench: chore(shfrm Contribution): Update shfrm deliverable table --- ..._6_0_20240204_0600__UpdateShfrmDeliverablesSubActionTable.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240204_0600__UpdateShfrmDeliverablesSubActionTable.sql diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240204_0600__UpdateShfrmDeliverablesSubActionTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240204_0600__UpdateShfrmDeliverablesSubActionTable.sql new file mode 100644 index 0000000000..cdf00ccc76 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240204_0600__UpdateShfrmDeliverablesSubActionTable.sql @@ -0,0 +1 @@ +RENAME TABLE deliverable_shfmr_sub_actions TO deliverable_shfrm_sub_actions; From c09dcfbf21524f2fc998a32d5fa4d4caa060d353 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Sun, 4 Feb 2024 08:54:26 -0500 Subject: [PATCH 30/65] :wrench: chore(shfrm Contribution): Update shfrm models --- .../DeliverableShfrmSubActionMySQLDAO.java | 2 +- .../DeliverableShfrmSubActionManagerImpl.java | 7 +++--- .../model/DeliverableShfrmPriorityAction.java | 12 ++++++++++ .../data/model/DeliverableShfrmSubAction.java | 18 +++++++-------- .../marlo/data/model/ShfrmPriorityAction.java | 23 +++++++++++++++++++ .../marlo/data/model/ShfrmSubAction.java | 22 ++++++++++++++++++ .../xmls/DeliverableShfrmSubActions.hbm.xml | 4 ++-- .../main/resources/xmls/Deliverables.hbm.xml | 8 ------- 8 files changed, 73 insertions(+), 23 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java index 29fb739859..5eff91c3e1 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java @@ -74,7 +74,7 @@ public List findAll() { @Override public List findByPriorityActionAndPhase(long priorityActionId, long phaseId) { String query = "from " + DeliverableShfrmSubAction.class.getName() - + " where is_active=1 and shfrm_priority_action_id=" + priorityActionId + " and id_phase=" + phaseId; + + " where is_active=1 and deliverable_shfrm_priority_action_id=" + priorityActionId + " and id_phase=" + phaseId; List list = super.findAll(query); if (list.size() > 0) { return list; diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java index 2b939cc3ca..a0615af940 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java @@ -90,7 +90,7 @@ public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmS if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { this.saveDeliverableShfrmSubActionPhase(currentPhase.getNext(), - deliverableShfrmSubActionResult.getShfrmPriorityAction().getId(), deliverableShfrmSubActionResult); + deliverableShfrmSubActionResult.getDeliverableShfrmPriorityAction().getId(), deliverableShfrmSubActionResult); } return deliverableShfrmSubActionResult; } @@ -101,12 +101,13 @@ public void saveDeliverableShfrmSubActionPhase(Phase next, long priorityActionId DeliverableShfrmSubAction deliverableShfrmSubActionAdd = new DeliverableShfrmSubAction(); deliverableShfrmSubActionAdd.setPhase(phase); - deliverableShfrmSubActionAdd.setShfrmPriorityAction(deliverableShfrmSubAction.getShfrmPriorityAction()); + deliverableShfrmSubActionAdd + .setDeliverableShfrmPriorityAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction()); deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); if (phase.getNext() != null) { this.saveDeliverableShfrmSubActionPhase(phase.getNext(), - deliverableShfrmSubAction.getShfrmPriorityAction().getId(), deliverableShfrmSubAction); + deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), deliverableShfrmSubAction); } } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java index a1a4b641fd..69afb759e4 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java @@ -3,6 +3,8 @@ import org.cgiar.ccafs.marlo.data.IAuditLog; +import java.util.List; + import com.google.gson.annotations.Expose; /** @@ -19,6 +21,8 @@ public class DeliverableShfrmPriorityAction extends MarloAuditableEntity impleme @Expose private Phase phase; + private List deliverableShfrmSubActions; + public DeliverableShfrmPriorityAction() { } @@ -26,6 +30,10 @@ public Deliverable getDeliverable() { return deliverable; } + public List getDeliverableShfrmSubActions() { + return deliverableShfrmSubActions; + } + @Override public String getLogDeatil() { StringBuilder sb = new StringBuilder(); @@ -50,6 +58,10 @@ public void setDeliverable(Deliverable deliverable) { this.deliverable = deliverable; } + public void setDeliverableShfrmSubActions(List deliverableShfrmSubActions) { + this.deliverableShfrmSubActions = deliverableShfrmSubActions; + } + public void setPhase(Phase phase) { this.phase = phase; } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java index 02e4a9f22c..af1726ca80 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java @@ -13,7 +13,7 @@ public class DeliverableShfrmSubAction extends MarloAuditableEntity implements j private static final long serialVersionUID = -3820243690705823369L; @Expose - private ShfrmPriorityAction shfrmPriorityAction; + private DeliverableShfrmPriorityAction deliverableShfrmPriorityAction; @Expose private ShfrmSubAction shfrmSubAction; @Expose @@ -22,6 +22,10 @@ public class DeliverableShfrmSubAction extends MarloAuditableEntity implements j public DeliverableShfrmSubAction() { } + public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityAction() { + return deliverableShfrmPriorityAction; + } + @Override public String getLogDeatil() { StringBuilder sb = new StringBuilder(); @@ -33,10 +37,6 @@ public Phase getPhase() { return phase; } - public ShfrmPriorityAction getShfrmPriorityAction() { - return shfrmPriorityAction; - } - public ShfrmSubAction getShfrmSubAction() { return shfrmSubAction; } @@ -46,12 +46,12 @@ public boolean isActive() { return true; } - public void setPhase(Phase phase) { - this.phase = phase; + public void setDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + this.deliverableShfrmPriorityAction = deliverableShfrmPriorityAction; } - public void setShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { - this.shfrmPriorityAction = shfrmPriorityAction; + public void setPhase(Phase phase) { + this.phase = phase; } public void setShfrmSubAction(ShfrmSubAction shfrmSubAction) { diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java index 9124d127de..eb56970e9d 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java @@ -20,12 +20,30 @@ public class ShfrmPriorityAction extends MarloAuditableEntity implements java.io @Expose private String description; + private String composedName; + // private Set shfrmSubAction = new HashSet(0); private List shfrmSubActions = new ArrayList(); public ShfrmPriorityAction() { } + public String getComposedName() { + if (composedName == null) { + if (this.getName() != null) { + composedName = "" + name + ": "; + } + if (this.getDescription() != null) { + composedName = composedName.concat(description); + } + + if (composedName != null && !composedName.isEmpty()) { + return composedName; + } + } + return composedName; + } + public String getDescription() { return description; } @@ -50,6 +68,10 @@ public boolean isActive() { return true; } + public void setComposedName(String composedName) { + this.composedName = composedName; + } + public void setDescription(String description) { this.description = description; } @@ -61,4 +83,5 @@ public void setName(String name) { public void setShfrmSubActions(List shfrmSubActions) { this.shfrmSubActions = shfrmSubActions; } + } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java index acd84e31d3..f9394d53da 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java @@ -19,9 +19,27 @@ public class ShfrmSubAction extends MarloAuditableEntity implements java.io.Seri @Expose private ShfrmPriorityAction shfrmPriorityAction; + private String composedName; + public ShfrmSubAction() { } + public String getComposedName() { + if (composedName == null) { + if (this.getName() != null) { + composedName = "" + name + ": "; + } + if (this.getDescription() != null) { + composedName = composedName.concat(description); + } + + if (composedName != null && !composedName.isEmpty()) { + return composedName; + } + } + return composedName; + } + public String getDescription() { return description; } @@ -46,6 +64,10 @@ public boolean isActive() { return true; } + public void setComposedName(String composedName) { + this.composedName = composedName; + } + public void setDescription(String description) { this.description = description; } diff --git a/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml index 1124a2be0d..a9f4a2563a 100644 --- a/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml +++ b/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml @@ -26,8 +26,8 @@ - - + + diff --git a/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml b/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml index 26ca95e681..f7b7f8998f 100644 --- a/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml +++ b/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml @@ -286,14 +286,6 @@ - - - - - - From 0aef188b5b18e3644fc30051a51e10648c3b747d Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Sun, 4 Feb 2024 10:22:52 -0500 Subject: [PATCH 31/65] :wrench: chore(shfrm Contribution): Create shfrm section deliverable front-end components --- .../crp/views/projects/deliverableInfo.ftl | 8 ++ .../crp/views/projects/projectDeliverable.ftl | 1 + .../global/macros/deliverableMacros.ftl | 118 +++++++++++++++++- 3 files changed, 126 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl index 869700a3cc..5d858b2c99 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl @@ -143,6 +143,14 @@ [@deliverableMacros.shfmrContributionMacro /] [/#if] + + [#-- Single partner TEMPLATE from partnersTemplate.ftl --] + [@deliverableMacros.priorityActionsMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] + + [#-- Contact person TEMPLATE from partnersTemplate.ftl --] + [@deliverableMacros.subActionsMacro element={} name="deliverable.shfrmPriorityActions[-1].shfrmDeliverableSubActions[-1]" isTemplate=true /] + + [#-- Key Outputs select --] [#if !project.projectInfo.administrative && !phaseOne && !isCenterProject ]
    diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl index 4f32df788f..fe2061e5bb 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl @@ -4,6 +4,7 @@ [#assign pageLibs = ["select2","font-awesome","dropzone","blueimp-file-upload","jsUri", "flag-icon-css", "pickadate", "vue"] /] [#assign customJS = [ "${baseUrlMedia}/js/projects/deliverables/deliverableInfo.js?20240123", + "${baseUrlMedia}/js/projects/deliverables/deliverableShfrm.js?20240203", "${baseUrlMedia}/js/projects/deliverables/deliverableDissemination.js?20230810", "${baseUrlMedia}/js/projects/deliverables/deliverableQualityCheck.js?20220721", "${baseUrlCdn}/crp/js/feedback/feedbackAutoImplementation.js?20231017", diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 47974c2fb7..18bf3ab010 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -599,11 +599,38 @@
    [#-- Shfrm Priority Action --]
    - [@customForm.elementsListComponent name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="name" required=true /] + [@customForm.elementsListComponent name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /]
    + + [#-- Testing area --] + [#if true] + [#-- Project Section Content --] +
    + [#-- Section Messages --] + [@s.form action=actionName method="POST" enctype="multipart/form-data" cssClass=""] + + [#-- Listing actions --] + + [#-- Priority actions list --] +
    + [#if deliverable.shfrmPriorityActions?has_content] + [#list deliverable.shfrmPriorityActions as priorityAction] + [@priorityActionsMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}].shfrmPriorityAction" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] + [/#list] + [#else] + [@priorityActionsMacro element={} name="deliverable.shfrmPriorityActions[0].shfrmPriorityAction" index=0 opened=true defaultPerson=true /] + [/#if] +
    [@s.text name="shfrmManagement.priorityActions.add" /]
    +
    + + [/@s.form] +
    + [/#if] + [#-- end testing area --]
    +
    [/#macro] [#macro findableOptions ] @@ -1540,3 +1567,92 @@ [/#macro] + +[#macro priorityActionsMacro element name index=-1 opened=false defaultPerson=false isTemplate=false] + +
    + [#-- Loading --] + + [#-- TODO: Please improve this validation at backend side --] + + [#-- Remove link for all partners --] + [#if editable ] [#--&& (isTemplate) --] + + [/#if] + + [#-- Partner Title --] +
    + [#-- Title --] + [#-- ${index+1}. --] ${(element.shfrmPriorityAction.name)!'Priority Action'}: ${(element.shfrmPriorityAction.description)!''} +
    + +
    +
    + + [#-- Action name --] + + +
    + [@customForm.input name="${name}.name" i18nkey="shfrmManagement.priorityActions.title" className="name limitWords-100" required=true /] +
    +
    + [#-- Action description --] +
    + [@customForm.input name="${name}.description" i18nkey="shfrmManagement.priorityActions.description" className="description limitWords-100" required=true /] +
    +
    + + + [#-- Sub Actions --] +
    +
    [@s.text name="shfrmManagement.subActions.add" /] [@customForm.req required=true /]
    +
    + [#if element.shfrmSubActions?has_content] + [#list element.shfrmSubActions as subAction] + [@subActionsMacro element=subAction name="${name}.shfrmSubActions[${subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] + [/#list] + [#else] +

    [@s.text name="shfrmManagement.subActionsEmpty" /]

    + [/#if] + [#if (editable && canEdit)] +
    [@s.text name="shfrmManagement.subActions.add"/]
    + [/#if] + +
    +
    + +
    + +
    +[/#macro] + +[#macro subActionsMacro element name index=-1 partnerIndex=-1 isTemplate=false institutionID=-1] +
    + [#-- Remove link for all partners --] + [#if editable && action.canBeDeleted((element.id)!-1,(element.class.name)!)] +
    + [/#if] +
    + +
    + + + [#if customForm.changedField('${name}.id') != ''] + Added/Updated + [/#if] +
    +
    + [#-- Sub action name --] +
    + [@customForm.input name="${name}.name" className="partnerPersonType" editable=editable i18nkey="shfrmManagement.subActions.title" value="${(element.name)!}" /] +
    + [#-- Sub action description --] +
    + [@customForm.input name="${name}.description" value="${(element.description)!}" type="text" i18nkey="shfrmManagement.subActions.description" required=true editable=editable /] +
    +
    + +
    + +
    +[/#macro] From d32b2948553e7025684dbb97dd4c329abb84dadf Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 5 Feb 2024 07:28:48 -0500 Subject: [PATCH 32/65] :wrench: chore(shfrm Contribution): Models and queries updates --- .../cgiar/ccafs/marlo/config/APConstants.java | 2 + ...verableShfrmPriorityActionManagerImpl.java | 35 + .../model/DeliverableShfrmPriorityAction.java | 22 +- .../marlo/data/model/ShfrmPriorityAction.java | 2 +- .../marlo/data/model/ShfrmSubAction.java | 2 +- .../DeliverableShfrmPriorityActions.hbm.xml | 8 + .../project/SubActionsByPriorityAction.java | 89 ++ .../action/projects/DeliverableAction.java | 185 +++- .../cgiar/ccafs/marlo/config/APConstants.java | 2 + .../main/resources/custom/aicrra.properties | 1 + .../src/main/resources/global.properties | 1 + marlo-web/src/main/resources/struts-json.xml | 8 + .../crp/views/projects/deliverableInfo.ftl | 7 +- .../global/macros/deliverableMacros.ftl | 66 +- .../projects/deliverables/deliverableShfrm.js | 944 ++++++++++++++++++ 15 files changed, 1323 insertions(+), 51 deletions(-) create mode 100644 marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java create mode 100644 marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index c5899d044f..652cc9f8f1 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -171,6 +171,8 @@ public final class APConstants { public static final String DELIVERABLE_FILE_LOCALLY_HOSTED_STR = "Locally"; public static final String DELIVERABLE_ID = "deliverableId"; + public static final String PRIORITY_ACTION_ID = "priority_action_id"; + public static final String SUB_ACTION_ID = "sub_action_id"; public static final int DELIVERABLE_QUALITY_ANSWER_NO = 3; public static final int DELIVERABLE_QUALITY_ANSWER_YES = 2; public static final int DELIVERABLE_QUALITY_ANSWER_YES_BUT_NO = 1; diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java index 7e5a43141d..55ee7f7a37 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java @@ -22,6 +22,7 @@ import org.cgiar.ccafs.marlo.data.model.Phase; import java.util.List; +import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Named; @@ -52,9 +53,43 @@ public DeliverableShfrmPriorityActionManagerImpl(DeliverableShfrmPriorityActionD @Override public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId) { + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction = + this.getDeliverableShfrmPriorityActionById(deliverableShfrmPriorityActionId); + Phase currentPhase = phaseDAO.find(deliverableShfrmPriorityAction.getPhase().getId()); + + if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { + + this.deleteDeliverableShfrmPriorityActionPhase(currentPhase.getNext(), + deliverableShfrmPriorityAction.getDeliverable().getId(), deliverableShfrmPriorityAction); + } + deliverableShfrmPriorityActionDAO.deleteDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionId); } + public void deleteDeliverableShfrmPriorityActionPhase(Phase next, long deliverableId, + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + Phase phase = phaseDAO.find(next.getId()); + + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionDelete = new DeliverableShfrmPriorityAction(); + deliverableShfrmPriorityActionDelete = deliverableShfrmPriorityActionDAO + .findByDeliverableAndPhase(deliverableId, phase.getId()).stream() + .filter( + d -> deliverableShfrmPriorityAction != null && deliverableShfrmPriorityAction.getShfrmPriorityAction() != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(deliverableShfrmPriorityAction.getShfrmPriorityAction().getId())) + .collect(Collectors.toList()).get(0); + deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityActionDelete); + + if (deliverableShfrmPriorityActionDelete != null) { + deliverableShfrmPriorityActionDAO + .deleteDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionDelete.getId()); + } + if (phase.getNext() != null) { + this.deleteDeliverableShfrmPriorityActionPhase(phase.getNext(), deliverableId, deliverableShfrmPriorityAction); + } + } + @Override public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID) { diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java index 69afb759e4..46ad8193ef 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java @@ -3,7 +3,9 @@ import org.cgiar.ccafs.marlo.data.IAuditLog; +import java.util.HashSet; import java.util.List; +import java.util.Set; import com.google.gson.annotations.Expose; @@ -21,7 +23,9 @@ public class DeliverableShfrmPriorityAction extends MarloAuditableEntity impleme @Expose private Phase phase; - private List deliverableShfrmSubActions; + private List shfrmSubActions; + + private Set deliverableShfrmSubAction = new HashSet(0); public DeliverableShfrmPriorityAction() { } @@ -30,8 +34,8 @@ public Deliverable getDeliverable() { return deliverable; } - public List getDeliverableShfrmSubActions() { - return deliverableShfrmSubActions; + public Set getDeliverableShfrmSubAction() { + return deliverableShfrmSubAction; } @Override @@ -49,6 +53,10 @@ public ShfrmPriorityAction getShfrmPriorityAction() { return shfrmPriorityAction; } + public List getShfrmSubActions() { + return shfrmSubActions; + } + @Override public boolean isActive() { return true; @@ -58,8 +66,8 @@ public void setDeliverable(Deliverable deliverable) { this.deliverable = deliverable; } - public void setDeliverableShfrmSubActions(List deliverableShfrmSubActions) { - this.deliverableShfrmSubActions = deliverableShfrmSubActions; + public void setDeliverableShfrmSubAction(Set deliverableShfrmSubAction) { + this.deliverableShfrmSubAction = deliverableShfrmSubAction; } public void setPhase(Phase phase) { @@ -69,4 +77,8 @@ public void setPhase(Phase phase) { public void setShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { this.shfrmPriorityAction = shfrmPriorityAction; } + + public void setShfrmSubActions(List shfrmSubActions) { + this.shfrmSubActions = shfrmSubActions; + } } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java index eb56970e9d..10b3291e19 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java @@ -31,7 +31,7 @@ public ShfrmPriorityAction() { public String getComposedName() { if (composedName == null) { if (this.getName() != null) { - composedName = "" + name + ": "; + composedName = "" + name + ": "; } if (this.getDescription() != null) { composedName = composedName.concat(description); diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java index f9394d53da..de0c15b8ab 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java @@ -27,7 +27,7 @@ public ShfrmSubAction() { public String getComposedName() { if (composedName == null) { if (this.getName() != null) { - composedName = "" + name + ": "; + composedName = "" + name + ": "; } if (this.getDescription() != null) { composedName = composedName.concat(description); diff --git a/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml index f03d90b386..4a02494a66 100644 --- a/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml +++ b/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml @@ -32,5 +32,13 @@ + + + + + + \ No newline at end of file diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java new file mode 100644 index 0000000000..260c7b7c0c --- /dev/null +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java @@ -0,0 +1,89 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + +package org.cgiar.ccafs.marlo.action.json.project; + +import org.cgiar.ccafs.marlo.action.BaseAction; +import org.cgiar.ccafs.marlo.config.APConstants; +import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; +import org.cgiar.ccafs.marlo.utils.APConfig; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.inject.Inject; + +import org.apache.commons.lang3.StringUtils; +import org.apache.struts2.dispatcher.Parameter; + +public class SubActionsByPriorityAction extends BaseAction { + + private static final long serialVersionUID = 3674950424554096761L; + private long priorityActionID; + private ShfrmSubActionManager shfrmSubActionManager; + private List> subActions; + + @Inject + public SubActionsByPriorityAction(APConfig config, ShfrmSubActionManager shfrmSubActionManager) { + super(config); + this.shfrmSubActionManager = shfrmSubActionManager; + } + + @Override + public String execute() throws Exception { + subActions = new ArrayList<>(); + Map subAction; + List shfrmSubActions = shfrmSubActionManager + .findAll().stream().filter(s -> s != null && s.getShfrmPriorityAction() != null + && s.getShfrmPriorityAction().getId() != null && s.getShfrmPriorityAction().getId().equals(priorityActionID)) + .collect(Collectors.toList()); + + if (shfrmSubActions != null && !shfrmSubActions.isEmpty()) { + for (ShfrmSubAction shfrmSubAction : shfrmSubActions) { + subAction = new HashMap(); + subAction.put("id", shfrmSubAction.getId()); + subAction.put("composedName", shfrmSubAction.getComposedName()); + subAction.put("name", shfrmSubAction.getName()); + subAction.put("description", shfrmSubAction.getDescription()); + subActions.add(subAction); + } + } + return SUCCESS; + + } + + public List> getSubActions() { + return subActions; + } + + @Override + public void prepare() throws Exception { + // Map parameters = this.getParameters(); + // partnerID = Long.parseLong(StringUtils.trim(((String[]) parameters.get(APConstants.PARTNER_ID))[0])); + + Map parameters = this.getParameters(); + priorityActionID = + Long.parseLong(StringUtils.trim(parameters.get(APConstants.PRIORITY_ACTION_ID).getMultipleValues()[0])); + } + + public void setSubActions(List> subActions) { + this.subActions = subActions; + } + +} diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 2890449ec9..0470d0e03e 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -109,6 +109,7 @@ import org.cgiar.ccafs.marlo.data.model.DeliverableQualityAnswer; import org.cgiar.ccafs.marlo.data.model.DeliverableQualityCheck; import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; import org.cgiar.ccafs.marlo.data.model.DeliverableTraineesIndicator; import org.cgiar.ccafs.marlo.data.model.DeliverableType; import org.cgiar.ccafs.marlo.data.model.DeliverableUser; @@ -145,6 +146,7 @@ import org.cgiar.ccafs.marlo.data.model.RepIndTypeParticipant; import org.cgiar.ccafs.marlo.data.model.RepositoryChannel; import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; import org.cgiar.ccafs.marlo.data.model.User; import org.cgiar.ccafs.marlo.security.Permission; import org.cgiar.ccafs.marlo.utils.APConfig; @@ -641,6 +643,44 @@ public void fillClusterParticipantsList() { } } + public void fillSubActionsList() { + try { + if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { + List subActions; + List subActionsAdd; + for (DeliverableShfrmPriorityAction deliverableShfrmPriorityAction : deliverable.getShfrmPriorityActions()) { + subActions = new ArrayList<>(); + + // Priority action front + if (deliverableShfrmPriorityAction != null && deliverableShfrmPriorityAction.getShfrmPriorityAction() != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction().getId() != null) { + subActionsAdd = new ArrayList<>(); + // Sub Actions DB + subActions = shfrmSubActionManager.findAll(); + if (subActions != null) { + for (ShfrmSubAction subAction : subActions) { + + if (subAction != null && subAction.getShfrmPriorityAction() != null + && subAction.getShfrmPriorityAction().getId() != null) { + if (subAction.getShfrmPriorityAction().getId() + .equals(deliverableShfrmPriorityAction.getShfrmPriorityAction().getId())) { + subActionsAdd.add(subAction); + } + } + } + if (subActionsAdd != null) { + deliverableShfrmPriorityAction.getShfrmPriorityAction().setShfrmSubActions(subActionsAdd); + } + } + } + } + } + + } catch (Exception e) { + logger.error("error getting sub actions: " + e); + } + } + public Integer getAcceptationPercentage() { return acceptationPercentage; } @@ -670,6 +710,7 @@ public long getActualClusterParticipantID() { } } + public List getAnswers() { return answers; } @@ -679,7 +720,6 @@ public List getAnswersDataDic() { return answersDataDic; } - private Path getAutoSaveFilePath() { // get the class simple name @@ -821,6 +861,7 @@ public List getMyProjects() { return myProjects; } + public List getPartnerInstitutions() { return partnerInstitutions; } @@ -830,7 +871,6 @@ public List getPartnerPersons() { return partnerPersons; } - public List getPartners() { return partners; } @@ -1438,12 +1478,34 @@ public void prepare() throws Exception { if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) { shfrmPriorityActions = shfrmPriorityActionManager.findAll(); - if (deliverable.getDeliverableShfrmPriorityAction() != null) { deliverable.setShfrmPriorityActions(new ArrayList<>(deliverable.getDeliverableShfrmPriorityAction().stream() .filter(o -> o.isActive() && o.getPhase().getId().equals(this.getActualPhase().getId())) .collect(Collectors.toList()))); } + this.fillSubActionsList(); + + + if (deliverable != null && deliverable.getShfrmPriorityActions() != null + && !deliverable.getShfrmPriorityActions().isEmpty()) { + for (DeliverableShfrmPriorityAction deliverablePriorityAction : deliverable.getShfrmPriorityActions()) { + try { + + if (deliverablePriorityAction.getDeliverableShfrmSubAction() != null) { + deliverablePriorityAction + .setShfrmSubActions(new ArrayList<>(deliverablePriorityAction.getDeliverableShfrmSubAction() + .stream().filter(o -> o.isActive() && o.getPhase().getId().equals(this.getActualPhase().getId())) + .collect(Collectors.toList()))); + } + + } catch (Exception e) { + logger.error("No se pueden obtener deliverableSubActions para deliverablePriorityAction: {}", + deliverablePriorityAction, e); + } + } + } + + } // Expected Study Geographic Regions List @@ -2208,6 +2270,10 @@ public void prepare() throws Exception { if (deliverable.getShfrmPriorityActions() != null) { deliverable.getShfrmPriorityActions().clear(); } + + if (deliverable.getShfrmSubActions() != null) { + deliverable.getShfrmSubActions().clear(); + } } try { @@ -2274,7 +2340,8 @@ public String save() { // this.saveProjectOutcomes(deliverableDB, this.getActualPhase()); this.saveCrpOutcomes(deliverableDB, this.getActualPhase()); - this.savePriorityActions(deliverableDB, this.getActualPhase()); + this.savePriorityActions(deliverableManagedState, this.getActualPhase()); + this.saveSubActions(deliverableManagedState, this.getActualPhase()); boolean haveRegions = false; boolean haveCountries = false; @@ -3580,20 +3647,29 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { // Search and deleted form Information try { - if (deliverable.getDeliverableShfrmPriorityAction() != null - && !deliverable.getDeliverableShfrmPriorityAction().isEmpty()) { - List priorityActionPrev = - new ArrayList<>(deliverable.getDeliverableShfrmPriorityAction().stream() - .filter(nu -> nu.isActive() && nu.getPhase().getId().equals(phase.getId())).collect(Collectors.toList())); + List subActionPrev = + deliverableShfrmPriorityActionManager.findByDeliverableAndPhase(deliverable.getId(), phase.getId()); - for (DeliverableShfrmPriorityAction priorityAction : priorityActionPrev) { - if (priorityAction != null && this.deliverable.getShfrmPriorityActions() == null - || !this.deliverable.getShfrmPriorityActions().contains(priorityAction)) { - this.deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); + if (this.deliverable.getShfrmPriorityActions() != null) { + List existingIds = new ArrayList<>(); + + for (DeliverableShfrmPriorityAction shfrmDeliverable : this.deliverable.getShfrmPriorityActions()) { + if (shfrmDeliverable != null && shfrmDeliverable.getId() != null) { + existingIds.add(shfrmDeliverable.getId()); + } + } + + if (subActionPrev != null) { + for (DeliverableShfrmPriorityAction priorityAction : subActionPrev) { + if (priorityAction != null && priorityAction.getId() != null + && !existingIds.contains(priorityAction.getId())) { + deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); + } } } } + } catch (Exception e) { logger.error("unable to delete priority action", e); } @@ -3625,7 +3701,7 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { && deliverablePriorityActions.getShfrmPriorityAction().getId() != null) { ShfrmPriorityAction priorityAction = shfrmPriorityActionManager .getShfrmPriorityActionById(deliverablePriorityActions.getShfrmPriorityAction().getId()); - if (priorityAction != null) { + if (deliverable != null && priorityAction != null && priorityAction.getId() != null) { deliverablePriorityActionsSave.setDeliverable(deliverable); deliverablePriorityActionsSave.setShfrmPriorityAction(priorityAction); deliverablePriorityActionsSave.setPhase(phase); @@ -3901,6 +3977,87 @@ public void saveQualityCheck() { } + /** + * Save Deliverable SHFRM sub actions Information + * + * @param deliverable + * @param phase + */ + public void saveSubActions(Deliverable deliverable, Phase phase) { + + // Search and deleted form Information + try { + if (deliverable.getDeliverableShfrmPriorityAction() != null + && !deliverable.getDeliverableShfrmPriorityAction().isEmpty()) { + for (DeliverableShfrmPriorityAction priorityAction : deliverable.getDeliverableShfrmPriorityAction()) { + + + List subActionPrev = + new ArrayList<>(priorityAction.getDeliverableShfrmSubAction().stream() + .filter(nu -> nu.isActive() && nu.getPhase().getId().equals(phase.getId())).collect(Collectors.toList())); + + for (DeliverableShfrmSubAction subAction : subActionPrev) { + if (subAction != null && subAction.getId() != null && (priorityAction.getShfrmSubActions() == null + || !priorityAction.getShfrmSubActions().contains(subAction))) { + this.deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + } + } + } + + } + } catch (Exception e) { + logger.error("unable to delete priority action", e); + } + + // Save form Information + if (this.deliverable.getShfrmPriorityActions() != null) { + DeliverableShfrmSubAction deliverableSubActionSave; + for (DeliverableShfrmPriorityAction deliverablePriorityAction : this.deliverable.getShfrmPriorityActions()) { + if (deliverablePriorityAction != null && deliverablePriorityAction.getShfrmSubActions() != null) { + for (DeliverableShfrmSubAction deliverableSubAction : deliverablePriorityAction.getShfrmSubActions()) { + deliverableSubActionSave = new DeliverableShfrmSubAction(); + + + if (deliverableSubAction != null) { + // For new deliverable Priority Actions + if (deliverableSubAction.getId() == null) { + deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); + deliverableSubActionSave.setPhase(phase); + } else { + // For old deliverable Priority Actions + try { + if (deliverableSubAction.getId() != null) { + deliverableSubActionSave = + deliverableShfrmSubActionManager.getDeliverableShfrmSubActionById(deliverableSubAction.getId()); + } + } catch (Exception e) { + logger.error("unable to get old deliverable sub Actions", e); + } + } + + if (deliverableSubAction.getShfrmSubAction() != null + && deliverableSubAction.getShfrmSubAction().getId() != null) { + ShfrmSubAction subAction = + shfrmSubActionManager.getShfrmSubActionById(deliverableSubAction.getShfrmSubAction().getId()); + if (subAction != null) { + deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); + deliverableSubActionSave.setShfrmSubAction(subAction); + deliverableSubActionSave.setPhase(phase); + } + + this.deliverableShfrmSubActionManager.saveDeliverableShfrmSubAction(deliverableSubActionSave); + // This is to add deliverablePriorityActions to generate correct auditlog. + if (!this.deliverable.getDeliverableShfrmSubAction().contains(deliverableSubActionSave)) { + this.deliverable.getDeliverableShfrmSubAction().add(deliverableSubActionSave); + } + } + } + } + } + } + } + } + public void saveUsers() { if (deliverable.getUsers() == null) { diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index 0d6868713e..049b4f059c 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -182,6 +182,8 @@ public final class APConstants { public static final String DELIVERABLE_FILE_LOCALLY_HOSTED_STR = "Locally"; public static final String DELIVERABLE_ID = "deliverableId"; + public static final String PRIORITY_ACTION_ID = "priority_action_id"; + public static final String SUB_ACTION_ID = "sub_action_id"; public static final int DELIVERABLE_QUALITY_ANSWER_NO = 3; public static final int DELIVERABLE_QUALITY_ANSWER_YES = 2; public static final int DELIVERABLE_QUALITY_ANSWER_YES_BUT_NO = 1; diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 8d391e42a2..8f3861f5c7 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -934,6 +934,7 @@ deliverable.shfrmContribution.narrative=Provide a short narrative on how this de deliverable.shfrmContribution.priorityAction=To which priority action of the SHFRM is this deliverable contributing to? deliverable.shfrmContribution.priorityAction.help=Select a priority action deliverable.shfrmContribution.subAction=To which specific sub-action of the SHFRM is this deliverable contributing to? +deliverable.shfrmContribution.subAction.help=Select a sub-action intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index 8fe6347983..416288d903 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -937,6 +937,7 @@ deliverable.shfrmContribution.narrative=Provide a short narrative on how this de deliverable.shfrmContribution.priorityAction=To which priority action of the SHFRM is this deliverable contributing to? deliverable.shfrmContribution.priorityAction.help=Select a priority action deliverable.shfrmContribution.subAction=To which specific sub-action of the SHFRM is this deliverable contributing to? +deliverable.shfrmContribution.subAction.help=Select a sub-action intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status diff --git a/marlo-web/src/main/resources/struts-json.xml b/marlo-web/src/main/resources/struts-json.xml index eda2de5c1a..dfc5091ee2 100644 --- a/marlo-web/src/main/resources/struts-json.xml +++ b/marlo-web/src/main/resources/struts-json.xml @@ -444,6 +444,14 @@ true + + + + true + true + + diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl index 5d858b2c99..318e5e0bc3 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl @@ -140,6 +140,7 @@ [#if action.hasSpecificities('shfrm_contribution_active') ] [#-- SHRFM contribution --] +
    [@deliverableMacros.shfmrContributionMacro /] [/#if] @@ -147,9 +148,9 @@ [#-- Single partner TEMPLATE from partnersTemplate.ftl --] [@deliverableMacros.priorityActionsMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] - [#-- Contact person TEMPLATE from partnersTemplate.ftl --] - [@deliverableMacros.subActionsMacro element={} name="deliverable.shfrmPriorityActions[-1].shfrmDeliverableSubActions[-1]" isTemplate=true /] - + [#-- Contact person TEMPLATE from partnersTemplate.ftl + [@deliverableMacros.subActionsMacro element={} name="deliverable.shfrmPriorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] +--] [#-- Key Outputs select --] [#if !project.projectInfo.administrative && !phaseOne && !isCenterProject ] diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 18bf3ab010..5ac4ae9339 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -599,35 +599,38 @@
    [#-- Shfrm Priority Action --]
    - [@customForm.elementsListComponent name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /] + [#-- + [@customForm.select name="deliverable.shfrmPriorityActions" label="" showTitle=true i18nkey="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" multiple=true header=true required=true className="activity" editable=editable keyFieldName="id" displayFieldName="composedName"/] + + --] + + [@customForm.elementsListComponent id="deliverablePriorityActions" name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /] +
    - - [#-- Testing area --] - [#if true] + [#-- Project Section Content --]
    [#-- Section Messages --] - [@s.form action=actionName method="POST" enctype="multipart/form-data" cssClass=""] [#-- Listing actions --] [#-- Priority actions list --] -
    [#if deliverable.shfrmPriorityActions?has_content] [#list deliverable.shfrmPriorityActions as priorityAction] - [@priorityActionsMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}].shfrmPriorityAction" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] + [@priorityActionsMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}]" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] [/#list] [#else] + [#-- [@priorityActionsMacro element={} name="deliverable.shfrmPriorityActions[0].shfrmPriorityAction" index=0 opened=true defaultPerson=true /] + --] +

    [@s.text name="shfrmManagement.actionsEmpty" /]

    [/#if] + [#--
    [@s.text name="shfrmManagement.priorityActions.add" /]
    -
    - - [/@s.form] + --]
    - [/#if] - [#-- end testing area --] +

    @@ -1569,44 +1572,52 @@ [/#macro] [#macro priorityActionsMacro element name index=-1 opened=false defaultPerson=false isTemplate=false] - + [#assign customName = "${name}" /] +
    [#-- Loading --] [#-- TODO: Please improve this validation at backend side --] [#-- Remove link for all partners --] - [#if editable ] [#--&& (isTemplate) --] + [#if false ] [#--&& (isTemplate) --] [/#if] [#-- Partner Title --]
    [#-- Title --] - [#-- ${index+1}. --] ${(element.shfrmPriorityAction.name)!'Priority Action'}: ${(element.shfrmPriorityAction.description)!''} + [#-- ${index+1}. --] ${(element.shfrmPriorityAction.name)!'Priority Action'}: ${(element.shfrmPriorityAction.description)!''}

    - - [#-- Action name --] - - -
    - [@customForm.input name="${name}.name" i18nkey="shfrmManagement.priorityActions.title" className="name limitWords-100" required=true /] -
    -
    - [#-- Action description --] + + + [#-- Shfrm Priority Action
    - [@customForm.input name="${name}.description" i18nkey="shfrmManagement.priorityActions.description" className="description limitWords-100" required=true /] + [@customForm.elementsListComponent name="${name}.shfrmPriorityAction" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true maxLimit=1/]
    -
    - + --] + [#-- Action name --] + [#-- Sub Actions --]
    + + [#-- Shfrm sub Action list --] +
    + [#-- + [@customForm.select name="${name}.shfrmSubActions" label="" help="deliverable.shfrmContribution.subAction.help" helpIcon=false i18nkey="deliverable.shfrmContribution.subAction" listName="shfrmSubActions" multiple=true required=true className="subActionSelect" editable=editable keyFieldName="id" displayFieldName="composedName"/] + --] + [@customForm.elementsListComponent name="${name}.shfrmSubActions" elementType="shfrmSubAction" help="deliverable.shfrmContribution.subAction.help" helpIcon=false elementList=(element.shfrmSubActions)![] label="deliverable.shfrmContribution.subAction" listName="(${customName}.shfrmPriorityAction.shfrmSubActions)!" keyFieldName="id" displayFieldName="composedName" required=true /] + +
    + + [#--
    [@s.text name="shfrmManagement.subActions.add" /] [@customForm.req required=true /]
    + [#if element.shfrmSubActions?has_content] [#list element.shfrmSubActions as subAction] [@subActionsMacro element=subAction name="${name}.shfrmSubActions[${subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] @@ -1619,6 +1630,7 @@ [/#if]
    + --]
    diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js new file mode 100644 index 0000000000..65b09d6051 --- /dev/null +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -0,0 +1,944 @@ +var $removePartnerDialog, $projectPPAPartners; +var defaultType, partnerRespRequired; +var projectLeader; +var lWordsResp = 100; + +$(document).ready(init); + +function init() { + + // Setting global variables + $removePartnerDialog = $('#partnerRemove-dialog'); + $partnersBlock = $('#projectPartnersBlock'); + $projectPPAPartners = $('#projectPPAPartners'); + partnerRespRequired = ($("#partnerRespRequired").val() === "true"); + defaultType = 'CP'; + + // Activate the chosen to the existing partners + addSelect2(); + + addUser = function(composedName,userId) { + var $contact = $elementSelected.parents('.contactsPerson ').find('input[value="' + userId + '"]'); + + if(!$contact.exists()) { + $elementSelected.parents('.userField ').find("input.userName").val(composedName).addClass('animated flash'); + $elementSelected.parents('.userField ').find("input.userId").val(userId); + } else { + var notyOptions = jQuery.extend({}, notyDefaultOptions); + notyOptions.text = 'Contact person cannot be repeated'; + noty(notyOptions); + } + dialog.dialog("close"); + } + + // This function enables launch the pop up window + popups(); + // Attaching listeners + attachEvents(); + + + $('.loadingBlock').hide().next().fadeIn(500, function() { + // Missing fields in parter person + $("form .projectPartner ").each(function(i,e) { + verifyMissingFields(e); + }); + showHelpText(); + setViewMore(); + }); + + $("textarea[id!='justification']").autoGrow(); + +} + +function attachEvents() { + + /** + * General + */ + + $('.blockTitle').on('click', function() { + if($(this).hasClass('closed')) { + $('.blockContent').slideUp(); + $('.blockTitle').removeClass('opened').addClass('closed'); + $(this).removeClass('closed').addClass('opened'); + } else { + $(this).removeClass('opened').addClass('closed'); + } + + $(this).next().slideToggle(500, function() { + $(this).find('textarea').autoGrow(); + $(this).find(".errorTag").hide(); + $(this).find(".errorTag").css("left", $(this).outerWidth()); + $(this).find(".errorTag").fadeIn(1000); + + // Scroll to selected partner + $('html, body').animate({scrollTop: $(this).offset().top - 100}, 500); + }); + }); + + $('.button-save').on('click', function(e) { + var missingFields = 0 + $('form select.institutionsList').each(function(i,e){ + if(!e.value){ + missingFields++; + } + }); + + // Validate if there are missing fields + if(missingFields) { + e.preventDefault(); + var notyOptions = jQuery.extend({}, notyDefaultOptions); + notyOptions.text = "You must select a partner organization"; + noty(notyOptions); + // Turn off the saving button state + turnSavingStateOff(this); + return + } + }); + + /** + * Project partner Events + */ + // Add a project partner Event + $(".addPriorityAction").on('click', addPartnerEvent); + // Add a project partner Event + $(".addProjectPartner").on('click', addPartnerEvent); + // Remove a project partner Event + $(".removePartner").on('click', removePartnerEvent); + // When Partner Type change + $("select.partnerTypes, select.countryList").change(updateOrganizationsList); + // When name change + $("input.name").on("change", function(e) { + find('.priorityActionTitle').text(this.name); + }); + + // Partners filters + $(".filters-link span").on("click", filterInstitutions); + + // Location Elements events + $(".countriesList").on('change', addLocElementCountry); + $('.removeLocElement').on('click', removeLocElement); + + // Request country office + $('#requestModal').on( + 'show.bs.modal', + function(event) { + $.noty.closeAll(); + var partner = new PartnerObject($(event.relatedTarget).parents('.projectPartner')); + + var $modal = $(this); + // Show Form & button + $modal.find('form, .requestButton').show(); + $modal.find('.messageBlock').hide(); + $modal.find('input.institution_id').val(partner.institutionId); + $modal.find('select.countriesRequest').val(null).trigger('select2:change'); + $modal.find('select.countriesRequest').trigger('change'); + $modal.find('.modal-title').html( + 'Request Country office(s)
    (' + partner.institutionName + ')'); + }); + $('#requestModal button.requestButton').on('click', function() { + var $modal = $(this).parents('.modal'); + if($modal.find('select.countriesRequest').val() == null) { + return + + } + + $.ajax({ + url: baseURL + '/requestCountryOffice.do', + data: $('#requestModal form').serialize(), + beforeSend: function(data) { + $modal.find('.loading').fadeIn(); + }, + success: function(data) { + console.log(data); + if(data.sucess.result == "1") { + // Hide Form & button + $modal.find('form, .requestButton').hide(); + $modal.find('.messageBlock').show(); + + // Noty Message + /* + * var message = $modal.find('.messageBlock .notyMessage').html(); var notyOptions = jQuery.extend({}, + * notyDefaultOptions); notyOptions.text = message; notyOptions.type = 'info'; notyOptions.timeout = 5000; + * notyOptions.animation = { open: 'animated fadeIn', // Animate.css class names close: 'animated fadeOut', // + * Animate.css class names easing: 'swing', // unavailable - no need speed: 400 // unavailable - no need }; + * notyOptions.callback = { onClose : function(){ $modal.modal('hide'); } }; $modal.find('.messageBlock + * .notyMessage').noty(notyOptions); + */ + } + }, + complete: function() { + $modal.find('.loading').fadeOut(); + } + }); + }); + + /** + * CCAFS Partners list events + */ + $('.ppaPartnersList select').on('change', function(e) { + addItemList($(this).find('option:selected')); + }); + $('ul li .remove').on('click', function(e) { + removeItemList($(this).parents('li')); + }); + + /** + * Partner Person Events + */ + // Add partner Person Event + // $(".addContact a.addLink").on('click', addContactEvent); + $(".addContact").on('click', addContactEvent); + // Remove partner person event + $(".removePerson").on('click', removePersonEvent); + // When partnerPersonType change + $("select.partnerPersonType").on("change", changePartnerPersonType); + // Event when click in a relation tag of partner person + $(".tag").on("click", showPersonRelations); + +} + +function showHelpText() { + $('.helpMessage').show(); + $('.helpMessage').addClass('animated flipInX'); +} + +function getProjectLeader() { + var contactLeader = {}; + $partnersBlock.find('.contactPerson').each(function(i,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + if(contact.isLeader()) { + contactLeader = jQuery.extend({}, contact); + } + }); + return contactLeader; +} + +function setProjectLeader(obj) { + projectLeader = jQuery.extend({}, obj); +} + +function filterInstitutions(e) { + var $filterContent = $(e.target).parent().next(); + if($filterContent.is(":visible")) { + updateOrganizationsList(e); + } + $filterContent.slideToggle(); +} + +function showPersonRelations(e) { + var $relations = $(this).next().html(); + $('#relations-dialog').dialog({ + modal: true, + closeText: "", + width: 500, + buttons: { + Close: function() { + $(this).dialog("close"); + } + }, + open: function() { + $(this).html($relations); + }, + close: function() { + $(this).empty(); + } + }); +} + +function changePartnerPersonType(e) { + var $contactPerson = $(e.target).parents('.contactPerson'); + var contact = new PartnerPersonObject($contactPerson); + // Set as unique contact type in the project + + // Change partner person type + contact.changeType(); + // Change parent partner type + var partner = new PartnerObject($contactPerson.parents('.projectPartner')); + partner.changeType(); + +} + +function updateOrganizationsList(e) { + var $parent = $(e.target).parents('.projectPartner'); + var partner = new PartnerObject($parent); + var $selectInstitutions = $parent.find("select.institutionsList"); // Institutions list + var optionSelected = $selectInstitutions.find('option:selected').val(); // Institution selected + var source = baseURL + "/institutionsByTypeAndCountry.do"; + + if($(e.target).parent().attr("class") != "filters-link") { + var partnerTypes = $parent.find("select.partnerTypes").find('option:selected').val() || -1; // Type value + var countryList = $parent.find("select.countryList").find('option:selected').val() || -1; // Value value + source += "?institutionTypeID=" + partnerTypes + "&countryID=" + countryList; + } else { + source += "?institutionTypeID=-1&countryID=-1"; + } + $.ajax({ + url: source, + beforeSend: function() { + partner.startLoader(); + $selectInstitutions.empty().append(setOption(-1, "Select an option")); + }, + success: function(data) { + $.each(data.institutions, function(index,institution) { + $selectInstitutions.append(setOption(institution.id, institution.name)); + }); + }, + complete: function() { + partner.stopLoader(); + $selectInstitutions.val(optionSelected); + $selectInstitutions.trigger("change.select2"); + } + }); +} + +function updateProjectPPAPartnersLists(e) { + var projectInstitutions = []; + // Clean PPA partners from hidden select + $projectPPAPartners.empty(); + // Loop for all projects partners + $partnersBlock.find('.projectPartner').each(function(i,projectPartner) { + var partner = new PartnerObject($(projectPartner)); + // Collecting partners institutions + projectInstitutions.push(parseInt(partner.institutionId)); + // Validating if the partners is PPA Partner + if(partner.isPPA()) { + partner.hidePPAs(); + // Collecting list CCAFS partners from all project partners + $projectPPAPartners.append(setOption(partner.institutionId, partner.institutionName)); + } else { + if(partner.institutionId == -1) { + partner.hidePPAs(); + } else { + partner.showPPAs(); + } + } + }); + $projectPPAPartners.trigger("change.select2"); + + // Validating if the institution chosen is already selected + if(e) { + var $fieldError = $(e.target).parents('.partnerName').find('p.fieldErrorInstitutions'); + $fieldError.text(''); + var count = 0; + // Verify if the partner is already selected + for(var i = 0; i < projectInstitutions.length; ++i) { + if(projectInstitutions[i] == e.target.value) { + count++; + } + } + // If there is one selected , show an error message + if(count > 1) { + var institutionName = $(e.target).find('option[value="' + e.target.value + '"]').text(); + var institutionName_saved = + $('input.institutionsList[value=' + e.target.value + ']').parents('.projectPartner').find('.partnerTitle') + .text(); + $fieldError.html('"' + (institutionName || institutionName_saved) + '" is already selected').animateCss( + 'flipInX'); + e.target.value = -1; + } + } + + // Filling CCAFS partners lists for each project partner cooment + $partnersBlock.find('.projectPartner').each(function(i,partner) { + var $select = $(partner).find('select.ppaPartnersSelect'); + $select.empty().append(setOption(-1, "Select an option")); + $select.append($projectPPAPartners.html()); + // Removing of the list CCAFS partners previously selected by project partner + $(partner).find('li input.id').each(function(i_id,id) { + $select.find('option[value=' + $(id).val() + ']').remove(); + }); + $select.trigger("change.select2"); + }); + +} + +function removePartnerEvent(e) { + e.preventDefault(); + var partner = new PartnerObject($(e.target).parent().parent()); + var messages = ""; + var activities = partner.getRelationsNumber('activities'); + var deliverables = partner.getRelationsNumber('deliverables'); + var partnerContributions = partner.hasPartnerContributions(); + var removeDialogOptions = { + modal: true, + width: 500, + buttons: {}, + closeText: "", + close: function() { + $(this).find('.messages').empty(); + } + }; + // The budget related with this partner will be deleted + if(partner.id != -1) { + // messages += '
  • Note that the budget affected to this partner will also be deleted.
  • '; + removeDialogOptions.buttons = { + "Remove partner": function() { + partner.remove(); + $(this).dialog("close"); + }, + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if there are any deliverables linked to any contact persons from this partner + if(deliverables > 0) { + messages += + '
  • Please bear in mind that if you delete this partner, ' + deliverables + + ' deliverables relations will be deleted
  • '; + removeDialogOptions.buttons = { + "Remove partner": function() { + partner.remove(); + $(this).dialog("close"); + }, + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if the CCAFS partner is currently contributing has any contributions to another partner + if(partner.isPPA() && (partnerContributions.length > 0)) { + messages += '
  • ' + partner.institutionName + ' is currently allocating budget to the following partner(s):'; + messages += '
      '; + for(var i = 0, len = partnerContributions.length; i < len; i++) { + messages += '
    • ' + partnerContributions[i] + '
    • '; + } + messages += '
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if the project partner has any project leader assigned + if(partner.hasLeader()) { + messages += + '
  • Please indicate another project leader from a different partner before deleting this partner.
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + // Validate if there are any activity linked to any contact person of this partner + if(activities > 0) { + messages += + '
  • This partner cannot be deleted because at least one or more contact persons is leading ' + activities + + ' activity(ies)
  • '; + messages += + '
  • If you want to proceed with the deletion, please go to the activities and change the activity leader
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + + if(messages === "") { + // Remove partner if there is not any problem + partner.remove(); + } else { + // Show pop up if there are any message + $("#partnerRemove-dialog").find('.messages').append(messages); + $("#partnerRemove-dialog").dialog(removeDialogOptions); + } +} + +function addPartnerEvent(e) { + console.log("addPartnerEvent"); + var $newElement = $("#projectPartner-template").clone(true).removeAttr("id"); + $(this).before($newElement); + $newElement.find('.blockTitle').trigger('click'); + $newElement.show("slow", function() { + // Update component + $(document).trigger('updateComponent'); + }); + + // Activate the select2 plugin for new partners created + // Organization + $newElement.find("select.institutionsList").parent().find("span.select2-selection__placeholder") + .text(placeholderText); + + // Role Selection + $newElement.find("select.partnerPersonType").select2({ + templateResult: formatState, + width: "100%" + }); + + // Research Phase + $newElement.find("select.researchPhasesSelect ").select2({ + placeholder: "Select here...", + width: '100%' + }); + + // Countries + $newElement.find('select.countriesList, select.countriesSelect').select2({ + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' + }); + + // Other Selects + $newElement.find('select.setSelect2').select2({ + width: '100%' + }); + + // Update indexes + setProjectPartnersIndexes(); +} + +function addContactEvent(e) { + e.preventDefault(); + var $newElement = $("#contactPerson-template").clone(true).removeAttr("id"); + var contact = new PartnerPersonObject($newElement); + var partner = new PartnerObject($(this).parents('.projectPartner')); + $(e.target).parent().before($newElement); + $newElement.show("slow"); + // Activate the select2 plugin for new partners created + $newElement.find("select").select2({ + templateResult: formatState, + width: '100%' + }); + + // IFPRI Division + if(partner.institutionId == 89){ + $newElement.find('.divisionBlock.division-IFPRI').show(); + } + + // Remove "No contact person added" message + $(e.target).parents('.contactsPerson').find('.noContactMessage').hide(); + + // Update PPA partners requirements + updateProjectPPAPartnersLists(); + + // Update indexes + setProjectPartnersIndexes(); +} + +function removePersonEvent(e) { + e.preventDefault(); + var person = new PartnerPersonObject($(e.target).parent()); + var messages = ""; + var activities = person.getRelationsNumber('activities'); + var deliverables = person.getRelationsNumber('deliverables'); + var removeDialogOptions = { + modal: true, + closeText: "", + width: 500, + buttons: {}, + close: function() { + $(this).find('.messages').empty(); + } + }; + // Validate if there are any deliverable linked to this person + if(deliverables > 0) { + messages += + '
  • Please bear in mind that if you delete this contact, ' + deliverables + + ' deliverables relations will be deleted.
  • '; + removeDialogOptions.buttons = { + "Remove Person": function() { + person.remove(); + $(this).dialog("close"); + }, + Close: function() { + $(this).dialog("close"); + } + }; + } + + // Validate if there are any activity linked to this person + if(activities > 0) { + messages += '
  • This contact person cannot be deleted because he/she is leading activity(ies)'; + messages += + '
  • If you want to proceed with the deletion, please go to the following activities and change the activity leader
  • '; + messages += '
      '; + messages += person.getRelations('activities'); + messages += '
    '; + messages += ''; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } + if(messages === "") { + // Remove person if there is not any message + person.remove(); + } else { + // Show a pop up with the message + $("#contactRemove-dialog").find('.messages').append(messages); + $("#contactRemove-dialog").dialog(removeDialogOptions); + } +} + +function setProjectPartnersIndexes() { + $partnersBlock.find(".projectPartner").each(function(index,element) { + var partner = new PartnerObject($(element)); + partner.setIndex(index); + }); +} + +/** + * Items list functions + */ + +function removeItemList($item) { + // Adding option to the select + var $select = $item.parents('.panel').find('select'); + $select.append(setOption($item.find('.id').val(), $item.find('.name').text())); + $select.trigger("change.select2"); + // Removing from list + $item.hide("slow", function() { + $item.remove(); + setProjectPartnersIndexes(); + }); +} + +function addItemList($option) { + var $select = $option.parent(); + var $list = $option.parents('.panel').find('ul.list'); + // Adding element to the list + var $li = $("#ppaListTemplate").clone(true).removeAttr("id"); + $li.find('.id').val($option.val()); + $li.find('.name').html($option.text()); + $li.appendTo($list).hide().show('slow'); + // Removing option from select + $option.remove(); + $select.trigger("change.select2"); + setProjectPartnersIndexes(); +} + +// Activate the chosen plugin to the countries, partner types and partners lists. +function addSelect2() { + + // Organization / institution + $("form select.institutionsList").parent().find("span.select2-selection__placeholder").text(placeholderText); + + // Role Selection + $("form select.partnerPersonType").select2({ + templateResult: formatState, + width: "100%" + }); + + // Research Phase + $("form select.researchPhasesSelect ").select2({ + placeholder: "Select here...", + width: '100%' + }); + + + + $('form select.countriesList, select.countriesRequest, form select.countriesSelect').select2({ + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' + }); + + // Other selects + $("form select.setSelect2 ").select2({ + width: '100%' + }); + +} + +/** + * PartnerObject + * + * @param {DOM} Project partner + */ + +function PartnerObject(partner) { + + var types = []; + this.id = parseInt($(partner).find('.partnerId').val()); + this.institutionId = parseInt($(partner).find('.institutionsList').val()); + this.institutionName = + $('#instID-' + this.institutionId + ' .composedName').text() || $(partner).find('.partnerTitle').text(); + this.allowSubDepart = ($('#instID-' + this.institutionId + ' .allowSubDepart').text() === "true") || false; + this.subDepartments = $('#instID-' + this.institutionId + ' .subDepartments option'); + this.ppaPartnersList = $(partner).find('.ppaPartnersList'); + this.persons = $(partner).find('.contactsPerson .contactPerson'); + this.countriesSelect = $(partner).find('.countriesList'); + this.setIndex = function(index) { + + // Updating indexes + $(partner).setNameIndexes(1, index); + // Update index for project Partner + $(partner).find("> .blockTitle .index_number").html(index + 1); + // Update index for CCAFS Partners + $(partner).find('.ppaPartnersList ul.list li').each(function(li_index,li) { + $(li).setNameIndexes(2, li_index); + }); + + // Update radio buttons labels and for + $(partner).find('input.hasPartnerships-yes').attr('id', "hasPartnerships-yes-"+ index).next().attr('for',"hasPartnerships-yes-"+ index); + $(partner).find('input.hasPartnerships-no').attr('id', "hasPartnerships-no-"+ index).next().attr('for',"hasPartnerships-no-"+ index); + + // Update index for partner persons + $(partner).find('.contactPerson').each(function(person_index,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + contact.setIndex(index, person_index); + }); + + // Update index for locations + $(partner).find('.locElement').each(function(i,element) { + $(element).setNameIndexes(2, i); + }); + }; + this.validateGovernmentType = function() { + if(this.allowSubDepart) { + $(partner).find('.subDepartment').slideDown(); + } else { + $(partner).find('.subDepartment').slideUp(); + } + }; + + this.hasPartnerContributions = function() { + var partners = []; + var institutionId = this.institutionId; + $partnersBlock.find(".projectPartner").each(function(index,element) { + var projectPartner = new PartnerObject($(element)); + $(element).find('.ppaPartnersList ul.list li input.id').each(function(i_id,id) { + if($(id).val() == institutionId) { + partners.push(projectPartner.institutionName); + } + }); + }); + return partners; + }; + this.hasLeader = function() { + var result = false; + $(partner).find('.contactPerson').each(function(i,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + if(contact.isLeader()) { + result = true; + } + }); + return result; + }; + this.isPPA = function() { + var instID = parseInt($(partner).find('.institutionsList').val()); + if(instID == -1) { + $(partner).find("> .blockTitle .index").removeClass('ppa').text('Partner'); + return false; + } + }; + this.getRelationsNumber = function(relation) { + var count = 0; + $(partner).find('.contactPerson').each(function(i,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + count += contact.getRelationsNumber(relation); + }); + return count; + }; + this.checkLeader = function() { + if($(partner).find('.contactPerson.PL').length == 0) { + $(partner).removeClass('leader'); + $(partner).find('.type-leader').hide(); + } else { + $(partner).find('.type-leader').show(); + $(partner).addClass('leader'); + types.push('Leader'); + } + }; + this.checkCoordinator = function() { + if($(partner).find('.contactPerson.PC').length == 0) { + $(partner).removeClass('coordinator'); + $(partner).find('.type-coordinator').hide(); + } else { + $(partner).addClass('coordinator'); + $(partner).find('.type-coordinator').show(); + types.push('Coordinator'); + } + }; + this.changeType = function() { + types = []; + this.checkLeader(); + this.checkCoordinator(); + if(types.length != 0) { + $(partner).find('strong.type').text(' (' + types.join(", ") + ')'); + } else { + $(partner).find('strong.type').text(''); + } + }; + this.remove = function() { + $(partner).hide("slow", function() { + $(partner).remove(); + updateProjectPPAPartnersLists(); + setProjectPartnersIndexes(); + }); + }; + this.clearCountries = function() { + var $list = $(partner).find(".countries-list.items-list ul"); + $list.empty(); + }; + this.addCountry = function(country) { + var contryISO = country.iso; + var countryName = country.name; + if(contryISO == "-1") { + return + + } + + var $list = $(partner).find(".items-list ul"); + + var selectedCountries = $list.find('.locElement').map(function() { + return $(this).find('input.locElementCountry').val(); + }).get(); + + if(selectedCountries.indexOf(contryISO) != -1) { + var notyOptions = jQuery.extend({}, notyDefaultOptions); + notyOptions.text = 'Countries office cannot be repeated'; + noty(notyOptions); + return + + } + + var $item = $('#locElement-template').clone(true).removeAttr('id'); + + // Fill item values + $item.find('span.name').text(countryName); + $item.find('span.coordinates').text(""); + $item.find('input.locElementName').val(countryName); + $item.find('input.locElementCountry').val(contryISO); + + // Add Flag + var $flag = $item.find('.flag-icon'); + var flag = ''; + $flag.html(flag); + // Remove coordinates span + $item.find('.coordinates').remove(); + // Adding item to the list + $list.append($item); + // Update Locations Indexes + setProjectPartnersIndexes(); + // Show item + $item.show('slow'); + // Remove message + $list.parent().find('p.message').hide(); + + // Reset select + $(this.countriesSelect).removeOption(contryISO) + $(this.countriesSelect).val('-1'); + $(this.countriesSelect).trigger('select2:change'); + }; + this.showPPAs = function() { + $(this.ppaPartnersList).slideDown(); + // $(partner).find('.partnerResponsabilities .requiredTag').hide(); + $(partner).find('.contactsPerson .requiredTag').hide(); + }; + this.hidePPAs = function() { + $(this.ppaPartnersList).slideUp(); + + // Add a contact person by default + if($(this.persons).length <= 0) { + console.log('asdfasdf'); + $(partner).find('.addContact .addLink').trigger('click'); + } + + // $(partner).find('.partnerResponsabilities .requiredTag').show(); + $(partner).find('.contactsPerson .requiredTag').show(); + + }; + + this.startLoader = function() { + $(partner).find('.loading').fadeIn(); + }; + this.stopLoader = function() { + $(partner).find('.loading').fadeOut(); + }; +} + +/** + * PartnerPersonObject + * + * @param {DOM} Partner person + */ +function PartnerPersonObject(partnerPerson) { + this.id = parseInt($(partnerPerson).find('.partnerPersonId').val()); + this.type = $(partnerPerson).find('.partnerPersonType').val(); + this.contactInfo = $(partnerPerson).find('.userName').val(); + this.canEditEmail = ($(partnerPerson).find('input.canEditEmail').val() === "true"); + this.setPartnerType = function(type) { + this.type = type; + $(partnerPerson).find('.partnerPersonType').val(type).trigger('change.select2'); + }; + this.getPartnerType = function() { + return $(partnerPerson).find('.partnerPersonType').val(); + }; + + this.getRelationsNumber = function(relation) { + return parseInt($(partnerPerson).find('.tag.' + relation + ' span').text()) || 0; + }; + this.getRelations = function(relation) { + return $(partnerPerson).find('.tag.' + relation).next().find('ul').html(); + }; + this.setIndex = function(partnerIndex,index) { + // Update Indexes + $(partnerPerson).setNameIndexes(2, index); + + // Update name & id for unused input + $(partnerPerson).find(".userName").attr("name", "partner-" + partnerIndex + "-person-" + index); + $(partnerPerson).find(".userName").attr("id", "partner-" + partnerIndex + "-person-" + index); + + }; + this.remove = function() { + var partner = new PartnerObject($(partnerPerson).parents('.projectPartner')); + $(partnerPerson).hide("slow", function() { + $(partnerPerson).remove(); + partner.changeType(this.type); + setProjectPartnersIndexes(); + }); + }; +} + +function formatState(state) { + var $state = + $("" + + state.text + + "
    " + + $('span.contactPersonRole-' + state.id).text() + "
    "); + return $state; + +}; + +function formatStateCountries(state) { + if(!state.id) { + return state.text; + } + var flag = ' '; + var $state; + if(state.id != -1) { + $state = $('' + flag + state.text + ''); + } else { + $state = $('' + state.text + ''); + } + return $state; +}; + +// Locations (Country Offices) +function addLocElementCountry() { + var $partner = $(this).parents('.projectPartner'); + var partner = new PartnerObject($partner); + + var $countrySelected = $(this).find("option:selected"); + partner.addCountry({ + iso: $countrySelected.val(), + name: $countrySelected.text() + }); +} + +function removeLocElement() { + var $parent = $(this).parent(); + var $select = $parent.parents('.countries-list ').find('select.countriesList'); + // Add removed item to the selection list + $select.addOption($parent.find('input.locElementCountry').val(), $parent.find('span.name').text()); + // Removing item + $parent.hide('slow', function() { + $parent.remove(); + setProjectPartnersIndexes(); + }); +} From b179927f0d2f13440fd79fcc2963764e594eb87c Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 5 Feb 2024 07:29:21 -0500 Subject: [PATCH 33/65] :wrench: chore(shfrm Contribution): Change delete process query --- .../mysql/DeliverableShfrmPriorityActionMySQLDAO.java | 8 ++++++-- .../dao/mysql/DeliverableShfrmSubActionMySQLDAO.java | 8 ++++++-- .../data/dao/mysql/ShfrmPriorityActionMySQLDAO.java | 10 +++++++--- .../marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java | 7 +++++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java index 937ad260c5..b9f8064b03 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java @@ -39,8 +39,12 @@ public DeliverableShfrmPriorityActionMySQLDAO(SessionFactory sessionFactory) { @Override public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId) { DeliverableShfrmPriorityAction deliverableShfrmPriorityAction = this.find(deliverableShfrmPriorityActionId); - deliverableShfrmPriorityAction.setActive(false); - this.update(deliverableShfrmPriorityAction); + /* + * deliverableShfrmPriorityAction.setActive(false); + * this.update(deliverableShfrmPriorityAction); + */ + this.delete(deliverableShfrmPriorityAction); + } @Override diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java index 5eff91c3e1..b6cf7206c7 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java @@ -39,8 +39,12 @@ public DeliverableShfrmSubActionMySQLDAO(SessionFactory sessionFactory) { @Override public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId) { DeliverableShfrmSubAction deliverableShfrmSubAction = this.find(deliverableShfrmSubActionId); - deliverableShfrmSubAction.setActive(false); - this.update(deliverableShfrmSubAction); + /* + * deliverableShfrmSubAction.setActive(false); + * this.update(deliverableShfrmSubAction); + */ + this.delete(deliverableShfrmSubAction); + } @Override diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java index d842049574..796cf45d58 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java @@ -27,7 +27,8 @@ import org.hibernate.SessionFactory; @Named -public class ShfrmPriorityActionMySQLDAO extends AbstractMarloDAO implements ShfrmPriorityActionDAO { +public class ShfrmPriorityActionMySQLDAO extends AbstractMarloDAO + implements ShfrmPriorityActionDAO { @Inject @@ -38,8 +39,11 @@ public ShfrmPriorityActionMySQLDAO(SessionFactory sessionFactory) { @Override public void deleteShfrmPriorityAction(long shfrmPriorityActionId) { ShfrmPriorityAction shfrmPriorityAction = this.find(shfrmPriorityActionId); - shfrmPriorityAction.setActive(false); - this.update(shfrmPriorityAction); + /* + * shfrmPriorityAction.setActive(false); + * this.update(shfrmPriorityAction); + */ + this.delete(shfrmPriorityAction); } @Override diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java index e6f03e7103..aabe72299e 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java @@ -38,8 +38,11 @@ public ShfrmSubActionMySQLDAO(SessionFactory sessionFactory) { @Override public void deleteShfrmSubAction(long shfrmSubActionId) { ShfrmSubAction shfrmSubAction = this.find(shfrmSubActionId); - shfrmSubAction.setActive(false); - this.update(shfrmSubAction); + /* + * shfrmSubAction.setActive(false); + * this.update(shfrmSubAction); + */ + this.delete(shfrmSubAction); } @Override From 345bfabcf464ec83f1374daea62665d43939e1da Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 5 Feb 2024 08:36:53 -0500 Subject: [PATCH 34/65] :wrench: chore(shfrm Contribution): Create deliverable action and sub-actions replication logic to save and delete process --- ...verableShfrmPriorityActionManagerImpl.java | 43 ++++++++++---- .../DeliverableShfrmSubActionManagerImpl.java | 58 +++++++++++++++---- 2 files changed, 77 insertions(+), 24 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java index 55ee7f7a37..b3147077b7 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java @@ -71,15 +71,14 @@ public void deleteDeliverableShfrmPriorityActionPhase(Phase next, long deliverab Phase phase = phaseDAO.find(next.getId()); DeliverableShfrmPriorityAction deliverableShfrmPriorityActionDelete = new DeliverableShfrmPriorityAction(); - deliverableShfrmPriorityActionDelete = deliverableShfrmPriorityActionDAO - .findByDeliverableAndPhase(deliverableId, phase.getId()).stream() - .filter( - d -> deliverableShfrmPriorityAction != null && deliverableShfrmPriorityAction.getShfrmPriorityAction() != null + deliverableShfrmPriorityActionDelete = + deliverableShfrmPriorityActionDAO.findByDeliverableAndPhase(deliverableId, phase.getId()).stream() + .filter(d -> d != null && deliverableShfrmPriorityAction != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction() != null && deliverableShfrmPriorityAction.getShfrmPriorityAction().getId() != null && d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null && d.getShfrmPriorityAction().getId().equals(deliverableShfrmPriorityAction.getShfrmPriorityAction().getId())) - .collect(Collectors.toList()).get(0); - deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityActionDelete); + .collect(Collectors.toList()).get(0); if (deliverableShfrmPriorityActionDelete != null) { deliverableShfrmPriorityActionDAO @@ -135,13 +134,33 @@ public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long public void saveDeliverableShfrmPriorityActionPhase(Phase next, long deliverableId, DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { Phase phase = phaseDAO.find(next.getId()); + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionPhase = new DeliverableShfrmPriorityAction(); + try { + deliverableShfrmPriorityActionPhase = deliverableShfrmPriorityActionDAO + .findByDeliverableAndPhase(deliverableId, phase.getId()).stream() + .filter(d -> d != null && deliverableShfrmPriorityAction != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction() != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(deliverableShfrmPriorityAction.getShfrmPriorityAction().getId())) + .collect(Collectors.toList()).get(0); + } catch (Exception e) { + logger.error("error getting deliverableShfrmPriorityActionPhase: " + e); + } - DeliverableShfrmPriorityAction deliverableShfrmPriorityActionAdd = new DeliverableShfrmPriorityAction(); - deliverableShfrmPriorityActionAdd.setDeliverable(deliverableShfrmPriorityAction.getDeliverable()); - deliverableShfrmPriorityActionAdd.setPhase(phase); - deliverableShfrmPriorityActionAdd.setShfrmPriorityAction(deliverableShfrmPriorityAction.getShfrmPriorityAction()); - deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityActionAdd); - + if (deliverableShfrmPriorityActionPhase != null) { + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionAdd = deliverableShfrmPriorityActionPhase; + deliverableShfrmPriorityActionAdd.setDeliverable(deliverableShfrmPriorityAction.getDeliverable()); + deliverableShfrmPriorityActionAdd.setPhase(phase); + deliverableShfrmPriorityActionAdd.setShfrmPriorityAction(deliverableShfrmPriorityAction.getShfrmPriorityAction()); + deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityActionAdd); + } else { + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionAdd = new DeliverableShfrmPriorityAction(); + deliverableShfrmPriorityActionAdd.setDeliverable(deliverableShfrmPriorityAction.getDeliverable()); + deliverableShfrmPriorityActionAdd.setPhase(phase); + deliverableShfrmPriorityActionAdd.setShfrmPriorityAction(deliverableShfrmPriorityAction.getShfrmPriorityAction()); + deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityActionAdd); + } if (phase.getNext() != null) { this.saveDeliverableShfrmPriorityActionPhase(phase.getNext(), deliverableId, deliverableShfrmPriorityAction); } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java index a0615af940..aa85f30181 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java @@ -51,9 +51,32 @@ public DeliverableShfrmSubActionManagerImpl(DeliverableShfrmSubActionDAO deliver @Override public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId) { + DeliverableShfrmSubAction deliverableShfrmSubAction = + this.getDeliverableShfrmSubActionById(deliverableShfrmSubActionId); + Phase currentPhase = phaseDAO.find(deliverableShfrmSubAction.getPhase().getId()); + + if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { + this.deleteDeliverableShfrmSubActionPhase(currentPhase.getNext(), deliverableShfrmSubAction); + } + deliverableShfrmSubActionDAO.deleteDeliverableShfrmSubAction(deliverableShfrmSubActionId); } + public void deleteDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSubAction deliverableShfrmSubAction) { + Phase phase = phaseDAO.find(next.getId()); + + DeliverableShfrmSubAction deliverableShfrmSubActionDelete = new DeliverableShfrmSubAction(); + deliverableShfrmSubActionDelete = deliverableShfrmSubActionDAO.findByPriorityActionAndPhase( + deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), phase.getId()).get(0); + + if (deliverableShfrmSubActionDelete != null) { + deliverableShfrmSubActionDAO.deleteDeliverableShfrmSubAction(deliverableShfrmSubActionDelete.getId()); + } + if (phase.getNext() != null) { + this.deleteDeliverableShfrmSubActionPhase(phase.getNext(), deliverableShfrmSubAction); + } + } + @Override public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID) { @@ -89,27 +112,38 @@ public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmS if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { - this.saveDeliverableShfrmSubActionPhase(currentPhase.getNext(), - deliverableShfrmSubActionResult.getDeliverableShfrmPriorityAction().getId(), deliverableShfrmSubActionResult); + this.saveDeliverableShfrmSubActionPhase(currentPhase.getNext(), deliverableShfrmSubActionResult); } return deliverableShfrmSubActionResult; } - public void saveDeliverableShfrmSubActionPhase(Phase next, long priorityActionId, - DeliverableShfrmSubAction deliverableShfrmSubAction) { + public void saveDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSubAction deliverableShfrmSubAction) { Phase phase = phaseDAO.find(next.getId()); + DeliverableShfrmSubAction deliverableShfrmSubActionPhase = new DeliverableShfrmSubAction(); + try { + deliverableShfrmSubActionPhase = deliverableShfrmSubActionDAO.findByPriorityActionAndPhase( + deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), phase.getId()).get(0); + } catch (Exception e) { + logger.error("error getting deliverableShfrmSubActionPhase: " + e); + } - DeliverableShfrmSubAction deliverableShfrmSubActionAdd = new DeliverableShfrmSubAction(); - deliverableShfrmSubActionAdd.setPhase(phase); - deliverableShfrmSubActionAdd - .setDeliverableShfrmPriorityAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction()); - deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); + if (deliverableShfrmSubActionPhase != null) { + DeliverableShfrmSubAction deliverableShfrmSubActionAdd = deliverableShfrmSubActionPhase; + deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd + .setDeliverableShfrmPriorityAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction()); + deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); + } else { + DeliverableShfrmSubAction deliverableShfrmSubActionAdd = new DeliverableShfrmSubAction(); + deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd + .setDeliverableShfrmPriorityAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction()); + deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); + } if (phase.getNext() != null) { - this.saveDeliverableShfrmSubActionPhase(phase.getNext(), - deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), deliverableShfrmSubAction); + this.saveDeliverableShfrmSubActionPhase(phase.getNext(), deliverableShfrmSubAction); } } - } From 40cb5fc2e17b833b6536acccd38bd0deb0e0c309 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 5 Feb 2024 11:46:13 -0500 Subject: [PATCH 35/65] :wrench: chore(shfrm Contribution): Validate shfrm management save process --- .../crp/admin/ShfrmManagementAction.java | 55 +++++++++++++++---- .../projects/DeliverableValidator.java | 24 +++++++- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java index 4d50a33c43..c3b062fdfb 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java @@ -96,11 +96,12 @@ public void prepare() throws Exception { public String save() { if (this.canAcessCrpAdmin()) { List subActionstoDelete = new ArrayList<>(); + List priorityActionsDB = null; + priorityActionsDB = shfrmPriorityActionManager.findAll(); + try { - List priorityActionsDB = null; List subActionsDB = null; - priorityActionsDB = shfrmPriorityActionManager.findAll(); subActionsDB = shfrmSubActionManager.findAll(); if (this.priorityActions != null && !this.priorityActions.isEmpty()) { for (ShfrmPriorityAction action : this.priorityActions) { @@ -126,9 +127,13 @@ public String save() { subActionstoDelete.add(subActionDB); }); + } else { + subActionsDB.forEach(subActionDB -> { + shfrmSubActionManager.deleteShfrmSubAction(subActionDB.getId()); + subActionstoDelete.add(subActionDB); + }); } - } } @@ -139,17 +144,29 @@ public String save() { if (this.priorityActions != null && !this.priorityActions.isEmpty()) { - // List priorityActionsDB = null; - // List subActionsDB = null; - try { - // priorityActionsDB = shfrmPriorityActionManager.findAll(); - // subActionsDB = shfrmSubActionManager.findAll(); + if (priorityActionsDB != null) { + try { + for (ShfrmPriorityAction actionDB : priorityActionsDB) { + if (this.priorityActions != null && !this.priorityActions.isEmpty()) { + Set actionIdsInFrontend = this.priorityActions.stream().filter(Objects::nonNull) + .map(ShfrmPriorityAction::getId).collect(Collectors.toSet()); + if (!actionIdsInFrontend.contains(actionDB.getId())) { - } catch (Exception e) { - logger.info(e + "no sub actions added yet"); - } + // Validate previous sub actions in DB for each priority actions + if (actionDB.getShfrmSubActions() == null + || (actionDB.getShfrmSubActions() != null && actionDB.getShfrmSubActions().isEmpty())) { + shfrmPriorityActionManager.deleteShfrmPriorityAction(actionDB.getId()); + } + } + } + } + } catch (Exception e) { + logger.info(e + " error deleting actions"); + } + } + for (ShfrmPriorityAction action : this.priorityActions) { ShfrmPriorityAction actionSave = new ShfrmPriorityAction(); if (action.getId() != null) { @@ -157,8 +174,11 @@ public String save() { } if (subActionstoDelete != null && !subActionstoDelete.isEmpty()) { + for (ShfrmSubAction subActiontoDelete : subActionstoDelete) { - actionSave.getShfrmSubActions().remove(subActiontoDelete); + if (actionSave.getShfrmSubActions().contains(subActiontoDelete)) { + actionSave.getShfrmSubActions().remove(subActiontoDelete); + } } } @@ -201,6 +221,17 @@ public String save() { } } } + } else { + // Delete all priority actions DB + try { + if (priorityActionsDB != null && !priorityActionsDB.isEmpty()) { + priorityActionsDB.forEach(priorityAction -> { + shfrmPriorityActionManager.deleteShfrmPriorityAction(priorityAction.getId()); + }); + } + } catch (Exception e) { + logger.error("error deleting priority actions: " + e); + } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java index d5b03680ed..b57dcc79d1 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java @@ -35,6 +35,7 @@ import org.cgiar.ccafs.marlo.data.model.DeliverableMetadataElement; import org.cgiar.ccafs.marlo.data.model.DeliverableParticipant; import org.cgiar.ccafs.marlo.data.model.DeliverablePublicationMetadata; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; import org.cgiar.ccafs.marlo.data.model.GlobalUnit; import org.cgiar.ccafs.marlo.data.model.Project; import org.cgiar.ccafs.marlo.data.model.ProjectSectionStatusEnum; @@ -566,9 +567,30 @@ public void validate(BaseAction action, Deliverable deliverable, boolean saving) action.getInvalidFields().put("input-deliverable.deliverableInfo.shfrmContributionNarrative", InvalidFieldsMessages.EMPTYFIELD); } - } + // Validate priority actions + if (deliverable.getShfrmPriorityActions() == null + || (deliverable.getShfrmPriorityActions() != null && deliverable.getShfrmPriorityActions().isEmpty())) { + action.addMessage(action.getText("deliverable.shfrmPriorityActions")); + action.addMissingField("deliverable.shfrmPriorityActions"); + action.getInvalidFields().put("list-deliverable.shfrmPriorityActions", InvalidFieldsMessages.EMPTYFIELD); + } else if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { + int index = 0; + for (DeliverableShfrmPriorityAction priorityAction : deliverable.getShfrmPriorityActions()) { + if (priorityAction != null && priorityAction.getShfrmSubActions() != null + && !priorityAction.getShfrmSubActions().isEmpty()) { + action.addMessage(action.getText("deliverable.shfrmSubActions[" + index + "]")); + action.addMissingField("deliverable.shfrmSubActions[" + index + "]"); + action.getInvalidFields().put("list-deliverable.shfrmPriorityAction[" + index + "].shfrmSubActions", + InvalidFieldsMessages.EMPTYFIELD); + index++; + } + } + } + + } } + this.saveMissingFields(deliverable, action.getActualPhase().getDescription(), action.getActualPhase().getYear(), action.getActualPhase().getUpkeep(), ProjectSectionStatusEnum.DELIVERABLES.getStatus(), action); } From df2cd4a087bc329873085715592c94b3d24c1d9c Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 5 Feb 2024 17:09:06 -0500 Subject: [PATCH 36/65] :wrench: chore(shfrm Contribution): Add shfrm save methods to specificity --- .../action/projects/DeliverableAction.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 0470d0e03e..fd1df2061d 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -1491,6 +1491,12 @@ public void prepare() throws Exception { for (DeliverableShfrmPriorityAction deliverablePriorityAction : deliverable.getShfrmPriorityActions()) { try { + // Test code + if (deliverablePriorityAction.getShfrmSubActions() == null) { + List deliverableShfrmSubAction = new ArrayList<>(); + deliverablePriorityAction.setShfrmSubActions(deliverableShfrmSubAction); + } + if (deliverablePriorityAction.getDeliverableShfrmSubAction() != null) { deliverablePriorityAction .setShfrmSubActions(new ArrayList<>(deliverablePriorityAction.getDeliverableShfrmSubAction() @@ -2340,8 +2346,11 @@ public String save() { // this.saveProjectOutcomes(deliverableDB, this.getActualPhase()); this.saveCrpOutcomes(deliverableDB, this.getActualPhase()); - this.savePriorityActions(deliverableManagedState, this.getActualPhase()); - this.saveSubActions(deliverableManagedState, this.getActualPhase()); + // SHFRM contribution + if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) { + this.savePriorityActions(deliverableManagedState, this.getActualPhase()); + this.saveSubActions(deliverableManagedState, this.getActualPhase()); + } boolean haveRegions = false; boolean haveCountries = false; @@ -3648,7 +3657,7 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { // Search and deleted form Information try { - List subActionPrev = + List actionPrev = deliverableShfrmPriorityActionManager.findByDeliverableAndPhase(deliverable.getId(), phase.getId()); if (this.deliverable.getShfrmPriorityActions() != null) { @@ -3660,11 +3669,19 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { } } - if (subActionPrev != null) { - for (DeliverableShfrmPriorityAction priorityAction : subActionPrev) { - if (priorityAction != null && priorityAction.getId() != null - && !existingIds.contains(priorityAction.getId())) { - deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); + List deliverableSubActions = new ArrayList<>(); + + if (actionPrev != null) { + for (DeliverableShfrmPriorityAction priorityAction : actionPrev) { + if (priorityAction != null && priorityAction.getId() != null) { + deliverableSubActions = deliverableShfrmSubActionManager + .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId()); + if (deliverableSubActions == null + || (deliverableSubActions != null && !deliverableSubActions.isEmpty())) { + if (!existingIds.contains(priorityAction.getId())) { + deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); + } + } } } } From 97c49864257614298c09f9b3c21c56830d808a44 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 7 Feb 2024 09:15:02 -0500 Subject: [PATCH 37/65] :wrench: chore(shfrm Contribution): Update shfrm sub actions table --- .../V2_6_0_20240207_0900__UpdateShfrmSubActionTable.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 marlo-web/src/main/resources/database/migrations/V2_6_0_20240207_0900__UpdateShfrmSubActionTable.sql diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240207_0900__UpdateShfrmSubActionTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240207_0900__UpdateShfrmSubActionTable.sql new file mode 100644 index 0000000000..c3f00b49fc --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240207_0900__UpdateShfrmSubActionTable.sql @@ -0,0 +1 @@ +ALTER TABLE shfrm_sub_actions COLLATE=utf8_general_ci; From a18ddc9148e223b0a118ddb10e359648e157fa7c Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 7 Feb 2024 09:15:50 -0500 Subject: [PATCH 38/65] :wrench: chore(shfrm Contribution): Create validation to check priority actions relations --- .../cgiar/ccafs/marlo/config/APConstants.java | 4 +-- .../cgiar/ccafs/marlo/action/BaseAction.java | 26 +++++++++++++++++++ .../cgiar/ccafs/marlo/config/APConstants.java | 4 +-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index 652cc9f8f1..0ae4447c10 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -171,8 +171,8 @@ public final class APConstants { public static final String DELIVERABLE_FILE_LOCALLY_HOSTED_STR = "Locally"; public static final String DELIVERABLE_ID = "deliverableId"; - public static final String PRIORITY_ACTION_ID = "priority_action_id"; - public static final String SUB_ACTION_ID = "sub_action_id"; + public static final String PRIORITY_ACTION_ID = "priorityActionId"; + public static final String SUB_ACTION_ID = "subActionId"; public static final int DELIVERABLE_QUALITY_ANSWER_NO = 3; public static final int DELIVERABLE_QUALITY_ANSWER_YES = 2; public static final int DELIVERABLE_QUALITY_ANSWER_YES_BUT_NO = 1; diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java index 6c8668c3d0..f21140f433 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java @@ -37,6 +37,7 @@ import org.cgiar.ccafs.marlo.data.manager.DeliverableCrpOutcomeManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableInfoManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableManager; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTraineesIndicatorManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTypeManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTypeRuleManager; @@ -82,6 +83,7 @@ import org.cgiar.ccafs.marlo.data.manager.ReportSynthesisManager; import org.cgiar.ccafs.marlo.data.manager.RoleManager; import org.cgiar.ccafs.marlo.data.manager.SectionStatusManager; +import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; import org.cgiar.ccafs.marlo.data.manager.SrfTargetUnitManager; import org.cgiar.ccafs.marlo.data.manager.UserManager; import org.cgiar.ccafs.marlo.data.manager.UserRoleManager; @@ -315,6 +317,12 @@ public class BaseAction extends ActionSupport implements Preparable, SessionAwar @Inject private ProjectBudgetManager projectBudgetManager; + @Inject + private DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager; + + @Inject + private ShfrmPriorityActionManager shfrmPriorityActionManager; + @Inject private ProjectPartnerPersonManager partnerPersonManager; @@ -885,6 +893,24 @@ public boolean canBeDeleted(long id, String className) { } + if (className != null && className.equals("shfrm")) { + ShfrmPriorityAction shfrmPriorityAction = this.shfrmPriorityActionManager.getShfrmPriorityActionById(id); + if (shfrmPriorityAction != null && shfrmPriorityAction.getId() != null) { + List deliverableShfrmPriorityActions = + deliverableShfrmPriorityActionManager.findAll().stream() + .filter(d -> d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(id) && d.getPhase() != null + && d.getPhase().getId().equals(this.getActualPhase().getId())) + .collect(Collectors.toList()); + if (deliverableShfrmPriorityActions != null && deliverableShfrmPriorityActions.isEmpty() + || (deliverableShfrmPriorityActions == null)) { + return true; + } else { + return false; + } + } + } + if (clazz == ProjectBudget.class) { ProjectBudget projectBudget = this.projectBudgetManager.getProjectBudgetById(id); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index 049b4f059c..dced0119bc 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -182,8 +182,8 @@ public final class APConstants { public static final String DELIVERABLE_FILE_LOCALLY_HOSTED_STR = "Locally"; public static final String DELIVERABLE_ID = "deliverableId"; - public static final String PRIORITY_ACTION_ID = "priority_action_id"; - public static final String SUB_ACTION_ID = "sub_action_id"; + public static final String PRIORITY_ACTION_ID = "priorityActionId"; + public static final String SUB_ACTION_ID = "subActionId"; public static final int DELIVERABLE_QUALITY_ANSWER_NO = 3; public static final int DELIVERABLE_QUALITY_ANSWER_YES = 2; public static final int DELIVERABLE_QUALITY_ANSWER_YES_BUT_NO = 1; From 17c6cc4f7cf406e19fc2b6b55f6174091ea68c1d Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 7 Feb 2024 09:24:52 -0500 Subject: [PATCH 39/65] :wrench: chore(shfrm Contribution): Update deliverable sub actions save and service action --- .../project/SubActionsByPriorityAction.java | 21 +++++++++++++++---- .../action/projects/DeliverableAction.java | 18 ++++++++-------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java index 260c7b7c0c..882fa4542a 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java @@ -31,6 +31,8 @@ import org.apache.commons.lang3.StringUtils; import org.apache.struts2.dispatcher.Parameter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SubActionsByPriorityAction extends BaseAction { @@ -38,6 +40,8 @@ public class SubActionsByPriorityAction extends BaseAction { private long priorityActionID; private ShfrmSubActionManager shfrmSubActionManager; private List> subActions; + private final Logger logger = LoggerFactory.getLogger(SubActionsByPriorityAction.class); + @Inject public SubActionsByPriorityAction(APConfig config, ShfrmSubActionManager shfrmSubActionManager) { @@ -49,10 +53,15 @@ public SubActionsByPriorityAction(APConfig config, ShfrmSubActionManager shfrmSu public String execute() throws Exception { subActions = new ArrayList<>(); Map subAction; - List shfrmSubActions = shfrmSubActionManager - .findAll().stream().filter(s -> s != null && s.getShfrmPriorityAction() != null - && s.getShfrmPriorityAction().getId() != null && s.getShfrmPriorityAction().getId().equals(priorityActionID)) - .collect(Collectors.toList()); + List shfrmSubActions = new ArrayList<>(); + try { + shfrmSubActions = shfrmSubActionManager.findAll().stream() + .filter(s -> s != null && s.isActive() && s.getShfrmPriorityAction() != null + && s.getShfrmPriorityAction().getId() != null && s.getShfrmPriorityAction().getId().equals(priorityActionID)) + .collect(Collectors.toList()); + } catch (Exception e) { + logger.error("error getting sub actions " + e); + } if (shfrmSubActions != null && !shfrmSubActions.isEmpty()) { for (ShfrmSubAction shfrmSubAction : shfrmSubActions) { @@ -61,6 +70,10 @@ public String execute() throws Exception { subAction.put("composedName", shfrmSubAction.getComposedName()); subAction.put("name", shfrmSubAction.getName()); subAction.put("description", shfrmSubAction.getDescription()); + if (shfrmSubAction.getShfrmPriorityAction() != null + && shfrmSubAction.getShfrmPriorityAction().getId() != null) { + subAction.put("priorityActionId", shfrmSubAction.getShfrmPriorityAction().getId()); + } subActions.add(subAction); } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index fd1df2061d..1adcfd0319 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -4008,15 +4008,15 @@ public void saveSubActions(Deliverable deliverable, Phase phase) { && !deliverable.getDeliverableShfrmPriorityAction().isEmpty()) { for (DeliverableShfrmPriorityAction priorityAction : deliverable.getDeliverableShfrmPriorityAction()) { - - List subActionPrev = - new ArrayList<>(priorityAction.getDeliverableShfrmSubAction().stream() - .filter(nu -> nu.isActive() && nu.getPhase().getId().equals(phase.getId())).collect(Collectors.toList())); - - for (DeliverableShfrmSubAction subAction : subActionPrev) { - if (subAction != null && subAction.getId() != null && (priorityAction.getShfrmSubActions() == null - || !priorityAction.getShfrmSubActions().contains(subAction))) { - this.deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + if (priorityAction != null && priorityAction.getId() != null) { + List subActionPrev = new ArrayList<>(deliverableShfrmSubActionManager + .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId())); + + for (DeliverableShfrmSubAction subAction : subActionPrev) { + if (subAction != null && subAction.getId() != null && (priorityAction.getShfrmSubActions() == null + || !priorityAction.getShfrmSubActions().contains(subAction))) { + this.deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + } } } } From 648050706bf1cd712e4bb067301670534b66b888 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 7 Feb 2024 21:21:59 -0500 Subject: [PATCH 40/65] :wrench: chore(shfrm Contribution): Create relations macro deliverables popup --- .../cgiar/ccafs/marlo/action/BaseAction.java | 28 +++++++++- .../crp/macros/relationsPopupMacro.ftl | 53 ++++++++++++++----- .../crp/views/admin/shfrmManagement.ftl | 17 ++++-- 3 files changed, 79 insertions(+), 19 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java index f21140f433..8c0e971871 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java @@ -139,7 +139,6 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.formula.functions.T; import org.apache.struts2.ServletActionContext; import org.apache.struts2.dispatcher.Parameter; import org.apache.struts2.interceptor.ServletRequestAware; @@ -5156,6 +5155,31 @@ public Map getSession() { return this.session; } + public List getShfrmActionDeliverablesRelation(long shfrmPrimaryActionId) { + List deliverablesRelated = new ArrayList<>(); + List deliverableShfrmPriorityActions = + deliverableShfrmPriorityActionManager.findAll().stream() + .filter(d -> d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(shfrmPrimaryActionId) && d.getPhase() != null + && d.getPhase().getId().equals(this.getActualPhase().getId())) + .collect(Collectors.toList()); + if (deliverableShfrmPriorityActions != null && !deliverableShfrmPriorityActions.isEmpty()) { + for (DeliverableShfrmPriorityAction deliverableShfrmPriorityAction : deliverableShfrmPriorityActions) { + if (deliverableShfrmPriorityAction != null && deliverableShfrmPriorityAction.getDeliverable() != null) { + Deliverable deliverableAdd = deliverableShfrmPriorityAction.getDeliverable(); + deliverableAdd.setDeliverableInfo(deliverableAdd.getDeliverableInfo(getActualPhase())); + deliverablesRelated.add(deliverableShfrmPriorityAction.getDeliverable()); + } + } + } + + if (deliverablesRelated != null && !deliverablesRelated.isEmpty()) { + return deliverablesRelated; + } else { + return null; + } + } + /** * This method return the first AF AICCRA ID Phase * @@ -8371,6 +8395,7 @@ public boolean validatePolicy(long policyID) { return true; } + // public boolean validURL(String URL) { try { @@ -8387,4 +8412,5 @@ public boolean validURL(String URL) { } + } diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl index 7994295d8f..aec60515fe 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl @@ -2,29 +2,48 @@ [#macro relationsMacro element labelText=true tag=""] [#local className = ((element.class.name)?split('.')?last)!''/] [#local composedID = "${className}-${(element.id)!}"] + [#-- [#local deliverablesProject = (action.getDeliverableRelationsProject(element.id, element.class.name,(element.project.id)!-1))! /] [#local deliverablesImpact = (action.getDeliverableRelationsImpact(element.id, element.class.name))! /] [#local deliverablesPartner = (action.getDeliverablesLedByPartner(element.id))! /] - - [#if className == "ProjectPartner"] - [#local deliverables = deliverablesPartner /] - [#elseif ((className == "ProjectOutcome") && (tag == "")) || (className == "ProjectBudget")] - [#local deliverables = deliverablesProject /] + --] + + [#if tag == "shfrm"] + [#local shfrmDeliverables = (action.getShfrmActionDeliverablesRelation(element.id))! /] + [#local deliverables = shfrmDeliverables /] [#else] - [#local deliverables = ((deliverablesImpact)!deliverablesPartner)! /] + + [#if className == "ProjectPartner"] + [#local deliverablesPartner = (action.getDeliverablesLedByPartner(element.id))! /] + [#local deliverables = deliverablesPartner /] + [#elseif ((className == "ProjectOutcome") && (tag == "")) || (className == "ProjectBudget")] + [#local deliverablesProject = (action.getDeliverableRelationsProject(element.id, element.class.name,(element.project.id)!-1))! /] + [#local deliverables = deliverablesProject /] + [#else] + [#local deliverablesImpact = (action.getDeliverableRelationsImpact(element.id, element.class.name))! /] + [#local deliverablesPartner = (action.getDeliverablesLedByPartner(element.id))! /] + [#local deliverables = ((deliverablesImpact)!deliverablesPartner)! /] + [/#if] + [/#if] + [#local projects = (action.getProjectRelationsImpact(element.id, element.class.name))! /] [#-- News buttons --] - [#local policies = (action.getPolicyContributingByPartner(element.id))![] /] - [#local innovations = (action.getInnovationContributingByPartner(element.id))![] /] - [#local evidencies = (action.getStudyContributingByPartner(element.id))![] /] + [#if !action.isAiccra()] + [#local policies = (action.getPolicyContributingByPartner(element.id))![] /] + [/#if] [#if tag == "expectedOutcomes"] [#local evidencies = (action.getexpectedCrpOutcomes(element.id))![] /] + [#else] + [#local evidencies = (action.getStudyContributingByPartner(element.id))![] /] [/#if] + [#if tag == "innovationOutcomes"] [#local innovations = (action.getInnovationProjectOutcomes(element.id))![] /] + [#else] + [#local innovations = (action.getInnovationContributingByPartner(element.id))![] /] [/#if] [#-- News buttons --] @@ -138,8 +157,12 @@ [@s.text name="projectsList.projectids" /] [@s.text name="project.deliverableList.deliverableName" /] [@s.text name="project.deliverableList.subtype" /] - [@s.text name="project.deliverableList.owner" /] - [@s.text name="project.deliverableList.sharedW" /] + + [#if tag != "shfrm"] + [@s.text name="project.deliverableList.owner" /] + [@s.text name="project.deliverableList.sharedW" /] + [/#if] + [@s.text name="project.deliverableList.status" /] [@s.text name="project.deliverableList.year" /] @@ -162,8 +185,12 @@ [/#if] ${(d.deliverableInfo.deliverableType.name?capitalize)!'-'} - ${(d.owner)!'-'} - ${(d.sharedWithProjects)!'-'} + + [#if tag != "shfrm"] + ${(d.owner)!'-'} + ${(d.sharedWithProjects)!'-'} + [/#if] + ${(d.deliverableInfo.getStatusName(action.getActualPhase()))!'None'} [#-- Deliverable Year --] diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index 5949cce2a4..c703aa950f 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -70,10 +70,10 @@ [/#if] [#-- Single partner TEMPLATE from partnersTemplate.ftl --] -[@projectPartnerMacro element={} name="priorityActions[-1]" isTemplate=true /] +[@projectPartnerMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] [#-- Contact person TEMPLATE from partnersTemplate.ftl --] -[@contactPersonMacro element={} name="priorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] +[@contactPersonMacro element={} name="deliverable.shfrmPriorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] [#-- Project roles descriptions --] @@ -124,7 +124,7 @@ [#-- TODO: Please improve this validation at backend side --] [#-- Remove link for all partners --] - [#if editable ] [#--&& (isTemplate) --] + [#if isTemplate || action.canBeDeleted((element.id)!-1,(element.class.name)!)] [/#if] @@ -134,6 +134,12 @@ ${index+1}. ${(element.name)!'Priority Action'}
    + [#if !isTemplate] +
    + [@popUps.relationsMacro element=element labelText=true tag="shfrm" /] +
    + + [/#if]

    @@ -170,14 +176,15 @@
    - + +
    [/#macro] [#macro contactPersonMacro element name index=-1 partnerIndex=-1 isTemplate=false institutionID=-1]
    [#-- Remove link for all partners --] - [#if editable && action.canBeDeleted((element.id)!-1,(element.class.name)!)] + [#if editable]
    [/#if]
    From daf46a05432b0375c6c6bb2303355492bf44b26a Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 9 Feb 2024 09:20:44 -0500 Subject: [PATCH 41/65] :bug: (BI feedback dashboard): Fix identity user parameter --- .../cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java index 3de5e3b804..afc1dfc3b3 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java @@ -102,7 +102,7 @@ private PowerBiBody generatePowerBiBody(BiReports biReport) { /* Identities */ List identities = new ArrayList<>(); Identities identitie = new Identities(); - identitie.setUsername(this.getCurrentUser().getUsername()); + identitie.setUsername(this.getCurrentUser().getEmail()); /* Roles */ List roles = new ArrayList<>(); From 98d052b147932fafa0d9908fc1c9b2253361e549 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 9 Feb 2024 10:37:28 -0500 Subject: [PATCH 42/65] :wrench: chore(shfrm Contribution): Update priority action relations information --- .../main/resources/custom/aicrra.properties | 1 + .../src/main/resources/global.properties | 1 + .../crp/macros/relationsPopupMacro.ftl | 6 +-- .../webapp/crp/js/admin/shfrmManagement.js | 39 +++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 8f3861f5c7..8e9718aceb 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -43,6 +43,7 @@ global.cookieConsentMessage=By default, MARLO uses cookies to ensure you get the global.webSiteLink.placeholder=https:// global.viewMore=View More global.crps=PTFs +global.shfrmPriorityAction=Priority Action # Systems Messages systemMessage.serverReset=We are restarting the server in order to apply some improvements to the system. Please save what you are doing in a word document (if needed) since you will have to login again. Sorry for the inconvenience. diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index 416288d903..a0189f81fb 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -43,6 +43,7 @@ global.cookieConsentMessage=By default, MARLO uses cookies to ensure you get the global.webSiteLink.placeholder=https:// global.viewMore=View More global.crps=CRPs +global.shfrmPriorityAction=Priority Action # Systems Messages systemMessage.serverReset=We are restarting the server in order to apply some improvements to the system. Please save what you are doing in a word document (if needed) since you will have to login again. Sorry for the inconvenience. diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl index aec60515fe..40fc842c04 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl @@ -156,9 +156,9 @@ [@s.text name="projectsList.projectids" /] [@s.text name="project.deliverableList.deliverableName" /] - [@s.text name="project.deliverableList.subtype" /] [#if tag != "shfrm"] + [@s.text name="project.deliverableList.subtype" /] [@s.text name="project.deliverableList.owner" /] [@s.text name="project.deliverableList.sharedW" /] [/#if] @@ -183,10 +183,10 @@ [#else] ${(d.deliverableInfo.title)!'Untitled'} [/#if] - - ${(d.deliverableInfo.deliverableType.name?capitalize)!'-'} + [#if tag != "shfrm"] + ${(d.deliverableInfo.deliverableType.name?capitalize)!'-'} ${(d.owner)!'-'} ${(d.sharedWithProjects)!'-'} [/#if] diff --git a/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js b/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js index 406ad84334..75c5d578d4 100644 --- a/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js +++ b/marlo-web/src/main/webapp/crp/js/admin/shfrmManagement.js @@ -35,6 +35,45 @@ function init() { // Activate the chosen to the existing partners addSelect2(); + var $deliverableList = $('table.deliverableList'); + var table = $deliverableList.DataTable({ + "bPaginate": true, // This option enable the table pagination + "bLengthChange": true, // This option disables the select table size option + "bFilter": true, // This option enable the search + "bSort": true, // this option enable the sort of contents by columns + "bAutoWidth": false, // This option enables the auto adjust columns width + "iDisplayLength": 25, // Number of rows to show on the table + "language": { + searchPlaceholder: "Search..." + }, + "fnDrawCallback": function() { + // This function locates the add activity button at left to the filter box + var table = $(this).parent().find("table"); + if($(table).attr("id") == "currentActivities") { + $("#currentActivities_filter").prepend($("#addActivity")); + } + }, + "order": [ + [ + 3, 'asc' + ] + ], + aoColumnDefs: [ + { + bSortable: true, + aTargets: [ + -1 + ] + }, { + sType: "natural", + aTargets: [ + 0 + ] + } + ] +}); + + addUser = function(composedName,userId) { var $contact = $elementSelected.parents('.contactsPerson ').find('input[value="' + userId + '"]'); From 7041f3d2cfd865bf4f9ef1c78ab310514725596d Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 9 Feb 2024 10:38:05 -0500 Subject: [PATCH 43/65] :wrench: chore(shfrm Contribution): Update priority action relations in management module --- .../crp/views/admin/shfrmManagement.ftl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index c703aa950f..f4eed1683f 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -1,7 +1,7 @@ [#ftl] [#assign title = "SHFRM Management" /] [#assign currentSectionString = "${actionName?replace('/','-')}-phase-${(actualPhase.id)!}" /] -[#assign pageLibs = ["select2", "flag-icon-css"] /] +[#assign pageLibs = ["select2", "flag-icon-css", "datatables.net", "datatables.net-bs"] /] [#assign customJS = [ "${baseUrlMedia}/js/admin/shfrmManagement.js", "${baseUrlCdn}/global/js/fieldsValidation.js", @@ -124,22 +124,24 @@ [#-- TODO: Please improve this validation at backend side --] [#-- Remove link for all partners --] - [#if isTemplate || action.canBeDeleted((element.id)!-1,(element.class.name)!)] + [#if isTemplate || action.canBeDeleted((element.id)!-1,("shfrm")!)] [/#if] [#-- Partner Title --]
    - [#-- Title --] + + [#-- Title --] ${index+1}. ${(element.name)!'Priority Action'} -
    - [#if !isTemplate] -
    - [@popUps.relationsMacro element=element labelText=true tag="shfrm" /] +
    +
    + [@popUps.relationsMacro element=element labelText=true tag="shfrm" /] +
    + [/#if]
    - [/#if] +

    From cf8b1b744676daf05568c872f4bc0b46850e1912 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 9 Feb 2024 15:27:26 -0500 Subject: [PATCH 44/65] :wrench: chore(shfrm Contribution): Update deliveble actions validations in sub-actions save --- .../marlo/action/projects/DeliverableAction.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 1adcfd0319..8f1e9e76d7 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -4009,13 +4009,16 @@ public void saveSubActions(Deliverable deliverable, Phase phase) { for (DeliverableShfrmPriorityAction priorityAction : deliverable.getDeliverableShfrmPriorityAction()) { if (priorityAction != null && priorityAction.getId() != null) { - List subActionPrev = new ArrayList<>(deliverableShfrmSubActionManager - .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId())); + List subActionPrev = new ArrayList<>(); + subActionPrev = deliverableShfrmSubActionManager.findByPriorityActionAndPhase(priorityAction.getId(), + this.getActualPhase().getId()); - for (DeliverableShfrmSubAction subAction : subActionPrev) { - if (subAction != null && subAction.getId() != null && (priorityAction.getShfrmSubActions() == null - || !priorityAction.getShfrmSubActions().contains(subAction))) { - this.deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + if (subActionPrev != null) { + for (DeliverableShfrmSubAction subAction : subActionPrev) { + if (subAction != null && subAction.getId() != null && (priorityAction.getShfrmSubActions() == null + || !priorityAction.getShfrmSubActions().contains(subAction))) { + this.deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + } } } } From e91c95a1e6980899cbdf34e44a914b846c8f2ce6 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 9 Feb 2024 15:28:03 -0500 Subject: [PATCH 45/65] :wrench: chore(shfrm Contribution): Update management section template macros --- .../main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index f4eed1683f..8388bf5285 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -70,10 +70,10 @@ [/#if] [#-- Single partner TEMPLATE from partnersTemplate.ftl --] -[@projectPartnerMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] +[@projectPartnerMacro element={} name="priorityActions[-1]" isTemplate=true /] [#-- Contact person TEMPLATE from partnersTemplate.ftl --] -[@contactPersonMacro element={} name="deliverable.shfrmPriorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] +[@contactPersonMacro element={} name="priorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] [#-- Project roles descriptions --] From ff5435b190ddb4410e9a3e5803ceefdc14ef0d19 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 9 Feb 2024 15:29:33 -0500 Subject: [PATCH 46/65] :wrench: chore(shfrm Contribution): General updates in shfrm components deliverables into front end files --- .../crp/views/projects/deliverableInfo.ftl | 16 +- .../global/macros/deliverableMacros.ftl | 193 ++++++++-------- .../projects/deliverables/deliverableInfo.js | 25 ++ .../projects/deliverables/deliverableShfrm.js | 217 +++++++++++++++--- 4 files changed, 305 insertions(+), 146 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl index 318e5e0bc3..5d8d553954 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl @@ -142,15 +142,17 @@ [#-- SHRFM contribution --]
    [@deliverableMacros.shfmrContributionMacro /] + + [#-- Single partner TEMPLATE from partnersTemplate.ftl --] + [@deliverableMacros.projectPartnerMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] + + [#-- Contact person TEMPLATE from partnersTemplate.ftl --] + [@deliverableMacros.contactPersonMacro element={} name="deliverable.shfrmPriorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] + [/#if] - [#-- Single partner TEMPLATE from partnersTemplate.ftl --] - [@deliverableMacros.priorityActionsMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] - - [#-- Contact person TEMPLATE from partnersTemplate.ftl - [@deliverableMacros.subActionsMacro element={} name="deliverable.shfrmPriorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] ---] + [#-- Key Outputs select --] [#if !project.projectInfo.administrative && !phaseOne && !isCenterProject ] @@ -349,4 +351,4 @@
    -[#-- /if --] +[#-- /if --] \ No newline at end of file diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 5ac4ae9339..3e2d4cd9c4 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -572,70 +572,6 @@
    [/#macro] -[#macro shfmrContributionMacro ] - [#local name = "deliverable.deliverableInfo" /] -
    -
    - - [#if reportingActive] - - [#else] - - [/#if] -

    [@s.text name="deliverable.shfrmContribution.question.help" /]

    -
    -
    - [@customForm.yesNoInputDeliverable name="${name}.contributingShfrm" editable=editable inverse=false cssClass="type-findable text-center" /] -
    -
    - [#local isContributingShfrm = (deliverable.deliverableInfo.contributingShfrm?string)!""] -
    -
    - - [#-- Shfrm Contribution Narrative --] -
    - [@customForm.textArea name="deliverable.deliverableInfo.shfrmContributionNarrative" value="${(deliverable.deliverableInfo.shfrmContributionNarrative)!}" i18nkey="deliverable.shfrmContribution.narrative" placeholder="" className="limitWords-200" required=true editable=editable /] -
    -
    - [#-- Shfrm Priority Action --] -
    - [#-- - [@customForm.select name="deliverable.shfrmPriorityActions" label="" showTitle=true i18nkey="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" multiple=true header=true required=true className="activity" editable=editable keyFieldName="id" displayFieldName="composedName"/] - - --] - - [@customForm.elementsListComponent id="deliverablePriorityActions" name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /] - -
    - - - [#-- Project Section Content --] -
    - [#-- Section Messages --] - - [#-- Listing actions --] - - [#-- Priority actions list --] - [#if deliverable.shfrmPriorityActions?has_content] - [#list deliverable.shfrmPriorityActions as priorityAction] - [@priorityActionsMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}]" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] - [/#list] - [#else] - [#-- - [@priorityActionsMacro element={} name="deliverable.shfrmPriorityActions[0].shfrmPriorityAction" index=0 opened=true defaultPerson=true /] - --] -

    [@s.text name="shfrmManagement.actionsEmpty" /]

    - [/#if] - [#-- -
    [@s.text name="shfrmManagement.priorityActions.add" /]
    - --] -
    - -
    -
    -
    -[/#macro] - [#macro findableOptions ] [#local isSynced = (deliverable.dissemination.synced)!false ] [#local customName = "deliverable.dissemination" /] @@ -1571,8 +1507,76 @@ [/#macro] -[#macro priorityActionsMacro element name index=-1 opened=false defaultPerson=false isTemplate=false] - [#assign customName = "${name}" /] +[#macro shfmrContributionMacro ] + [#local name = "deliverable.deliverableInfo" /] +
    +
    + + [#if reportingActive] + + [#else] + + [/#if] +

    [@s.text name="deliverable.shfrmContribution.question.help" /]

    +
    +
    + [@customForm.yesNoInputDeliverable name="${name}.contributingShfrm" editable=editable inverse=false cssClass="type-findable text-center" /] +
    +
    + [#local isContributingShfrm = (deliverable.deliverableInfo.contributingShfrm?string)!""] +
    +
    + + [#-- Shfrm Contribution Narrative --] +
    + [@customForm.textArea name="deliverable.deliverableInfo.shfrmContributionNarrative" value="${(deliverable.deliverableInfo.shfrmContributionNarrative)!}" i18nkey="deliverable.shfrmContribution.narrative" placeholder="" className="limitWords-200" required=true editable=editable /] +
    +
    + [#-- Shfrm Priority Action --] +
    + [#-- + [@customForm.select name="deliverable.shfrmPriorityActions" label="" showTitle=true i18nkey="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" multiple=true header=true required=true className="activity" editable=editable keyFieldName="id" displayFieldName="composedName"/] + + --] + + [@customForm.elementsListComponent id="deliverablePriorityActions" name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /] + +
    + + + [#-- Project Section Content --] +
    + [#-- Section Messages --] + + [#-- Listing actions --] + + [#-- Priority actions list --] +
    + + [#if deliverable.shfrmPriorityActions?has_content] + [#list deliverable.shfrmPriorityActions as priorityAction] + [@projectPartnerMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}]" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] + [/#list] + [#else] + [#-- + [@priorityActionsMacro element={} name="deliverable.shfrmPriorityActions[0].shfrmPriorityAction" index=0 opened=true defaultPerson=true /] + --] +

    [@s.text name="shfrmManagement.actionsEmpty" /]

    + [/#if] +
    [@s.text name="shfrmManagement.priorityActions.add" /]
    +
    + [#-- +
    [@s.text name="shfrmManagement.priorityActions.add" /]
    + --] +
    + +
    +
    +
    +[/#macro] + + +[#macro projectPartnerMacro element name index=-1 opened=false defaultPerson=false isTemplate=false]
    [#-- Loading --] @@ -1580,57 +1584,44 @@ [#-- TODO: Please improve this validation at backend side --] [#-- Remove link for all partners --] - [#if false ] [#--&& (isTemplate) --] + [#if isTemplate] [#--&& (isTemplate) --] [/#if] [#-- Partner Title --]
    [#-- Title --] - [#-- ${index+1}. --] ${(element.shfrmPriorityAction.name)!'Priority Action'}: ${(element.shfrmPriorityAction.description)!''} + ${index+1}. ${(element.shfrmPriorityAction.name)!'Priority Action'}

    + + [#-- Action name + + + --] - - [#-- Shfrm Priority Action -
    - [@customForm.elementsListComponent name="${name}.shfrmPriorityAction" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true maxLimit=1/] -
    - --] - [#-- Action name --] - + [#-- Sub Actions --]
    - - [#-- Shfrm sub Action list --] -
    - [#-- - [@customForm.select name="${name}.shfrmSubActions" label="" help="deliverable.shfrmContribution.subAction.help" helpIcon=false i18nkey="deliverable.shfrmContribution.subAction" listName="shfrmSubActions" multiple=true required=true className="subActionSelect" editable=editable keyFieldName="id" displayFieldName="composedName"/] - --] - [@customForm.elementsListComponent name="${name}.shfrmSubActions" elementType="shfrmSubAction" help="deliverable.shfrmContribution.subAction.help" helpIcon=false elementList=(element.shfrmSubActions)![] label="deliverable.shfrmContribution.subAction" listName="(${customName}.shfrmPriorityAction.shfrmSubActions)!" keyFieldName="id" displayFieldName="composedName" required=true /] - -
    - - [#--
    [@s.text name="shfrmManagement.subActions.add" /] [@customForm.req required=true /]
    -
    - +
    + [#-- Sub Actions --] [#if element.shfrmSubActions?has_content] [#list element.shfrmSubActions as subAction] - [@subActionsMacro element=subAction name="${name}.shfrmSubActions[${subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] + [@contactPersonMacro element=subAction name="${name}.shfrmSubActions[${subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] [/#list] [#else]

    [@s.text name="shfrmManagement.subActionsEmpty" /]

    [/#if] + [#if (editable && canEdit)]
    [@s.text name="shfrmManagement.subActions.add"/]
    [/#if]
    - --]
    @@ -1638,10 +1629,10 @@
    [/#macro] -[#macro subActionsMacro element name index=-1 partnerIndex=-1 isTemplate=false institutionID=-1] +[#macro contactPersonMacro element name index=-1 partnerIndex=-1 isTemplate=false institutionID=-1]
    [#-- Remove link for all partners --] - [#if editable && action.canBeDeleted((element.id)!-1,(element.class.name)!)] + [#if editable]
    [/#if]
    @@ -1653,18 +1644,16 @@ Added/Updated [/#if]
    +
    - [#-- Sub action name --] -
    - [@customForm.input name="${name}.name" className="partnerPersonType" editable=editable i18nkey="shfrmManagement.subActions.title" value="${(element.name)!}" /] -
    - [#-- Sub action description --] -
    - [@customForm.input name="${name}.description" value="${(element.description)!}" type="text" i18nkey="shfrmManagement.subActions.description" required=true editable=editable /] -
    + + [@customForm.elementsListComponent name="${name}.shfrmSubActions.id" elementType="shfrmSubAction" help="deliverable.shfrmContribution.subAction.help" helpIcon=false elementList=(element.shfrmSubActions)![] label="deliverable.shfrmContribution.subAction" listName="element.deliverableShfrmPriorityAction.shfrmPriorityAction.shfrmSubActions" keyFieldName="id" displayFieldName="composedName" required=true /] + [#-- + [@customForm.select name="${name}.shfrmSubAction.id" label="" i18nkey="deliverable.shfrmContribution.subAction" listName="element.deliverableShfrmPriorityAction.shfrmPriorityAction.shfrmSubActions" keyFieldName="id" displayFieldName="composedName" multiple=false required=true className="countriesSelect" disabled=!editable/] +--]
    -[/#macro] +[/#macro] \ No newline at end of file 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 9a6fb97c56..876de4a699 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 @@ -184,6 +184,31 @@ function init() { } $subTypeSelect.trigger('change'); }); + + $('.actionSelect').on('change', function() { + var $subActionSelect = $(".subActionSelect"); + var data = { + priorityActionId: $(this).find("option:selected").val() + }; + $subActionSelect.empty(); + $subActionSelect.append(""); + $subActionSelect.trigger("change.select2"); + var option = $(this).find("option:selected"); + + if(option.val() != "-1") { + $.ajax({ + url: baseURL + "/subActionsByPriorityAction.do", + type: 'GET', + dataType: "json", + data: data + }).success(function(m) { + for(var i = 0; i < m.subActions.length; i++) { + $subActionSelect.addOption(m.subActions[i].id, m.subActions[i].name) + } + }); + } + $subActionSelect.trigger('change'); + }); $(".subTypeSelect").on("change", function() { var subTypeOption = $(this).find("option:selected").val(); diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index 65b09d6051..51c2cab3bb 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -1,5 +1,5 @@ var $removePartnerDialog, $projectPPAPartners; -var defaultType, partnerRespRequired; +var canUpdatePPAPartners, partnerPersonTypes, leaderType, coordinatorType, defaultType, partnerRespRequired; var projectLeader; var lWordsResp = 100; @@ -11,9 +11,22 @@ function init() { $removePartnerDialog = $('#partnerRemove-dialog'); $partnersBlock = $('#projectPartnersBlock'); $projectPPAPartners = $('#projectPPAPartners'); + canUpdatePPAPartners = ($("#canUpdatePPAPartners").val() === "true"); partnerRespRequired = ($("#partnerRespRequired").val() === "true"); + leaderType = 'PL'; + coordinatorType = 'PC'; defaultType = 'CP'; + partnerPersonTypes = [ + coordinatorType, leaderType, defaultType, '-1' + ]; + if(editable) { + // Getting the actual project leader + projectLeader = jQuery.extend({}, getProjectLeader()); + // Update initial project CCAFS partners list for each partner + updateProjectPPAPartnersLists(); + + } // Activate the chosen to the existing partners addSelect2(); @@ -36,6 +49,11 @@ function init() { // Attaching listeners attachEvents(); + // Set the unique person as leader + /* + * if(editable){ var contactPeople = $partnersBlock.find('.projectPartner'); if ((contactPeople.length == 1)){ var + * person = new PartnerPersonObject(contactPeople); person.setPartnerType(leaderType); person.changeType(); } } + */ $('.loadingBlock').hide().next().fadeIn(500, function() { // Missing fields in parter person @@ -47,7 +65,6 @@ function init() { }); $("textarea[id!='justification']").autoGrow(); - } function attachEvents() { @@ -100,8 +117,6 @@ function attachEvents() { * Project partner Events */ // Add a project partner Event - $(".addPriorityAction").on('click', addPartnerEvent); - // Add a project partner Event $(".addProjectPartner").on('click', addPartnerEvent); // Remove a project partner Event $(".removePartner").on('click', removePartnerEvent); @@ -111,7 +126,97 @@ function attachEvents() { $("input.name").on("change", function(e) { find('.priorityActionTitle').text(this.name); }); + // When organization change + $("select.institutionsList").on("change", function(e) { + var partner = new PartnerObject($(this).parents('.projectPartner')); + // Update Partner Title + partner.updateBlockContent(); + + // Get Countries from Institution ID + $.ajax({ + url: baseURL + "/institutionBranchList.do", + data: { + institutionID: $(this).val(), + phaseID: phaseID + }, + beforeSend: function() { + partner.startLoader(); + }, + success: function(data) { + partner.clearCountries(); + + $(partner.countriesSelect).empty(); + $(partner.countriesSelect).addOption(-1, "Select a country..."); + + // Validate if the current partner is not selected, then add the countries + if(!($('input.institutionsList[value=' + partner.institutionId + ']').exists())) { + $.each(data.branches, function(index,branch) { + + if((branch.name).indexOf("HQ") != "-1") { + partner.addCountry({ + iso: branch.iso, + name: branch.name + }); + } else { + $(partner.countriesSelect).addOption(branch.iso, branch.name); + } + }); + } + + $(partner.countriesSelect).trigger("change.select2"); + }, + complete: function() { + partner.stopLoader(); + } + }); + + // Update PPA Partners List + updateProjectPPAPartnersLists(e); + }); + // Partnership Geographic Scope + $(".geographicScopeSelect").on('change', function(){ + var $partner = $(this).parents('.projectPartner'); + var $regionalBlock = $partner.find('.regionalBlock'); + var $nationalBlock = $partner.find('.nationalBlock'); + + var isRegional = this.value == 2; + var isMultiNational = this.value == 3; + var isNational = this.value == 4; + var isSubNational = this.value == 5; + + // Regions + if(isRegional){ + $regionalBlock.show(); + }else{ + $regionalBlock.hide(); + } + + // Countries + $nationalBlock.find("select").val(null).trigger('change'); + if(isMultiNational || isNational || isSubNational){ + if (isMultiNational){ + $nationalBlock.find("select").select2({ + maximumSelectionLength: 0, + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' + }); + }else{ + $nationalBlock.find("select").select2({ + maximumSelectionLength: 1, + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' + }); + } + $nationalBlock.show(); + }else{ + $nationalBlock.hide(); + } + }); // Partners filters $(".filters-link span").on("click", filterInstitutions); @@ -250,13 +355,43 @@ function changePartnerPersonType(e) { var $contactPerson = $(e.target).parents('.contactPerson'); var contact = new PartnerPersonObject($contactPerson); // Set as unique contact type in the project - + if((contact.type == leaderType)) { + setPartnerTypeToDefault(contact.type); + } // Change partner person type contact.changeType(); // Change parent partner type var partner = new PartnerObject($contactPerson.parents('.projectPartner')); partner.changeType(); - + console.log(contact.type); + // If the contact type selected is PL + if(contact.type == leaderType) { + // If there is a PL previous selected + if(!jQuery.isEmptyObject(projectLeader)) { + var previousLeaderName = projectLeader.contactInfo; + var messages = '
  • Please note that there can only be one project leader per project.
    '; + messages += + 'Therefore ' + previousLeaderName + + ' was assigned a Project collaborator/partner role.
  • '; + // Show a pop up with the message + $("#contactChangeType-dialog").find('.messages').append(messages); + $("#contactChangeType-dialog").dialog({ + modal: true, + closeText: "", + width: 500, + buttons: { + Close: function() { + $(this).dialog("close"); + } + }, + close: function() { + $(this).find('.messages').empty(); + } + }); + } + } + // Update project leader contact person + setProjectLeader(getProjectLeader()); } function updateOrganizationsList(e) { @@ -301,18 +436,13 @@ function updateProjectPPAPartnersLists(e) { var partner = new PartnerObject($(projectPartner)); // Collecting partners institutions projectInstitutions.push(parseInt(partner.institutionId)); - // Validating if the partners is PPA Partner - if(partner.isPPA()) { - partner.hidePPAs(); - // Collecting list CCAFS partners from all project partners - $projectPPAPartners.append(setOption(partner.institutionId, partner.institutionName)); - } else { + // Validating if the partners is PPA Partner if(partner.institutionId == -1) { partner.hidePPAs(); } else { partner.showPPAs(); } - } + }); $projectPPAPartners.trigger("change.select2"); @@ -353,6 +483,20 @@ function updateProjectPPAPartnersLists(e) { } +function setPartnerTypeToDefault(type) { + $partnersBlock.find('.projectPartner').each(function(i,partner) { + var projectPartner = new PartnerObject($(partner)); + $(partner).find('.contactPerson').each(function(i,partnerPerson) { + var contact = new PartnerPersonObject($(partnerPerson)); + if(contact.type == type) { + $(partnerPerson).removeClass(partnerPersonTypes.join(' ')).addClass(defaultType); + contact.setPartnerType(defaultType); + } + }); + projectPartner.changeType(); + }); +} + function removePartnerEvent(e) { e.preventDefault(); var partner = new PartnerObject($(e.target).parent().parent()); @@ -397,20 +541,6 @@ function removePartnerEvent(e) { } }; } - // Validate if the CCAFS partner is currently contributing has any contributions to another partner - if(partner.isPPA() && (partnerContributions.length > 0)) { - messages += '
  • ' + partner.institutionName + ' is currently allocating budget to the following partner(s):'; - messages += '
      '; - for(var i = 0, len = partnerContributions.length; i < len; i++) { - messages += '
    • ' + partnerContributions[i] + '
    • '; - } - messages += '
  • '; - removeDialogOptions.buttons = { - Close: function() { - $(this).dialog("close"); - } - }; - } // Validate if the project partner has any project leader assigned if(partner.hasLeader()) { messages += @@ -457,6 +587,7 @@ function addPartnerEvent(e) { // Activate the select2 plugin for new partners created // Organization + $newElement.find("select.institutionsList").select2(searchInstitutionsOptions(canUpdatePPAPartners)); $newElement.find("select.institutionsList").parent().find("span.select2-selection__placeholder") .text(placeholderText); @@ -547,7 +678,16 @@ function removePersonEvent(e) { } }; } - + // Validate if the person type is PL + if(person.isLeader()) { + messages += + '
  • There must be one project leader per project. Please select another project leader before deleting this contact.
  • '; + removeDialogOptions.buttons = { + Close: function() { + $(this).dialog("close"); + } + }; + } // Validate if there are any activity linked to this person if(activities > 0) { messages += '
  • This contact person cannot be deleted because he/she is leading activity(ies)'; @@ -614,6 +754,7 @@ function addItemList($option) { function addSelect2() { // Organization / institution + $("form select.institutionsList").select2(searchInstitutionsOptions(canUpdatePPAPartners)); $("form select.institutionsList").parent().find("span.select2-selection__placeholder").text(placeholderText); // Role Selection @@ -695,7 +836,10 @@ function PartnerObject(partner) { $(partner).find('.subDepartment').slideUp(); } }; - + this.updateBlockContent = function() { + $(partner).find('.partnerTitle').text(this.institutionName); + this.validateGovernmentType(); + }; this.hasPartnerContributions = function() { var partners = []; var institutionId = this.institutionId; @@ -719,13 +863,6 @@ function PartnerObject(partner) { }); return result; }; - this.isPPA = function() { - var instID = parseInt($(partner).find('.institutionsList').val()); - if(instID == -1) { - $(partner).find("> .blockTitle .index").removeClass('ppa').text('Partner'); - return false; - } - }; this.getRelationsNumber = function(relation) { var count = 0; $(partner).find('.contactPerson').each(function(i,partnerPerson) { @@ -869,7 +1006,10 @@ function PartnerPersonObject(partnerPerson) { this.getPartnerType = function() { return $(partnerPerson).find('.partnerPersonType').val(); }; - + this.changeType = function() { + $(partnerPerson).removeClass(partnerPersonTypes.join(' ')).addClass(this.type); + this.setPartnerType(this.type); + }; this.getRelationsNumber = function(relation) { return parseInt($(partnerPerson).find('.tag.' + relation + ' span').text()) || 0; }; @@ -885,6 +1025,9 @@ function PartnerPersonObject(partnerPerson) { $(partnerPerson).find(".userName").attr("id", "partner-" + partnerIndex + "-person-" + index); }; + this.isLeader = function() { + return(this.type == leaderType); + }; this.remove = function() { var partner = new PartnerObject($(partnerPerson).parents('.projectPartner')); $(partnerPerson).hide("slow", function() { From 0eb315b466c9afa8c8bd0fda625042304cd7bc6e Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 12 Feb 2024 09:07:46 -0500 Subject: [PATCH 47/65] :wrench: chore(shfrm Contribution): Update deliverable macros --- .../ccafs/marlo/action/projects/DeliverableAction.java | 10 +++++----- .../webapp/WEB-INF/global/macros/deliverableMacros.ftl | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 8f1e9e76d7..5db1581055 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -4004,9 +4004,8 @@ public void saveSubActions(Deliverable deliverable, Phase phase) { // Search and deleted form Information try { - if (deliverable.getDeliverableShfrmPriorityAction() != null - && !deliverable.getDeliverableShfrmPriorityAction().isEmpty()) { - for (DeliverableShfrmPriorityAction priorityAction : deliverable.getDeliverableShfrmPriorityAction()) { + if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { + for (DeliverableShfrmPriorityAction priorityAction : deliverable.getShfrmPriorityActions()) { if (priorityAction != null && priorityAction.getId() != null) { List subActionPrev = new ArrayList<>(); @@ -4015,8 +4014,9 @@ public void saveSubActions(Deliverable deliverable, Phase phase) { if (subActionPrev != null) { for (DeliverableShfrmSubAction subAction : subActionPrev) { - if (subAction != null && subAction.getId() != null && (priorityAction.getShfrmSubActions() == null - || !priorityAction.getShfrmSubActions().contains(subAction))) { + if (subAction != null && subAction.getId() != null + && (priorityAction.getShfrmSubActions() == null || (priorityAction.getShfrmSubActions() != null + && !priorityAction.getShfrmSubActions().contains(subAction)))) { this.deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); } } diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 3e2d4cd9c4..24b0ae0dbf 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1643,13 +1643,15 @@ [#if customForm.changedField('${name}.id') != ''] Added/Updated [/#if] + +
    - [@customForm.elementsListComponent name="${name}.shfrmSubActions.id" elementType="shfrmSubAction" help="deliverable.shfrmContribution.subAction.help" helpIcon=false elementList=(element.shfrmSubActions)![] label="deliverable.shfrmContribution.subAction" listName="element.deliverableShfrmPriorityAction.shfrmPriorityAction.shfrmSubActions" keyFieldName="id" displayFieldName="composedName" required=true /] - [#-- - [@customForm.select name="${name}.shfrmSubAction.id" label="" i18nkey="deliverable.shfrmContribution.subAction" listName="element.deliverableShfrmPriorityAction.shfrmPriorityAction.shfrmSubActions" keyFieldName="id" displayFieldName="composedName" multiple=false required=true className="countriesSelect" disabled=!editable/] + [@customForm.elementsListComponent name="${name}.shfrmSubAction.id" elementType="shfrmSubAction" help="deliverable.shfrmContribution.subAction.help" helpIcon=false label="deliverable.shfrmContribution.subAction" elementList=shfrmSubAction listName="(element.deliverableShfrmPriorityAction.shfrmSubActions)![]" keyFieldName="id" displayFieldName="name" required=true /] + [#-- + [@customForm.select name="${name}.shfrmSubAction.id" label="" i18nkey="deliverable.shfrmContribution.subAction" listName="(element.deliverableShfrmPriorityAction.shfrmSubActions)![]" keyFieldName="id" displayFieldName="name" multiple=false required=true className="countriesSelect" disabled=!editable/] --]
    From e126a86fac2a531920bdac283a44a304215a8f90 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 12 Feb 2024 10:14:55 -0500 Subject: [PATCH 48/65] :wrench: chore(shfrm Contribution): Update deliverabl subActions save method --- .../action/projects/DeliverableAction.java | 51 +++++++++++++++---- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 5db1581055..95b29cb91e 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -4004,24 +4004,53 @@ public void saveSubActions(Deliverable deliverable, Phase phase) { // Search and deleted form Information try { - if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { + if (this.deliverable.getShfrmPriorityActions() != null && !this.deliverable.getShfrmPriorityActions().isEmpty()) { for (DeliverableShfrmPriorityAction priorityAction : deliverable.getShfrmPriorityActions()) { - if (priorityAction != null && priorityAction.getId() != null) { - List subActionPrev = new ArrayList<>(); - subActionPrev = deliverableShfrmSubActionManager.findByPriorityActionAndPhase(priorityAction.getId(), - this.getActualPhase().getId()); - if (subActionPrev != null) { - for (DeliverableShfrmSubAction subAction : subActionPrev) { - if (subAction != null && subAction.getId() != null - && (priorityAction.getShfrmSubActions() == null || (priorityAction.getShfrmSubActions() != null - && !priorityAction.getShfrmSubActions().contains(subAction)))) { - this.deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + /*************/ + List existingIds = new ArrayList<>(); + + + List subPrev = deliverableShfrmSubActionManager + .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId()); + + if (priorityAction.getShfrmSubActions() != null) { + + for (DeliverableShfrmSubAction shfrmSubDeliverable : priorityAction.getShfrmSubActions()) { + if (shfrmSubDeliverable != null && shfrmSubDeliverable.getId() != null) { + existingIds.add(shfrmSubDeliverable.getId()); + } + } + + if (subPrev != null) { + for (DeliverableShfrmSubAction subAction : subPrev) { + if (subAction != null && subAction.getId() != null) { + + if (!existingIds.contains(subAction.getId())) { + deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(subAction.getId()); + } + + } + } + } + } else { + // Delete all in DB + if (subPrev != null && !subPrev.isEmpty()) { + for (DeliverableShfrmSubAction subAction : subPrev) { + if (subAction != null && subAction.getId() != null) { + + if (!existingIds.contains(subAction.getId())) { + deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(subAction.getId()); + } + } } } } + + /***************/ + } } From 5aa300c3411205a5d8cf78f88ffcf672753393a8 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Mon, 12 Feb 2024 11:27:13 -0500 Subject: [PATCH 49/65] :wrench: chore(shfrm Contribution): Validate null element in relationship table --- .../cgiar/ccafs/marlo/action/BaseAction.java | 34 +++++++++++-------- .../crp/macros/relationsPopupMacro.ftl | 2 +- .../crp/views/admin/shfrmManagement.ftl | 2 +- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java index 8c0e971871..b7e53ff305 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java @@ -5155,24 +5155,30 @@ public Map getSession() { return this.session; } - public List getShfrmActionDeliverablesRelation(long shfrmPrimaryActionId) { + public List getShfrmActionDeliverablesRelation(Long shfrmPrimaryActionId) { + List deliverablesRelated = new ArrayList<>(); - List deliverableShfrmPriorityActions = - deliverableShfrmPriorityActionManager.findAll().stream() - .filter(d -> d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null - && d.getShfrmPriorityAction().getId().equals(shfrmPrimaryActionId) && d.getPhase() != null - && d.getPhase().getId().equals(this.getActualPhase().getId())) - .collect(Collectors.toList()); - if (deliverableShfrmPriorityActions != null && !deliverableShfrmPriorityActions.isEmpty()) { - for (DeliverableShfrmPriorityAction deliverableShfrmPriorityAction : deliverableShfrmPriorityActions) { - if (deliverableShfrmPriorityAction != null && deliverableShfrmPriorityAction.getDeliverable() != null) { - Deliverable deliverableAdd = deliverableShfrmPriorityAction.getDeliverable(); - deliverableAdd.setDeliverableInfo(deliverableAdd.getDeliverableInfo(getActualPhase())); - deliverablesRelated.add(deliverableShfrmPriorityAction.getDeliverable()); + if (shfrmPrimaryActionId != null && shfrmPrimaryActionId != 0) { + List deliverableShfrmPriorityActions = null; + try { + deliverableShfrmPriorityActions = deliverableShfrmPriorityActionManager.findAll().stream() + .filter(d -> d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(shfrmPrimaryActionId) && d.getPhase() != null + && d.getPhase().getId().equals(this.getActualPhase().getId())) + .collect(Collectors.toList()); + } catch (Exception e) { + Log.error("error getting shfrm " + e); + } + if (deliverableShfrmPriorityActions != null && !deliverableShfrmPriorityActions.isEmpty()) { + for (DeliverableShfrmPriorityAction deliverableShfrmPriorityAction : deliverableShfrmPriorityActions) { + if (deliverableShfrmPriorityAction != null && deliverableShfrmPriorityAction.getDeliverable() != null) { + Deliverable deliverableAdd = deliverableShfrmPriorityAction.getDeliverable(); + deliverableAdd.setDeliverableInfo(deliverableAdd.getDeliverableInfo(getActualPhase())); + deliverablesRelated.add(deliverableShfrmPriorityAction.getDeliverable()); + } } } } - if (deliverablesRelated != null && !deliverablesRelated.isEmpty()) { return deliverablesRelated; } else { diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl index 40fc842c04..bc8380203e 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl @@ -10,7 +10,7 @@ [#if tag == "shfrm"] [#local shfrmDeliverables = (action.getShfrmActionDeliverablesRelation(element.id))! /] - [#local deliverables = shfrmDeliverables /] + [#local deliverables = (shfrmDeliverables)![] /] [#else] [#if className == "ProjectPartner"] diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index 8388bf5285..d6bb3f6eb1 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -133,7 +133,7 @@ [#-- Title --] ${index+1}. ${(element.name)!'Priority Action'} - [#if !isTemplate] + [#if !isTemplate && element?has_content && element.id?has_content]
    [@popUps.relationsMacro element=element labelText=true tag="shfrm" /] From ab313392247a22f4e975d10cbc3fca1e9382c9d5 Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:16:47 -0500 Subject: [PATCH 50/65] :art: style(projectDeliverable.css): added deliverableActivity styles --- .../webapp/crp/css/projects/projectDeliverable.css | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/marlo-web/src/main/webapp/crp/css/projects/projectDeliverable.css b/marlo-web/src/main/webapp/crp/css/projects/projectDeliverable.css index 8ab544f07d..10f7bf6ddb 100644 --- a/marlo-web/src/main/webapp/crp/css/projects/projectDeliverable.css +++ b/marlo-web/src/main/webapp/crp/css/projects/projectDeliverable.css @@ -50,6 +50,17 @@ body .WOS_tag p{ margin-top: 60px; } +.deliverableActivity { + list-style: none; + padding: 1px 4px 0px 6px; + background-color: #F7F7F7; + border: 1px solid #E0E0E0 !important; + box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.1); + border-radius: 4px; + margin-bottom: 5px; + position: relative; +} + /* Bootstrap Tabs */ .tab-content>.active { display: block; From 1b9b92531705c68187a432e4d93e1abae95bc1ac Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:22:17 -0500 Subject: [PATCH 51/65] :wrench: chore(deliverableInfo.ftl): added subActionItemMacro macro template --- .../webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl index 5d8d553954..2545e81a9e 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl @@ -137,6 +137,7 @@ There are required fields still incompleted [/#if]
    + [#if action.hasSpecificities('shfrm_contribution_active') ] [#-- SHRFM contribution --] @@ -147,7 +148,9 @@ [@deliverableMacros.projectPartnerMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] [#-- Contact person TEMPLATE from partnersTemplate.ftl --] - [@deliverableMacros.contactPersonMacro element={} name="deliverable.shfrmPriorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] + [@deliverableMacros.contactPersonMacro element={} allSubActions=[] name="deliverable.shfrmPriorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] + + [@deliverableMacros.subActionItemMacro subActionItem={} name="deliverable.shfrmPriorityActions[-1].shfrmSubActions" index=-1 isTemplate=true /] [/#if] From d9d6b0ab1ec2a68746e86bda5772368926e99094 Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:26:34 -0500 Subject: [PATCH 52/65] :wrench: chore(projectDeliverable): add actions and sub-actions developed --- .../crp/views/projects/projectDeliverable.ftl | 2 +- .../global/macros/deliverableMacros.ftl | 83 +- .../projects/deliverables/deliverableInfo.js | 383 +++++----- .../projects/deliverables/deliverableShfrm.js | 708 ++++++++++-------- marlo-web/src/main/webapp/global/js/global.js | 576 +++++++------- 5 files changed, 931 insertions(+), 821 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl index fe2061e5bb..732a0f4e18 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl @@ -7,7 +7,7 @@ "${baseUrlMedia}/js/projects/deliverables/deliverableShfrm.js?20240203", "${baseUrlMedia}/js/projects/deliverables/deliverableDissemination.js?20230810", "${baseUrlMedia}/js/projects/deliverables/deliverableQualityCheck.js?20220721", - "${baseUrlCdn}/crp/js/feedback/feedbackAutoImplementation.js?20231017", + "${baseUrlCdn}/crp/js/feedback/feedbackAutoImplementation.js?20241017", [#-- "${baseUrlMedia}/js/projects/deliverables/deliverableDataSharing.js?20180523",--] [#-- "${baseUrlCdn}/global/js/autoSave.js",--] "${baseUrlCdn}/global/js/fieldsValidation.js?20180529" diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 24b0ae0dbf..cff005fad9 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1534,12 +1534,10 @@
    [#-- Shfrm Priority Action --]
    - [#-- - [@customForm.select name="deliverable.shfrmPriorityActions" label="" showTitle=true i18nkey="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" multiple=true header=true required=true className="activity" editable=editable keyFieldName="id" displayFieldName="composedName"/] - - --] - - [@customForm.elementsListComponent id="deliverablePriorityActions" name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /] + +
    + [@customForm.elementsListComponent id="deliverablePriorityActions" name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /] +
    @@ -1552,22 +1550,17 @@ [#-- Priority actions list --]
    - + [#if deliverable.shfrmPriorityActions?has_content] [#list deliverable.shfrmPriorityActions as priorityAction] [@projectPartnerMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}]" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] - [/#list] + [/#list] [#else] - [#-- - [@priorityActionsMacro element={} name="deliverable.shfrmPriorityActions[0].shfrmPriorityAction" index=0 opened=true defaultPerson=true /] - --]

    [@s.text name="shfrmManagement.actionsEmpty" /]

    [/#if] -
    [@s.text name="shfrmManagement.priorityActions.add" /]
    +
    [@s.text name="shfrmManagement.priorityActions.add" /]
    - [#-- -
    [@s.text name="shfrmManagement.priorityActions.add" /]
    - --] +
  • @@ -1576,6 +1569,21 @@ [/#macro] +[#macro subActionItemMacro subActionItem name index=-1 isTemplate=false] + [#assign deliverableCustomName = "${name}[${index}]" /] +
    + [#if editable]
    [/#if] + + + + [#-- --] + ${(subActionItem.shfrmSubAction.name)!'null'} +
    +
    +[/#macro] + + + [#macro projectPartnerMacro element name index=-1 opened=false defaultPerson=false isTemplate=false]
    @@ -1597,29 +1605,29 @@

    - [#-- Action name - - - --] - [#-- Sub Actions --]
    -
    [@s.text name="shfrmManagement.subActions.add" /] [@customForm.req required=true /]
    +
    - [#-- Sub Actions --] - [#if element.shfrmSubActions?has_content] - [#list element.shfrmSubActions as subAction] - [@contactPersonMacro element=subAction name="${name}.shfrmSubActions[${subAction_index}]" index=subAction_index partnerIndex=index institutionID=(element.institution.id)! /] - [/#list] - [#else] -

    [@s.text name="shfrmManagement.subActionsEmpty" /]

    - [/#if] - - [#if (editable && canEdit)] -
    [@s.text name="shfrmManagement.subActions.add"/]
    - [/#if] + +
    +
    + [#if element.shfrmSubActions?has_content] + [#list (element.shfrmSubActions)![] as subActionListItem] + [@subActionItemMacro subActionItem=subActionListItem name="${name}.shfrmSubActions" index=subActionListItem_index /] + [/#list] + [/#if] +
    + + [#if editable] +
    [@s.text name="shfrmManagement.subActions.add" /] [@customForm.req required=true /]
    +
    + [@customForm.select name="" label="" i18nkey="project.activities.deliverableSelect" listName="${name}.shfrmPriorityAction.shfrmSubActions" keyFieldName="id" displayFieldName="name" multiple=false required=true className=" deliverableList" disabled=!editable/] +
    + [/#if] +
    @@ -1629,7 +1637,7 @@
    [/#macro] -[#macro contactPersonMacro element name index=-1 partnerIndex=-1 isTemplate=false institutionID=-1] +[#macro contactPersonMacro element allSubActions name index=-1 partnerIndex=-1 isTemplate=false institutionID=-1]
    [#-- Remove link for all partners --] [#if editable] @@ -1646,8 +1654,15 @@
    +

    In sua => Actions size: ${allSubActions?size}

    + + + [#list allSubActions as ctrlistitemmmm] +

         * ctrl name: ${(ctrlistitemmmm.name)!'Empty name'} - id: ${(ctrlistitemmmm.id)!'Empty id'}

    + [/#list]
    + [@customForm.elementsListComponent name="${name}.shfrmSubAction.id" elementType="shfrmSubAction" help="deliverable.shfrmContribution.subAction.help" helpIcon=false label="deliverable.shfrmContribution.subAction" elementList=shfrmSubAction listName="(element.deliverableShfrmPriorityAction.shfrmSubActions)![]" keyFieldName="id" displayFieldName="name" required=true /] [#-- 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 876de4a699..b13cff4055 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 @@ -1,24 +1,24 @@ var $statuses, $statusDescription; $(document).ready(init); -function hideOrShowCheckBoxIsOtherUrl(value){ +function hideOrShowCheckBoxIsOtherUrl(value) { if (value) { $('.isOtherUrlTohide').show('slow'); - }else{ + } else { $('input.isOtherUrl').prop('checked', false); $('.other-url').hide('slow'); $('.isOtherUrlFiel').val(false); } } -function checkDOI() { +function checkDOI() { setTimeout(() => { - if ($('.deliverableDisseminationUrl ').prop('readonly') || $('.disseminationChannel').val() == 'other' ) { + if ($('.deliverableDisseminationUrl ').prop('readonly') || $('.disseminationChannel').val() == 'other') { if ($('#doi-bridge').val()) { $('.isOtherUrlTohide').hide('slow'); - hideOrShowCheckBoxIsOtherUrl(false); - }else{ - if (($('.typeSelect').val() == 49 && $('.subTypeSelect ').val() ==63 )) { + hideOrShowCheckBoxIsOtherUrl(false); + } else { + if (($('.typeSelect').val() == 49 && $('.subTypeSelect ').val() == 63)) { hideOrShowCheckBoxIsOtherUrl(true); } } @@ -31,31 +31,30 @@ function checkDOI() { // nuevo doi // ^((https?:\/\/)?(www\.)?[a-zA-Z0-9.-]+\.+[a-zA-Z0-9.-]+\/10\.\d{4,9}\/[-._;():A-Z0-9]+$|^10\.\d{4,9}\/[-._;():A-Z0-9]+$) var result = /^((https?:\/\/)?(www\.)?[a-zA-Z0-9.-]+\.+[a-zA-Z0-9.-]+\/10\.\d{4,9}\/[-._;()/:A-Z0-9]+$|^10\.\d{4,9}\/[-._;()/:A-Z0-9]+$)/i.test($('#doi-bridge').val()); - - if ( result ) { - $('#doi-bridge').css("border", "1px solid #ccc"); - $('.invalidDOI').hide('slow'); - $('.validDOI').show('slow'); - } - if(!result && $('#doi-bridge').val()) - { - $('#doi-bridge').css("border", "red solid 1px"); - $('.invalidDOI').show('slow'); - $('.validDOI').hide('slow'); - - } - if ( !$('#doi-bridge').val() ) { - $('#doi-bridge').css("border", "1px solid #ccc"); - $('.invalidDOI').hide('slow'); - $('.validDOI').hide('slow'); - - } + + if (result) { + $('#doi-bridge').css("border", "1px solid #ccc"); + $('.invalidDOI').hide('slow'); + $('.validDOI').show('slow'); + } + if (!result && $('#doi-bridge').val()) { + $('#doi-bridge').css("border", "red solid 1px"); + $('.invalidDOI').show('slow'); + $('.validDOI').hide('slow'); + + } + if (!$('#doi-bridge').val()) { + $('#doi-bridge').css("border", "1px solid #ccc"); + $('.invalidDOI').hide('slow'); + $('.validDOI').hide('slow'); + + } }, 50); } -function init() { +function init() { $statuses = $('select.status'); isDeliverableNew = $statuses.classParam('isNew') == "true"; $statusDescription = $('#statusDescription'); @@ -70,21 +69,29 @@ function init() { // Event to validate the expected date $(".yearExpected").on("change", validateCurrentDate); + $(".elementType-shfrmPriorityAction-deliverablePriorityActions").on("change", function () { + // console.log("change action"); + console.log("addProjectPartner") + $('.addProjectPartner').trigger('click'); + + + }); + // Event when status is changed - $statuses.on("change", function() { + $statuses.on("change", function () { justificationByStatus(this.value); }); validateDeliverableStatus(); - + $('#doi-bridge').keydown(checkDOI); $('#doi-bridge').change(checkDOI); - $('#doi-bridge').bind("paste",checkDOI); + $('#doi-bridge').bind("paste", checkDOI); if ($('#doi-bridge')[0]) { document.getElementById("doi-bridge").addEventListener("paste", checkDOI); } - + $('input.isOtherUrl').on("click", activeByNoDOIProvidedCheckbox); activeByNoDOIProvidedCheckbox(); @@ -93,9 +100,9 @@ function init() { /** Activities * */ - $(".activity").on("change", function() { + $(".activity").on("change", function () { var option = $(this).find("option:selected"); - if(option.val() != "-1") { + if (option.val() != "-1") { addActivity(option); } // Remove option from select @@ -105,10 +112,10 @@ function init() { $(".removeActivity").on("click", removeActivity); // Validate if funding source exists in select - $("form .activities").each(function(i,e) { + $("form .activities").each(function (i, e) { var options = $(".activity option"); - options.each(function(iOption,eOption) { - if($(e).find(".Id").val() == $(eOption).val()) { + options.each(function (iOption, eOption) { + if ($(e).find(".Id").val() == $(eOption).val()) { $(eOption).remove(); } }); @@ -116,9 +123,9 @@ function init() { /** Funding source * */ - $(".fundingSource").on("change", function() { + $(".fundingSource").on("change", function () { var option = $(this).find("option:selected"); - if(option.val() != "-1") { + if (option.val() != "-1") { addFundingSource(option); } // Remove option from select @@ -128,10 +135,10 @@ function init() { $(".removeFundingSource").on("click", removeFundingSource); // Validate if funding source exists in select - $("form .fundingSources").each(function(i,e) { + $("form .fundingSources").each(function (i, e) { var options = $(".fundingSource option"); - options.each(function(iOption,eOption) { - if($(e).find(".fId").val() == $(eOption).val()) { + options.each(function (iOption, eOption) { + if ($(e).find(".fId").val() == $(eOption).val()) { $(eOption).remove(); } }); @@ -139,9 +146,9 @@ function init() { /** Gender Levels * */ - $(".genderLevelsSelect.add").on("change", function() { + $(".genderLevelsSelect.add").on("change", function () { var option = $(this).find("option:selected"); - if(option.val() != "-1") { + if (option.val() != "-1") { addGenderLevel(option); } // Remove option from select @@ -151,58 +158,58 @@ function init() { $(".removeGenderLevel").on("click", removeGenderLevel); // Validate if funding source exists in select - $("form .genderLevel").each(function(i,e) { + $("form .genderLevel").each(function (i, e) { var options = $(".genderLevelsSelect option"); - options.each(function(iOption,eOption) { - if($(e).find(".fId").val() == $(eOption).val()) { + options.each(function (iOption, eOption) { + if ($(e).find(".fId").val() == $(eOption).val()) { $(eOption).remove(); } }); }); - $('.typeSelect').on('change', function() { + $('.typeSelect').on('change', function () { var $subTypeSelect = $(".subTypeSelect"); $subTypeSelect.empty(); $subTypeSelect.append(""); $subTypeSelect.trigger("change.select2"); var option = $(this).find("option:selected"); - if(option.val() != "-1") { + if (option.val() != "-1") { $.ajax({ - url: baseURL + "/deliverableSubType.do", - type: 'GET', - dataType: "json", - data: { - deliverableTypeId: option.val(), - phaseID: phaseID - } - }).success(function(m) { - for(var i = 0; i < m.deliverableSubTypes.length; i++) { + url: baseURL + "/deliverableSubType.do", + type: 'GET', + dataType: "json", + data: { + deliverableTypeId: option.val(), + phaseID: phaseID + } + }).success(function (m) { + for (var i = 0; i < m.deliverableSubTypes.length; i++) { $subTypeSelect.addOption(m.deliverableSubTypes[i].id, m.deliverableSubTypes[i].name) } }); } $subTypeSelect.trigger('change'); }); - - $('.actionSelect').on('change', function() { + + $('.actionSelect').on('change', function () { var $subActionSelect = $(".subActionSelect"); - var data = { + var data = { priorityActionId: $(this).find("option:selected").val() - }; + }; $subActionSelect.empty(); $subActionSelect.append(""); $subActionSelect.trigger("change.select2"); var option = $(this).find("option:selected"); - if(option.val() != "-1") { + if (option.val() != "-1") { $.ajax({ - url: baseURL + "/subActionsByPriorityAction.do", - type: 'GET', - dataType: "json", - data: data - }).success(function(m) { - for(var i = 0; i < m.subActions.length; i++) { + url: baseURL + "/subActionsByPriorityAction.do", + type: 'GET', + dataType: "json", + data: data + }).success(function (m) { + for (var i = 0; i < m.subActions.length; i++) { $subActionSelect.addOption(m.subActions[i].id, m.subActions[i].name) } }); @@ -210,28 +217,28 @@ function init() { $subActionSelect.trigger('change'); }); - $(".subTypeSelect").on("change", function() { + $(".subTypeSelect").on("change", function () { var subTypeOption = $(this).find("option:selected").val(); var typeOption = $('.typeSelect').find("option:selected").val(); // Show or hide publication metadata - if(hasDeliverableRule('publicationMetadata', [ - subTypeOption, typeOption + if (hasDeliverableRule('publicationMetadata', [ + subTypeOption, typeOption ])) { $(".publicationMetadataBlock").show("slow"); } else { $(".publicationMetadataBlock").hide("slow"); } // Compliance Check Rule - if(hasDeliverableRule('complianceCheck', [ - subTypeOption, typeOption + if (hasDeliverableRule('complianceCheck', [ + subTypeOption, typeOption ])) { $("#complianceCheck").show("slow"); } else { $("#complianceCheck").hide("slow"); } // Data License - if(hasDeliverableRule('dataLicense', [ - subTypeOption, typeOption + if (hasDeliverableRule('dataLicense', [ + subTypeOption, typeOption ])) { $(".dataLicense").show("slow"); } else { @@ -240,8 +247,8 @@ function init() { $('.computerLicense input').prop("checked", false); } // Computer software - if(hasDeliverableRule('computerLicense', [ - subTypeOption, typeOption + if (hasDeliverableRule('computerLicense', [ + subTypeOption, typeOption ])) { $(".computerLicense").show("slow"); } else { @@ -258,45 +265,45 @@ function init() { }); $(".fundingSource").select2({ - templateResult: formatState, - templateSelection: formatState, - width: "100%" + templateResult: formatState, + templateSelection: formatState, + width: "100%" }); $(".genderLevelsSelect").select2({ - templateResult: formatStateGenderType, - width: "100%" + templateResult: formatStateGenderType, + width: "100%" }); // Deliverable Geographic Scope - $('select.elementType-repIndGeographicScope').on("addElement removeElement", function(event,id,name) { + $('select.elementType-repIndGeographicScope').on("addElement removeElement", function (event, id, name) { setGeographicScope(this); }); setGeographicScope($('form select.elementType-repIndGeographicScope')[0]); - // valiate checkbox "No DOI provided" value - + // valiate checkbox "No DOI provided" value + deliverablePartnersModule.init(); feedbackAutoImplementation(); justificationByStatus($statuses.val()) } -function activeByNoDOIProvidedCheckbox(){ - if ($('input.isOtherUrl').is(":checked")) { - console.log("checked"); - $('.isOtherUrlFiel').val(true); - }else{ - console.log("No checked"); - $('.isOtherUrlFiel').val(false); +function activeByNoDOIProvidedCheckbox() { + if ($('input.isOtherUrl').is(":checked")) { + console.log("checked"); + $('.isOtherUrlFiel').val(true); + } else { + console.log("No checked"); + $('.isOtherUrlFiel').val(false); + + } - } - } function openDialog() { $("#dialog").dialog({ - width: '980', - modal: true, - closeText: "" + width: '980', + modal: true, + closeText: "" }); } @@ -304,7 +311,7 @@ function openDialog() { function addActivity(option) { var canAdd = true; console.log(option.val()); - if(option.val() == "-1") { + if (option.val() == "-1") { canAdd = false; } @@ -313,13 +320,13 @@ function addActivity(option) { var v = $(option).text().length > 80 ? $(option).text().substr(0, 80) + ' ... ' : $(option).text(); // Check if is already selected - $list.find('.activities').each(function(i,e) { - if($(e).find('input.aId').val() == option.val()) { + $list.find('.activities').each(function (i, e) { + if ($(e).find('input.aId').val() == option.val()) { canAdd = false; return; } }); - if(!canAdd) { + if (!canAdd) { return; } @@ -341,7 +348,7 @@ function addActivity(option) { function addFundingSource(option) { var canAdd = true; console.log(option.val()); - if(option.val() == "-1") { + if (option.val() == "-1") { canAdd = false; } @@ -350,13 +357,13 @@ function addFundingSource(option) { var v = $(option).text().length > 80 ? $(option).text().substr(0, 80) + ' ... ' : $(option).text(); // Check if is already selected - $list.find('.fundingSources').each(function(i,e) { - if($(e).find('input.fId').val() == option.val()) { + $list.find('.fundingSources').each(function (i, e) { + if ($(e).find('input.fId').val() == option.val()) { canAdd = false; return; } }); - if(!canAdd) { + if (!canAdd) { return; } @@ -381,18 +388,18 @@ function removeActivity() { var name = document.getElementById("activity-" + value).innerHTML; console.log(name + "-" + value); var $select = $(".activity"); - $item.hide(500, function() { + $item.hide(500, function () { $item.remove(); checkActivityItems($list); updateActivities($list); }); -// Add activity option again + // Add activity option again $select.addOption(value, name); $select.trigger("change.select2"); } function updateActivities($list) { - $($list).find('.activities').each(function(i,e) { + $($list).find('.activities').each(function (i, e) { // Set activites indexes $(e).setNameIndexes(1, i); }); @@ -405,18 +412,18 @@ function removeFundingSource() { var name = $item.find(".name").attr("title"); console.log(name + "-" + value); var $select = $(".fundingSource"); - $item.hide(500, function() { + $item.hide(500, function () { $item.remove(); checkFundingItems($list); updateFundingSources($list); }); -// Add funding source option again + // Add funding source option again $select.addOption(value, name); $select.trigger("change.select2"); } function updateFundingSources($list) { - $($list).find('.fundingSources').each(function(i,e) { + $($list).find('.fundingSources').each(function (i, e) { // Set funding sources indexes $(e).setNameIndexes(1, i); }); @@ -427,7 +434,7 @@ function updateFundingSources($list) { function addGenderLevel(option) { var canAdd = true; console.log(option.val()); - if(option.val() == "-1") { + if (option.val() == "-1") { canAdd = false; } @@ -436,13 +443,13 @@ function addGenderLevel(option) { var v = $(option).text().length > 80 ? $(option).text().substr(0, 80) + ' ... ' : $(option).text(); // Check if is already selected - $list.find('.genderLevel').each(function(i,e) { - if($(e).find('input.fId').val() == option.val()) { + $list.find('.genderLevel').each(function (i, e) { + if ($(e).find('input.fId').val() == option.val()) { canAdd = false; return; } }); - if(!canAdd) { + if (!canAdd) { return; } @@ -468,18 +475,18 @@ function removeGenderLevel() { var name = $item.find(".name").attr("title"); console.log(name + "-" + value); var $select = $(".genderLevelsSelect"); - $item.hide(800, function() { + $item.hide(800, function () { $item.remove(); checkGenderItems($list); updateGenderLevels($list); }); -// Add funding source option again + // Add funding source option again $select.addOption(value, name); $select.trigger("change.select2"); } function updateGenderLevels($list) { - $($list).find('.genderLevel').each(function(i,e) { + $($list).find('.genderLevel').each(function (i, e) { // Set funding sources indexes $(e).setNameIndexes(1, i); }); @@ -489,10 +496,10 @@ function validateCurrentDate() { var $statuses = $("form select.status"); var statusValue = $("form select.status").val(); var $yearSelect = $(".yearExpected"); - var status = function() { + var status = function () { return $statuses.val(); } - var year = function() { + var year = function () { return $yearSelect.val(); }; @@ -500,32 +507,32 @@ function validateCurrentDate() { // Ajax $.ajax({ - url: baseURL + '/deliverableStatus.do', - data: { - deliverableId: $('input[name=deliverableID]').val(), - year: year(), - phaseID: phaseID - }, - beforeSend: function() { - statusValue = $("form select.status").val(); - $statuses.empty(); - }, - success: function(data) { - $.each(data.status, function(val,name) { - $statuses.addOption(val, name); - }); - $statuses.val(statusValue); - $statuses.trigger("change.select2"); - justificationByStatus(statusValue); - - // Check year and status - if((year() < currentCycleYear) && (status() == 4)) { - // $('#newExpectedYear').show(); - } else { - // $('#newExpectedYear').hide(); - } + url: baseURL + '/deliverableStatus.do', + data: { + deliverableId: $('input[name=deliverableID]').val(), + year: year(), + phaseID: phaseID + }, + beforeSend: function () { + statusValue = $("form select.status").val(); + $statuses.empty(); + }, + success: function (data) { + $.each(data.status, function (val, name) { + $statuses.addOption(val, name); + }); + $statuses.val(statusValue); + $statuses.trigger("change.select2"); + justificationByStatus(statusValue); + // Check year and status + if ((year() < currentCycleYear) && (status() == 4)) { + // $('#newExpectedYear').show(); + } else { + // $('#newExpectedYear').hide(); } + + } }); $statuses.trigger("change.select2"); @@ -537,34 +544,34 @@ function justificationByStatus(statusId) { var $newExpectedYearSelect = $newExpectedYearBlock.find('select'); var newExpectedYear = $newExpectedYearSelect.val(); var hasExpectedYear = - ((newExpectedYear != "") && newExpectedYear != "-1") && (typeof newExpectedYear !== 'undefined'); + ((newExpectedYear != "") && newExpectedYear != "-1") && (typeof newExpectedYear !== 'undefined'); var isCompletedWithoutExpectedYear = ((!reportingActive) && isStatusComplete(statusId) && hasExpectedYear); // Validate the justification - if(isStatusCancelled(statusId) || isStatusExtended(statusId)) { + if (isStatusCancelled(statusId) || isStatusExtended(statusId)) { $statusDescription.slideDown(400); $statusDescription.find('label').html($('#status-' + statusId).html()); } else { $statusDescription.slideUp(400); } - if(true) { + if (true) { // Validate the new extended year - if(isDeliverableNew) { + if (isDeliverableNew) { showNewExpectedComponent(isStatusExtended(statusId) && upKeepActive); } else { console.log("hasExpectedYear", hasExpectedYear); - if(isStatusOnGoing(statusId)) { + if (isStatusOnGoing(statusId)) { console.log("if"); showNewExpectedComponent(false); } else { console.log("else"); - if(statusId==4) { + 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())) { + } else if (statusId == 2 || statusId == 3 || statusId == 5 || statusId == 6) { + + if (($('.yearNewExpected').val() != '-1') && ($('.yearNewExpected').val() != $('.yearExpected').val())) { showNewExpectedComponent(true); } else { showNewExpectedComponent(false); @@ -585,12 +592,12 @@ function justificationByStatus(statusId) { function showNewExpectedComponent(state) { var $newExpectedYearBlock = $('#newExpectedYear'); var $yearOverlay = $('#deliverableYear .overlay'); - if(state) { + if (state) { $newExpectedYearBlock.show(); $yearOverlay.show(); } else { $newExpectedYearBlock.hide(); - if(isDeliverableNew) { + if (isDeliverableNew) { $yearOverlay.hide(); } } @@ -599,8 +606,8 @@ function showNewExpectedComponent(state) { function validateDeliverableStatus() { // New Expected year should be greater than current reporting cycle year - if(reportingActive) { - if(isDeliverableNew) { + if (reportingActive) { + if (isDeliverableNew) { $statuses.find('option').prop("disabled", true); // Disable All $statuses.find('option[value="3"]').prop("disabled", false); // Enable Complete $statuses.find('option[value="5"]').prop("disabled", false); // Enable Cancelled @@ -618,7 +625,7 @@ function checkActivityItems(block) { console.log(block); var items = $(block).find('.activities').length; console.log(items); - if(items == 0) { + if (items == 0) { $(block).parent().find('p.emptyText').fadeIn(); } else { $(block).parent().find('p.emptyText').fadeOut(); @@ -629,7 +636,7 @@ function checkFundingItems(block) { console.log(block); var items = $(block).find('.fundingSources').length; console.log(items); - if(items == 0) { + if (items == 0) { $(block).parent().find('p.emptyText').fadeIn(); } else { $(block).parent().find('p.emptyText').fadeOut(); @@ -640,7 +647,7 @@ function checkGenderItems(block) { console.log(block); var items = $(block).find('.genderLevel').length; console.log(items); - if(items == 0) { + if (items == 0) { $(block).parent().find('p.emptyText').fadeIn(); } else { $(block).parent().find('p.emptyText').fadeOut(); @@ -655,7 +662,7 @@ function notify(text) { } function formatState(state) { - if(state.id == -1) { + if (state.id == -1) { return state.text; } var $state = $("#fundingSource-" + state.id).clone(true); @@ -664,21 +671,21 @@ function formatState(state) { }; function formatStateGenderType(state) { - if(state.id == -1) { + if (state.id == -1) { return; } var $state = $("#genderLevel-" + state.id).clone(true); return $state; } -function hasDeliverableRule(rule,arrValues) { +function hasDeliverableRule(rule, arrValues) { var result = 0; - $.each(arrValues, function(index,value) { - if(($.inArray(value, getDeliverableTypesByRule(rule))) != -1) { + $.each(arrValues, function (index, value) { + if (($.inArray(value, getDeliverableTypesByRule(rule))) != -1) { result++; } }); - return(result > 0); + return (result > 0); } function getDeliverableTypesByRule(rule) { @@ -691,14 +698,14 @@ function selectKeyOutput() { var keyOutputOptions = $keyOutputList.find('option') var keyOutputsLength = keyOutputOptions.length; - if(keyOutputsLength == 2) { + if (keyOutputsLength == 2) { var optionValue = keyOutputOptions[1].value; $keyOutputList.val(optionValue); $keyOutputList.trigger('change'); } } -var deliverablePartnersModule = (function() { +var deliverablePartnersModule = (function () { function init() { console.log('Starting deliverablePartnersModule'); @@ -719,7 +726,7 @@ var deliverablePartnersModule = (function() { $('.addSlo').on('click', addIdo); } - + function addIdo() { console.log("add sub action"); var $itemsList = $(this).parent().find('.slos-list'); @@ -730,20 +737,20 @@ var deliverablePartnersModule = (function() { updateSubActionIndexes(); $item.trigger('addComponent'); } - + function updateSubActionIndexes() { - $('.slos-list .srfSlo').each(function(i,slo) { - // Updating indexes - $(slo).setNameIndexes(1, i); - $(slo).find('.srfSloIndicator').each(function(subIdoIndex,subIdo) { + $('.slos-list .srfSlo').each(function (i, slo) { // Updating indexes - $(subIdo).setNameIndexes(2, subIdoIndex); + $(slo).setNameIndexes(1, i); + $(slo).find('.srfSloIndicator').each(function (subIdoIndex, subIdo) { + // Updating indexes + $(subIdo).setNameIndexes(2, subIdoIndex); + }); }); - }); - $('.issues-list .srfCCIssue').each(function(i,crossCutting) { - // Updating indexes - $(crossCutting).setNameIndexes(1, i); + $('.issues-list .srfCCIssue').each(function (i, crossCutting) { + // Updating indexes + $(crossCutting).setNameIndexes(1, i); }); } @@ -758,7 +765,7 @@ var deliverablePartnersModule = (function() { function removePartnerItem() { var $item = $(this).parents('.deliverablePartnerItem'); - $item.hide(500, function() { + $item.hide(500, function () { $item.remove(); updateIndexes(); }); @@ -776,18 +783,18 @@ var deliverablePartnersModule = (function() { // Show them $usersBlock.append($newUsersBlock.html()); // Update indexes - if(!isResponsible) { + if (!isResponsible) { updateIndexes(); } } function updateIndexes() { - $('.otherDeliverablePartners .deliverablePartnerItem').each(function(i,partner) { + $('.otherDeliverablePartners .deliverablePartnerItem').each(function (i, partner) { // Update deliverable partner index $(partner).setNameIndexes(1, i); - $(partner).find('.deliverableUserItem').each(function(j,user) { + $(partner).find('.deliverableUserItem').each(function (j, user) { var personID = $(user).find('input[type="checkbox"]').val(); var customID = "jsGenerated-" + i + "-" + j + "-" + personID; // Update user index @@ -807,24 +814,24 @@ var deliverablePartnersModule = (function() { var $institutionsSelects = $listBlock.find('select.partnerInstitutionID'); // Get selected values - selectedValues = $institutionsSelects.map(function(i,select) { + selectedValues = $institutionsSelects.map(function (i, select) { return select.value; }); - $institutionsSelects.each(function(i,select) { + $institutionsSelects.each(function (i, select) { // Enable options $(select).find('option').prop('disabled', false); // Disable only the selected values - $.each(selectedValues, function(key,val) { - if(select.value != val) { + $.each(selectedValues, function (key, val) { + if (select.value != val) { $(select).find('option[value="' + val + '"]').prop('disabled', true); } }); }); // Reset Select2 - setTimeout(function() { + setTimeout(function () { $institutionsSelects.select2({ width: '98%' }); diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index 51c2cab3bb..6f8ecd8654 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -17,10 +17,10 @@ function init() { coordinatorType = 'PC'; defaultType = 'CP'; partnerPersonTypes = [ - coordinatorType, leaderType, defaultType, '-1' + coordinatorType, leaderType, defaultType, '-1' ]; - if(editable) { + if (editable) { // Getting the actual project leader projectLeader = jQuery.extend({}, getProjectLeader()); // Update initial project CCAFS partners list for each partner @@ -30,10 +30,10 @@ function init() { // Activate the chosen to the existing partners addSelect2(); - addUser = function(composedName,userId) { + addUser = function (composedName, userId) { var $contact = $elementSelected.parents('.contactsPerson ').find('input[value="' + userId + '"]'); - if(!$contact.exists()) { + if (!$contact.exists()) { $elementSelected.parents('.userField ').find("input.userName").val(composedName).addClass('animated flash'); $elementSelected.parents('.userField ').find("input.userId").val(userId); } else { @@ -50,14 +50,14 @@ function init() { attachEvents(); // Set the unique person as leader - /* - * if(editable){ var contactPeople = $partnersBlock.find('.projectPartner'); if ((contactPeople.length == 1)){ var - * person = new PartnerPersonObject(contactPeople); person.setPartnerType(leaderType); person.changeType(); } } - */ + /* + * if(editable){ var contactPeople = $partnersBlock.find('.projectPartner'); if ((contactPeople.length == 1)){ var + * person = new PartnerPersonObject(contactPeople); person.setPartnerType(leaderType); person.changeType(); } } + */ - $('.loadingBlock').hide().next().fadeIn(500, function() { + $('.loadingBlock').hide().next().fadeIn(500, function () { // Missing fields in parter person - $("form .projectPartner ").each(function(i,e) { + $("form .projectPartner ").each(function (i, e) { verifyMissingFields(e); }); showHelpText(); @@ -65,6 +65,89 @@ function init() { }); $("textarea[id!='justification']").autoGrow(); + $(".deliverableList").on("change", addDeliverable); +} + +// Add a new deliverable element +function addDeliverable() { + var option = $(this).find("option:selected"); + console.log(option) + var canAdd = true; + if (option.val() == "-1") { + canAdd = false; + } + + var $list = $(this).parents(".select").parent().parent().find(".deliverableWrapper"); + var $item = $("#deliverableActivity-template").clone(true).removeAttr("id"); + console.log($item) + var v = $(option).text().length > 80 ? $(option).text().substr(0, 80) + ' ... ' : $(option).text(); + + // Check if is already selected + $list.find('.deliverableActivity').each(function (i, e) { + if ($(e).find('input.id').val() == option.val()) { + canAdd = false; + return; + } + }); + + // Reset select + $(this).val("-1"); + $(this).trigger('change.select2'); + + if (!canAdd) { + return; + } + + // Set deliverable parameters + $item.find(".name").attr("title", $(option).text()); + $item.find(".name").val($(option).text()); + $item.find(".name").html(v); + $item.find(".id").val(option.val()); + $list.append($item); + $item.show('slow'); + // var $actionContainer = $(this).parents(".fullPartBlock"); + // var activityIndex = $activity.find(".index").html(); + updateDeliverable(this); + checkItems($list); + +} + +function checkItems(block) { + console.log(block); + var items = $(block).find('.deliverableActivity').length; + if (items == 0) { + $(block).parent().find('p.inf').fadeIn(); + } else { + $(block).parent().find('p.inf').fadeOut(); + } +} + + +function updateDeliverable(currentElement) { + + console.clear(); + + var $subSectionsSelector = $(currentElement).parents(".subSectionsSelector"); + var actionindex = $subSectionsSelector.attr("actionindex"); + console.log($subSectionsSelector) + console.log(actionindex) + + + let itemsSize = Number($('#actionsListReference').find('.list').length ?? 0); + itemsSize && itemsSize++; + + console.log(itemsSize) + + + $subSectionsSelector.find('.deliverableActivity').each(function (indexDeliverable, deliverableItem) { + // console.log(indexDeliverable); + // console.log(deliverableItem) + console.log(actionindex) + // Set activity indexes + $(deliverableItem).setNameIndexes(1, actionindex); + // Set indexes + $(deliverableItem).setNameIndexes(2, indexDeliverable); + }); } function attachEvents() { @@ -73,8 +156,8 @@ function attachEvents() { * General */ - $('.blockTitle').on('click', function() { - if($(this).hasClass('closed')) { + $('.blockTitle').on('click', function () { + if ($(this).hasClass('closed')) { $('.blockContent').slideUp(); $('.blockTitle').removeClass('opened').addClass('closed'); $(this).removeClass('closed').addClass('opened'); @@ -82,27 +165,27 @@ function attachEvents() { $(this).removeClass('opened').addClass('closed'); } - $(this).next().slideToggle(500, function() { + $(this).next().slideToggle(500, function () { $(this).find('textarea').autoGrow(); $(this).find(".errorTag").hide(); $(this).find(".errorTag").css("left", $(this).outerWidth()); $(this).find(".errorTag").fadeIn(1000); // Scroll to selected partner - $('html, body').animate({scrollTop: $(this).offset().top - 100}, 500); + $('html, body').animate({ scrollTop: $(this).offset().top - 100 }, 500); }); }); - $('.button-save').on('click', function(e) { + $('.button-save').on('click', function (e) { var missingFields = 0 - $('form select.institutionsList').each(function(i,e){ - if(!e.value){ + $('form select.institutionsList').each(function (i, e) { + if (!e.value) { missingFields++; } }); // Validate if there are missing fields - if(missingFields) { + if (missingFields) { e.preventDefault(); var notyOptions = jQuery.extend({}, notyDefaultOptions); notyOptions.text = "You must select a partner organization"; @@ -123,58 +206,58 @@ function attachEvents() { // When Partner Type change $("select.partnerTypes, select.countryList").change(updateOrganizationsList); // When name change - $("input.name").on("change", function(e) { + $("input.name").on("change", function (e) { find('.priorityActionTitle').text(this.name); - }); + }); // When organization change - $("select.institutionsList").on("change", function(e) { + $("select.institutionsList").on("change", function (e) { var partner = new PartnerObject($(this).parents('.projectPartner')); // Update Partner Title partner.updateBlockContent(); // Get Countries from Institution ID $.ajax({ - url: baseURL + "/institutionBranchList.do", - data: { - institutionID: $(this).val(), - phaseID: phaseID - }, - beforeSend: function() { - partner.startLoader(); - }, - success: function(data) { - partner.clearCountries(); - - $(partner.countriesSelect).empty(); - $(partner.countriesSelect).addOption(-1, "Select a country..."); - - // Validate if the current partner is not selected, then add the countries - if(!($('input.institutionsList[value=' + partner.institutionId + ']').exists())) { - $.each(data.branches, function(index,branch) { - - if((branch.name).indexOf("HQ") != "-1") { - partner.addCountry({ - iso: branch.iso, - name: branch.name - }); - } else { - $(partner.countriesSelect).addOption(branch.iso, branch.name); - } - }); - } - - $(partner.countriesSelect).trigger("change.select2"); - }, - complete: function() { - partner.stopLoader(); + url: baseURL + "/institutionBranchList.do", + data: { + institutionID: $(this).val(), + phaseID: phaseID + }, + beforeSend: function () { + partner.startLoader(); + }, + success: function (data) { + partner.clearCountries(); + + $(partner.countriesSelect).empty(); + $(partner.countriesSelect).addOption(-1, "Select a country..."); + + // Validate if the current partner is not selected, then add the countries + if (!($('input.institutionsList[value=' + partner.institutionId + ']').exists())) { + $.each(data.branches, function (index, branch) { + + if ((branch.name).indexOf("HQ") != "-1") { + partner.addCountry({ + iso: branch.iso, + name: branch.name + }); + } else { + $(partner.countriesSelect).addOption(branch.iso, branch.name); + } + }); } + + $(partner.countriesSelect).trigger("change.select2"); + }, + complete: function () { + partner.stopLoader(); + } }); // Update PPA Partners List updateProjectPPAPartnersLists(e); }); // Partnership Geographic Scope - $(".geographicScopeSelect").on('change', function(){ + $(".geographicScopeSelect").on('change', function () { var $partner = $(this).parents('.projectPartner'); var $regionalBlock = $partner.find('.regionalBlock'); var $nationalBlock = $partner.find('.nationalBlock'); @@ -185,16 +268,16 @@ function attachEvents() { var isSubNational = this.value == 5; // Regions - if(isRegional){ + if (isRegional) { $regionalBlock.show(); - }else{ + } else { $regionalBlock.hide(); } // Countries $nationalBlock.find("select").val(null).trigger('change'); - if(isMultiNational || isNational || isSubNational){ - if (isMultiNational){ + if (isMultiNational || isNational || isSubNational) { + if (isMultiNational) { $nationalBlock.find("select").select2({ maximumSelectionLength: 0, placeholder: "Select a country(ies)", @@ -202,7 +285,7 @@ function attachEvents() { templateSelection: formatStateCountries, width: '100%' }); - }else{ + } else { $nationalBlock.find("select").select2({ maximumSelectionLength: 1, placeholder: "Select a country(ies)", @@ -212,7 +295,7 @@ function attachEvents() { }); } $nationalBlock.show(); - }else{ + } else { $nationalBlock.hide(); } @@ -226,65 +309,65 @@ function attachEvents() { // Request country office $('#requestModal').on( - 'show.bs.modal', - function(event) { - $.noty.closeAll(); - var partner = new PartnerObject($(event.relatedTarget).parents('.projectPartner')); - - var $modal = $(this); - // Show Form & button - $modal.find('form, .requestButton').show(); - $modal.find('.messageBlock').hide(); - $modal.find('input.institution_id').val(partner.institutionId); - $modal.find('select.countriesRequest').val(null).trigger('select2:change'); - $modal.find('select.countriesRequest').trigger('change'); - $modal.find('.modal-title').html( - 'Request Country office(s)
    (' + partner.institutionName + ')'); - }); - $('#requestModal button.requestButton').on('click', function() { + 'show.bs.modal', + function (event) { + $.noty.closeAll(); + var partner = new PartnerObject($(event.relatedTarget).parents('.projectPartner')); + + var $modal = $(this); + // Show Form & button + $modal.find('form, .requestButton').show(); + $modal.find('.messageBlock').hide(); + $modal.find('input.institution_id').val(partner.institutionId); + $modal.find('select.countriesRequest').val(null).trigger('select2:change'); + $modal.find('select.countriesRequest').trigger('change'); + $modal.find('.modal-title').html( + 'Request Country office(s)
    (' + partner.institutionName + ')'); + }); + $('#requestModal button.requestButton').on('click', function () { var $modal = $(this).parents('.modal'); - if($modal.find('select.countriesRequest').val() == null) { + if ($modal.find('select.countriesRequest').val() == null) { return } $.ajax({ - url: baseURL + '/requestCountryOffice.do', - data: $('#requestModal form').serialize(), - beforeSend: function(data) { - $modal.find('.loading').fadeIn(); - }, - success: function(data) { - console.log(data); - if(data.sucess.result == "1") { - // Hide Form & button - $modal.find('form, .requestButton').hide(); - $modal.find('.messageBlock').show(); - - // Noty Message - /* - * var message = $modal.find('.messageBlock .notyMessage').html(); var notyOptions = jQuery.extend({}, - * notyDefaultOptions); notyOptions.text = message; notyOptions.type = 'info'; notyOptions.timeout = 5000; - * notyOptions.animation = { open: 'animated fadeIn', // Animate.css class names close: 'animated fadeOut', // - * Animate.css class names easing: 'swing', // unavailable - no need speed: 400 // unavailable - no need }; - * notyOptions.callback = { onClose : function(){ $modal.modal('hide'); } }; $modal.find('.messageBlock - * .notyMessage').noty(notyOptions); - */ - } - }, - complete: function() { - $modal.find('.loading').fadeOut(); + url: baseURL + '/requestCountryOffice.do', + data: $('#requestModal form').serialize(), + beforeSend: function (data) { + $modal.find('.loading').fadeIn(); + }, + success: function (data) { + console.log(data); + if (data.sucess.result == "1") { + // Hide Form & button + $modal.find('form, .requestButton').hide(); + $modal.find('.messageBlock').show(); + + // Noty Message + /* + * var message = $modal.find('.messageBlock .notyMessage').html(); var notyOptions = jQuery.extend({}, + * notyDefaultOptions); notyOptions.text = message; notyOptions.type = 'info'; notyOptions.timeout = 5000; + * notyOptions.animation = { open: 'animated fadeIn', // Animate.css class names close: 'animated fadeOut', // + * Animate.css class names easing: 'swing', // unavailable - no need speed: 400 // unavailable - no need }; + * notyOptions.callback = { onClose : function(){ $modal.modal('hide'); } }; $modal.find('.messageBlock + * .notyMessage').noty(notyOptions); + */ } + }, + complete: function () { + $modal.find('.loading').fadeOut(); + } }); }); /** * CCAFS Partners list events */ - $('.ppaPartnersList select').on('change', function(e) { + $('.ppaPartnersList select').on('change', function (e) { addItemList($(this).find('option:selected')); }); - $('ul li .remove').on('click', function(e) { + $('ul li .remove').on('click', function (e) { removeItemList($(this).parents('li')); }); @@ -310,9 +393,9 @@ function showHelpText() { function getProjectLeader() { var contactLeader = {}; - $partnersBlock.find('.contactPerson').each(function(i,partnerPerson) { + $partnersBlock.find('.contactPerson').each(function (i, partnerPerson) { var contact = new PartnerPersonObject($(partnerPerson)); - if(contact.isLeader()) { + if (contact.isLeader()) { contactLeader = jQuery.extend({}, contact); } }); @@ -325,7 +408,7 @@ function setProjectLeader(obj) { function filterInstitutions(e) { var $filterContent = $(e.target).parent().next(); - if($filterContent.is(":visible")) { + if ($filterContent.is(":visible")) { updateOrganizationsList(e); } $filterContent.slideToggle(); @@ -334,20 +417,20 @@ function filterInstitutions(e) { function showPersonRelations(e) { var $relations = $(this).next().html(); $('#relations-dialog').dialog({ - modal: true, - closeText: "", - width: 500, - buttons: { - Close: function() { - $(this).dialog("close"); - } - }, - open: function() { - $(this).html($relations); - }, - close: function() { - $(this).empty(); + modal: true, + closeText: "", + width: 500, + buttons: { + Close: function () { + $(this).dialog("close"); } + }, + open: function () { + $(this).html($relations); + }, + close: function () { + $(this).empty(); + } }); } @@ -355,7 +438,7 @@ function changePartnerPersonType(e) { var $contactPerson = $(e.target).parents('.contactPerson'); var contact = new PartnerPersonObject($contactPerson); // Set as unique contact type in the project - if((contact.type == leaderType)) { + if ((contact.type == leaderType)) { setPartnerTypeToDefault(contact.type); } // Change partner person type @@ -365,28 +448,28 @@ function changePartnerPersonType(e) { partner.changeType(); console.log(contact.type); // If the contact type selected is PL - if(contact.type == leaderType) { + if (contact.type == leaderType) { // If there is a PL previous selected - if(!jQuery.isEmptyObject(projectLeader)) { + if (!jQuery.isEmptyObject(projectLeader)) { var previousLeaderName = projectLeader.contactInfo; var messages = '
  • Please note that there can only be one project leader per project.
    '; messages += - 'Therefore ' + previousLeaderName - + ' was assigned a Project collaborator/partner role.
  • '; + 'Therefore ' + previousLeaderName + + ' was assigned a Project collaborator/partner role.'; // Show a pop up with the message $("#contactChangeType-dialog").find('.messages').append(messages); $("#contactChangeType-dialog").dialog({ - modal: true, - closeText: "", - width: 500, - buttons: { - Close: function() { - $(this).dialog("close"); - } - }, - close: function() { - $(this).find('.messages').empty(); + modal: true, + closeText: "", + width: 500, + buttons: { + Close: function () { + $(this).dialog("close"); } + }, + close: function () { + $(this).find('.messages').empty(); + } }); } } @@ -401,7 +484,7 @@ function updateOrganizationsList(e) { var optionSelected = $selectInstitutions.find('option:selected').val(); // Institution selected var source = baseURL + "/institutionsByTypeAndCountry.do"; - if($(e.target).parent().attr("class") != "filters-link") { + if ($(e.target).parent().attr("class") != "filters-link") { var partnerTypes = $parent.find("select.partnerTypes").find('option:selected').val() || -1; // Type value var countryList = $parent.find("select.countryList").find('option:selected').val() || -1; // Value value source += "?institutionTypeID=" + partnerTypes + "&countryID=" + countryList; @@ -409,21 +492,21 @@ function updateOrganizationsList(e) { source += "?institutionTypeID=-1&countryID=-1"; } $.ajax({ - url: source, - beforeSend: function() { - partner.startLoader(); - $selectInstitutions.empty().append(setOption(-1, "Select an option")); - }, - success: function(data) { - $.each(data.institutions, function(index,institution) { - $selectInstitutions.append(setOption(institution.id, institution.name)); - }); - }, - complete: function() { - partner.stopLoader(); - $selectInstitutions.val(optionSelected); - $selectInstitutions.trigger("change.select2"); - } + url: source, + beforeSend: function () { + partner.startLoader(); + $selectInstitutions.empty().append(setOption(-1, "Select an option")); + }, + success: function (data) { + $.each(data.institutions, function (index, institution) { + $selectInstitutions.append(setOption(institution.id, institution.name)); + }); + }, + complete: function () { + partner.stopLoader(); + $selectInstitutions.val(optionSelected); + $selectInstitutions.trigger("change.select2"); + } }); } @@ -432,50 +515,50 @@ function updateProjectPPAPartnersLists(e) { // Clean PPA partners from hidden select $projectPPAPartners.empty(); // Loop for all projects partners - $partnersBlock.find('.projectPartner').each(function(i,projectPartner) { + $partnersBlock.find('.projectPartner').each(function (i, projectPartner) { var partner = new PartnerObject($(projectPartner)); // Collecting partners institutions projectInstitutions.push(parseInt(partner.institutionId)); // Validating if the partners is PPA Partner - if(partner.institutionId == -1) { - partner.hidePPAs(); - } else { - partner.showPPAs(); - } - + if (partner.institutionId == -1) { + partner.hidePPAs(); + } else { + partner.showPPAs(); + } + }); $projectPPAPartners.trigger("change.select2"); // Validating if the institution chosen is already selected - if(e) { + if (e) { var $fieldError = $(e.target).parents('.partnerName').find('p.fieldErrorInstitutions'); $fieldError.text(''); var count = 0; // Verify if the partner is already selected - for(var i = 0; i < projectInstitutions.length; ++i) { - if(projectInstitutions[i] == e.target.value) { + for (var i = 0; i < projectInstitutions.length; ++i) { + if (projectInstitutions[i] == e.target.value) { count++; } } // If there is one selected , show an error message - if(count > 1) { + if (count > 1) { var institutionName = $(e.target).find('option[value="' + e.target.value + '"]').text(); var institutionName_saved = - $('input.institutionsList[value=' + e.target.value + ']').parents('.projectPartner').find('.partnerTitle') - .text(); + $('input.institutionsList[value=' + e.target.value + ']').parents('.projectPartner').find('.partnerTitle') + .text(); $fieldError.html('"' + (institutionName || institutionName_saved) + '" is already selected').animateCss( - 'flipInX'); + 'flipInX'); e.target.value = -1; } } // Filling CCAFS partners lists for each project partner cooment - $partnersBlock.find('.projectPartner').each(function(i,partner) { + $partnersBlock.find('.projectPartner').each(function (i, partner) { var $select = $(partner).find('select.ppaPartnersSelect'); $select.empty().append(setOption(-1, "Select an option")); $select.append($projectPPAPartners.html()); // Removing of the list CCAFS partners previously selected by project partner - $(partner).find('li input.id').each(function(i_id,id) { + $(partner).find('li input.id').each(function (i_id, id) { $select.find('option[value=' + $(id).val() + ']').remove(); }); $select.trigger("change.select2"); @@ -484,11 +567,11 @@ function updateProjectPPAPartnersLists(e) { } function setPartnerTypeToDefault(type) { - $partnersBlock.find('.projectPartner').each(function(i,partner) { + $partnersBlock.find('.projectPartner').each(function (i, partner) { var projectPartner = new PartnerObject($(partner)); - $(partner).find('.contactPerson').each(function(i,partnerPerson) { + $(partner).find('.contactPerson').each(function (i, partnerPerson) { var contact = new PartnerPersonObject($(partnerPerson)); - if(contact.type == type) { + if (contact.type == type) { $(partnerPerson).removeClass(partnerPersonTypes.join(' ')).addClass(defaultType); contact.setPartnerType(defaultType); } @@ -505,67 +588,67 @@ function removePartnerEvent(e) { var deliverables = partner.getRelationsNumber('deliverables'); var partnerContributions = partner.hasPartnerContributions(); var removeDialogOptions = { - modal: true, - width: 500, - buttons: {}, - closeText: "", - close: function() { - $(this).find('.messages').empty(); - } + modal: true, + width: 500, + buttons: {}, + closeText: "", + close: function () { + $(this).find('.messages').empty(); + } }; // The budget related with this partner will be deleted - if(partner.id != -1) { + if (partner.id != -1) { // messages += '
  • Note that the budget affected to this partner will also be deleted.
  • '; removeDialogOptions.buttons = { - "Remove partner": function() { - partner.remove(); - $(this).dialog("close"); - }, - Close: function() { - $(this).dialog("close"); - } + "Remove partner": function () { + partner.remove(); + $(this).dialog("close"); + }, + Close: function () { + $(this).dialog("close"); + } }; } // Validate if there are any deliverables linked to any contact persons from this partner - if(deliverables > 0) { + if (deliverables > 0) { messages += - '
  • Please bear in mind that if you delete this partner, ' + deliverables - + ' deliverables relations will be deleted
  • '; + '
  • Please bear in mind that if you delete this partner, ' + deliverables + + ' deliverables relations will be deleted
  • '; removeDialogOptions.buttons = { - "Remove partner": function() { - partner.remove(); - $(this).dialog("close"); - }, - Close: function() { - $(this).dialog("close"); - } + "Remove partner": function () { + partner.remove(); + $(this).dialog("close"); + }, + Close: function () { + $(this).dialog("close"); + } }; } // Validate if the project partner has any project leader assigned - if(partner.hasLeader()) { + if (partner.hasLeader()) { messages += - '
  • Please indicate another project leader from a different partner before deleting this partner.
  • '; + '
  • Please indicate another project leader from a different partner before deleting this partner.
  • '; removeDialogOptions.buttons = { - Close: function() { + Close: function () { $(this).dialog("close"); } }; } // Validate if there are any activity linked to any contact person of this partner - if(activities > 0) { + if (activities > 0) { messages += - '
  • This partner cannot be deleted because at least one or more contact persons is leading ' + activities - + ' activity(ies)
  • '; + '
  • This partner cannot be deleted because at least one or more contact persons is leading ' + activities + + ' activity(ies)
  • '; messages += - '
  • If you want to proceed with the deletion, please go to the activities and change the activity leader
  • '; + '
  • If you want to proceed with the deletion, please go to the activities and change the activity leader
  • '; removeDialogOptions.buttons = { - Close: function() { + Close: function () { $(this).dialog("close"); } }; } - if(messages === "") { + if (messages === "") { // Remove partner if there is not any problem partner.remove(); } else { @@ -575,12 +658,14 @@ function removePartnerEvent(e) { } } + + function addPartnerEvent(e) { console.log("addPartnerEvent"); var $newElement = $("#projectPartner-template").clone(true).removeAttr("id"); $(this).before($newElement); $newElement.find('.blockTitle').trigger('click'); - $newElement.show("slow", function() { + $newElement.show("slow", function () { // Update component $(document).trigger('updateComponent'); }); @@ -589,31 +674,31 @@ function addPartnerEvent(e) { // Organization $newElement.find("select.institutionsList").select2(searchInstitutionsOptions(canUpdatePPAPartners)); $newElement.find("select.institutionsList").parent().find("span.select2-selection__placeholder") - .text(placeholderText); + .text(placeholderText); // Role Selection $newElement.find("select.partnerPersonType").select2({ - templateResult: formatState, - width: "100%" + templateResult: formatState, + width: "100%" }); // Research Phase $newElement.find("select.researchPhasesSelect ").select2({ - placeholder: "Select here...", - width: '100%' + placeholder: "Select here...", + width: '100%' }); // Countries $newElement.find('select.countriesList, select.countriesSelect').select2({ - placeholder: "Select a country(ies)", - templateResult: formatStateCountries, - templateSelection: formatStateCountries, - width: '100%' + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' }); // Other Selects $newElement.find('select.setSelect2').select2({ - width: '100%' + width: '100%' }); // Update indexes @@ -629,12 +714,12 @@ function addContactEvent(e) { $newElement.show("slow"); // Activate the select2 plugin for new partners created $newElement.find("select").select2({ - templateResult: formatState, - width: '100%' + templateResult: formatState, + width: '100%' }); // IFPRI Division - if(partner.institutionId == 89){ + if (partner.institutionId == 89) { $newElement.find('.divisionBlock.division-IFPRI').show(); } @@ -655,55 +740,55 @@ function removePersonEvent(e) { var activities = person.getRelationsNumber('activities'); var deliverables = person.getRelationsNumber('deliverables'); var removeDialogOptions = { - modal: true, - closeText: "", - width: 500, - buttons: {}, - close: function() { - $(this).find('.messages').empty(); - } + modal: true, + closeText: "", + width: 500, + buttons: {}, + close: function () { + $(this).find('.messages').empty(); + } }; // Validate if there are any deliverable linked to this person - if(deliverables > 0) { + if (deliverables > 0) { messages += - '
  • Please bear in mind that if you delete this contact, ' + deliverables - + ' deliverables relations will be deleted.
  • '; + '
  • Please bear in mind that if you delete this contact, ' + deliverables + + ' deliverables relations will be deleted.
  • '; removeDialogOptions.buttons = { - "Remove Person": function() { - person.remove(); - $(this).dialog("close"); - }, - Close: function() { - $(this).dialog("close"); - } + "Remove Person": function () { + person.remove(); + $(this).dialog("close"); + }, + Close: function () { + $(this).dialog("close"); + } }; } // Validate if the person type is PL - if(person.isLeader()) { + if (person.isLeader()) { messages += - '
  • There must be one project leader per project. Please select another project leader before deleting this contact.
  • '; + '
  • There must be one project leader per project. Please select another project leader before deleting this contact.
  • '; removeDialogOptions.buttons = { - Close: function() { + Close: function () { $(this).dialog("close"); } }; } // Validate if there are any activity linked to this person - if(activities > 0) { + if (activities > 0) { messages += '
  • This contact person cannot be deleted because he/she is leading activity(ies)'; messages += - '
  • If you want to proceed with the deletion, please go to the following activities and change the activity leader
  • '; + '
  • If you want to proceed with the deletion, please go to the following activities and change the activity leader
  • '; messages += '
      '; messages += person.getRelations('activities'); messages += '
    '; messages += ''; removeDialogOptions.buttons = { - Close: function() { + Close: function () { $(this).dialog("close"); } }; } - if(messages === "") { + if (messages === "") { // Remove person if there is not any message person.remove(); } else { @@ -714,7 +799,10 @@ function removePersonEvent(e) { } function setProjectPartnersIndexes() { - $partnersBlock.find(".projectPartner").each(function(index,element) { + console.log("tal vez") + $partnersBlock.find(".projectPartner").each(function (index, element) { + console.log(element) + console.log(index) var partner = new PartnerObject($(element)); partner.setIndex(index); }); @@ -730,7 +818,7 @@ function removeItemList($item) { $select.append(setOption($item.find('.id').val(), $item.find('.name').text())); $select.trigger("change.select2"); // Removing from list - $item.hide("slow", function() { + $item.hide("slow", function () { $item.remove(); setProjectPartnersIndexes(); }); @@ -759,28 +847,28 @@ function addSelect2() { // Role Selection $("form select.partnerPersonType").select2({ - templateResult: formatState, - width: "100%" + templateResult: formatState, + width: "100%" }); // Research Phase $("form select.researchPhasesSelect ").select2({ - placeholder: "Select here...", - width: '100%' + placeholder: "Select here...", + width: '100%' }); $('form select.countriesList, select.countriesRequest, form select.countriesSelect').select2({ - placeholder: "Select a country(ies)", - templateResult: formatStateCountries, - templateSelection: formatStateCountries, - width: '100%' + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' }); // Other selects $("form select.setSelect2 ").select2({ - width: '100%' + width: '100%' }); } @@ -797,82 +885,82 @@ function PartnerObject(partner) { this.id = parseInt($(partner).find('.partnerId').val()); this.institutionId = parseInt($(partner).find('.institutionsList').val()); this.institutionName = - $('#instID-' + this.institutionId + ' .composedName').text() || $(partner).find('.partnerTitle').text(); + $('#instID-' + this.institutionId + ' .composedName').text() || $(partner).find('.partnerTitle').text(); this.allowSubDepart = ($('#instID-' + this.institutionId + ' .allowSubDepart').text() === "true") || false; this.subDepartments = $('#instID-' + this.institutionId + ' .subDepartments option'); this.ppaPartnersList = $(partner).find('.ppaPartnersList'); this.persons = $(partner).find('.contactsPerson .contactPerson'); this.countriesSelect = $(partner).find('.countriesList'); - this.setIndex = function(index) { + this.setIndex = function (index) { // Updating indexes $(partner).setNameIndexes(1, index); // Update index for project Partner $(partner).find("> .blockTitle .index_number").html(index + 1); // Update index for CCAFS Partners - $(partner).find('.ppaPartnersList ul.list li').each(function(li_index,li) { + $(partner).find('.ppaPartnersList ul.list li').each(function (li_index, li) { $(li).setNameIndexes(2, li_index); }); // Update radio buttons labels and for - $(partner).find('input.hasPartnerships-yes').attr('id', "hasPartnerships-yes-"+ index).next().attr('for',"hasPartnerships-yes-"+ index); - $(partner).find('input.hasPartnerships-no').attr('id', "hasPartnerships-no-"+ index).next().attr('for',"hasPartnerships-no-"+ index); + $(partner).find('input.hasPartnerships-yes').attr('id', "hasPartnerships-yes-" + index).next().attr('for', "hasPartnerships-yes-" + index); + $(partner).find('input.hasPartnerships-no').attr('id', "hasPartnerships-no-" + index).next().attr('for', "hasPartnerships-no-" + index); // Update index for partner persons - $(partner).find('.contactPerson').each(function(person_index,partnerPerson) { + $(partner).find('.contactPerson').each(function (person_index, partnerPerson) { var contact = new PartnerPersonObject($(partnerPerson)); contact.setIndex(index, person_index); }); // Update index for locations - $(partner).find('.locElement').each(function(i,element) { + $(partner).find('.locElement').each(function (i, element) { $(element).setNameIndexes(2, i); }); }; - this.validateGovernmentType = function() { - if(this.allowSubDepart) { + this.validateGovernmentType = function () { + if (this.allowSubDepart) { $(partner).find('.subDepartment').slideDown(); } else { $(partner).find('.subDepartment').slideUp(); } }; - this.updateBlockContent = function() { + this.updateBlockContent = function () { $(partner).find('.partnerTitle').text(this.institutionName); this.validateGovernmentType(); }; - this.hasPartnerContributions = function() { + this.hasPartnerContributions = function () { var partners = []; var institutionId = this.institutionId; - $partnersBlock.find(".projectPartner").each(function(index,element) { + $partnersBlock.find(".projectPartner").each(function (index, element) { var projectPartner = new PartnerObject($(element)); - $(element).find('.ppaPartnersList ul.list li input.id').each(function(i_id,id) { - if($(id).val() == institutionId) { + $(element).find('.ppaPartnersList ul.list li input.id').each(function (i_id, id) { + if ($(id).val() == institutionId) { partners.push(projectPartner.institutionName); } }); }); return partners; }; - this.hasLeader = function() { + this.hasLeader = function () { var result = false; - $(partner).find('.contactPerson').each(function(i,partnerPerson) { + $(partner).find('.contactPerson').each(function (i, partnerPerson) { var contact = new PartnerPersonObject($(partnerPerson)); - if(contact.isLeader()) { + if (contact.isLeader()) { result = true; } }); return result; }; - this.getRelationsNumber = function(relation) { + this.getRelationsNumber = function (relation) { var count = 0; - $(partner).find('.contactPerson').each(function(i,partnerPerson) { + $(partner).find('.contactPerson').each(function (i, partnerPerson) { var contact = new PartnerPersonObject($(partnerPerson)); count += contact.getRelationsNumber(relation); }); return count; }; - this.checkLeader = function() { - if($(partner).find('.contactPerson.PL').length == 0) { + this.checkLeader = function () { + if ($(partner).find('.contactPerson.PL').length == 0) { $(partner).removeClass('leader'); $(partner).find('.type-leader').hide(); } else { @@ -881,8 +969,8 @@ function PartnerObject(partner) { types.push('Leader'); } }; - this.checkCoordinator = function() { - if($(partner).find('.contactPerson.PC').length == 0) { + this.checkCoordinator = function () { + if ($(partner).find('.contactPerson.PC').length == 0) { $(partner).removeClass('coordinator'); $(partner).find('.type-coordinator').hide(); } else { @@ -891,42 +979,42 @@ function PartnerObject(partner) { types.push('Coordinator'); } }; - this.changeType = function() { + this.changeType = function () { types = []; this.checkLeader(); this.checkCoordinator(); - if(types.length != 0) { + if (types.length != 0) { $(partner).find('strong.type').text(' (' + types.join(", ") + ')'); } else { $(partner).find('strong.type').text(''); } }; - this.remove = function() { - $(partner).hide("slow", function() { + this.remove = function () { + $(partner).hide("slow", function () { $(partner).remove(); updateProjectPPAPartnersLists(); setProjectPartnersIndexes(); }); }; - this.clearCountries = function() { + this.clearCountries = function () { var $list = $(partner).find(".countries-list.items-list ul"); $list.empty(); }; - this.addCountry = function(country) { + this.addCountry = function (country) { var contryISO = country.iso; var countryName = country.name; - if(contryISO == "-1") { + if (contryISO == "-1") { return } var $list = $(partner).find(".items-list ul"); - var selectedCountries = $list.find('.locElement').map(function() { + var selectedCountries = $list.find('.locElement').map(function () { return $(this).find('input.locElementCountry').val(); }).get(); - if(selectedCountries.indexOf(contryISO) != -1) { + if (selectedCountries.indexOf(contryISO) != -1) { var notyOptions = jQuery.extend({}, notyDefaultOptions); notyOptions.text = 'Countries office cannot be repeated'; noty(notyOptions); @@ -962,16 +1050,16 @@ function PartnerObject(partner) { $(this.countriesSelect).val('-1'); $(this.countriesSelect).trigger('select2:change'); }; - this.showPPAs = function() { + this.showPPAs = function () { $(this.ppaPartnersList).slideDown(); // $(partner).find('.partnerResponsabilities .requiredTag').hide(); $(partner).find('.contactsPerson .requiredTag').hide(); }; - this.hidePPAs = function() { + this.hidePPAs = function () { $(this.ppaPartnersList).slideUp(); // Add a contact person by default - if($(this.persons).length <= 0) { + if ($(this.persons).length <= 0) { console.log('asdfasdf'); $(partner).find('.addContact .addLink').trigger('click'); } @@ -981,10 +1069,10 @@ function PartnerObject(partner) { }; - this.startLoader = function() { + this.startLoader = function () { $(partner).find('.loading').fadeIn(); }; - this.stopLoader = function() { + this.stopLoader = function () { $(partner).find('.loading').fadeOut(); }; } @@ -999,24 +1087,24 @@ function PartnerPersonObject(partnerPerson) { this.type = $(partnerPerson).find('.partnerPersonType').val(); this.contactInfo = $(partnerPerson).find('.userName').val(); this.canEditEmail = ($(partnerPerson).find('input.canEditEmail').val() === "true"); - this.setPartnerType = function(type) { + this.setPartnerType = function (type) { this.type = type; $(partnerPerson).find('.partnerPersonType').val(type).trigger('change.select2'); }; - this.getPartnerType = function() { + this.getPartnerType = function () { return $(partnerPerson).find('.partnerPersonType').val(); }; - this.changeType = function() { + this.changeType = function () { $(partnerPerson).removeClass(partnerPersonTypes.join(' ')).addClass(this.type); this.setPartnerType(this.type); }; - this.getRelationsNumber = function(relation) { + this.getRelationsNumber = function (relation) { return parseInt($(partnerPerson).find('.tag.' + relation + ' span').text()) || 0; }; - this.getRelations = function(relation) { + this.getRelations = function (relation) { return $(partnerPerson).find('.tag.' + relation).next().find('ul').html(); }; - this.setIndex = function(partnerIndex,index) { + this.setIndex = function (partnerIndex, index) { // Update Indexes $(partnerPerson).setNameIndexes(2, index); @@ -1025,12 +1113,12 @@ function PartnerPersonObject(partnerPerson) { $(partnerPerson).find(".userName").attr("id", "partner-" + partnerIndex + "-person-" + index); }; - this.isLeader = function() { - return(this.type == leaderType); + this.isLeader = function () { + return (this.type == leaderType); }; - this.remove = function() { + this.remove = function () { var partner = new PartnerObject($(partnerPerson).parents('.projectPartner')); - $(partnerPerson).hide("slow", function() { + $(partnerPerson).hide("slow", function () { $(partnerPerson).remove(); partner.changeType(this.type); setProjectPartnersIndexes(); @@ -1040,21 +1128,21 @@ function PartnerPersonObject(partnerPerson) { function formatState(state) { var $state = - $("" - + state.text - + "
    " - + $('span.contactPersonRole-' + state.id).text() + "
    "); + $("" + + state.text + + "
    " + + $('span.contactPersonRole-' + state.id).text() + "
    "); return $state; }; function formatStateCountries(state) { - if(!state.id) { + if (!state.id) { return state.text; } var flag = ' '; var $state; - if(state.id != -1) { + if (state.id != -1) { $state = $('' + flag + state.text + ''); } else { $state = $('' + state.text + ''); @@ -1069,8 +1157,8 @@ function addLocElementCountry() { var $countrySelected = $(this).find("option:selected"); partner.addCountry({ - iso: $countrySelected.val(), - name: $countrySelected.text() + iso: $countrySelected.val(), + name: $countrySelected.text() }); } @@ -1080,7 +1168,7 @@ function removeLocElement() { // Add removed item to the selection list $select.addOption($parent.find('input.locElementCountry').val(), $parent.find('span.name').text()); // Removing item - $parent.hide('slow', function() { + $parent.hide('slow', function () { $parent.remove(); setProjectPartnersIndexes(); }); diff --git a/marlo-web/src/main/webapp/global/js/global.js b/marlo-web/src/main/webapp/global/js/global.js index 83287a0e27..23ac69c53a 100644 --- a/marlo-web/src/main/webapp/global/js/global.js +++ b/marlo-web/src/main/webapp/global/js/global.js @@ -5,26 +5,26 @@ $.widget.bridge('uitooltip', $.ui.tooltip); // Global Vars var yesnoEvent; var notyDefaultOptions = { - text: '', - layout: 'bottomRight', - type: 'error', - theme: 'relax', - timeout: 6000, - progressBar: true, - animation: { - open: 'animated bounceInRight', - close: 'animated bounceOutRight' - }, - closeWith: [ - 'click' - ] + text: '', + layout: 'bottomRight', + type: 'error', + theme: 'relax', + timeout: 6000, + progressBar: true, + animation: { + open: 'animated bounceInRight', + close: 'animated bounceOutRight' + }, + closeWith: [ + 'click' + ] }; /** * Global javascript must be here. */ -$(document).ready(function() { - +$(document).ready(function () { + showNotificationMessages(); showHelpText(); @@ -35,7 +35,7 @@ $(document).ready(function() { $('p.changesDetected strong').text($('.changedField').length); // Help text in each section - $('.scrollup').click(function() { + $('.scrollup').click(function () { $("html, body").animate({ scrollTop: 0 }, 600); @@ -49,48 +49,48 @@ $(document).ready(function() { // View More link button $('#helpViewMoreLink').on("click", expandViewMoreLink); - $('.primarySelect').on("change", function(){ - $($(this).parents('.panel-body')).find(".radio-input").each(function(i,e) { - if ($(this).parents('.panel-body').find('.list').find('li').size() == 1) { - $(e).attr('checked',true); - } + $('.primarySelect').on("change", function () { + $($(this).parents('.panel-body')).find(".radio-input").each(function (i, e) { + if ($(this).parents('.panel-body').find('.list').find('li').size() == 1) { + $(e).attr('checked', true); + } }); }); // View More link button - $('.in-radio-list').on("click", function (){ + $('.in-radio-list').on("click", function () { $list = $(this).parents('.list'); - $($list ).find(".radio-input").each(function(i,e) { + $($list).find(".radio-input").each(function (i, e) { // console.log(e.value); $(e).val('false'); $(e).removeAttr('checked') - // var option = - // $("#regionSelect").find( - // "option[value='" + $(e).find("input.rId").val() + "-" + $(e).find("input.regionScope").val() + "']"); - // option.prop('disabled', true); - }); + // var option = + // $("#regionSelect").find( + // "option[value='" + $(e).find("input.rId").val() + "-" + $(e).find("input.regionScope").val() + "']"); + // option.prop('disabled', true); + }); - $(this).parents('.radioFlat').find('.radio-input').val('true'); + $(this).parents('.radioFlat').find('.radio-input').val('true'); - $(this).parents('.radioFlat').find('.radio-input').attr('checked'); + $(this).parents('.radioFlat').find('.radio-input').attr('checked'); }); - $(".removeHelp").on("click", function() { - $(this).parent().parent().fadeOut(function() { + $(".removeHelp").on("click", function () { + $(this).parent().parent().fadeOut(function () { $(this).remove(); }); }); // Save Button click (Loading state) - $('button[name=save]').on('click', function(e) { + $('button[name=save]').on('click', function (e) { $('.container_page_load').show(); - if($(this).hasClass('disabled')) { + if ($(this).hasClass('disabled')) { e.preventDefault(); return; } // Validate if there ia a justification var justification = $("form:first").find("textarea.justification"); - if(justification.exists() && justification.val().trim().length == 0) { + if (justification.exists() && justification.val().trim().length == 0) { e.preventDefault(); return; } @@ -104,13 +104,13 @@ $(document).ready(function() { }); // Yes / No Event - $('input.onoffswitch-radio').on('change', function(e) { + $('input.onoffswitch-radio').on('change', function (e) { // yesnoEvent($(this)); }); // hash url animation - if(window.location.hash) { - if($(window.location.hash).exists() && hashScroll) { + if (window.location.hash) { + if ($(window.location.hash).exists() && hashScroll) { $('html, body').animate({ scrollTop: $(window.location.hash).offset().top - 110 }, 1500); @@ -118,10 +118,10 @@ $(document).ready(function() { } // Main Menu always visible - if($('#mainMenu').exists()) { + if ($('#mainMenu').exists()) { var mainMenuPosition = $('#mainMenu').position().top + 20; - $(window).scroll(function() { - if($(window).scrollTop() >= mainMenuPosition) { + $(window).scroll(function () { + if ($(window).scrollTop() >= mainMenuPosition) { $('#mainMenu .menuContent').addClass('positionFixedTop'); } else { $('#mainMenu .menuContent').removeClass('positionFixedTop'); @@ -130,15 +130,15 @@ $(document).ready(function() { } // Phase tag visible - if($('#phaseTag').exists()) { + if ($('#phaseTag').exists()) { var phaseTagPos = $('#timelineScroll').parent().position().top + 20; $('#phaseTag').find('span').css({ right: $(document).width() - ($('.phaseTag').offset().left + $('.phaseTag').width()) }); - $(window).scroll(function() { - if($(window).scrollTop() >= phaseTagPos) { + $(window).scroll(function () { + if ($(window).scrollTop() >= phaseTagPos) { $('#phaseTag span').fadeIn(); } else { $('#phaseTag span').hide(); @@ -148,29 +148,29 @@ $(document).ready(function() { // Function that set the interface buttons always visible var $buttons = $('.buttons'); - if($buttons.exists()) { - var menuOffset = function() { + if ($buttons.exists()) { + var menuOffset = function () { return $(document).height() - ($buttons.offset().top + $buttons.height()); } $buttons.find('.buttons-content').css({ right: $(document).width() - ($buttons.offset().left + $buttons.width()) }); - setTimeout(function() { + setTimeout(function () { setFixedElement($(window).scrollBottom() >= menuOffset()); }, 500); - $(document).on('updateComponent', function() { + $(document).on('updateComponent', function () { setFixedElement($(window).scrollBottom() >= menuOffset()); }); - $(window).scroll(function() { + $(window).scroll(function () { setFixedElement($(window).scrollBottom() >= menuOffset()); }); } function setFixedElement(isFixed) { - if(isFixed) { + if (isFixed) { $buttons.find('.buttons-content').addClass('positionFixedBot animated flipInX'); } else { $buttons.find('.buttons-content').removeClass('positionFixedBot animated flipInX'); @@ -186,18 +186,18 @@ $(document).ready(function() { function showNotificationMessages() { var messageSelector = $('#generalMessages').find("#message"); // VALIDATE IF IS ERROR O SUCCES CLASS - if($(messageSelector).hasClass("success")) { + if ($(messageSelector).hasClass("success")) { // SUCCESS MESSAGE - if(messageSelector.length == 1 && messageSelector.html().split(":")[0] === "message") { + if (messageSelector.length == 1 && messageSelector.html().split(":")[0] === "message") { var message = $(messageSelector).html().split(":")[1]; var messageType = "success"; notifyErrorMessage(messageType, message); - } else if(messageSelector.length == 1 && messageSelector.html().split(":")[0] === "draft") { + } else if (messageSelector.length == 1 && messageSelector.html().split(":")[0] === "draft") { // DRAFT MESSAGE var message = $(messageSelector).html().split(":")[1]; var messageType = "success"; notifyErrorMessage(messageType, message); - } else if(messageSelector.length >= 1 && messageSelector.html().split(":")[0] != "message") { + } else if (messageSelector.length >= 1 && messageSelector.html().split(":")[0] != "message") { // WARNING MESSAGE var message = "" message += "The Information was correctly saved.
    "; @@ -205,7 +205,7 @@ $(document).ready(function() { var messageType = "warning"; notifyErrorMessage(messageType, message); } - } else if($(messageSelector).hasClass("error")) { + } else if ($(messageSelector).hasClass("error")) { // ERROR MESSAGE var message = $(messageSelector).html(); var messageType = "error"; @@ -214,7 +214,7 @@ $(document).ready(function() { } - function notifyErrorMessage(messageType,message) { + function notifyErrorMessage(messageType, message) { var containerAlert = document.getElementsByClassName("globalContainerAlert") var containerLine = document.getElementsByClassName("globalContainerLine") var containerIcon = document.getElementsByClassName("globalContainerIcon") @@ -225,7 +225,7 @@ $(document).ready(function() { switch (messageType) { case "success": $(element).find('.alertText').html(message); - $(iconAlert).attr("src",baseURL+'/global/images/icon-done.png'); + $(iconAlert).attr("src", baseURL + '/global/images/icon-done.png'); $(containerAlert).addClass("alertColorBackgroundSucces"); $(containerLine).addClass("alertColorSucces"); $(containerIcon).addClass("alertColorSucces"); @@ -233,7 +233,7 @@ $(document).ready(function() { break; case "warning": $(element).find('.alertText').html(message); - $(iconAlert).attr("src",baseURL+'/global/images/icon-alert.png'); + $(iconAlert).attr("src", baseURL + '/global/images/icon-alert.png'); $(containerAlert).addClass("alertColorBackgroundWarning"); $(containerLine).addClass("alertColorWarning"); $(containerIcon).addClass("alertColorWarning"); @@ -243,7 +243,7 @@ $(document).ready(function() { //Declaraciones ejecutadas cuando el resultado de expresión coincide con valorN break; } - + // $('#generalMessages').noty({ // theme: 'relax', @@ -281,20 +281,20 @@ $(document).ready(function() { /* Tooltips with JQuery UI */ $(this).tooltip({ - track: true, - content: function() { - return $(this).attr('title'); - }, - position: { - my: "left+15 center", - at: "right center" - } + track: true, + content: function () { + return $(this).attr('title'); + }, + position: { + my: "left+15 center", + at: "right center" + } }); /* ADD TITLE TOOLTIP TO ALL REQUIRED SIGN */ $(".requiredTag").attr('title', 'This is a required field'); - yesnoEvent = function(target) { + yesnoEvent = function (target) { } @@ -304,9 +304,9 @@ $(document).ready(function() { var $tickBoxWp = $('.tickBox-wrapper input[type=checkbox]'); $tickBoxWp.on('change', toggleInputs); - $tickBoxWp.each(function() { + $tickBoxWp.each(function () { var $toggle = $(this).closest('.tickBox-wrapper').find('.tickBox-toggle'); - if($(this).is(':checked')) { + if ($(this).is(':checked')) { $toggle.show(); } else { $toggle.hide(); @@ -318,24 +318,24 @@ $(document).ready(function() { } // History log pop up - $('.button-history').on('click', function() { + $('.button-history').on('click', function () { $('#log-history').dialog({ - modal: true, - maxWidth: 500, - closeText: "", - width: '70%', - buttons: { - Cancel: function() { - $(this).dialog("close"); - } + modal: true, + maxWidth: 500, + closeText: "", + width: '70%', + buttons: { + Cancel: function () { + $(this).dialog("close"); } + } }); }); // Datatables language - if($.fn.dataTable) { + if ($.fn.dataTable) { $.extend(true, $.fn.dataTable.defaults, { "language": { "infoFiltered": "(filtered from a total of _MAX_ entries)" @@ -344,7 +344,7 @@ $(document).ready(function() { } // Cancel button - $('#cancelButton').on('click', function() { + $('#cancelButton').on('click', function () { $('button[name="cancel"]').trigger('click'); }); @@ -353,19 +353,19 @@ $(document).ready(function() { $('form .allowTextEditor').setTrumbowyg(); - $('.decodeHTML').each(function(i,e) { + $('.decodeHTML').each(function (i, e) { $(this).html($(this).text()); }); // Accessible enter click when button is focus - $("input[type='submit']").keyup(function(event) { - if(event.keyCode === 13) { + $("input[type='submit']").keyup(function (event) { + if (event.keyCode === 13) { $(this).click(); } }); // Remove concurrency block - $('.removeConcurrenceBlock').on('click', function(e) { + $('.removeConcurrenceBlock').on('click', function (e) { e.preventDefault(); $('#concurrenceBlock').fadeOut(); }); @@ -388,54 +388,54 @@ function closeLoadPage() { $('.container_page_load').hide(); } -$(document).ajaxError(function(event,jqxhr,settings,exception) { - if(production && (jqxhr.status == 500)) { +$(document).ajaxError(function (event, jqxhr, settings, exception) { + if (production && (jqxhr.status == 500)) { var slackMessage = { - "text": "MARLO Ajax Exception", - "attachments": [ - { - "color": "#e74c3c", - "author_name": $('.login-input-container.username span').text(), - "text": jqxhr.status + " - " + jqxhr.statusText, - "fields": [ - { - "title": "Section URL", - "value": window.location.href, - "short": true - }, { - "title": "User Name", - "value": currentUserName, - "short": true - } - ], - "footer": settings.url, - } - ] + "text": "MARLO Ajax Exception", + "attachments": [ + { + "color": "#e74c3c", + "author_name": $('.login-input-container.username span').text(), + "text": jqxhr.status + " - " + jqxhr.statusText, + "fields": [ + { + "title": "Section URL", + "value": window.location.href, + "short": true + }, { + "title": "User Name", + "value": currentUserName, + "short": true + } + ], + "footer": settings.url, + } + ] }; postMessageToSlack(JSON.stringify(slackMessage)); } }); -jQuery.fn.setTrumbowyg = function() { +jQuery.fn.setTrumbowyg = function () { var $editor = $(this); - if($.fn.trumbowyg) { + if ($.fn.trumbowyg) { $editor.trumbowyg({ - btns: [ - [ - 'strong', 'link' - ] - ], - allowTagsFromPaste: [ - 'a', 'p', 'br', 'b', 'i' - ], - urlProtocol: true, - autogrow: true, - minimalLinks: true, - semantic: true, - defaultLinkTarget: '_blank' + btns: [ + [ + 'strong', 'link' + ] + ], + allowTagsFromPaste: [ + 'a', 'p', 'br', 'b', 'i' + ], + urlProtocol: true, + autogrow: true, + minimalLinks: true, + semantic: true, + defaultLinkTarget: '_blank' }); - $editor.trumbowyg().on('tbwpaste ', function() { + $editor.trumbowyg().on('tbwpaste ', function () { }); } }; @@ -461,10 +461,10 @@ setWordCounterToInputs('limitWords'); function setWordCounterToInputs(cssName) { // Attribute contains certain value somewhere -> [class*="limitWords"] var check = cssName + "-"; - $('input[type=text][class*="' + cssName + '"], textarea[class*="' + cssName + '"]').each(function(i,input) { + $('input[type=text][class*="' + cssName + '"], textarea[class*="' + cssName + '"]').each(function (i, input) { var className = $(input).attr('class') || ''; - var cls = $.map(className.split(' '), function(val,i) { - if(val.indexOf(check) > -1) { + var cls = $.map(className.split(' '), function (val, i) { + if (val.indexOf(check) > -1) { return val.slice(check.length, val.length); } }); @@ -474,7 +474,7 @@ function setWordCounterToInputs(cssName) { /** secondaryMenu * */ -$('.selectedProgram, selectedProject').on('click', function() { +$('.selectedProgram, selectedProject').on('click', function () { $(this).parent().next().slideToggle('slow'); }); @@ -486,9 +486,9 @@ $('.selectedProgram, selectedProject').on('click', function() { /* prevent enter key to inputs */ -$('input').on("keypress", function(event) { +$('input').on("keypress", function (event) { - if(event.keyCode === 10 || event.keyCode === 13) { + if (event.keyCode === 10 || event.keyCode === 13) { event.preventDefault(); } @@ -496,7 +496,7 @@ $('input').on("keypress", function(event) { function setViewMore() { var element = $('.helpText'); - if($('.helpMessage').height() < 100) { + if ($('.helpMessage').height() < 100) { $(element).find('.viewMore').hide(); } else { $(element).css({ @@ -509,12 +509,12 @@ function setViewMore() { function setViewMoreCollapse() { var element = $('#containerAlert'); - if($(element).height() < 100) { + if ($(element).height() < 100) { $(element).find('.viewMoreCollapse').hide(); } else { $(element).css({ "height": 65, - "align-items":"initial", + "align-items": "initial", }) $(element).find('.viewMoreCollapse').html('View More'); $(element).find('.viewMoreCollapse').show(); @@ -523,20 +523,20 @@ function setViewMoreCollapse() { function expandViewMoreBlockCollapse() { var element = $('.containerAlert'); - if($(this).hasClass("closed")) { + if ($(this).hasClass("closed")) { $(element).css({ "height": '100%', - "align-items":"center", - "padding-bottom":20 + "align-items": "center", + "padding-bottom": 20 }) - + $(this).html('View less'); $(this).addClass("opened"); $(this).removeClass("closed"); - } else if($(this).hasClass("opened")) { + } else if ($(this).hasClass("opened")) { $(element).css({ "height": '65', - "align-items":"initial", + "align-items": "initial", }) $(this).html('View More'); $(this).addClass("closed"); @@ -546,7 +546,7 @@ function expandViewMoreBlockCollapse() { } function expandViewMoreBlock() { - if($(this).hasClass("closed")) { + if ($(this).hasClass("closed")) { $(this).parent().css({ height: $(this).parent().find('.helpMessage').height() + $(this).height() + 5 }); @@ -554,7 +554,7 @@ function expandViewMoreBlock() { $(this).html('View less'); $(this).addClass("opened"); $(this).removeClass("closed"); - } else if($(this).hasClass("opened")) { + } else if ($(this).hasClass("opened")) { $(this).parent().css({ height: 70 }); @@ -567,11 +567,11 @@ function expandViewMoreBlock() { } function expandViewMoreLink() { - if($(this).hasClass("viewMoreLinkclosed")) { + if ($(this).hasClass("viewMoreLinkclosed")) { $(this).html('View Less'); $(this).addClass("viewMoreLinkopened"); $(this).removeClass("viewMoreLinkclosed"); - } else if($(this).hasClass("viewMoreLinkopened")) { + } else if ($(this).hasClass("viewMoreLinkopened")) { $(this).html('View More'); $(this).addClass("viewMoreLinkclosed"); $(this).removeClass("viewMoreLinkopened"); @@ -583,19 +583,19 @@ function expandViewMoreLink() { */ function isStatusCancelled(statusId) { - return(statusId == "5"); + return (statusId == "5"); } function isStatusComplete(statusId) { - return(statusId == "3"); + return (statusId == "3"); } function isStatusExtended(statusId) { - return(statusId == "4"); + return (statusId == "4"); } function isStatusOnGoing(statusId) { - return(statusId == "2"); + return (statusId == "2"); } /** @@ -603,57 +603,57 @@ function isStatusOnGoing(statusId) { */ var placeholderText = 'Search the organization here...' -var searchInstitutionsOptions = function(includePPA) { - +var searchInstitutionsOptions = function (includePPA) { + return searchInstitutionsOptionsData({ - includePPA: includePPA, - projectPreSetting: projectPreSetting + includePPA: includePPA, + projectPreSetting: projectPreSetting }); } -var searchInstitutionsOptionsData = function(optionsData) { - +var searchInstitutionsOptionsData = function (optionsData) { + var customLanguage = { - noResults: function() { + noResults: function () { var projectID = $('input[type="hidden"][name="projectID"]').val(); - return "The partner was not found, request to be added to this list."; + return "The partner was not found, request to be added to this list."; } }; - + return { - ajax: { - url: baseURL + '/searchInstitutions.do', - dataType: 'json', - delay: 350, - data: function(params) { - return { - q: params.term || '', // search term - withPPA: optionsData.includePPA ? 1 : 0, - onlyPPA: optionsData.projectPreSetting, - phaseID: phaseID - }; - }, - processResults: function(data,params) { - return { - results: data.institutions, - }; - } + ajax: { + url: baseURL + '/searchInstitutions.do', + dataType: 'json', + delay: 350, + data: function (params) { + return { + q: params.term || '', // search term + withPPA: optionsData.includePPA ? 1 : 0, + onlyPPA: optionsData.projectPreSetting, + phaseID: phaseID + }; }, - escapeMarkup: function(markup) { - return markup; - }, // let our custom formatter work - language: customLanguage, - minimumInputLength: 0, - templateResult: formatRepo, - templateSelection: formatRepoSelection, - placeholder: placeholderText, - width: '100%' + processResults: function (data, params) { + return { + results: data.institutions, + }; + } + }, + escapeMarkup: function (markup) { + return markup; + }, // let our custom formatter work + language: customLanguage, + minimumInputLength: 0, + templateResult: formatRepo, + templateSelection: formatRepoSelection, + placeholder: placeholderText, + width: '100%' }; - + } function formatRepo(repo) { - if(repo.loading) { + if (repo.loading) { return repo.text; } var markup = ""; @@ -661,14 +661,14 @@ function formatRepo(repo) { // Is PPA markup += ""; - if(repo.isPPA) { + if (repo.isPPA) { markup += "Managing Partner" } else { markup += "Partner"; } markup += ""; // Acronym & Title - if(repo.acronym) { + if (repo.acronym) { markup += "" + repo.acronym + " - " + repo.name; } else { markup += "" + repo.name + ""; @@ -698,15 +698,15 @@ function notificationError(message) { */ function setElementsListComponent() { // Settings - $('select[class*="elementType-"]').each(function(i,e) { + $('select[class*="elementType-"]').each(function (i, e) { $(this).setOneToManyComponent(); }); - $('select[class*="primarySelectorField"]').each(function(i,e) { + $('select[class*="primarySelectorField"]').each(function (i, e) { $(this).setPrimarySelectorFunction(); }); } -jQuery.fn.setOneToManyComponent = function() { +jQuery.fn.setOneToManyComponent = function () { var $parent = $(this).parents('.elementsListComponent'); var $select = $parent.find('select'); var elementType = $select.classParam('elementType'); @@ -717,36 +717,36 @@ jQuery.fn.setOneToManyComponent = function() { // Disabled elements already selected - $list.find("li").each(function(index,domElement) { + $list.find("li").each(function (index, domElement) { var id = $(domElement).find('.elementRelationID').val(); $select.find('option[value="' + id + '"]').prop("disabled", true); // Verify if already exist and remove - if(($list.find('.elementRelationID[value="' + id + '"]').length) > 1) { + if (($list.find('.elementRelationID[value="' + id + '"]').length) > 1) { // $(domElement).remove(); updateIndex++; } }); // Update indexes - if(updateIndex) { - $list.find('li.relationElement').each(function(i,element) { + if (updateIndex) { + $list.find('li.relationElement').each(function (i, element) { var indexLevel = $(element).classParam('indexLevel'); $(element).setNameIndexes(indexLevel, i); }); } // Validate limit reached - if((maxLimit > 0) && (counted >= maxLimit)) { + if ((maxLimit > 0) && (counted >= maxLimit)) { $select.prop('disabled', true).trigger('change.select2'); } // Set placeholder - if((maxLimit == 0)) { + if ((maxLimit == 0)) { $select.find('option[value="-1"]').text("Select multiple options..."); - } else if((maxLimit > 1)) { + } else if ((maxLimit > 1)) { $select.find('option[value="-1"]').text("Select multiple options (Max " + maxLimit + ")..."); - } else if((maxLimit == 1)) { + } else if ((maxLimit == 1)) { $select.find('option[value="-1"]').text("Select a single option..."); } @@ -758,7 +758,7 @@ jQuery.fn.setOneToManyComponent = function() { }; //Function for Primary selector fields -jQuery.fn.setPrimarySelectorFunction = function() { +jQuery.fn.setPrimarySelectorFunction = function () { var $parent = $(this).parents('.elementsListComponent'); var $select = $parent.find('select'); @@ -780,7 +780,7 @@ function onSelectElement() { var className = $list.attr('class'); // Select an option - if($option.val() == "-1") { + if ($option.val() == "-1") { return; } @@ -790,7 +790,7 @@ function onSelectElement() { $element.attr('class', ' ' + $element.attr('class')); // Remove template tag - $element.find('input').each(function(i,e) { + $element.find('input').each(function (i, e) { e.name = (e.name).replace("_TEMPLATE_", ""); e.id = (e.id).replace("_TEMPLATE_", ""); }); @@ -805,7 +805,7 @@ function onSelectElement() { // console.log($element); // Show the element - $element.appendTo($list).hide().show(350, function() { + $element.appendTo($list).hide().show(350, function () { $select.val('-1').trigger('change.select2'); // Disabled option in select component @@ -814,31 +814,31 @@ function onSelectElement() { // Create event addElement $select.trigger("addElement", [ - id, name + id, name ]); }); // Validate limit reached - if((maxLimit > 0) && ((counted + 1) >= maxLimit)) { + if ((maxLimit > 0) && ((counted + 1) >= maxLimit)) { $select.prop('disabled', true).trigger('change.select2'); } // Update indexes - $list.find('li.relationElement').each(function(i,element) { + $list.find('li.relationElement').each(function (i, element) { var indexLevel = $(element).classParam('indexLevel'); $(element).setNameIndexes(indexLevel, i); }); $element.find('label.radio-label').attr('for', $element.find('label.radio-label').parents('.radioFlat').find('input').attr("id")); //Validate if is a primary radioButton group - if(className.indexOf("primary") >= 0){ - if(($list.children().length < 3 && $list.children().first().is('label')) || $list.children().length < 2){ + if (className.indexOf("primary") >= 0) { + if (($list.children().length < 3 && $list.children().first().is('label')) || $list.children().length < 2) { $element.find('input.radio-input').attr('checked', true); } else { $element.find('input.radio-input').attr('checked', false); } $element.find('label.radio-label').attr('for', - $element.find('label.radio-label').parents('.radioFlat').find('input').attr("id")); + $element.find('label.radio-label').parents('.radioFlat').find('input').attr("id")); $element.find('input.radio-input').on('change', onSelectElementPrimary); } } @@ -858,38 +858,38 @@ async function onClickRemoveElement() { var hasListClusters = $parentCluster.hasClass('listClusters'); var $primaryDisplay = $(this).parents(".elementsListComponent").find('div.primarySelectorDisplayBox'); var eventData = [ - id, name + id, name ]; var eventRemove = jQuery.Event("beforeRemoveElement"); $select.trigger(eventRemove, eventData); - if(eventRemove.isDefaultPrevented()) { + if (eventRemove.isDefaultPrevented()) { return; } - - if(hasListClusters){ - const inputs = document.querySelectorAll("div.form-group.row[clusteridparticipant='" + id + "'] input"); - const values = []; - inputs.forEach(input => { - values.push(parseInt(input.value)); - }) - var sumData = values.reduce((a, b) => a + b, 0); - if(sumData > 0){ - try { - // Wait for the user to click on the modal - await alertRemoveCluster(); - } catch (error) { - // User clicked on the close button instead of the remove button - return; - } - - } - removeCluster(id); - + + if (hasListClusters) { + const inputs = document.querySelectorAll("div.form-group.row[clusteridparticipant='" + id + "'] input"); + const values = []; + inputs.forEach(input => { + values.push(parseInt(input.value)); + }) + var sumData = values.reduce((a, b) => a + b, 0); + if (sumData > 0) { + try { + // Wait for the user to click on the modal + await alertRemoveCluster(); + } catch (error) { + // User clicked on the close button instead of the remove button + return; + } + } + removeCluster(id); - $parent.slideUp(300, function() { + } + + $parent.slideUp(300, function () { $parent.remove(); // Enabled option in select component @@ -898,18 +898,18 @@ async function onClickRemoveElement() { // Create event removeElement $select.trigger("removeElement", [ - id, name + id, name ]); // Update indexes - $list.find('li.relationElement').each(function(i,element) { + $list.find('li.relationElement').each(function (i, element) { var indexLevel = $(element).classParam('indexLevel'); $(element).setNameIndexes(indexLevel, i); $(element).find('label.radio-label').attr('for', $(element).find('label.radio-label').parents('.radioFlat').find('input').attr("id")); - - if(className.indexOf("primary") >= 0){ + + if (className.indexOf("primary") >= 0) { $(element).find('label.radio-label').attr('for', $(element).find('label.radio-label').parents('.radioFlat').find('input').attr("id")); - + //$(element).find('input.radio-input').attr('checked', true); /* if ($list.children().length < 3){ @@ -920,18 +920,18 @@ async function onClickRemoveElement() { }); // Enabled select component if needed - if((maxLimit > 0) && (counted >= maxLimit)) { + if ((maxLimit > 0) && (counted >= maxLimit)) { $select.prop('disabled', false).trigger('change.select2'); } }); } function alertRemoveCluster() { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { let modal = $('.modal-evidences'); modal.show(); - $('.close-modal-evidences').on('click', function() { + $('.close-modal-evidences').on('click', function () { modal.hide(); if ($(this).hasClass('remove-cluster-alert')) { resolve(false); @@ -942,34 +942,34 @@ function alertRemoveCluster() { }); } -function removeCluster(idCluster){ +function removeCluster(idCluster) { var spanText = $("#existCurrentCluster").text(); - if($('.listClusters ul.list li').length == 1 && spanText =="false"){ //existCurrentCluster + if ($('.listClusters ul.list li').length == 1 && spanText == "false") { //existCurrentCluster var projectID = $('input[name="projectID"]').val(); $('.listClusterDM [clusteridparticipant="' + idCluster + '"]').remove(); $('.listClusterDM [clusteridparticipant="' + projectID + '"]').remove(); initialRemaining(); $('.sharedClustersList').hide(); } - if($('.listClusters ul.list li').length == 1 && spanText =="true"){ + if ($('.listClusters ul.list li').length == 1 && spanText == "true") { $('.listClusterDM [clusteridparticipant="' + idCluster + '"]').remove(); initialRemaining(); $('.sharedClustersList').hide(); - }else{ + } else { $('.listClusterDM [clusteridparticipant="' + idCluster + '"]').remove(); initialRemaining(); } - - + + } -function initialRemaining(){ +function initialRemaining() { const inputsParticipants = document.querySelectorAll('.listClusterDM input[name^="deliverable.clusterParticipant"][name*=".participants"]'); const inputsFemales = document.querySelectorAll('.listClusterDM input[name^="deliverable.clusterParticipant"][name*=".females"]'); const inputsAfrican = document.querySelectorAll('.listClusterDM input[name^="deliverable.clusterParticipant"][name*=".african"]'); const inputsYouth = document.querySelectorAll('.listClusterDM input[name^="deliverable.clusterParticipant"][name*=".youth"]'); - + const valuesParticipants = []; const valuesFemales = []; const valuesAfrican = []; @@ -982,7 +982,7 @@ function initialRemaining(){ inputsFemales.forEach(input => { valuesFemales.push(parseInt(input.value)); }); - + inputsAfrican.forEach(input => { valuesAfrican.push(parseInt(input.value)); }); @@ -1008,29 +1008,29 @@ function initialRemaining(){ }, 0); // console.log('totalTrainees: '+ $('.totalTrainees').text()); - let remainingTrainees = parseInt($('.totalTrainees').text())-parseInt(sumaParticipants); - let remainingFemales = parseInt($('.totalFemales').text())-parseInt(sumaFemales); - let remainingAfrican = parseInt($('.totalAfrican').text())-parseInt(sumaAfrican); - let remainingYouth = parseInt($('.totalYouth').text())-parseInt(sumaYouth); - + let remainingTrainees = parseInt($('.totalTrainees').text()) - parseInt(sumaParticipants); + let remainingFemales = parseInt($('.totalFemales').text()) - parseInt(sumaFemales); + let remainingAfrican = parseInt($('.totalAfrican').text()) - parseInt(sumaAfrican); + let remainingYouth = parseInt($('.totalYouth').text()) - parseInt(sumaYouth); + $('.remainingTrainees').text(remainingTrainees); $('.remainingFemales').text(remainingFemales); $('.remainingAfrican').text(remainingAfrican); $('.remainingYouth').text(remainingYouth); //Change the colors and messages of the Total and Remaining fields in real time -if(remainingYouth == 0 && remainingAfrican == 0 && remainingFemales == 0 && remainingTrainees == 0){ - $('.remaining-container').css('color', '#8ea786'); - $('.alertParticipant').css('display', 'none'); - $('.doneParticipant').css('display', 'flex'); -} -else{ - $('.remaining-container').css('color', '#FFC300'); - $('.doneParticipant').css('display', 'none'); - $('.alertParticipant').css('display', 'flex'); -} + if (remainingYouth == 0 && remainingAfrican == 0 && remainingFemales == 0 && remainingTrainees == 0) { + $('.remaining-container').css('color', '#8ea786'); + $('.alertParticipant').css('display', 'none'); + $('.doneParticipant').css('display', 'flex'); + } + else { + $('.remaining-container').css('color', '#FFC300'); + $('.doneParticipant').css('display', 'none'); + $('.alertParticipant').css('display', 'flex'); + } + - } @@ -1051,13 +1051,13 @@ function onSelectElementPrimary() { var className = $primaryDisplay.attr('class'); var idenfitierClassName = className.split(' '); - $primaryDisplay.css("display","block"); + $primaryDisplay.css("display", "block"); - var $contentDiv =$("
    "); - var $radiobutton = $(""); - var $radioLabel = $(""); + var $contentDiv = $("
    "); + var $radiobutton = $(""); + var $radioLabel = $(""); - if($primaryList.children().length < 1){ + if ($primaryList.children().length < 1) { $radiobutton.attr('checked', true); } @@ -1078,22 +1078,22 @@ function onClickRemoveElementPrimary() { var $primaryDisplay = $(this).parents(".elementsListComponent").find('div.primarySelectorDisplayBox'); var $primaryRadioElement = $(this).parents('.elementsListComponent').find('ul.primaryRadio'); - var $tempo = $primaryRadioElement.find(".radioFlat.selectPrimary.radioContentBox.ID-"+ id +""); + var $tempo = $primaryRadioElement.find(".radioFlat.selectPrimary.radioContentBox.ID-" + id + ""); var $input = $tempo.find("input"); - if($input.is(':checked')){ + if ($input.is(':checked')) { $tempo.remove(); - if($primaryRadioElement.children().length > 0){ + if ($primaryRadioElement.children().length > 0) { $primaryRadioElement.children(":first").find("input").attr('checked', true); } - }else{ + } else { $tempo.remove(); } //$tempo.remove(); - if($primaryRadioElement.children().length < 1){ + if ($primaryRadioElement.children().length < 1) { $primaryDisplay.css("display", "none"); } } @@ -1102,12 +1102,12 @@ function onClickRemoveElementPrimary() { * Geographic Scope Component */ function formatStateCountries(state) { - if(!state.id) { + if (!state.id) { return state.text; } var flag = ' '; var $state; - if(state.id != -1) { + if (state.id != -1) { $state = $('' + flag + state.text + ''); } else { $state = $('' + state.text + ''); @@ -1129,7 +1129,7 @@ function setGeographicScope(component) { var isSubNational = $scopes.find('.elementRelationID[value="5"]').exists(); // Regions - if(isRegional) { + if (isRegional) { $regionalBlock.slideDown(); } else { $regionalBlock.slideUp(); @@ -1138,26 +1138,26 @@ function setGeographicScope(component) { } // Countries - if(isMultiNational || isNational || isSubNational) { - if(isMultiNational) { + if (isMultiNational || isNational || isSubNational) { + if (isMultiNational) { $nationalBlock.find("select").select2({ - maximumSelectionLength: 0, - placeholder: "Select a country(ies)", - templateResult: formatStateCountries, - templateSelection: formatStateCountries, - width: '100%' + maximumSelectionLength: 0, + placeholder: "Select a country(ies)", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' }); } else { var countries = ($nationalBlock.find("select").val()) || []; - if(countries.length > 1) { + if (countries.length > 1) { $nationalBlock.find("select").val(null).trigger('change'); } $nationalBlock.find("select").select2({ - maximumSelectionLength: 1, - placeholder: "Select a country", - templateResult: formatStateCountries, - templateSelection: formatStateCountries, - width: '100%' + maximumSelectionLength: 1, + placeholder: "Select a country", + templateResult: formatStateCountries, + templateSelection: formatStateCountries, + width: '100%' }); } $nationalBlock.slideDown(); From 3226f5bd42f1fa8d8cb471558e28e82ddfd007b9 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Tue, 13 Feb 2024 18:33:00 -0500 Subject: [PATCH 53/65] :wrench: chore(shfrm Contribution): Update sub actions save and replication process --- .../dao/DeliverableShfrmSubActionDAO.java | 3 + .../DeliverableShfrmSubActionMySQLDAO.java | 14 +++ .../DeliverableShfrmSubActionManager.java | 3 + .../DeliverableShfrmSubActionManagerImpl.java | 21 +++- .../action/projects/DeliverableAction.java | 95 ++++++++++--------- 5 files changed, 89 insertions(+), 47 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java index 2d0869d63d..0f0b1979df 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java @@ -57,6 +57,9 @@ public interface DeliverableShfrmSubActionDAO { public List findByPriorityActionAndPhase(long priorityActionId, long phaseId); + public List findByPriorityActionPhaseAndSubAction(long priorityActionId, long phaseId, + long shfrmSubActionId); + /** * This method saves the information of the given deliverableShfrmSubAction diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java index b6cf7206c7..3c87150e4a 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java @@ -87,6 +87,20 @@ public List findByPriorityActionAndPhase(long priorit } + @Override + public List findByPriorityActionPhaseAndSubAction(long priorityActionId, long phaseId, + long shfrmSubActionId) { + String query = "from " + DeliverableShfrmSubAction.class.getName() + + " where is_active=1 and deliverable_shfrm_priority_action_id=" + priorityActionId + " and id_phase=" + phaseId + + " and shfrm_sub_action_id=" + shfrmSubActionId; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + @Override public DeliverableShfrmSubAction save(DeliverableShfrmSubAction deliverableShfrmSubAction) { if (deliverableShfrmSubAction.getId() == null) { diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java index a04b6d3915..7b5e69a8a5 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java @@ -54,6 +54,9 @@ public interface DeliverableShfrmSubActionManager { public List findByPriorityActionAndPhase(long priorityActionId, long phaseId); + public List findByPriorityActionPhaseAndSubAction(long priorityActionId, long phaseId, + long shfrmSubActionId); + /** * This method gets a deliverableShfrmSubAction object by a given deliverableShfrmSubAction identifier. * diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java index aa85f30181..4811696bd4 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java @@ -66,8 +66,10 @@ public void deleteDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSub Phase phase = phaseDAO.find(next.getId()); DeliverableShfrmSubAction deliverableShfrmSubActionDelete = new DeliverableShfrmSubAction(); - deliverableShfrmSubActionDelete = deliverableShfrmSubActionDAO.findByPriorityActionAndPhase( - deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), phase.getId()).get(0); + deliverableShfrmSubActionDelete = deliverableShfrmSubActionDAO + .findByPriorityActionPhaseAndSubAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), + phase.getId(), deliverableShfrmSubAction.getShfrmSubAction().getId()) + .get(0); if (deliverableShfrmSubActionDelete != null) { deliverableShfrmSubActionDAO.deleteDeliverableShfrmSubAction(deliverableShfrmSubActionDelete.getId()); @@ -97,6 +99,13 @@ public List findByPriorityActionAndPhase(long priorit } + @Override + public List findByPriorityActionPhaseAndSubAction(long priorityActionId, long phaseId, + long shfrmSubActionId) { + return deliverableShfrmSubActionDAO.findByPriorityActionPhaseAndSubAction(priorityActionId, phaseId, + shfrmSubActionId); + } + @Override public DeliverableShfrmSubAction getDeliverableShfrmSubActionById(long deliverableShfrmSubActionID) { @@ -121,8 +130,10 @@ public void saveDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSubAc Phase phase = phaseDAO.find(next.getId()); DeliverableShfrmSubAction deliverableShfrmSubActionPhase = new DeliverableShfrmSubAction(); try { - deliverableShfrmSubActionPhase = deliverableShfrmSubActionDAO.findByPriorityActionAndPhase( - deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), phase.getId()).get(0); + deliverableShfrmSubActionPhase = deliverableShfrmSubActionDAO + .findByPriorityActionPhaseAndSubAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), + phase.getId(), deliverableShfrmSubAction.getShfrmSubAction().getId()) + .get(0); } catch (Exception e) { logger.error("error getting deliverableShfrmSubActionPhase: " + e); } @@ -130,12 +141,14 @@ public void saveDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSubAc if (deliverableShfrmSubActionPhase != null) { DeliverableShfrmSubAction deliverableShfrmSubActionAdd = deliverableShfrmSubActionPhase; deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd.setShfrmSubAction(deliverableShfrmSubAction.getShfrmSubAction()); deliverableShfrmSubActionAdd .setDeliverableShfrmPriorityAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction()); deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); } else { DeliverableShfrmSubAction deliverableShfrmSubActionAdd = new DeliverableShfrmSubAction(); deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd.setShfrmSubAction(deliverableShfrmSubAction.getShfrmSubAction()); deliverableShfrmSubActionAdd .setDeliverableShfrmPriorityAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction()); deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 95b29cb91e..f8f9a6711d 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -2346,11 +2346,6 @@ public String save() { // this.saveProjectOutcomes(deliverableDB, this.getActualPhase()); this.saveCrpOutcomes(deliverableDB, this.getActualPhase()); - // SHFRM contribution - if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) { - this.savePriorityActions(deliverableManagedState, this.getActualPhase()); - this.saveSubActions(deliverableManagedState, this.getActualPhase()); - } boolean haveRegions = false; boolean haveCountries = false; @@ -2408,6 +2403,12 @@ public String save() { } } + // SHFRM contribution + if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) { + this.savePriorityActions(); + this.saveSubActions(); + } + /* * Delete the field 'new expected year' when the status is different to Extended and this field has information */ @@ -3652,13 +3653,13 @@ private void saveParticipant() { * @param deliverable * @param phase */ - public void savePriorityActions(Deliverable deliverable, Phase phase) { + public void savePriorityActions() { // Search and deleted form Information try { - List actionPrev = - deliverableShfrmPriorityActionManager.findByDeliverableAndPhase(deliverable.getId(), phase.getId()); + List actionPrev = deliverableShfrmPriorityActionManager + .findByDeliverableAndPhase(deliverable.getId(), this.getActualPhase().getId()); if (this.deliverable.getShfrmPriorityActions() != null) { List existingIds = new ArrayList<>(); @@ -3701,7 +3702,7 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { // For new deliverable Priority Actions if (deliverablePriorityActions.getId() == null) { deliverablePriorityActionsSave.setDeliverable(deliverable); - deliverablePriorityActionsSave.setPhase(phase); + deliverablePriorityActionsSave.setPhase(this.getActualPhase()); } else { // For old deliverable Priority Actions try { @@ -3721,7 +3722,7 @@ public void savePriorityActions(Deliverable deliverable, Phase phase) { if (deliverable != null && priorityAction != null && priorityAction.getId() != null) { deliverablePriorityActionsSave.setDeliverable(deliverable); deliverablePriorityActionsSave.setShfrmPriorityAction(priorityAction); - deliverablePriorityActionsSave.setPhase(phase); + deliverablePriorityActionsSave.setPhase(this.getActualPhase()); } this.deliverableShfrmPriorityActionManager @@ -4000,20 +4001,23 @@ public void saveQualityCheck() { * @param deliverable * @param phase */ - public void saveSubActions(Deliverable deliverable, Phase phase) { + public void saveSubActions() { // Search and deleted form Information try { if (this.deliverable.getShfrmPriorityActions() != null && !this.deliverable.getShfrmPriorityActions().isEmpty()) { - for (DeliverableShfrmPriorityAction priorityAction : deliverable.getShfrmPriorityActions()) { + for (DeliverableShfrmPriorityAction priorityAction : this.deliverable.getShfrmPriorityActions()) { /*************/ List existingIds = new ArrayList<>(); - - - List subPrev = deliverableShfrmSubActionManager - .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId()); + List subPrev = new ArrayList<>(); + try { + subPrev = deliverableShfrmSubActionManager.findByPriorityActionAndPhase(priorityAction.getId(), + this.getActualPhase().getId()); + } catch (Exception e) { + logger.error("No sub actions added ", e); + } if (priorityAction.getShfrmSubActions() != null) { @@ -4028,7 +4032,7 @@ public void saveSubActions(Deliverable deliverable, Phase phase) { if (subAction != null && subAction.getId() != null) { if (!existingIds.contains(subAction.getId())) { - deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(subAction.getId()); + deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); } } @@ -4041,7 +4045,7 @@ public void saveSubActions(Deliverable deliverable, Phase phase) { if (subAction != null && subAction.getId() != null) { if (!existingIds.contains(subAction.getId())) { - deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(subAction.getId()); + deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); } } @@ -4066,38 +4070,43 @@ public void saveSubActions(Deliverable deliverable, Phase phase) { for (DeliverableShfrmSubAction deliverableSubAction : deliverablePriorityAction.getShfrmSubActions()) { deliverableSubActionSave = new DeliverableShfrmSubAction(); - if (deliverableSubAction != null) { - // For new deliverable Priority Actions - if (deliverableSubAction.getId() == null) { - deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); - deliverableSubActionSave.setPhase(phase); - } else { - // For old deliverable Priority Actions - try { - if (deliverableSubAction.getId() != null) { - deliverableSubActionSave = - deliverableShfrmSubActionManager.getDeliverableShfrmSubActionById(deliverableSubAction.getId()); - } - } catch (Exception e) { - logger.error("unable to get old deliverable sub Actions", e); - } - } - if (deliverableSubAction.getShfrmSubAction() != null && deliverableSubAction.getShfrmSubAction().getId() != null) { ShfrmSubAction subAction = shfrmSubActionManager.getShfrmSubActionById(deliverableSubAction.getShfrmSubAction().getId()); if (subAction != null) { - deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); - deliverableSubActionSave.setShfrmSubAction(subAction); - deliverableSubActionSave.setPhase(phase); - } + // For new deliverable Priority Actions + if (deliverableSubAction.getId() == null || deliverableSubAction.getId() == -1) { + deliverableSubActionSave.setId(null); + deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); + deliverableSubActionSave.setPhase(this.getActualPhase()); + deliverableSubActionSave.setShfrmSubAction(subAction); + this.deliverableShfrmSubActionManager.saveDeliverableShfrmSubAction(deliverableSubActionSave); + + } else { + // For old deliverable Priority Actions + try { + deliverableSubActionSave = + deliverableShfrmSubActionManager.getDeliverableShfrmSubActionById(deliverableSubAction.getId()); + if (deliverableSubActionSave != null) { + deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); + deliverableSubActionSave.setPhase(this.getActualPhase()); + deliverableSubActionSave.setShfrmSubAction(subAction); + this.deliverableShfrmSubActionManager.saveDeliverableShfrmSubAction(deliverableSubActionSave); + } + + } catch (Exception e) { + logger.error("unable to get old deliverable sub Actions", e); + } + } - this.deliverableShfrmSubActionManager.saveDeliverableShfrmSubAction(deliverableSubActionSave); - // This is to add deliverablePriorityActions to generate correct auditlog. - if (!this.deliverable.getDeliverableShfrmSubAction().contains(deliverableSubActionSave)) { - this.deliverable.getDeliverableShfrmSubAction().add(deliverableSubActionSave); + // This is to add deliverablePriorityActions to generate correct auditlog. + /* + * if (!this.deliverable.getDeliverableShfrmSubAction().contains(deliverableSubActionSave)) { + * this.deliverable.getDeliverableShfrmSubAction().add(deliverableSubActionSave); + * } + */ } } } From 5bc1b8ba60c0da51faadfed1f8451c86c742d0be Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 14 Feb 2024 07:32:11 -0500 Subject: [PATCH 54/65] :wrench: chore(shfrm Contribution): Update validations in deliverable action class --- .../action/projects/DeliverableAction.java | 34 +++++++++---------- .../main/resources/custom/aicrra.properties | 2 +- .../crp/views/admin/shfrmManagement.ftl | 2 +- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index f8f9a6711d..e5e892955a 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -163,6 +163,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -1481,7 +1482,7 @@ public void prepare() throws Exception { if (deliverable.getDeliverableShfrmPriorityAction() != null) { deliverable.setShfrmPriorityActions(new ArrayList<>(deliverable.getDeliverableShfrmPriorityAction().stream() .filter(o -> o.isActive() && o.getPhase().getId().equals(this.getActualPhase().getId())) - .collect(Collectors.toList()))); + .sorted(Comparator.comparing(DeliverableShfrmPriorityAction::getId)).collect(Collectors.toList()))); } this.fillSubActionsList(); @@ -1501,7 +1502,7 @@ public void prepare() throws Exception { deliverablePriorityAction .setShfrmSubActions(new ArrayList<>(deliverablePriorityAction.getDeliverableShfrmSubAction() .stream().filter(o -> o.isActive() && o.getPhase().getId().equals(this.getActualPhase().getId())) - .collect(Collectors.toList()))); + .sorted(Comparator.comparing(DeliverableShfrmSubAction::getId)).collect(Collectors.toList()))); } } catch (Exception e) { @@ -3677,8 +3678,7 @@ public void savePriorityActions() { if (priorityAction != null && priorityAction.getId() != null) { deliverableSubActions = deliverableShfrmSubActionManager .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId()); - if (deliverableSubActions == null - || (deliverableSubActions != null && !deliverableSubActions.isEmpty())) { + if (deliverableSubActions == null || (deliverableSubActions != null && deliverableSubActions.isEmpty())) { if (!existingIds.contains(priorityAction.getId())) { deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); } @@ -4008,10 +4008,8 @@ public void saveSubActions() { if (this.deliverable.getShfrmPriorityActions() != null && !this.deliverable.getShfrmPriorityActions().isEmpty()) { for (DeliverableShfrmPriorityAction priorityAction : this.deliverable.getShfrmPriorityActions()) { - - /*************/ List existingIds = new ArrayList<>(); - List subPrev = new ArrayList<>(); + List subPrev = null; try { subPrev = deliverableShfrmSubActionManager.findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId()); @@ -4040,17 +4038,17 @@ public void saveSubActions() { } } else { // Delete all in DB - if (subPrev != null && !subPrev.isEmpty()) { - for (DeliverableShfrmSubAction subAction : subPrev) { - if (subAction != null && subAction.getId() != null) { - - if (!existingIds.contains(subAction.getId())) { - deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); - } - - } - } - } + /* + * if (subPrev != null && !subPrev.isEmpty()) { + * for (DeliverableShfrmSubAction subAction : subPrev) { + * if (subAction != null && subAction.getId() != null) { + * if (!existingIds.contains(subAction.getId())) { + * deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + * } + * } + * } + * } + */ } /***************/ diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 8e9718aceb..85b001de33 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -43,7 +43,7 @@ global.cookieConsentMessage=By default, MARLO uses cookies to ensure you get the global.webSiteLink.placeholder=https:// global.viewMore=View More global.crps=PTFs -global.shfrmPriorityAction=Priority Action +global.ShfrmPriorityAction=Priority Action # Systems Messages systemMessage.serverReset=We are restarting the server in order to apply some improvements to the system. Please save what you are doing in a word document (if needed) since you will have to login again. Sorry for the inconvenience. diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index d6bb3f6eb1..69e3898012 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -8,7 +8,7 @@ "${baseUrlCdn}/global/js/usersManagement.js?20230927" ] /] -[#assign customCSS = [ "${baseUrlMedia}/css/admin/crpPhases.css" ] /] +[#assign customCSS = [ "${baseUrlMedia}/css/admin/crpPhases.css", "${baseUrlMedia}/css/annualReport/annualReportGlobal.css?20240213"] /] [#assign currentSection = "admin" /] [#assign currentStage = "shfrmManagement" /] [#assign hideJustification = true /] From 68874da71c45a9d312e1e7c8d1fc89655dd56972 Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Wed, 14 Feb 2024 09:18:36 -0500 Subject: [PATCH 55/65] :wrench: chore(deliverableMacros.ftl): Add action developed --- .../global/macros/deliverableMacros.ftl | 17 +++++-- .../projects/deliverables/deliverableInfo.js | 8 ---- .../projects/deliverables/deliverableShfrm.js | 47 ++++--------------- 3 files changed, 22 insertions(+), 50 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index cff005fad9..0785459e7c 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1534,6 +1534,16 @@
    [#-- Shfrm Priority Action --]
    + + + +
    [@customForm.elementsListComponent id="deliverablePriorityActions" name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /] @@ -1550,7 +1560,6 @@ [#-- Priority actions list --]
    - [#if deliverable.shfrmPriorityActions?has_content] [#list deliverable.shfrmPriorityActions as priorityAction] [@projectPartnerMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}]" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] @@ -1558,8 +1567,6 @@ [#else]

    [@s.text name="shfrmManagement.actionsEmpty" /]

    [/#if] -
    [@s.text name="shfrmManagement.priorityActions.add" /]
    -
    @@ -1592,9 +1599,9 @@ [#-- TODO: Please improve this validation at backend side --] [#-- Remove link for all partners --] - [#if isTemplate] [#--&& (isTemplate) --] + [#-- [#if isTemplate] - [/#if] + [/#if] --] [#-- Partner Title --]
    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 b13cff4055..c764d5a908 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 @@ -69,14 +69,6 @@ function init() { // Event to validate the expected date $(".yearExpected").on("change", validateCurrentDate); - $(".elementType-shfrmPriorityAction-deliverablePriorityActions").on("change", function () { - // console.log("change action"); - console.log("addProjectPartner") - $('.addProjectPartner').trigger('click'); - - - }); - // Event when status is changed $statuses.on("change", function () { justificationByStatus(this.value); diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index 6f8ecd8654..3f27f66186 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -200,7 +200,8 @@ function attachEvents() { * Project partner Events */ // Add a project partner Event - $(".addProjectPartner").on('click', addPartnerEvent); + $(".elementType-shfrmPriorityAction-deliverablePriorityActions").on("change", addPartnerEvent); + // Remove a project partner Event $(".removePartner").on('click', removePartnerEvent); // When Partner Type change @@ -661,48 +662,20 @@ function removePartnerEvent(e) { function addPartnerEvent(e) { - console.log("addPartnerEvent"); + + console.log("addPartnerEvent") + var $newElement = $("#projectPartner-template").clone(true).removeAttr("id"); - $(this).before($newElement); - $newElement.find('.blockTitle').trigger('click'); + console.log($('#projectPartnersBlock')) + $('#projectPartnersBlock').append($newElement); + // $(this).before($newElement); + // $newElement.find('.blockTitle').trigger('click'); $newElement.show("slow", function () { // Update component $(document).trigger('updateComponent'); }); - // Activate the select2 plugin for new partners created - // Organization - $newElement.find("select.institutionsList").select2(searchInstitutionsOptions(canUpdatePPAPartners)); - $newElement.find("select.institutionsList").parent().find("span.select2-selection__placeholder") - .text(placeholderText); - - // Role Selection - $newElement.find("select.partnerPersonType").select2({ - templateResult: formatState, - width: "100%" - }); - - // Research Phase - $newElement.find("select.researchPhasesSelect ").select2({ - placeholder: "Select here...", - width: '100%' - }); - - // Countries - $newElement.find('select.countriesList, select.countriesSelect').select2({ - placeholder: "Select a country(ies)", - templateResult: formatStateCountries, - templateSelection: formatStateCountries, - width: '100%' - }); - - // Other Selects - $newElement.find('select.setSelect2').select2({ - width: '100%' - }); - - // Update indexes - setProjectPartnersIndexes(); + // setProjectPartnersIndexes(); } function addContactEvent(e) { From a16e831e6e67cc23a51b8db05939b4bda9a97321 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 14 Feb 2024 09:51:52 -0500 Subject: [PATCH 56/65] :wrench: chore(shfrm Contribution): Update sub actions validators in deliverable section --- .../projects/DeliverableValidator.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java index b57dcc79d1..6bd9907487 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java @@ -575,15 +575,21 @@ public void validate(BaseAction action, Deliverable deliverable, boolean saving) action.addMissingField("deliverable.shfrmPriorityActions"); action.getInvalidFields().put("list-deliverable.shfrmPriorityActions", InvalidFieldsMessages.EMPTYFIELD); } else if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { - int index = 0; + int indexJ = 0; + for (DeliverableShfrmPriorityAction priorityAction : deliverable.getShfrmPriorityActions()) { - if (priorityAction != null && priorityAction.getShfrmSubActions() != null - && !priorityAction.getShfrmSubActions().isEmpty()) { - action.addMessage(action.getText("deliverable.shfrmSubActions[" + index + "]")); - action.addMissingField("deliverable.shfrmSubActions[" + index + "]"); - action.getInvalidFields().put("list-deliverable.shfrmPriorityAction[" + index + "].shfrmSubActions", - InvalidFieldsMessages.EMPTYFIELD); - index++; + if (priorityAction != null && priorityAction.getShfrmSubActions() == null + || (priorityAction.getShfrmSubActions() != null && priorityAction.getShfrmSubActions().isEmpty())) { + action.addMessage(action.getText("deliverable.shfrmSubActions")); + action.addMissingField("deliverable.shfrmPriorityActions"); + action.getInvalidFields().put("list-deliverable.shfrmPriorityActions", InvalidFieldsMessages.EMPTYFIELD); + /* + * action.addMessage(action.getText("deliverable.shfrmSubActions[" + indexJ + "]")); + * action.addMissingField("deliverable.shfrmSubActions[" + indexJ + "]"); + * action.getInvalidFields().put("list-deliverable.shfrmPriorityAction[" + indexJ + "].shfrmSubActions", + * InvalidFieldsMessages.EMPTYFIELD); + */ + indexJ++; } } } From 0b37cd650c8e638daaf8fe8a1edbde9b770f7bc2 Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:14:49 -0500 Subject: [PATCH 57/65] :wrench: chore(deliverableMacros.ftl): remove action developed --- .../global/macros/deliverableMacros.ftl | 5 +- .../projects/deliverables/deliverableShfrm.js | 103 +++++------------- 2 files changed, 30 insertions(+), 78 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 0785459e7c..d691386f2b 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1539,7 +1539,9 @@ @@ -1606,6 +1608,7 @@ [#-- Partner Title --]
    [#-- Title --] + ${index+1}. ${(element.shfrmPriorityAction.name)!'Priority Action'}
    diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index 3f27f66186..aadec7b057 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -201,9 +201,14 @@ function attachEvents() { */ // Add a project partner Event $(".elementType-shfrmPriorityAction-deliverablePriorityActions").on("change", addPartnerEvent); + $(".removeElementType-shfrmPriorityAction-deliverablePriorityActions").on('click', removePartnerEvent); + $(".removeElementType-shfrmPriorityAction-deliverablePriorityActions").on('mouseenter', function () { + currentDeleteActionId = $(this).parent('.relationElement').find('.elementRelationID').val(); + }); + // Remove a project partner Event - $(".removePartner").on('click', removePartnerEvent); + // $(".removePartner").on('click', removePartnerEvent); // When Partner Type change $("select.partnerTypes, select.countryList").change(updateOrganizationsList); // When name change @@ -581,91 +586,35 @@ function setPartnerTypeToDefault(type) { }); } +let currentDeleteActionId = null; function removePartnerEvent(e) { - e.preventDefault(); - var partner = new PartnerObject($(e.target).parent().parent()); - var messages = ""; - var activities = partner.getRelationsNumber('activities'); - var deliverables = partner.getRelationsNumber('deliverables'); - var partnerContributions = partner.hasPartnerContributions(); - var removeDialogOptions = { - modal: true, - width: 500, - buttons: {}, - closeText: "", - close: function () { - $(this).find('.messages').empty(); - } - }; - // The budget related with this partner will be deleted - if (partner.id != -1) { - // messages += '
  • Note that the budget affected to this partner will also be deleted.
  • '; - removeDialogOptions.buttons = { - "Remove partner": function () { - partner.remove(); - $(this).dialog("close"); - }, - Close: function () { - $(this).dialog("close"); - } - }; - } - // Validate if there are any deliverables linked to any contact persons from this partner - if (deliverables > 0) { - messages += - '
  • Please bear in mind that if you delete this partner, ' + deliverables - + ' deliverables relations will be deleted
  • '; - removeDialogOptions.buttons = { - "Remove partner": function () { - partner.remove(); - $(this).dialog("close"); - }, - Close: function () { - $(this).dialog("close"); - } - }; - } - // Validate if the project partner has any project leader assigned - if (partner.hasLeader()) { - messages += - '
  • Please indicate another project leader from a different partner before deleting this partner.
  • '; - removeDialogOptions.buttons = { - Close: function () { - $(this).dialog("close"); - } - }; - } - // Validate if there are any activity linked to any contact person of this partner - if (activities > 0) { - messages += - '
  • This partner cannot be deleted because at least one or more contact persons is leading ' + activities - + ' activity(ies)
  • '; - messages += - '
  • If you want to proceed with the deletion, please go to the activities and change the activity leader
  • '; - removeDialogOptions.buttons = { - Close: function () { - $(this).dialog("close"); - } - }; - } + $(`input.actionidvalue[value="${currentDeleteActionId}"]`).parents('.projectPartner').remove(); + updateActionsAndSubActionsIndexes(); +} - if (messages === "") { - // Remove partner if there is not any problem - partner.remove(); - } else { - // Show pop up if there are any message - $("#partnerRemove-dialog").find('.messages').append(messages); - $("#partnerRemove-dialog").dialog(removeDialogOptions); - } +function updateActionsAndSubActionsIndexes() { + console.log("updateActionsAndSubActionsIndexes") } function addPartnerEvent(e) { + var option = $(this).find("option:selected"); + console.log(option) - console.log("addPartnerEvent") var $newElement = $("#projectPartner-template").clone(true).removeAttr("id"); + $newElement.find(".actionidvalue").val(option.val()); + + let itemsSize = Number($('#projectPartnersBlock').find('.projectPartner').length ?? 0); + itemsSize && itemsSize++; + + console.log(itemsSize) + + $newElement.find(".index_number").html(itemsSize); + $newElement.find(".priorityActionTitle").html($(option).text()); + + console.log($('#projectPartnersBlock')) $('#projectPartnersBlock').append($newElement); // $(this).before($newElement); @@ -675,7 +624,7 @@ function addPartnerEvent(e) { $(document).trigger('updateComponent'); }); - // setProjectPartnersIndexes(); + updateActionsAndSubActionsIndexes(); } function addContactEvent(e) { From 0d7162e9144495e8f1df9e35d7379d779c290e4a Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:35:39 -0500 Subject: [PATCH 58/65] :wrench: chore(deliverableMacros.ftl): sub actions select templates added --- .../global/macros/deliverableMacros.ftl | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index d691386f2b..374e8c7243 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1536,15 +1536,13 @@
    - +
    @@ -1554,24 +1552,19 @@
    - [#-- Project Section Content --] -
    - [#-- Section Messages --] - [#-- Listing actions --] - [#-- Priority actions list --] -
    - [#if deliverable.shfrmPriorityActions?has_content] - [#list deliverable.shfrmPriorityActions as priorityAction] - [@projectPartnerMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}]" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] - [/#list] - [#else] -

    [@s.text name="shfrmManagement.actionsEmpty" /]

    - [/#if] - -
    - + [#-- Priority actions list --] +
    + [#if deliverable.shfrmPriorityActions?has_content] + [#list deliverable.shfrmPriorityActions as priorityAction] + [@projectPartnerMacro element=priorityAction!{} name="deliverable.shfrmPriorityActions[${priorityAction_index}]" index=priorityAction_index opened=(deliverable.shfrmPriorityActions?size = 1)/] + [/#list] + [#else] +

    [@s.text name="shfrmManagement.actionsEmpty" /]

    + [/#if] + +

    @@ -1633,7 +1626,7 @@ [#if editable]
    [@s.text name="shfrmManagement.subActions.add" /] [@customForm.req required=true /]
    -
    +
    [@customForm.select name="" label="" i18nkey="project.activities.deliverableSelect" listName="${name}.shfrmPriorityAction.shfrmSubActions" keyFieldName="id" displayFieldName="name" multiple=false required=true className=" deliverableList" disabled=!editable/]
    [/#if] From 5b81e3f38db311193cc081ac99515d29359fe5f3 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 14 Feb 2024 11:16:43 -0500 Subject: [PATCH 59/65] :wrench: chore(shfrm Contribution): Fill main priority actions list with sub actions information --- .../action/projects/DeliverableAction.java | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index e5e892955a..888832ef6b 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -644,6 +644,42 @@ public void fillClusterParticipantsList() { } } + public void fillSubActionsGeneralList() { + try { + if (shfrmPriorityActions != null && !shfrmPriorityActions.isEmpty()) { + List subActions; + List subActionsAdd; + for (ShfrmPriorityAction shfrmPriorityAction : shfrmPriorityActions) { + subActions = new ArrayList<>(); + + // Priority action front + if (shfrmPriorityAction != null && shfrmPriorityAction.getId() != null) { + subActionsAdd = new ArrayList<>(); + // Sub Actions DB + subActions = shfrmSubActionManager.findAll(); + if (subActions != null) { + for (ShfrmSubAction subAction : subActions) { + + if (subAction != null && subAction.getShfrmPriorityAction() != null + && subAction.getShfrmPriorityAction().getId() != null) { + if (subAction.getShfrmPriorityAction().getId().equals(shfrmPriorityAction.getId())) { + subActionsAdd.add(subAction); + } + } + } + if (subActionsAdd != null) { + shfrmPriorityAction.setShfrmSubActions(subActionsAdd); + } + } + } + } + } + + } catch (Exception e) { + logger.error("error getting sub actions: " + e); + } + } + public void fillSubActionsList() { try { if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { @@ -1485,7 +1521,7 @@ public void prepare() throws Exception { .sorted(Comparator.comparing(DeliverableShfrmPriorityAction::getId)).collect(Collectors.toList()))); } this.fillSubActionsList(); - + this.fillSubActionsGeneralList(); if (deliverable != null && deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { From 347892ec50b3feae0b4dd9f485a989705f4352c5 Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:52:56 -0500 Subject: [PATCH 60/65] :wrench: chore(deliverableShfrm.js): update index when add subaction developed --- .../crp/views/projects/deliverableInfo.ftl | 1 - .../crp/views/projects/projectDeliverable.ftl | 4 ++ .../global/macros/deliverableMacros.ftl | 32 ++++++++++------ .../projects/deliverables/deliverableShfrm.js | 37 ++++++++++--------- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl index 2545e81a9e..0ed4bfdd8d 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/deliverableInfo.ftl @@ -145,7 +145,6 @@ [@deliverableMacros.shfmrContributionMacro /] [#-- Single partner TEMPLATE from partnersTemplate.ftl --] - [@deliverableMacros.projectPartnerMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] [#-- Contact person TEMPLATE from partnersTemplate.ftl --] [@deliverableMacros.contactPersonMacro element={} allSubActions=[] name="deliverable.shfrmPriorityActions[-1].shfrmSubActions[-1]" isTemplate=true /] diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl index 732a0f4e18..1768ff75fd 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl @@ -269,6 +269,10 @@
    [/#if] + +[@deliverableMacros.projectPartnerMacro element={} name="deliverable.shfrmPriorityActions[-1]" isTemplate=true /] +[@deliverableMacros.subactionsSelectsctrlList /] + [#-- ----------------------------------- Deliverable Type Rules ------------------------------------------------] [#-- Publication Metadata 49 -> Articles and Books --] diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 374e8c7243..850f3c40b2 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1535,16 +1535,6 @@ [#-- Shfrm Priority Action --]
    - - - -
    [@customForm.elementsListComponent id="deliverablePriorityActions" name="deliverable.shfrmPriorityActions" elementType="shfrmPriorityAction" help="deliverable.shfrmContribution.priorityAction.help" helpIcon=false elementList=(deliverable.shfrmPriorityActions)![] label="deliverable.shfrmContribution.priorityAction" listName="shfrmPriorityActions" keyFieldName="id" displayFieldName="composedName" required=true /]
    @@ -1575,7 +1565,7 @@ [#assign deliverableCustomName = "${name}[${index}]" /]
    [#if editable]
    [/#if] - + [#-- --] @@ -1584,6 +1574,26 @@
    [/#macro] +[#macro subactionsSelectsctrlList ] + + + + [#list shfrmPriorityActions as priorityAction] +
    + [#-- ${(shfrmPriorityActions[${priorityAction_index}].shfrmSubActions)![]} --] + [#if priorityAction.shfrmSubActions?has_content] +
    + [@customForm.select name="" label="" i18nkey="project.activities.deliverableSelect" listName="shfrmPriorityActions[${priorityAction_index}].shfrmSubActions" keyFieldName="id" displayFieldName="name" multiple=false required=true className=" deliverableList" disabled=!editable/] +
    + + [/#if] +
    + +
    + [/#list] + +[/#macro] + [#macro projectPartnerMacro element name index=-1 opened=false defaultPerson=false isTemplate=false] diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index aadec7b057..e52c892a0f 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -71,15 +71,12 @@ function init() { // Add a new deliverable element function addDeliverable() { var option = $(this).find("option:selected"); - console.log(option) var canAdd = true; if (option.val() == "-1") { canAdd = false; } - - var $list = $(this).parents(".select").parent().parent().find(".deliverableWrapper"); + var $list = $(this).parents(".subSectionsSelector").find('.deliverableWrapper') var $item = $("#deliverableActivity-template").clone(true).removeAttr("id"); - console.log($item) var v = $(option).text().length > 80 ? $(option).text().substr(0, 80) + ' ... ' : $(option).text(); // Check if is already selected @@ -107,7 +104,8 @@ function addDeliverable() { $item.show('slow'); // var $actionContainer = $(this).parents(".fullPartBlock"); // var activityIndex = $activity.find(".index").html(); - updateDeliverable(this); + // updateDeliverable(this); + updateActionsAndSubActionsIndexes(); checkItems($list); } @@ -125,7 +123,6 @@ function checkItems(block) { function updateDeliverable(currentElement) { - console.clear(); var $subSectionsSelector = $(currentElement).parents(".subSectionsSelector"); var actionindex = $subSectionsSelector.attr("actionindex"); @@ -141,7 +138,7 @@ function updateDeliverable(currentElement) { $subSectionsSelector.find('.deliverableActivity').each(function (indexDeliverable, deliverableItem) { // console.log(indexDeliverable); - // console.log(deliverableItem) + // console.log(deliverableItem); console.log(actionindex) // Set activity indexes $(deliverableItem).setNameIndexes(1, actionindex); @@ -593,40 +590,46 @@ function removePartnerEvent(e) { } function updateActionsAndSubActionsIndexes() { - console.log("updateActionsAndSubActionsIndexes") + const $actionsList = $('#projectPartnersBlock').find('.projectPartner'); + $actionsList.each(function (actionIndex, $actionItem) { + $($actionItem).setNameIndexes(1, actionIndex); + const $subActionsList = $($actionItem).find('.deliverableWrapper').find('.deliverableActivity'); + $subActionsList.each(function (subActionIndex, $subActionItem) { + $($subActionItem).setNameIndexes(2, subActionIndex); + }); + }); + } function addPartnerEvent(e) { var option = $(this).find("option:selected"); - console.log(option) - - var $newElement = $("#projectPartner-template").clone(true).removeAttr("id"); $newElement.find(".actionidvalue").val(option.val()); let itemsSize = Number($('#projectPartnersBlock').find('.projectPartner').length ?? 0); itemsSize && itemsSize++; - console.log(itemsSize) - $newElement.find(".index_number").html(itemsSize); $newElement.find(".priorityActionTitle").html($(option).text()); - + $newElement.find(".subActionsSelector").html(cloneSubActionSelect(option.val())); console.log($('#projectPartnersBlock')) $('#projectPartnersBlock').append($newElement); - // $(this).before($newElement); - // $newElement.find('.blockTitle').trigger('click'); $newElement.show("slow", function () { - // Update component $(document).trigger('updateComponent'); + $newElement.find("select").select2(); }); updateActionsAndSubActionsIndexes(); } +function cloneSubActionSelect(value) { + var $select = $(`#subactionSelect-${value}`).find('.baseselect').clone(true); + return $select; +} + function addContactEvent(e) { e.preventDefault(); var $newElement = $("#contactPerson-template").clone(true).removeAttr("id"); From 3ec86704bc1ec9af1ecaa37bd8e8f2a703ad7cc6 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 14 Feb 2024 17:45:33 -0500 Subject: [PATCH 61/65] :wrench: chore(shfrm Contribution): Update save process for deliverable actions and sub actions for the new front-end model --- .../ccafs/marlo/action/projects/DeliverableAction.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 888832ef6b..178796c364 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -3736,7 +3736,7 @@ public void savePriorityActions() { if (deliverablePriorityActions != null) { // For new deliverable Priority Actions - if (deliverablePriorityActions.getId() == null) { + if (deliverablePriorityActions.getId() == null || deliverablePriorityActions.getId() == -1) { deliverablePriorityActionsSave.setDeliverable(deliverable); deliverablePriorityActionsSave.setPhase(this.getActualPhase()); } else { @@ -3761,8 +3761,11 @@ public void savePriorityActions() { deliverablePriorityActionsSave.setPhase(this.getActualPhase()); } - this.deliverableShfrmPriorityActionManager + DeliverableShfrmPriorityAction priorityActionTemp = this.deliverableShfrmPriorityActionManager .saveDeliverableShfrmPriorityAction(deliverablePriorityActionsSave); + if (priorityActionTemp != null && priorityActionTemp.getId() != null) { + deliverablePriorityActions.setId(priorityActionTemp.getId()); + } // This is to add deliverablePriorityActions to generate correct auditlog. if (!this.deliverable.getDeliverableShfrmPriorityAction().contains(deliverablePriorityActionsSave)) { this.deliverable.getDeliverableShfrmPriorityAction().add(deliverablePriorityActionsSave); From 63f599664c3ff5c2d450e9d0c1f4af73782ff093 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Wed, 14 Feb 2024 19:08:33 -0500 Subject: [PATCH 62/65] :wrench: chore(shfrm Contribution): Update method documentation and validate mapped priority actions --- .../cgiar/ccafs/marlo/action/BaseAction.java | 4 ++-- .../action/projects/DeliverableAction.java | 19 +++++++++++-------- .../crp/views/admin/shfrmManagement.ftl | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java index b7e53ff305..0ae0209948 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java @@ -892,7 +892,7 @@ public boolean canBeDeleted(long id, String className) { } - if (className != null && className.equals("shfrm")) { + if (clazz == ShfrmPriorityAction.class) { ShfrmPriorityAction shfrmPriorityAction = this.shfrmPriorityActionManager.getShfrmPriorityActionById(id); if (shfrmPriorityAction != null && shfrmPriorityAction.getId() != null) { List deliverableShfrmPriorityActions = @@ -1087,7 +1087,7 @@ public boolean canBeDeleted(long id, String className) { } return true; } catch (Exception e) { - + Log.error("error getting class " + e); return true; } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 178796c364..def85bb230 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -2442,7 +2442,7 @@ public String save() { // SHFRM contribution if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) { - this.savePriorityActions(); + this.savePriorityActions(false); this.saveSubActions(); } @@ -3687,10 +3687,9 @@ private void saveParticipant() { /** * Save Deliverable SHFRM priority action Information * - * @param deliverable - * @param phase + * @param delete - true for only execute delete process */ - public void savePriorityActions() { + public void savePriorityActions(boolean onlyDeleteProcess) { // Search and deleted form Information try { @@ -3729,7 +3728,7 @@ public void savePriorityActions() { } // Save form Information - if (this.deliverable.getShfrmPriorityActions() != null) { + if (this.deliverable.getShfrmPriorityActions() != null && onlyDeleteProcess == false) { DeliverableShfrmPriorityAction deliverablePriorityActionsSave; for (DeliverableShfrmPriorityAction deliverablePriorityActions : this.deliverable.getShfrmPriorityActions()) { deliverablePriorityActionsSave = new DeliverableShfrmPriorityAction(); @@ -4036,9 +4035,6 @@ public void saveQualityCheck() { /** * Save Deliverable SHFRM sub actions Information - * - * @param deliverable - * @param phase */ public void saveSubActions() { @@ -4151,6 +4147,13 @@ public void saveSubActions() { } } } + + // Try to check -> delete priority actions deleted from front-end after delete the sub-actions when all sub actions + // was deleted + if (this.deliverable.getShfrmPriorityActions() == null + || (this.deliverable.getShfrmPriorityActions() != null && this.deliverable.getShfrmPriorityActions().isEmpty())) { + this.savePriorityActions(true); + } } public void saveUsers() { diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index 69e3898012..20e9c6158d 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -124,7 +124,7 @@ [#-- TODO: Please improve this validation at backend side --] [#-- Remove link for all partners --] - [#if isTemplate || action.canBeDeleted((element.id)!-1,("shfrm")!)] + [#if isTemplate || action.canBeDeleted((element.id)!-1,(element.class.name)!)!false] [/#if] From b45a0a07148f1cad3de3c5de451badfaa0bdc0d0 Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Thu, 15 Feb 2024 08:38:25 -0500 Subject: [PATCH 63/65] :wrench: chore(deliverableShfrm.js): removeSubActionEvent added --- .../main/webapp/WEB-INF/global/macros/deliverableMacros.ftl | 5 ----- .../webapp/crp/js/projects/deliverables/deliverableShfrm.js | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 850f3c40b2..946659d192 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1575,9 +1575,6 @@ [/#macro] [#macro subactionsSelectsctrlList ] - - - [#list shfrmPriorityActions as priorityAction]
    [#-- ${(shfrmPriorityActions[${priorityAction_index}].shfrmSubActions)![]} --] @@ -1588,10 +1585,8 @@ [/#if]
    -
    [/#list] - [/#macro] diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index e52c892a0f..f88ba358e0 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -202,6 +202,7 @@ function attachEvents() { $(".removeElementType-shfrmPriorityAction-deliverablePriorityActions").on('mouseenter', function () { currentDeleteActionId = $(this).parent('.relationElement').find('.elementRelationID').val(); }); + $(".removeDeliverable ").on('click', removeSubActionEvent); // Remove a project partner Event @@ -601,7 +602,10 @@ function updateActionsAndSubActionsIndexes() { } - +function removeSubActionEvent() { + $(this).parents('.deliverableActivity').remove(); + updateActionsAndSubActionsIndexes(); +} function addPartnerEvent(e) { var option = $(this).find("option:selected"); From 278f14188c8a1f391b0fdfc0cebcbfe6bda0a448 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Thu, 15 Feb 2024 10:24:30 -0500 Subject: [PATCH 64/65] :wrench: chore(shfrm Contribution): Update saving process for deliverable sub actions model --- .../action/projects/DeliverableAction.java | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index def85bb230..a4b117f2ab 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -3711,13 +3711,29 @@ public void savePriorityActions(boolean onlyDeleteProcess) { if (actionPrev != null) { for (DeliverableShfrmPriorityAction priorityAction : actionPrev) { if (priorityAction != null && priorityAction.getId() != null) { - deliverableSubActions = deliverableShfrmSubActionManager - .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId()); - if (deliverableSubActions == null || (deliverableSubActions != null && deliverableSubActions.isEmpty())) { - if (!existingIds.contains(priorityAction.getId())) { - deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); + + // if (deliverableSubActions == null || (deliverableSubActions != null && + // deliverableSubActions.isEmpty())) { + + if (!existingIds.contains(priorityAction.getId())) { + deliverableSubActions = deliverableShfrmSubActionManager + .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId()); + + if (deliverableSubActions != null && !deliverableSubActions.isEmpty()) { + + // delete sub actions + for (DeliverableShfrmSubAction deliverableSubActionDelete : deliverableSubActions) { + if (deliverableSubActionDelete != null && deliverableSubActionDelete.getId() != null) { + deliverableShfrmSubActionManager + .deleteDeliverableShfrmSubAction(deliverableSubActionDelete.getId()); + } + } } + + // delete actions + deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); } + } } } @@ -4150,10 +4166,13 @@ public void saveSubActions() { // Try to check -> delete priority actions deleted from front-end after delete the sub-actions when all sub actions // was deleted - if (this.deliverable.getShfrmPriorityActions() == null - || (this.deliverable.getShfrmPriorityActions() != null && this.deliverable.getShfrmPriorityActions().isEmpty())) { - this.savePriorityActions(true); - } + /* + * if (this.deliverable.getShfrmPriorityActions() == null + * || (this.deliverable.getShfrmPriorityActions() != null && this.deliverable.getShfrmPriorityActions().isEmpty())) + * { + * this.savePriorityActions(true); + * } + */ } public void saveUsers() { From a2102d50b528f3cb93641cc37701ddd52dede871 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Thu, 15 Feb 2024 10:25:27 -0500 Subject: [PATCH 65/65] :art: style(shfrm Contribution): Update deliverable sections labels for shfrm module --- marlo-web/src/main/resources/custom/aicrra.properties | 2 +- marlo-web/src/main/resources/global.properties | 2 +- .../webapp/WEB-INF/global/macros/deliverableMacros.ftl | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 85b001de33..fe9cb07312 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -935,7 +935,7 @@ deliverable.shfrmContribution.narrative=Provide a short narrative on how this de deliverable.shfrmContribution.priorityAction=To which priority action of the SHFRM is this deliverable contributing to? deliverable.shfrmContribution.priorityAction.help=Select a priority action deliverable.shfrmContribution.subAction=To which specific sub-action of the SHFRM is this deliverable contributing to? -deliverable.shfrmContribution.subAction.help=Select a sub-action +deliverable.shfrmContribution.subAction.help=Select sub-action(s) intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index a0189f81fb..fb18d4a87d 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -938,7 +938,7 @@ deliverable.shfrmContribution.narrative=Provide a short narrative on how this de deliverable.shfrmContribution.priorityAction=To which priority action of the SHFRM is this deliverable contributing to? deliverable.shfrmContribution.priorityAction.help=Select a priority action deliverable.shfrmContribution.subAction=To which specific sub-action of the SHFRM is this deliverable contributing to? -deliverable.shfrmContribution.subAction.help=Select a sub-action +deliverable.shfrmContribution.subAction.help=Select sub-action(s) intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 946659d192..76e5c686a6 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1564,7 +1564,7 @@ [#macro subActionItemMacro subActionItem name index=-1 isTemplate=false] [#assign deliverableCustomName = "${name}[${index}]" /]
    - [#if editable]
    [/#if] + [#if editable]
    [/#if] @@ -1607,7 +1607,7 @@
    [#-- Title --] - ${index+1}. ${(element.shfrmPriorityAction.name)!'Priority Action'} + ${index+1}. ${(element.shfrmPriorityAction.composedName)!'Priority Action'}
    @@ -1626,13 +1626,15 @@ [#list (element.shfrmSubActions)![] as subActionListItem] [@subActionItemMacro subActionItem=subActionListItem name="${name}.shfrmSubActions" index=subActionListItem_index /] [/#list] + [#else] +

    [@s.text name="shfrmManagement.subActionsEmpty" /]

    [/#if]
    [#if editable]
    [@s.text name="shfrmManagement.subActions.add" /] [@customForm.req required=true /]
    - [@customForm.select name="" label="" i18nkey="project.activities.deliverableSelect" listName="${name}.shfrmPriorityAction.shfrmSubActions" keyFieldName="id" displayFieldName="name" multiple=false required=true className=" deliverableList" disabled=!editable/] + [@customForm.select name="" label="" help="deliverable.shfrmContribution.subAction.help" helpIcon=false i18nkey="shfrmManagement.subActions.add" listName="${name}.shfrmPriorityAction.shfrmSubActions" keyFieldName="id" displayFieldName="composedName" multiple=false required=true className=" deliverableList" disabled=!editable/]
    [/#if]