Skip to content

Commit

Permalink
tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
Goulven.Furet authored and Goulven.Furet committed Oct 19, 2023
1 parent fb7523d commit 079fc74
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
8 changes: 8 additions & 0 deletions commons/src/main/java/org/open4goods/model/data/Score.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.open4goods.model.Validable;
import org.open4goods.model.attribute.Cardinality;
import org.open4goods.model.constants.Currency;
import org.open4goods.model.product.AggregatedPrice;
import org.open4goods.services.StandardiserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -107,6 +108,13 @@ public Long percent() {
return Math.round(relativ.getValue() * 100 / StandardiserService.DEFAULT_MAX_RATING);
}

public String absValue () {
return AggregatedPrice.numberFormater.format(absolute.getValue());
}

public String relValue () {
return AggregatedPrice.numberFormater.format(relativ.getValue());
}

///////////////////////
// The following helper allow to know the ranking, on a 5 scale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

public class AggregatedPrice extends Price {

private static final DecimalFormat df = new DecimalFormat("0.00");
//TODO : shared, ugly
public static final DecimalFormat numberFormater = new DecimalFormat("0.00");

@Field(index = false, store = false, type = FieldType.Keyword)
private String datasourceName;
Expand Down Expand Up @@ -90,7 +91,7 @@ public String shortPrice() {
if (isInt) {
return String.valueOf(p.intValue());
} else {
return String.valueOf(df.format(p));
return String.valueOf(numberFormater.format(p));
}

}
Expand Down
6 changes: 6 additions & 0 deletions ui/src/main/resources/i18n/messages_fr.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
ecoscore.WARRANTY.tooltip = La garantie est de {0} an(s).
ecoscore.DATA-QUALITY.tooltip = La qualité de la donnée est de {1} sur 5.
ecoscore.REPAIRABILITY_INDEX.tooltip = L''indice de réparabilité est de {0} sur 10 ({1}/5 en valeur relative).
ecoscore.CLASSE_ENERGY.tooltip = La classe énergétique est {2}. ({1}/5 en valeur relative)
ecoscore.BRAND_SUSTAINABILITY.tooltip = L''évaluation de la marque indique {0} sur 10 ({1}/5 en valeur relative). Cliquez sur ''Explications'' pour en savoir plus.

score-BRAND_SUSTAINABILITY = Evaluation de la marque
score-DATA-QUALITY = Qualité de la donnée
score-WARRANTY = Garantie
Expand Down
4 changes: 2 additions & 2 deletions ui/src/main/resources/templates/ecoscore.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<div class="col-12 col-md-8 col-lg-8 text-center text-md-left">
<h1 class="display-2 mb-4">L’écoscore : l’évaluation écologique des produits</h1>
<th:block th:with="path='ECOSCORE/1/'">
<th:block th:insert="inc/wiki.html"></th:block>
</th:block>
<p class="lead" th:insert="inc/wiki.html"></p>
</th:block>
</div>
<div class="col-12 col-md-4 d-none d-md-block text-center"><img src="../../assets/img/illustrations/about-illustration.svg" alt=""></div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions ui/src/main/resources/templates/inc/product-ecoscore.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@
<div class="text-center">
<img width="350px" src="/icons/ecoscore.png">
</div>

<div class="m-5">
<div th:each="score : ${product.realScores()}" class="progress-wrapper">

<div class="progress-info">
<span class="h4 progress-tooltip" th:classappend="'bg-'+${score.colorClassName()}" th:text="#{'score-'+${score.name}}"></span>
<span class="h4 help-pointer progress-tooltip" data-bs-toggle="tooltip" data-bs-placement="top" th:title="#{'ecoscore.' +${score.name}+'.tooltip'(${score.absValue()}, ${score.relValue()}, ${product.attributes.aggregatedAttributes.get(score.name)})}" th:classappend="'bg-'+${score.colorClassName()}" th:text="#{'score-'+${score.name}}"></span>
<div class="progress-percentage">
<!--
<span th:if="${score.relativValue}" th:text="${score.relativValue*20}+'%'"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

<tr th:if="${product.brand()}">
<th scope="row">Marque</th>
<td th:text="${product.brand()}"></td>
<td>
<img height="25px" th:if="${hasBrandLogo}" th:src="'/images/marques/'+${product.brand()}+'.png'">
<th:block th:unless="${hasBrandLogo}" th:text="${product.brand()}"></th:block>
</td>
</tr>


Expand Down
4 changes: 2 additions & 2 deletions ui/src/main/resources/templates/product.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@


<!-- Core -->
<script src="../../vendor/@popperjs/core/dist/umd/popper.min.js"></script>
<script src="/webjars/bootstrap/js/bootstrap.min.js"></script>


Expand All @@ -188,7 +189,6 @@
-->


<script src="../../vendor/@popperjs/core/dist/umd/popper.min.js"></script>
<script src="/webjars/jquery/jquery.min.js"></script>
<script type="text/javascript" language="javascript" src="/webjars/datatables/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="/webjars/datatables/js/dataTables.bootstrap5.min.js"></script>
Expand All @@ -207,7 +207,7 @@
$(document).ready(function() {

// Enable tooltips
$('[data-toggle="tooltip"]').tooltip();
$('[data-bs-toggle="tooltip"]').tooltip();

// Responsive datatables
if (($("#offersTableOccasion")).length) {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/resources/templates/vertical-home.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ <h1 class="mt-2 text-center" th:text="${config.homeTitle.i18n(siteLanguage)}"></
data : data,
vertical: vertical,
productUrl : baseUrl+verticalPath+'/'+data.names.name,
imageUrl : baseUrl+verticalPath+'/'+data.names.name+'/image.png',
imageUrl : baseUrl+'images/'+data.attributes.referentielAttributes.GTIN+'-cover.png',
name : (data.attributes.referentielAttributes.MODEL == null ? data.names.name : data.attributes.referentielAttributes.MODEL)
});
}
Expand Down

0 comments on commit 079fc74

Please sign in to comment.