Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Knowledge panels for labels #5950

Merged
merged 7 commits into from
Oct 8, 2021
Merged

feat: Knowledge panels for labels #5950

merged 7 commits into from
Oct 8, 2021

Conversation

stephanegigandet
Copy link
Contributor

@stephanegigandet stephanegigandet commented Oct 7, 2021

  • Added new panels for the labels used for Eco-Score (e.g. organic labels)
    -> Panel data comes from the taxonomy. We may want to add a way to references translations from the po/common files instead of managing translations inside the taxonomies. That would ease the translations.

  • Added a way to generate strings that contain a comma separated list (e.g. a list of labels), by genering the string with trailing commas on all elements, and removing the last trailing comma. (hacky but should work)

  • Fixed sample Nutella brand panel to use the new title_element structure

@stephanegigandet stephanegigandet requested a review from a team as a code owner October 7, 2021 13:29
@stephanegigandet stephanegigandet added the 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels label Oct 7, 2021
@stephanegigandet
Copy link
Contributor Author

Current look:

image

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo two style comments.

# Add panels for environmental Eco-Score labels
if ((defined $product_ref->{ecoscore_data}) and (defined $product_ref->{ecoscore_data}{adjustments})
and (defined $product_ref->{ecoscore_data}{adjustments}{production_system})
and (defined $product_ref->{ecoscore_data}{adjustments}{production_system}{labels})) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you have some utils function to ask is_defined($product_ref, "ecoscore_data", "adjastments", "production_system", "labels") ? It would make sense, I think !
(and it could directly return the value)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,8 +1,8 @@
[% panel = panels.$panel_id %]
<!-- start templates/[% template.name %] - panel_id: [% panel_id %] -->
<ul data-accordion class="accordion" id="[% panel_id %]" style="margin-top:0.5rem;margin-bottom:0.5rem;">
<ul data-accordion class="accordion" id="[% panel_id | replace(':','_') %]" style="margin-top:0.5rem;margin-bottom:0.5rem;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(very minor) HTML guys usually use "-" more than "_" as a separator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I can change that

@sonarcloud
Copy link

sonarcloud bot commented Oct 8, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@stephanegigandet stephanegigandet merged commit a64919c into main Oct 8, 2021
@stephanegigandet stephanegigandet deleted the panels branch October 8, 2021 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels
Projects
Development

Successfully merging this pull request may close these issues.

3 participants