-
-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: packaging stats per parent materials (#8594)
- Loading branch information
1 parent
83687a1
commit 3ee4411
Showing
201 changed files
with
6,826 additions
and
4,327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
templates/api/knowledge-panels/environment/packaging_components.tt.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Create a structure so that we can display the packaging components for each recycling type | ||
[% SET recycling_types = {} %] | ||
[% SET unknown = "en:unknown" %] | ||
[% IF product.packagings %] | ||
[%# Check which of recycling / discard / unknown packaging types we have to build each panel (one for each) %] | ||
[% FOREACH packaging IN product.packagings %] | ||
[% IF packaging.recycling.defined AND ((packaging.recycling == "en:discard") OR (packaging.recycling == "en:recycle")) %] | ||
[% SET recycling_types.${packaging.recycling} = 1 %] | ||
[% ELSE %] | ||
[% SET recycling_types.$unknown = 1 %] | ||
[% END %] | ||
[% END %] | ||
[% END %] | ||
|
||
{ | ||
"level" :"info", | ||
"topics": [ | ||
"environment" | ||
], | ||
"title_element": { | ||
"title": "[% lang('packaging_parts') %]", | ||
}, | ||
"expanded": true, | ||
"elements": [ | ||
[% FOREACH recycling_type IN ["en:recycle", "en:discard", "en:unknown"] %] | ||
[% IF recycling_types.$recycling_type.defined %] | ||
{ | ||
"element_type": "text", | ||
"text_element": { | ||
"type": "summary", | ||
"icon_color_from_evaluation": true, | ||
[% IF recycling_type == "en:recycle" %] | ||
"evaluation": "good", | ||
"icon_url": "[% static_subdomain %]/images/icons/dist/recycle-variant.svg", | ||
"icon_alt": "[% display_taxonomy_tag_name("packaging_recycling",recycling_type) %]", | ||
[% ELSIF recycling_type == "en:discard" %] | ||
"evaluation": "bad", | ||
"icon_url": "[% static_subdomain %]/images/icons/dist/delete.svg", | ||
"icon_alt": "[% display_taxonomy_tag_name("packaging_recycling",recycling_type) %]", | ||
[% ELSE %] | ||
"evaluation": "neutral", | ||
"icon_url": "[% static_subdomain %]/images/icons/dist/help.svg", | ||
"icon_alt": "[% lang('unknown') %]", | ||
[% END %] | ||
"html": ` | ||
[% FOREACH packaging IN product.packagings %] | ||
[% IF packaging.recycling == recycling_type OR (recycling_type == "en:unknown" AND ((NOT packaging.recycling.defined) OR ((packaging.recycling != "en:discard") AND (packaging.recycling != "en:recycle")))) %] | ||
[% IF packaging.number_of_units %][% packaging.number_of_units %] x [% END %] | ||
<strong> | ||
[% display_taxonomy_tag_name('packaging_shapes',packaging.shape) %] | ||
[% IF packaging.quantity_per_unit %][% packaging.quantity_per_unit %] [% END %] | ||
</strong> | ||
[% IF packaging.material %] | ||
([% display_taxonomy_tag_name('packaging_materials',packaging.material) %][% IF packaging.weight_specified %][% sep %]: [% packaging.weight_specified %] g[% ELSIF packaging.weight_measured %][% sep %]: [% packaging.weight_measured %] g[% END %]) | ||
[% END %] | ||
<br> | ||
[% END %] | ||
[% END %] | ||
` | ||
} | ||
}, | ||
[% END %] | ||
[% END %] | ||
] | ||
} |
Oops, something went wrong.