'
+ ''
);
+
+ activate_preferences_switch_buttons(change);
$( ".attribute_radio").change( function () {
if (this.checked) {
@@ -274,8 +295,8 @@ function display_user_product_preferences (target_selected, target_selection_for
display_use_preferences_switch_and_edit_preferences_button(target_selected, target_selection_form, change);
}
- $( "#delete_all_preferences_button").on("click", function() {
- user_product_preferences = {};
+ $( "#reset_preferences_button").on("click", function() {
+ user_product_preferences = default_preferences;
localStorage.setItem('user_product_preferences', JSON.stringify(user_product_preferences));
// Redisplay user preferences
@@ -288,9 +309,9 @@ function display_user_product_preferences (target_selected, target_selection_for
}
});
- $("#delete_all_preferences_button").on('keydown', (event) => {
+ $("#reset_preferences_button").on('keydown', (event) => {
if (event.key === 'Space' || event.key === 'Enter') {
- $("#delete_all_preferences_button").trigger("click");
+ $("#reset_preferences_button").trigger("click");
}
});
diff --git a/html/js/product-search.js b/html/js/product-search.js
index ad4406514b968..c999bb133ac24 100644
--- a/html/js/product-search.js
+++ b/html/js/product-search.js
@@ -8,15 +8,18 @@
//
// Output values are returned in the product object
//
-// - match_status:
-// very_good_match
-// good_match
-// poor_match
-// unknown_match
-// may_not_match
-// does_not_match
-//
// - match_score: number from 0 to 100
+// - the score is 0 if
+// - otherwise the score is a weighted average of how well the product matches
+// each attribute selected by the user
+//
+// - match_status:
+// - very_good_match score >= 75
+// - good_match score >= 50
+// - poor_match score < 50
+// - unknown_match at least one mandatory attribute is unknown, or unknown attributes weight more than 50% of the score
+// - may_not_match at least one mandatory attribute score is <= 50 (e.g. may contain traces of an allergen)
+// - does_not_match at least one mandatory attribute score is <= 10 (e.g. contains an allergen, is not vegan)
//
// - match_attributes: array of arrays of attributes corresponding to the product and
// each set of preferences: mandatory, very_important, important
@@ -125,6 +128,10 @@ function match_product_to_preferences (product, product_preferences) {
else if ("may_not_match" in product.attributes_for_status) {
product.match_status = "may_not_match";
}
+ // If one of the mandatory attribute is unknown, set an unknown match
+ else if ("unknown_match" in product.attributes_for_status) {
+ product.match_status = "unknown_match";
+ }
// If too many attributes are unknown, set an unknown match
else if (sum_of_factors_for_unknown_attributes >= sum_of_factors / 2) {
product.match_status = "unknown_match";
diff --git a/po/common/common.pot b/po/common/common.pot
index 5b065668766f8..c0e39f34514cc 100644
--- a/po/common/common.pot
+++ b/po/common/common.pot
@@ -6131,4 +6131,14 @@ msgstr "May not match"
# The translation needs to be short as it is displayed at the top of small product cards
msgctxt "products_match_does_not_match"
msgid "Does not match"
-msgstr "Does not match"
\ No newline at end of file
+msgstr "Does not match"
+
+msgctxt "reset_preferences"
+msgid "Use default preferences"
+msgstr "Use default preferences"
+
+msgctxt "reset_preferences_details"
+msgid "Nutri-Score, Eco-Score and food processing level (NOVA)"
+msgstr "Nutri-Score, Eco-Score and food processing level (NOVA)"
+
+
diff --git a/po/common/en.po b/po/common/en.po
index a67d507f53958..7798549a58411 100644
--- a/po/common/en.po
+++ b/po/common/en.po
@@ -6155,3 +6155,13 @@ msgstr "May not match"
msgctxt "products_match_does_not_match"
msgid "Does not match"
msgstr "Does not match"
+
+msgctxt "reset_preferences"
+msgid "Use default preferences"
+msgstr "Use default preferences"
+
+msgctxt "reset_preferences_details"
+msgid "Nutri-Score, Eco-Score and food processing level (NOVA)"
+msgstr "Nutri-Score, Eco-Score and food processing level (NOVA)"
+
+