From 36c1412a5b3c9daeb0c04ef194ea232bf7ea4d97 Mon Sep 17 00:00:00 2001
From: jnizet <jb@ninja-squad.com>
Date: Wed, 22 Sep 2021 11:36:32 +0200
Subject: [PATCH] feat: add links to faidare search in germplasm card

---
 .../web/thymeleaf/FaidareExpressions.java     |  4 ++
 .../main/resources/templates/germplasm.html   | 43 +++++++++++++------
 2 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/backend/src/main/java/fr/inra/urgi/faidare/web/thymeleaf/FaidareExpressions.java b/backend/src/main/java/fr/inra/urgi/faidare/web/thymeleaf/FaidareExpressions.java
index 342c4165..c76f84cb 100644
--- a/backend/src/main/java/fr/inra/urgi/faidare/web/thymeleaf/FaidareExpressions.java
+++ b/backend/src/main/java/fr/inra/urgi/faidare/web/thymeleaf/FaidareExpressions.java
@@ -84,6 +84,10 @@ public class FaidareExpressions {
         return NAVBAR_ENTRIES;
     }
 
+    public String searchUrl() {
+        return "https://urgi.versailles.inrae.fr/faidare/search";
+    }
+
     private String collPopTitle(CollPopVO collPopVO, Function<String, String> nameTransformer) {
         if (Strings.isBlank(collPopVO.getType())) {
             return nameTransformer.apply(collPopVO.getName());
diff --git a/backend/src/main/resources/templates/germplasm.html b/backend/src/main/resources/templates/germplasm.html
index a3ced8b4..79742fba 100644
--- a/backend/src/main/resources/templates/germplasm.html
+++ b/backend/src/main/resources/templates/germplasm.html
@@ -652,9 +652,10 @@
                       th:text="${population.germplasmRef.name}"
                     ></span>
                     is composed by
-                    <span th:text="${population.germplasmCount}"></span>
-                    accession(s)
-                    <!-- TODO there was a link pointing at a search here -->
+                    <a
+                      th:href="@{${#faidare.searchUrl()}(gl=${population.name},entry='Germplasm')}"
+                      th:text="${population.germplasmCount + ' accession(s)'}"
+                    ></a>
                   </div>
                 </div>
               </th:block>
@@ -662,9 +663,15 @@
 
             <th:block th:if="${population.germplasmRef == null}">
               <div
-                th:replace="fragments/row::text-row(label=${#faidare.collPopTitle(population)}, text=${population.germplasmCount + ' accession(s)'})"
-              ></div>
-              <!-- TODO there was a link pointing at a search here -->
+                th:replace="fragments/row::row(label=${#faidare.collPopTitle(population)}, content=~{::.population-2})"
+              >
+                <div class="population-2">
+                  <a
+                    th:href="@{${#faidare.searchUrl()}(gl=${population.name},entry='Germplasm')}"
+                    th:text="${population.germplasmCount + ' accession(s)'}"
+                  ></a>
+                </div>
+              </div>
             </th:block>
           </th:block>
         </div>
@@ -678,9 +685,15 @@
         <div class="f-card-body">
           <th:block th:each="collection : ${model.germplasm.collection}">
             <div
-              th:replace="fragments/row::text-row(label=${#faidare.collPopTitle(collection)}, text=${collection.germplasmCount + ' accession(s)'})"
-            ></div>
-            <!-- TODO there was a link pointing at a search here -->
+              th:replace="fragments/row::row(label=${#faidare.collPopTitle(collection)}, content=~{::.collection})"
+            >
+              <div class="collection">
+                <a
+                  th:href="@{${#faidare.searchUrl()}(gl=${collection.name},entry='Germplasm')}"
+                  th:text="${collection.germplasmCount + ' accession(s)'}"
+                ></a>
+              </div>
+            </div>
           </th:block>
         </div>
       </div>
@@ -690,9 +703,15 @@
         <div class="f-card-body">
           <th:block th:each="panel : ${model.germplasm.panel}">
             <div
-              th:replace="fragments/row::text-row(label=${#faidare.collPopTitleWithoutUnderscores(panel)}, text=${panel.germplasmCount + ' accession(s)'})"
-            ></div>
-            <!-- TODO there was a link pointing at a search here -->
+              th:replace="fragments/row::row(label=${#faidare.collPopTitleWithoutUnderscores(panel)}, content=~{::.panel})"
+            >
+              <div class="panel">
+                <a
+                  th:href="@{${#faidare.searchUrl()}(gl=${panel.name},entry='Germplasm')}"
+                  th:text="${panel.germplasmCount + ' accession(s)'}"
+                ></a>
+              </div>
+            </div>
           </th:block>
         </div>
       </div>
-- 
GitLab