From b637a015ff2647845686d5be2c6d66d37b73adf1 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Wed, 6 Oct 2021 16:18:12 +0200 Subject: [PATCH 01/33] Updates to KnowledgePanel json object to comply to latest BE changes --- lib/model/KnowledgePanel.g.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 55ac8abe17..005358e9b3 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -9,6 +9,8 @@ part of 'KnowledgePanel.dart'; KnowledgePanel _$KnowledgePanelFromJson(Map json) => KnowledgePanel( parentPanelId: json['parent_panel_id'] as String, + titleElement: + TitleElement.fromJson(json['title_element'] as Map), type: _$enumDecode(_$KnowledgePanelTypeEnumMap, json['type']), level: _$enumDecode(_$LevelEnumMap, json['level'], unknownValue: Level.UNKNOWN), @@ -24,6 +26,7 @@ KnowledgePanel _$KnowledgePanelFromJson(Map json) => Map _$KnowledgePanelToJson(KnowledgePanel instance) => { 'parent_panel_id': instance.parentPanelId, + 'title_element': instance.titleElement, 'type': _$KnowledgePanelTypeEnumMap[instance.type], 'level': _$LevelEnumMap[instance.level], 'topics': instance.topics, From 3a9186a938a38ffd6697807cae822b7c789015a8 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Wed, 6 Oct 2021 17:02:59 +0200 Subject: [PATCH 02/33] Changes to KnowledgePanel to comply to BE --- lib/model/KnowledgePanel.dart | 48 ++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 5e709feb18..59839536e1 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -59,8 +59,13 @@ enum Grade { @JsonSerializable() class KnowledgePanel extends JsonObject { /// Panel id of the parent panel. + @JsonKey(name: 'parent_panel_id') final String parentPanelId; + /// Title of the KnowledgePanel. + @JsonKey(name: 'title_element') + final TitleElement titleElement; + final KnowledgePanelType type; /// Level of this KnowledgePanel. Client may choose to display the panel based @@ -71,22 +76,10 @@ class KnowledgePanel extends JsonObject { /// The topics discussed in this knowledge panel, example: 'Environment'. final List? topics; - /// Each KnowledgePanel has a unique id. Example - 'ecoscore'. - - /// Title of the panel. Example - 'Eco-Score D'. - final String title; - /// KnowledgePanelElement is a single unit of KnowledgePanel that can be /// rendered on the client. final List elements; - /// Subtitle of the panel. Example - 'High environmental impact'. - final String? subtitle; - - /// URL of an icon representing the Panel. - @JsonKey(name: 'icon_url') - final String? iconUrl; - /// Grade of the panel, depicting the level of impact the product has for the /// corresponding topics. Client can choose to color code the panel depending /// on how good/bad the grade is. @@ -96,13 +89,11 @@ class KnowledgePanel extends JsonObject { const KnowledgePanel({ required this.parentPanelId, + required this.titleElement, required this.type, required this.level, - required this.title, required this.elements, this.topics, - this.subtitle, - this.iconUrl, this.grade, }); @@ -112,3 +103,30 @@ class KnowledgePanel extends JsonObject { @override Map toJson() => _$KnowledgePanelToJson(this); } + +/// An element representing the title of the KnowledgePanel which could consist +/// of a text title, subtitle and an icon. +@JsonSerializable() +class TitleElement extends JsonObject { + /// Title string of the panel. Example - 'Eco-Score D'. + final String title; + + /// Subtitle of the panel. Example - 'High environmental impact'. + final String? subtitle; + + /// URL of an icon representing the Panel. + @JsonKey(name: 'icon_url') + final String? iconUrl; + + const TitleElement({ + required this.title, + this.subtitle, + this.iconUrl, + }); + + factory TitleElement.fromJson(Map json) => + _$TitleElementFromJson(json); + + @override + Map toJson() => _$TitleElementToJson(this); +} From 835a8bb6fc3c718395cc372d6ae13acfa8a00959 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Wed, 6 Oct 2021 17:14:11 +0200 Subject: [PATCH 03/33] Changes to KnowledgePanel to comply to BE --- lib/model/KnowledgePanel.g.dart | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 66f52d5e62..005358e9b3 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -8,32 +8,29 @@ part of 'KnowledgePanel.dart'; KnowledgePanel _$KnowledgePanelFromJson(Map json) => KnowledgePanel( - parentPanelId: json['parentPanelId'] as String, + parentPanelId: json['parent_panel_id'] as String, + titleElement: + TitleElement.fromJson(json['title_element'] as Map), type: _$enumDecode(_$KnowledgePanelTypeEnumMap, json['type']), level: _$enumDecode(_$LevelEnumMap, json['level'], unknownValue: Level.UNKNOWN), - title: json['title'] as String, elements: (json['elements'] as List) .map((e) => KnowledgePanelElement.fromJson(e as Map)) .toList(), topics: (json['topics'] as List?)?.map((e) => e as String).toList(), - subtitle: json['subtitle'] as String?, - iconUrl: json['icon_url'] as String?, grade: _$enumDecodeNullable(_$GradeEnumMap, json['grade'], unknownValue: Grade.UNKNOWN), ); Map _$KnowledgePanelToJson(KnowledgePanel instance) => { - 'parentPanelId': instance.parentPanelId, + 'parent_panel_id': instance.parentPanelId, + 'title_element': instance.titleElement, 'type': _$KnowledgePanelTypeEnumMap[instance.type], 'level': _$LevelEnumMap[instance.level], 'topics': instance.topics, - 'title': instance.title, 'elements': instance.elements, - 'subtitle': instance.subtitle, - 'icon_url': instance.iconUrl, 'grade': _$GradeEnumMap[instance.grade], }; @@ -98,3 +95,16 @@ const _$GradeEnumMap = { Grade.E: 'E', Grade.UNKNOWN: 'UNKNOWN', }; + +TitleElement _$TitleElementFromJson(Map json) => TitleElement( + title: json['title'] as String, + subtitle: json['subtitle'] as String?, + iconUrl: json['icon_url'] as String?, + ); + +Map _$TitleElementToJson(TitleElement instance) => + { + 'title': instance.title, + 'subtitle': instance.subtitle, + 'icon_url': instance.iconUrl, + }; From db1d0ee212bbf2f723ac446769c4e0928372794e Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Thu, 7 Oct 2021 09:32:20 +0200 Subject: [PATCH 04/33] Update tests --- lib/model/KnowledgePanel.dart | 4 + lib/model/KnowledgePanel.g.dart | 3 + test/knowledge_panels_from_json_test.dart | 631 +++++++++++++++------- 3 files changed, 431 insertions(+), 207 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 59839536e1..aa1b018d18 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -118,10 +118,14 @@ class TitleElement extends JsonObject { @JsonKey(name: 'icon_url') final String? iconUrl; + @JsonKey(name: 'icon_color_from_evaluation', defaultValue: false) + final bool? iconColorFromEvaluation; + const TitleElement({ required this.title, this.subtitle, this.iconUrl, + this.iconColorFromEvaluation, }); factory TitleElement.fromJson(Map json) => diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 005358e9b3..22959927b5 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -100,6 +100,8 @@ TitleElement _$TitleElementFromJson(Map json) => TitleElement( title: json['title'] as String, subtitle: json['subtitle'] as String?, iconUrl: json['icon_url'] as String?, + iconColorFromEvaluation: + json['icon_color_from_evaluation'] as bool? ?? false, ); Map _$TitleElementToJson(TitleElement instance) => @@ -107,4 +109,5 @@ Map _$TitleElementToJson(TitleElement instance) => 'title': instance.title, 'subtitle': instance.subtitle, 'icon_url': instance.iconUrl, + 'icon_color_from_evaluation': instance.iconColorFromEvaluation, }; diff --git a/test/knowledge_panels_from_json_test.dart b/test/knowledge_panels_from_json_test.dart index 88eb958f1c..12b27e57ed 100644 --- a/test/knowledge_panels_from_json_test.dart +++ b/test/knowledge_panels_from_json_test.dart @@ -5,311 +5,525 @@ void main() { // Verify that we can successfully load the Knowledge panel from a JSON string test('Load KP from JSON', () async { Map panels = { - 'ecoscore': { - 'elements': [ + 'ecoscore':{ + 'elements':[ { - 'element_type': 'image', - 'image_element': { - 'alt': 'Eco-score e', - 'height': 130, - 'link_title': 'Information about the Eco-score', - 'link_url': - 'https://uk.openfoodfacts.org/eco-score-the-environmental-impact-of-food-products', - 'url': - 'https://static.openfoodfacts.org/images/icons/ecoscore-e.svg', - 'width': 274 + 'element_type':'text', + 'text_element':{ + 'html':'The Eco-Score is an experimental score that summarizes the environmental impacts of food products.' } }, { - 'element_type': 'text', - 'text_element': { - 'html': - 'The Eco-Score is an experimental score that summarizes the environmental impacts of food products.' + 'element_type':'text', + 'text_element':{ + 'html':'\n \n The Eco-Score was initially developped for France and it is being extended to other European countries. The Eco-Score formula is subject to change as it is regularly improved to make it more precise and better suited to each country.\n \n ', + 'type':'note' } }, { - 'element_type': 'text', - 'text_element': { - 'html': - '\n \n The Eco-Score was initially developped for France and it is being extended to other European countries. The Eco-Score formula is subject to change as it is regularly improved to make it more precise and better suited to each country.\n \n ', - 'type': 'note' + 'element_type':'panel', + 'panel_element':{ + 'panel_id':'ecoscore_agribalyse' } }, { - 'element_type': 'text', - 'text_element': { - 'html': - 'Average impact of products of the Chocolate spread with hazelnuts category: C (Score: 40/100)', - 'type': 'h1' + 'element_type':'text', + 'text_element':{ + 'html':'Positive and negative points of this product:' } }, { - 'element_type': 'panel', - 'panel_element': {'panel_id': 'ecoscore_agribalyse'} - }, - { - 'element_type': 'text', - 'text_element': { - 'html': 'Impact for this product: E (Score: 10/100)', - 'type': 'h1' + 'element_type':'panel', + 'panel_element':{ + 'panel_id':'ecoscore_production_system' } }, { - 'element_type': 'panel', - 'panel_element': {'panel_id': 'ecoscore_production_system'} + 'element_type':'panel', + 'panel_element':{ + 'panel_id':'ecoscore_origins_of_ingredients' + } }, { - 'element_type': 'panel', - 'panel_element': {'panel_id': 'ecoscore_origins_of_ingredients'} + 'element_type':'panel', + 'panel_element':{ + 'panel_id':'ecoscore_packaging' + } }, { - 'element_type': 'panel', - 'panel_element': {'panel_id': 'ecoscore_threatened_species'} - }, + 'element_type':'text', + 'text_element':{ + 'html':'Impact for this product: D (Score: 39/100)', + 'type':'h1' + } + } + ], + 'grade':'', + 'level':'info', + 'parent_panel_id':'root', + 'title_element':{ + 'icon_url':'https://static.openfoodfacts.dev/images/attributes/ecoscore-d.svg', + 'title':'Eco-Score D - High environmental impact' + }, + 'topics':[ + 'environment' + ], + 'type':'score' + }, + 'ecoscore_agribalyse':{ + 'elements':[ { - 'element_type': 'panel', - 'panel_element': {'panel_id': 'ecoscore_packaging'} + 'element_type':'text', + 'text_element':{ + 'html':'\n

Agribalyse category: \n Chocolate spread with hazelnuts\n

\n
    \n
  • \n PEF environmental score: 0.74\n (the lower the score, the lower the impact)\n
  • \n
  • \n including impact on climate change: 9.87\n kg CO2 eq/kg of product\n
  • \n
\n ', + 'text_type':'summary' + } }, { - 'element_type': 'text', - 'text_element': { - 'html': - '

The Eco-Score is an experimental score that summarizes the environmental impacts of food products.

', - 'type': 'warning' + 'element_type':'table', + 'table_element':{ + 'columns':[ + { + 'text':'Stage', + 'type':'text' + }, + { + 'text':'Impact', + 'type':'percent' + } + ], + 'id':'ecoscore_lca_impacts_by_stages_table', + 'rows':[ + { + 'id':'agriculture', + 'values':[ + { + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/agriculture.svg', + 'text':'Agriculture' + }, + { + 'percent':82.6683253659907, + 'text':'82.7 %' + } + ] + }, + { + 'id':'processing', + 'values':[ + { + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/processing.svg', + 'text':'Processing' + }, + { + 'percent':11.5205649227182, + 'text':'11.5 %' + } + ] + }, + { + 'id':'packaging', + 'values':[ + { + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/packaging.svg', + 'text':'Packaging' + }, + { + 'percent':2.75038601617178, + 'text':'2.8 %' + } + ] + }, + { + 'id':'transportation', + 'values':[ + { + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/transportation.svg', + 'text':'Transportation' + }, + { + 'percent':2.39678556140912, + 'text':'2.4 %' + } + ] + }, + { + 'id':'distribution', + 'values':[ + { + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/distribution.svg', + 'text':'Distribution' + }, + { + 'percent':0.617299532560963, + 'text':'0.6 %' + } + ] + }, + { + 'id':'consumption', + 'values':[ + { + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/consumption.svg', + 'text':'Consumption' + }, + { + 'percent':0, + 'text':'0.0 %' + } + ] + } + ], + 'table_type':'percents', + 'title':'Details of the impacts by stages of the life cycle' } } ], - 'grade': '', - 'icon_url': - 'https://static.openfoodfacts.org/images/attributes/ecoscore-e.svg', - 'level': 'info', - 'parent_panel_id': 'root', - 'title': 'Eco-Score E - Very high environmental impact', - 'topics': ['environment'], - 'type': 'score' + 'grade':'c', + 'level':'info', + 'parent_panel_id':'ecoscore', + 'title_element':{ + 'subtitle':'Category: Chocolate spread with hazelnuts', + 'title':'Average impact for products of the same category: C (Score: 40/100)' + }, + 'topics':[ + 'environment' + ], + 'type':'score' }, - 'ecoscore_agribalyse': { - 'elements': [ + 'ecoscore_carbon_impact':{ + 'elements':[ { - 'element_type': 'text', - 'text_element': { - 'html': - '\n

Agribalyse category: \n Chocolate spread with hazelnuts\n

\n
    \n
  • \n PEF environmental score: 0.74\n (the lower the score, the lower the impact)\n
  • \n
  • \n including impact on climate change: 9.87\n kg CO2 eq/kg of product\n
  • \n
\n ', - 'text_type': 'summary' + 'element_type':'text', + 'text_element':{ + 'html':"\n

The carbon emission figure comes from ADEME's Agribalyse database, for the category: \n Chocolate spread with hazelnuts\n

\n ", + 'text_type':'summary' } }, { - 'element_type': 'table', - 'table_element': { - 'columns': [ - {'text': 'Stage', 'type': 'text'}, - {'text': 'Impact', 'type': 'percent'} + 'element_type':'table', + 'table_element':{ + 'columns':[ + { + 'text':'Stage', + 'type':'text' + }, + { + 'text':'Impact', + 'type':'percent' + } ], - 'id': 'ecoscore_lca_impacts_by_stages_table', - 'rows': [ + 'id':'ecoscore_carbon_impact_by_stages_table', + 'rows':[ { - 'id': 'agriculture', - 'values': [ + 'id':'agriculture', + 'values':[ { - 'icon_url': - 'https://static.openfoodfacts.org/images/icons/dist/agriculture.svg', - 'text': 'Agriculture' + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/agriculture.svg', + 'text':'Agriculture' }, - {'percent': 82.6683253659907, 'text': '82.7 %'} + { + 'percent':88.8889136446762, + 'text':'88.9 %' + } ] }, { - 'id': 'processing', - 'values': [ + 'id':'processing', + 'values':[ { - 'icon_url': - 'https://static.openfoodfacts.org/images/icons/dist/processing.svg', - 'text': 'Processing' + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/processing.svg', + 'text':'Processing' }, - {'percent': 11.5205649227182, 'text': '11.5 %'} + { + 'percent':7.00489485042906, + 'text':'7.0 %' + } ] }, { - 'id': 'packaging', - 'values': [ + 'id':'packaging', + 'values':[ { - 'icon_url': - 'https://static.openfoodfacts.org/images/icons/dist/packaging.svg', - 'text': 'Packaging' + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/packaging.svg', + 'text':'Packaging' }, - {'percent': 2.75038601617178, 'text': '2.8 %'} + { + 'percent':1.9105118864761, + 'text':'1.9 %' + } ] }, { - 'id': 'transportation', - 'values': [ + 'id':'transportation', + 'values':[ { - 'icon_url': - 'https://static.openfoodfacts.org/images/icons/dist/transportation.svg', - 'text': 'Transportation' + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/transportation.svg', + 'text':'Transportation' }, - {'percent': 2.39678556140912, 'text': '2.4 %'} + { + 'percent':1.99595294189039, + 'text':'2.0 %' + } ] }, { - 'id': 'distribution', - 'values': [ + 'id':'distribution', + 'values':[ { - 'icon_url': - 'https://static.openfoodfacts.org/images/icons/dist/distribution.svg', - 'text': 'Distribution' + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/distribution.svg', + 'text':'Distribution' }, - {'percent': 0.617299532560963, 'text': '0.6 %'} + { + 'percent':0.142846509121219, + 'text':'0.1 %' + } ] }, { - 'id': 'consumption', - 'values': [ + 'id':'consumption', + 'values':[ { - 'icon_url': - 'https://static.openfoodfacts.org/images/icons/dist/consumption.svg', - 'text': 'Consumption' + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/consumption.svg', + 'text':'Consumption' }, - {'percent': 0, 'text': '0.0 %'} + { + 'percent':0, + 'text':'0.0 %' + } ] } ], - 'table_type': 'percents', - 'title': 'Details of the impacts by stages of the life cycle' + 'table_type':'percents', + 'title':'Details of the impacts by stages of the life cycle' } } ], - 'grade': 'c', - 'level': 'info', - 'parent_panel_id': 'ecoscore', - 'title': - 'Environmental impact on average for products of the same category', - 'topics': ['environment'], - 'type': 'score' + 'evaluation':'bad', + 'level':'info', + 'name':'Carbon impact', + 'parent_panel_id':'root', + 'title_element':{ + 'icon_color_from_evaluation':true, + 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/car.svg', + 'subtitle':'987 g CO² per 100g of product', + 'title':'Equal to driving 5.1 km in a petrol car' + }, + 'topics':[ + 'environment' + ], + 'type':'score' }, - 'ecoscore_origins_of_ingredients': { - 'elements': [ + 'ecoscore_packaging':{ + 'elements':[ { - 'element_type': 'table', - 'table_element': { - 'columns': [ - {'text': 'Origin', 'type': 'text'}, - {'text': '% of ingredients', 'type': 'percent'}, - {'text': 'Impact', 'type': 'text'} + 'element_type':'table', + 'table_element':{ + 'columns':[ + { + 'text':'Shape', + 'type':'text' + }, + { + 'text':'Material', + 'type':'text' + }, + { + 'text':'Recycling', + 'type':'text' + }, + { + 'text':'Impact', + 'type':'text' + } ], - 'id': 'ecoscore_origins_of_ingredients_table', - 'rows': [ + 'id':'ecoscore_packaging_components', + 'rows':[ + { + 'values':[ + { + 'text':'1 Lid' + }, + { + 'text':'PP - Polypropylene' + }, + { + 'evaluation':'bad', + 'text':'Discard' + }, + { + 'evaluation':'bad', + 'text':'High' + } + ] + }, { - 'values': [ - {'text': 'Unknown'}, - {'evaluation': 'bad', 'percent': 100, 'text': '100 %'}, - {'evaluation': 'bad', 'text': 'High'} + 'values':[ + { + 'text':'1 Backing' + }, + { + 'text':'Cardboard' + }, + { + 'evaluation':'good', + 'text':'Recycle' + }, + { + 'evaluation':'good', + 'text':'Low' + } + ] + }, + { + 'values':[ + { + 'text':'1 Seal' + }, + { + 'text':'Cardboard' + }, + { + 'evaluation':'good', + 'text':'Recycle' + }, + { + 'evaluation':'good', + 'text':'Low' + } + ] + }, + { + 'values':[ + { + 'text':'1 Pot' + }, + { + 'text':'Glass' + }, + { + 'evaluation':'good', + 'text':'Recycle' + }, + { + 'evaluation':'good', + 'text':'Low' + } ] } ], - 'table_type': 'percents', - 'title': 'Origins of ingredients' + 'title':'Packaging parts', + 'type':'table' } } ], - 'evaluation': 'bad', - 'level': 'info', - 'parent_panel_id': 'ecoscore', - 'title': - 'Transportation and origins of ingredients have a high impact.', - 'topics': ['environment'], - 'type': 'score' + 'evaluation':'good', + 'level':'info', + 'parent_panel_id':'ecoscore', + 'title_element':{ + 'title':"This product's packaging has a low impact on the environment." + }, + 'topics':[ + 'environment' + ], + 'type':'score' }, - 'ecoscore_packaging': { - 'elements': [ + 'ecoscore_production_system':{ + 'elements':[ { - 'element_type': 'text', - 'text_element': { - 'html': - '\n The information about the packaging of this product is not filled in.\n ', - 'type': 'warning' + 'element_type':'panel', + 'panel_element':{ + 'panel_id':'environment_label_fr:ab-agriculture-biologique' } }, { - 'element_type': 'text', - 'text_element': { - 'html': - '\n For a more precise calculation of the Eco-Score, you can modify the product page and add them.\n

\n If you are the manufacturer of this product, you can send us the information with our free platform for producers.\n ', - 'type': 'warning' + 'element_type':'panel', + 'panel_element':{ + 'panel_id':'environment_label_en:eu-organic' } } ], - 'evaluation': 'unknown', - 'level': 'info', - 'parent_panel_id': 'ecoscore', - 'title': "The information about this product's packaging is missing.", - 'topics': ['environment'], - 'type': 'score' + 'evaluation':'good', + 'level':'info', + 'parent_panel_id':'ecoscore', + 'title_element':{ + 'subtitle':'AB Agriculture Biologique, EU Organic', + 'title':'Production mode with high environmental benefits' + }, + 'topics':[ + 'environment' + ], + 'type':'score' }, - 'ecoscore_production_system': { - 'elements': [ + 'ecoscore_threatened_species':{ + 'elements':[ { - 'element_type': 'text', - 'text_element': { - 'html': - '\n

[give more details here]

\n ', - 'text_type': 'summary' + 'element_type':'text', + 'text_element':{ + 'html':'\n

[give more details here]

\n ', + 'text_type':'summary' } } ], - 'level': 'info', - 'parent_panel_id': 'ecoscore', - 'title': '', - 'topics': ['environment'], - 'type': 'score' + 'evaluation':'bad', + 'level':'info', + 'parent_panel_id':'ecoscore', + 'title_element':{ + 'title':'' + }, + 'topics':[ + 'environment' + ], + 'type':'score' }, - 'ecoscore_threatened_species': { - 'elements': [ + 'environment_label_en:eu-organic':{ + 'elements':[ { - 'element_type': 'text', - 'text_element': { - 'html': - '\n

[give more details here]

\n ', - 'text_type': 'summary' + 'element_type':'text', + 'text_element':{ + 'html':'\n Organic food is food produced by methods complying with the standards of organic farming and features practices that cycle resources, promote ecological balance, and conserve biodiversity.\n ', + 'type':'default' } } ], - 'level': 'info', - 'parent_panel_id': 'ecoscore', - 'title': '', - 'topics': ['environment'], - 'type': 'score' + 'evaluation':'good', + 'level':'info', + 'parent_panel_id':'ecoscore', + 'title_element':{ + 'icon_url':'/images/lang/en/labels/eu-organic.135x90.svg', + 'subtitle':'Organic agriculture contributes to preserve biodiversity, climate, water quality and soil fertility.', + 'title':'EU Organic' + }, + 'topics':[ + 'environment' + ], + 'type':'doyouknow' }, - 'tags_brands_nutella_doyouknow': { - 'elements': [ + 'environment_label_fr:ab-agriculture-biologique':{ + 'elements':[ { - 'element': { - 'html': - 'Cocoa beans were expensive and hard to come by after the second world war, so in Piedmont (Italy) where Pietro Ferrero created Nutella, they were replaced with hazelnuts to make gianduja, a mix of hazelnut paste and chocolate.', - 'text_type': 'default' - }, - 'element_type': 'text' - }, - { - 'element': { - 'height': 192, - 'url': - 'https://static.openfoodfacts.org/images/attributes/contains-nuts.png', - 'width': 192 - }, - 'element_type': 'image' + 'element_type':'text', + 'text_element':{ + 'html':'\n Organic food is food produced by methods complying with the standards of organic farming and features practices that cycle resources, promote ecological balance, and conserve biodiversity.\n ', + 'type':'default' + } } ], - 'level': 'trivia', - 'parent_panel_id': 'root', - 'subtitle': 'It all started after the second world war...', - 'title': 'Do you know why Nutella contains hazelnuts?', - 'topics': ['ingredients'], - 'type': 'doyouknow' - } + 'evaluation':'good', + 'level':'info', + 'parent_panel_id':'ecoscore', + 'title_element':{ + 'icon_url':'/images/lang/fr/labels/ab-agriculture-biologique.74x90.svg', + 'subtitle':'Organic agriculture contributes to preserve biodiversity, climate, water quality and soil fertility.', + 'title':'AB Agriculture Biologique' + }, + 'topics':[ + 'environment' + ], + 'type':'doyouknow' + }, }; KnowledgePanels kp = KnowledgePanels.fromJson(panels); - expect(kp.panelIdToPanelMap.length, equals(7)); + expect(kp.panelIdToPanelMap.length, equals(8)); }); // Verify that one KnowledgePanelElement must have a known KP element. @@ -320,8 +534,11 @@ void main() { 'type': 'doyouknow', 'level': 'trivia', 'topics': ['ingredients'], - 'title': 'Do you know why Nutella contains hazelnuts?', - 'subtitle': 'It all started after the second world war...', + 'title_element':{ + 'icon_url':'/images/lang/fr/labels/ab-agriculture-biologique.74x90.svg', + 'title': 'Do you know why Nutella contains hazelnuts?', + 'subtitle': 'It all started after the second world war...', + }, 'elements': [ { 'element_type': 'unknown', From 8e57e3243592f8b85454d733e631e610765a7883 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Thu, 7 Oct 2021 09:32:47 +0200 Subject: [PATCH 05/33] format --- test/knowledge_panels_from_json_test.dart | 635 +++++++++------------- 1 file changed, 267 insertions(+), 368 deletions(-) diff --git a/test/knowledge_panels_from_json_test.dart b/test/knowledge_panels_from_json_test.dart index 12b27e57ed..da48fd75bf 100644 --- a/test/knowledge_panels_from_json_test.dart +++ b/test/knowledge_panels_from_json_test.dart @@ -5,521 +5,419 @@ void main() { // Verify that we can successfully load the Knowledge panel from a JSON string test('Load KP from JSON', () async { Map panels = { - 'ecoscore':{ - 'elements':[ + 'ecoscore': { + 'elements': [ { - 'element_type':'text', - 'text_element':{ - 'html':'The Eco-Score is an experimental score that summarizes the environmental impacts of food products.' + 'element_type': 'text', + 'text_element': { + 'html': + 'The Eco-Score is an experimental score that summarizes the environmental impacts of food products.' } }, { - 'element_type':'text', - 'text_element':{ - 'html':'\n \n The Eco-Score was initially developped for France and it is being extended to other European countries. The Eco-Score formula is subject to change as it is regularly improved to make it more precise and better suited to each country.\n \n ', - 'type':'note' + 'element_type': 'text', + 'text_element': { + 'html': + '\n \n The Eco-Score was initially developped for France and it is being extended to other European countries. The Eco-Score formula is subject to change as it is regularly improved to make it more precise and better suited to each country.\n \n ', + 'type': 'note' } }, { - 'element_type':'panel', - 'panel_element':{ - 'panel_id':'ecoscore_agribalyse' - } + 'element_type': 'panel', + 'panel_element': {'panel_id': 'ecoscore_agribalyse'} }, { - 'element_type':'text', - 'text_element':{ - 'html':'Positive and negative points of this product:' + 'element_type': 'text', + 'text_element': { + 'html': 'Positive and negative points of this product:' } }, { - 'element_type':'panel', - 'panel_element':{ - 'panel_id':'ecoscore_production_system' - } + 'element_type': 'panel', + 'panel_element': {'panel_id': 'ecoscore_production_system'} }, { - 'element_type':'panel', - 'panel_element':{ - 'panel_id':'ecoscore_origins_of_ingredients' - } + 'element_type': 'panel', + 'panel_element': {'panel_id': 'ecoscore_origins_of_ingredients'} }, { - 'element_type':'panel', - 'panel_element':{ - 'panel_id':'ecoscore_packaging' - } + 'element_type': 'panel', + 'panel_element': {'panel_id': 'ecoscore_packaging'} }, { - 'element_type':'text', - 'text_element':{ - 'html':'Impact for this product: D (Score: 39/100)', - 'type':'h1' + 'element_type': 'text', + 'text_element': { + 'html': 'Impact for this product: D (Score: 39/100)', + 'type': 'h1' } } ], - 'grade':'', - 'level':'info', - 'parent_panel_id':'root', - 'title_element':{ - 'icon_url':'https://static.openfoodfacts.dev/images/attributes/ecoscore-d.svg', - 'title':'Eco-Score D - High environmental impact' + 'grade': '', + 'level': 'info', + 'parent_panel_id': 'root', + 'title_element': { + 'icon_url': + 'https://static.openfoodfacts.dev/images/attributes/ecoscore-d.svg', + 'title': 'Eco-Score D - High environmental impact' }, - 'topics':[ - 'environment' - ], - 'type':'score' + 'topics': ['environment'], + 'type': 'score' }, - 'ecoscore_agribalyse':{ - 'elements':[ + 'ecoscore_agribalyse': { + 'elements': [ { - 'element_type':'text', - 'text_element':{ - 'html':'\n

Agribalyse category: \n Chocolate spread with hazelnuts\n

\n
    \n
  • \n PEF environmental score: 0.74\n (the lower the score, the lower the impact)\n
  • \n
  • \n including impact on climate change: 9.87\n kg CO2 eq/kg of product\n
  • \n
\n ', - 'text_type':'summary' + 'element_type': 'text', + 'text_element': { + 'html': + '\n

Agribalyse category: \n Chocolate spread with hazelnuts\n

\n
    \n
  • \n PEF environmental score: 0.74\n (the lower the score, the lower the impact)\n
  • \n
  • \n including impact on climate change: 9.87\n kg CO2 eq/kg of product\n
  • \n
\n ', + 'text_type': 'summary' } }, { - 'element_type':'table', - 'table_element':{ - 'columns':[ - { - 'text':'Stage', - 'type':'text' - }, - { - 'text':'Impact', - 'type':'percent' - } + 'element_type': 'table', + 'table_element': { + 'columns': [ + {'text': 'Stage', 'type': 'text'}, + {'text': 'Impact', 'type': 'percent'} ], - 'id':'ecoscore_lca_impacts_by_stages_table', - 'rows':[ + 'id': 'ecoscore_lca_impacts_by_stages_table', + 'rows': [ { - 'id':'agriculture', - 'values':[ + 'id': 'agriculture', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/agriculture.svg', - 'text':'Agriculture' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/agriculture.svg', + 'text': 'Agriculture' }, - { - 'percent':82.6683253659907, - 'text':'82.7 %' - } + {'percent': 82.6683253659907, 'text': '82.7 %'} ] }, { - 'id':'processing', - 'values':[ + 'id': 'processing', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/processing.svg', - 'text':'Processing' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/processing.svg', + 'text': 'Processing' }, - { - 'percent':11.5205649227182, - 'text':'11.5 %' - } + {'percent': 11.5205649227182, 'text': '11.5 %'} ] }, { - 'id':'packaging', - 'values':[ + 'id': 'packaging', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/packaging.svg', - 'text':'Packaging' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/packaging.svg', + 'text': 'Packaging' }, - { - 'percent':2.75038601617178, - 'text':'2.8 %' - } + {'percent': 2.75038601617178, 'text': '2.8 %'} ] }, { - 'id':'transportation', - 'values':[ + 'id': 'transportation', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/transportation.svg', - 'text':'Transportation' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/transportation.svg', + 'text': 'Transportation' }, - { - 'percent':2.39678556140912, - 'text':'2.4 %' - } + {'percent': 2.39678556140912, 'text': '2.4 %'} ] }, { - 'id':'distribution', - 'values':[ + 'id': 'distribution', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/distribution.svg', - 'text':'Distribution' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/distribution.svg', + 'text': 'Distribution' }, - { - 'percent':0.617299532560963, - 'text':'0.6 %' - } + {'percent': 0.617299532560963, 'text': '0.6 %'} ] }, { - 'id':'consumption', - 'values':[ + 'id': 'consumption', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/consumption.svg', - 'text':'Consumption' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/consumption.svg', + 'text': 'Consumption' }, - { - 'percent':0, - 'text':'0.0 %' - } + {'percent': 0, 'text': '0.0 %'} ] } ], - 'table_type':'percents', - 'title':'Details of the impacts by stages of the life cycle' + 'table_type': 'percents', + 'title': 'Details of the impacts by stages of the life cycle' } } ], - 'grade':'c', - 'level':'info', - 'parent_panel_id':'ecoscore', - 'title_element':{ - 'subtitle':'Category: Chocolate spread with hazelnuts', - 'title':'Average impact for products of the same category: C (Score: 40/100)' + 'grade': 'c', + 'level': 'info', + 'parent_panel_id': 'ecoscore', + 'title_element': { + 'subtitle': 'Category: Chocolate spread with hazelnuts', + 'title': + 'Average impact for products of the same category: C (Score: 40/100)' }, - 'topics':[ - 'environment' - ], - 'type':'score' + 'topics': ['environment'], + 'type': 'score' }, - 'ecoscore_carbon_impact':{ - 'elements':[ + 'ecoscore_carbon_impact': { + 'elements': [ { - 'element_type':'text', - 'text_element':{ - 'html':"\n

The carbon emission figure comes from ADEME's Agribalyse database, for the category: \n Chocolate spread with hazelnuts\n

\n ", - 'text_type':'summary' + 'element_type': 'text', + 'text_element': { + 'html': + "\n

The carbon emission figure comes from ADEME's Agribalyse database, for the category: \n Chocolate spread with hazelnuts\n

\n ", + 'text_type': 'summary' } }, { - 'element_type':'table', - 'table_element':{ - 'columns':[ - { - 'text':'Stage', - 'type':'text' - }, - { - 'text':'Impact', - 'type':'percent' - } + 'element_type': 'table', + 'table_element': { + 'columns': [ + {'text': 'Stage', 'type': 'text'}, + {'text': 'Impact', 'type': 'percent'} ], - 'id':'ecoscore_carbon_impact_by_stages_table', - 'rows':[ + 'id': 'ecoscore_carbon_impact_by_stages_table', + 'rows': [ { - 'id':'agriculture', - 'values':[ + 'id': 'agriculture', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/agriculture.svg', - 'text':'Agriculture' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/agriculture.svg', + 'text': 'Agriculture' }, - { - 'percent':88.8889136446762, - 'text':'88.9 %' - } + {'percent': 88.8889136446762, 'text': '88.9 %'} ] }, { - 'id':'processing', - 'values':[ + 'id': 'processing', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/processing.svg', - 'text':'Processing' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/processing.svg', + 'text': 'Processing' }, - { - 'percent':7.00489485042906, - 'text':'7.0 %' - } + {'percent': 7.00489485042906, 'text': '7.0 %'} ] }, { - 'id':'packaging', - 'values':[ + 'id': 'packaging', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/packaging.svg', - 'text':'Packaging' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/packaging.svg', + 'text': 'Packaging' }, - { - 'percent':1.9105118864761, - 'text':'1.9 %' - } + {'percent': 1.9105118864761, 'text': '1.9 %'} ] }, { - 'id':'transportation', - 'values':[ + 'id': 'transportation', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/transportation.svg', - 'text':'Transportation' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/transportation.svg', + 'text': 'Transportation' }, - { - 'percent':1.99595294189039, - 'text':'2.0 %' - } + {'percent': 1.99595294189039, 'text': '2.0 %'} ] }, { - 'id':'distribution', - 'values':[ + 'id': 'distribution', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/distribution.svg', - 'text':'Distribution' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/distribution.svg', + 'text': 'Distribution' }, - { - 'percent':0.142846509121219, - 'text':'0.1 %' - } + {'percent': 0.142846509121219, 'text': '0.1 %'} ] }, { - 'id':'consumption', - 'values':[ + 'id': 'consumption', + 'values': [ { - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/consumption.svg', - 'text':'Consumption' + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/consumption.svg', + 'text': 'Consumption' }, - { - 'percent':0, - 'text':'0.0 %' - } + {'percent': 0, 'text': '0.0 %'} ] } ], - 'table_type':'percents', - 'title':'Details of the impacts by stages of the life cycle' + 'table_type': 'percents', + 'title': 'Details of the impacts by stages of the life cycle' } } ], - 'evaluation':'bad', - 'level':'info', - 'name':'Carbon impact', - 'parent_panel_id':'root', - 'title_element':{ - 'icon_color_from_evaluation':true, - 'icon_url':'https://static.openfoodfacts.dev/images/icons/dist/car.svg', - 'subtitle':'987 g CO² per 100g of product', - 'title':'Equal to driving 5.1 km in a petrol car' + 'evaluation': 'bad', + 'level': 'info', + 'name': 'Carbon impact', + 'parent_panel_id': 'root', + 'title_element': { + 'icon_color_from_evaluation': true, + 'icon_url': + 'https://static.openfoodfacts.dev/images/icons/dist/car.svg', + 'subtitle': '987 g CO² per 100g of product', + 'title': 'Equal to driving 5.1 km in a petrol car' }, - 'topics':[ - 'environment' - ], - 'type':'score' + 'topics': ['environment'], + 'type': 'score' }, - 'ecoscore_packaging':{ - 'elements':[ + 'ecoscore_packaging': { + 'elements': [ { - 'element_type':'table', - 'table_element':{ - 'columns':[ - { - 'text':'Shape', - 'type':'text' - }, - { - 'text':'Material', - 'type':'text' - }, - { - 'text':'Recycling', - 'type':'text' - }, - { - 'text':'Impact', - 'type':'text' - } + 'element_type': 'table', + 'table_element': { + 'columns': [ + {'text': 'Shape', 'type': 'text'}, + {'text': 'Material', 'type': 'text'}, + {'text': 'Recycling', 'type': 'text'}, + {'text': 'Impact', 'type': 'text'} ], - 'id':'ecoscore_packaging_components', - 'rows':[ + 'id': 'ecoscore_packaging_components', + 'rows': [ { - 'values':[ - { - 'text':'1 Lid' - }, - { - 'text':'PP - Polypropylene' - }, - { - 'evaluation':'bad', - 'text':'Discard' - }, - { - 'evaluation':'bad', - 'text':'High' - } + 'values': [ + {'text': '1 Lid'}, + {'text': 'PP - Polypropylene'}, + {'evaluation': 'bad', 'text': 'Discard'}, + {'evaluation': 'bad', 'text': 'High'} ] }, { - 'values':[ - { - 'text':'1 Backing' - }, - { - 'text':'Cardboard' - }, - { - 'evaluation':'good', - 'text':'Recycle' - }, - { - 'evaluation':'good', - 'text':'Low' - } + 'values': [ + {'text': '1 Backing'}, + {'text': 'Cardboard'}, + {'evaluation': 'good', 'text': 'Recycle'}, + {'evaluation': 'good', 'text': 'Low'} ] }, { - 'values':[ - { - 'text':'1 Seal' - }, - { - 'text':'Cardboard' - }, - { - 'evaluation':'good', - 'text':'Recycle' - }, - { - 'evaluation':'good', - 'text':'Low' - } + 'values': [ + {'text': '1 Seal'}, + {'text': 'Cardboard'}, + {'evaluation': 'good', 'text': 'Recycle'}, + {'evaluation': 'good', 'text': 'Low'} ] }, { - 'values':[ - { - 'text':'1 Pot' - }, - { - 'text':'Glass' - }, - { - 'evaluation':'good', - 'text':'Recycle' - }, - { - 'evaluation':'good', - 'text':'Low' - } + 'values': [ + {'text': '1 Pot'}, + {'text': 'Glass'}, + {'evaluation': 'good', 'text': 'Recycle'}, + {'evaluation': 'good', 'text': 'Low'} ] } ], - 'title':'Packaging parts', - 'type':'table' + 'title': 'Packaging parts', + 'type': 'table' } } ], - 'evaluation':'good', - 'level':'info', - 'parent_panel_id':'ecoscore', - 'title_element':{ - 'title':"This product's packaging has a low impact on the environment." + 'evaluation': 'good', + 'level': 'info', + 'parent_panel_id': 'ecoscore', + 'title_element': { + 'title': + "This product's packaging has a low impact on the environment." }, - 'topics':[ - 'environment' - ], - 'type':'score' + 'topics': ['environment'], + 'type': 'score' }, - 'ecoscore_production_system':{ - 'elements':[ + 'ecoscore_production_system': { + 'elements': [ { - 'element_type':'panel', - 'panel_element':{ - 'panel_id':'environment_label_fr:ab-agriculture-biologique' + 'element_type': 'panel', + 'panel_element': { + 'panel_id': 'environment_label_fr:ab-agriculture-biologique' } }, { - 'element_type':'panel', - 'panel_element':{ - 'panel_id':'environment_label_en:eu-organic' - } + 'element_type': 'panel', + 'panel_element': {'panel_id': 'environment_label_en:eu-organic'} } ], - 'evaluation':'good', - 'level':'info', - 'parent_panel_id':'ecoscore', - 'title_element':{ - 'subtitle':'AB Agriculture Biologique, EU Organic', - 'title':'Production mode with high environmental benefits' + 'evaluation': 'good', + 'level': 'info', + 'parent_panel_id': 'ecoscore', + 'title_element': { + 'subtitle': 'AB Agriculture Biologique, EU Organic', + 'title': 'Production mode with high environmental benefits' }, - 'topics':[ - 'environment' - ], - 'type':'score' + 'topics': ['environment'], + 'type': 'score' }, - 'ecoscore_threatened_species':{ - 'elements':[ + 'ecoscore_threatened_species': { + 'elements': [ { - 'element_type':'text', - 'text_element':{ - 'html':'\n

[give more details here]

\n ', - 'text_type':'summary' + 'element_type': 'text', + 'text_element': { + 'html': + '\n

[give more details here]

\n ', + 'text_type': 'summary' } } ], - 'evaluation':'bad', - 'level':'info', - 'parent_panel_id':'ecoscore', - 'title_element':{ - 'title':'' - }, - 'topics':[ - 'environment' - ], - 'type':'score' + 'evaluation': 'bad', + 'level': 'info', + 'parent_panel_id': 'ecoscore', + 'title_element': {'title': ''}, + 'topics': ['environment'], + 'type': 'score' }, - 'environment_label_en:eu-organic':{ - 'elements':[ + 'environment_label_en:eu-organic': { + 'elements': [ { - 'element_type':'text', - 'text_element':{ - 'html':'\n Organic food is food produced by methods complying with the standards of organic farming and features practices that cycle resources, promote ecological balance, and conserve biodiversity.\n ', - 'type':'default' + 'element_type': 'text', + 'text_element': { + 'html': + '\n Organic food is food produced by methods complying with the standards of organic farming and features practices that cycle resources, promote ecological balance, and conserve biodiversity.\n ', + 'type': 'default' } } ], - 'evaluation':'good', - 'level':'info', - 'parent_panel_id':'ecoscore', - 'title_element':{ - 'icon_url':'/images/lang/en/labels/eu-organic.135x90.svg', - 'subtitle':'Organic agriculture contributes to preserve biodiversity, climate, water quality and soil fertility.', - 'title':'EU Organic' + 'evaluation': 'good', + 'level': 'info', + 'parent_panel_id': 'ecoscore', + 'title_element': { + 'icon_url': '/images/lang/en/labels/eu-organic.135x90.svg', + 'subtitle': + 'Organic agriculture contributes to preserve biodiversity, climate, water quality and soil fertility.', + 'title': 'EU Organic' }, - 'topics':[ - 'environment' - ], - 'type':'doyouknow' + 'topics': ['environment'], + 'type': 'doyouknow' }, - 'environment_label_fr:ab-agriculture-biologique':{ - 'elements':[ + 'environment_label_fr:ab-agriculture-biologique': { + 'elements': [ { - 'element_type':'text', - 'text_element':{ - 'html':'\n Organic food is food produced by methods complying with the standards of organic farming and features practices that cycle resources, promote ecological balance, and conserve biodiversity.\n ', - 'type':'default' + 'element_type': 'text', + 'text_element': { + 'html': + '\n Organic food is food produced by methods complying with the standards of organic farming and features practices that cycle resources, promote ecological balance, and conserve biodiversity.\n ', + 'type': 'default' } } ], - 'evaluation':'good', - 'level':'info', - 'parent_panel_id':'ecoscore', - 'title_element':{ - 'icon_url':'/images/lang/fr/labels/ab-agriculture-biologique.74x90.svg', - 'subtitle':'Organic agriculture contributes to preserve biodiversity, climate, water quality and soil fertility.', - 'title':'AB Agriculture Biologique' + 'evaluation': 'good', + 'level': 'info', + 'parent_panel_id': 'ecoscore', + 'title_element': { + 'icon_url': + '/images/lang/fr/labels/ab-agriculture-biologique.74x90.svg', + 'subtitle': + 'Organic agriculture contributes to preserve biodiversity, climate, water quality and soil fertility.', + 'title': 'AB Agriculture Biologique' }, - 'topics':[ - 'environment' - ], - 'type':'doyouknow' + 'topics': ['environment'], + 'type': 'doyouknow' }, }; KnowledgePanels kp = KnowledgePanels.fromJson(panels); @@ -534,8 +432,9 @@ void main() { 'type': 'doyouknow', 'level': 'trivia', 'topics': ['ingredients'], - 'title_element':{ - 'icon_url':'/images/lang/fr/labels/ab-agriculture-biologique.74x90.svg', + 'title_element': { + 'icon_url': + '/images/lang/fr/labels/ab-agriculture-biologique.74x90.svg', 'title': 'Do you know why Nutella contains hazelnuts?', 'subtitle': 'It all started after the second world war...', }, From cfbc0dc122f37448b3956cce7b8d93a836189483 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Thu, 7 Oct 2021 09:36:55 +0200 Subject: [PATCH 06/33] add a comment --- lib/model/KnowledgePanel.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index aa1b018d18..f95a966dbf 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -118,6 +118,9 @@ class TitleElement extends JsonObject { @JsonKey(name: 'icon_url') final String? iconUrl; + /// If true, the icon can be tinted with a color (red/green/yellow) in + /// accordance with the [evaluation] of the knowledge panel as per the + /// client's discretion. @JsonKey(name: 'icon_color_from_evaluation', defaultValue: false) final bool? iconColorFromEvaluation; From 79e85da2247edeb0156cef0b5be6d887f6241b8e Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Thu, 7 Oct 2021 09:37:29 +0200 Subject: [PATCH 07/33] update comment --- lib/model/KnowledgePanel.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index f95a966dbf..ac9b94ce63 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -118,8 +118,8 @@ class TitleElement extends JsonObject { @JsonKey(name: 'icon_url') final String? iconUrl; - /// If true, the icon can be tinted with a color (red/green/yellow) in - /// accordance with the [evaluation] of the knowledge panel as per the + /// If true, the icon can be tinted with a color (red/green/yellow/whatever) + /// in accordance with the [evaluation] of the knowledge panel as per the /// client's discretion. @JsonKey(name: 'icon_color_from_evaluation', defaultValue: false) final bool? iconColorFromEvaluation; From c18b3dc4d1136dd2704077c90a741f248cbeadd2 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Thu, 7 Oct 2021 16:06:55 +0200 Subject: [PATCH 08/33] Add Evaluation --- lib/model/KnowledgePanel.dart | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index ac9b94ce63..a70b5688e3 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -51,6 +51,15 @@ enum Grade { UNKNOWN, } +/// Evaluation of the panel, depicting whether the content of the panel is +/// good/bad/neutral for the topic to which the panel applies. +enum Evaluation { + GOOD, + NEUTRAL, + BAD, + UNKNOWN, +} + /// KnowledgePanels are a standardized and generic units of information that /// the client can display on the product page. /// @@ -66,20 +75,20 @@ class KnowledgePanel extends JsonObject { @JsonKey(name: 'title_element') final TitleElement titleElement; - final KnowledgePanelType type; - /// Level of this KnowledgePanel. Client may choose to display the panel based /// on the level. @JsonKey(unknownEnumValue: Level.UNKNOWN) final Level level; - /// The topics discussed in this knowledge panel, example: 'Environment'. - final List? topics; - /// KnowledgePanelElement is a single unit of KnowledgePanel that can be /// rendered on the client. final List elements; + final KnowledgePanelType? type; + + /// The topics discussed in this knowledge panel, example: 'Environment'. + final List? topics; + /// Grade of the panel, depicting the level of impact the product has for the /// corresponding topics. Client can choose to color code the panel depending /// on how good/bad the grade is. @@ -87,14 +96,20 @@ class KnowledgePanel extends JsonObject { @JsonKey(unknownEnumValue: Grade.UNKNOWN) final Grade? grade; + /// Evaluation of the panel, depicting whether the content of the panel is + /// good/bad/neutral for the topic to which the panel applies. + @JsonKey(unknownEnumValue: Evaluation.UNKNOWN) + final Evaluation? evaluation; + const KnowledgePanel({ required this.parentPanelId, required this.titleElement, - required this.type, required this.level, required this.elements, + this.type, this.topics, this.grade, + this.evaluation, }); factory KnowledgePanel.fromJson(Map json) => From fd027959dc325ecd28ac9ba8ebfc4669f1e78ed6 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Thu, 7 Oct 2021 18:45:35 +0200 Subject: [PATCH 09/33] Fix tests --- lib/model/KnowledgePanel.dart | 3 +++ lib/model/KnowledgePanel.g.dart | 30 ++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index a70b5688e3..4d3350caa3 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -54,8 +54,11 @@ enum Grade { /// Evaluation of the panel, depicting whether the content of the panel is /// good/bad/neutral for the topic to which the panel applies. enum Evaluation { + @JsonValue('good') GOOD, + @JsonValue('neutral') NEUTRAL, + @JsonValue('bad') BAD, UNKNOWN, } diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 22959927b5..7bd32cac63 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -11,27 +11,30 @@ KnowledgePanel _$KnowledgePanelFromJson(Map json) => parentPanelId: json['parent_panel_id'] as String, titleElement: TitleElement.fromJson(json['title_element'] as Map), - type: _$enumDecode(_$KnowledgePanelTypeEnumMap, json['type']), level: _$enumDecode(_$LevelEnumMap, json['level'], unknownValue: Level.UNKNOWN), elements: (json['elements'] as List) .map((e) => KnowledgePanelElement.fromJson(e as Map)) .toList(), + type: _$enumDecodeNullable(_$KnowledgePanelTypeEnumMap, json['type']), topics: (json['topics'] as List?)?.map((e) => e as String).toList(), grade: _$enumDecodeNullable(_$GradeEnumMap, json['grade'], unknownValue: Grade.UNKNOWN), + evaluation: _$enumDecodeNullable(_$EvaluationEnumMap, json['evaluation'], + unknownValue: Evaluation.UNKNOWN), ); Map _$KnowledgePanelToJson(KnowledgePanel instance) => { 'parent_panel_id': instance.parentPanelId, 'title_element': instance.titleElement, - 'type': _$KnowledgePanelTypeEnumMap[instance.type], 'level': _$LevelEnumMap[instance.level], - 'topics': instance.topics, 'elements': instance.elements, + 'type': _$KnowledgePanelTypeEnumMap[instance.type], + 'topics': instance.topics, 'grade': _$GradeEnumMap[instance.grade], + 'evaluation': _$EvaluationEnumMap[instance.evaluation], }; K _$enumDecode( @@ -60,13 +63,6 @@ K _$enumDecode( ).key; } -const _$KnowledgePanelTypeEnumMap = { - KnowledgePanelType.DO_YOU_KNOW: 'doyouknow', - KnowledgePanelType.SCORE: 'score', - KnowledgePanelType.ECOSCORE_LCA: 'ecoscore_lca', - KnowledgePanelType.UNKNOWN: 'UNKNOWN', -}; - const _$LevelEnumMap = { Level.TRIVIA: 'trivia', Level.INFO: 'info', @@ -87,6 +83,13 @@ K? _$enumDecodeNullable( return _$enumDecode(enumValues, source, unknownValue: unknownValue); } +const _$KnowledgePanelTypeEnumMap = { + KnowledgePanelType.DO_YOU_KNOW: 'doyouknow', + KnowledgePanelType.SCORE: 'score', + KnowledgePanelType.ECOSCORE_LCA: 'ecoscore_lca', + KnowledgePanelType.UNKNOWN: 'UNKNOWN', +}; + const _$GradeEnumMap = { Grade.A: 'A', Grade.B: 'B', @@ -96,6 +99,13 @@ const _$GradeEnumMap = { Grade.UNKNOWN: 'UNKNOWN', }; +const _$EvaluationEnumMap = { + Evaluation.GOOD: 'good', + Evaluation.NEUTRAL: 'neutral', + Evaluation.BAD: 'bad', + Evaluation.UNKNOWN: 'UNKNOWN', +}; + TitleElement _$TitleElementFromJson(Map json) => TitleElement( title: json['title'] as String, subtitle: json['subtitle'] as String?, From f80c6961dc45dac0e7ff808a8b12a6d7f2d2ac24 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Sat, 9 Oct 2021 14:55:48 +0200 Subject: [PATCH 10/33] Add to KnowledgePanels --- lib/model/KnowledgePanel.dart | 4 ++++ lib/model/KnowledgePanel.g.dart | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 4d3350caa3..eff864cf99 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -87,6 +87,9 @@ class KnowledgePanel extends JsonObject { /// rendered on the client. final List elements; + /// Name of the panel, can be displayed by the client if present. + final String? name; + final KnowledgePanelType? type; /// The topics discussed in this knowledge panel, example: 'Environment'. @@ -109,6 +112,7 @@ class KnowledgePanel extends JsonObject { required this.titleElement, required this.level, required this.elements, + this.name, this.type, this.topics, this.grade, diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 7bd32cac63..0b1d08d39f 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -16,6 +16,7 @@ KnowledgePanel _$KnowledgePanelFromJson(Map json) => elements: (json['elements'] as List) .map((e) => KnowledgePanelElement.fromJson(e as Map)) .toList(), + name: json['name'] as String?, type: _$enumDecodeNullable(_$KnowledgePanelTypeEnumMap, json['type']), topics: (json['topics'] as List?)?.map((e) => e as String).toList(), @@ -31,6 +32,7 @@ Map _$KnowledgePanelToJson(KnowledgePanel instance) => 'title_element': instance.titleElement, 'level': _$LevelEnumMap[instance.level], 'elements': instance.elements, + 'name': instance.name, 'type': _$KnowledgePanelTypeEnumMap[instance.type], 'topics': instance.topics, 'grade': _$GradeEnumMap[instance.grade], From 65dba15d270fe8acfde957fa38908dc49a868ddc Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Mon, 11 Oct 2021 21:30:11 +0200 Subject: [PATCH 11/33] Remove from KnowledgePanel and add a KnowledgePanelGroupElement to panels. --- lib/model/KnowledgePanel.dart | 3 --- lib/model/KnowledgePanel.g.dart | 2 -- lib/model/KnowledgePanelElement.dart | 27 ++++++++++++++++++++++++++ lib/model/KnowledgePanelElement.g.dart | 21 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index eff864cf99..2ba69d7ae1 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -87,9 +87,6 @@ class KnowledgePanel extends JsonObject { /// rendered on the client. final List elements; - /// Name of the panel, can be displayed by the client if present. - final String? name; - final KnowledgePanelType? type; /// The topics discussed in this knowledge panel, example: 'Environment'. diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 0b1d08d39f..7bd32cac63 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -16,7 +16,6 @@ KnowledgePanel _$KnowledgePanelFromJson(Map json) => elements: (json['elements'] as List) .map((e) => KnowledgePanelElement.fromJson(e as Map)) .toList(), - name: json['name'] as String?, type: _$enumDecodeNullable(_$KnowledgePanelTypeEnumMap, json['type']), topics: (json['topics'] as List?)?.map((e) => e as String).toList(), @@ -32,7 +31,6 @@ Map _$KnowledgePanelToJson(KnowledgePanel instance) => 'title_element': instance.titleElement, 'level': _$LevelEnumMap[instance.level], 'elements': instance.elements, - 'name': instance.name, 'type': _$KnowledgePanelTypeEnumMap[instance.type], 'topics': instance.topics, 'grade': _$GradeEnumMap[instance.grade], diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index c895af85b8..002395c0bc 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -76,6 +76,25 @@ class KnowledgePanelImageElement extends JsonObject { Map toJson() => _$KnowledgePanelImageElementToJson(this); } +/// Element representing a Panel group that contains 1+ KnowledgePanels. +@JsonSerializable() +class KnowledgePanelPanelGroupElement extends JsonObject { + final String title; + + @JsonKey(name: 'panel_ids') + final List panelIds; + + const KnowledgePanelPanelGroupElement( + {required this.title, required this.panelIds}); + + factory KnowledgePanelPanelGroupElement.fromJson(Map json) => + _$KnowledgePanelPanelGroupElementFromJson(json); + + @override + Map toJson() => + _$KnowledgePanelPanelGroupElementToJson(this); +} + /// Element representing a Panel Id of a KnowledgePanel. This element is a /// Knowledge panel itself, the KnowledgePanel can be found in the list of /// Knowledge panels using the id. @@ -189,6 +208,10 @@ enum KnowledgePanelElementType { @JsonValue('panel') PANEL, + /// Disclaimer notes that the client may or may not choose to display. + @JsonValue('panel_group') + PANEL_GROUP, + /// Disclaimer notes that the client may or may not choose to display. @JsonValue('table') TABLE, @@ -215,6 +238,9 @@ class KnowledgePanelElement extends JsonObject { @JsonKey(name: 'panel_element') final KnowledgePanelPanelIdElement? panelElement; + @JsonKey(name: 'panel_group') + final KnowledgePanelPanelGroupElement? panelGroupElement; + /// Id of a KnowledgePanel embedded inside [this] KnowledgePanel. final KnowledgePanelTableElement? tableElement; @@ -223,6 +249,7 @@ class KnowledgePanelElement extends JsonObject { this.textElement, this.imageElement, this.panelElement, + this.panelGroupElement, this.tableElement, }); diff --git a/lib/model/KnowledgePanelElement.g.dart b/lib/model/KnowledgePanelElement.g.dart index 04f384485a..eb03f3325c 100644 --- a/lib/model/KnowledgePanelElement.g.dart +++ b/lib/model/KnowledgePanelElement.g.dart @@ -74,6 +74,21 @@ Map _$KnowledgePanelImageElementToJson( 'alt_text': instance.altText, }; +KnowledgePanelPanelGroupElement _$KnowledgePanelPanelGroupElementFromJson( + Map json) => + KnowledgePanelPanelGroupElement( + title: json['title'] as String, + panelIds: + (json['panel_ids'] as List).map((e) => e as String).toList(), + ); + +Map _$KnowledgePanelPanelGroupElementToJson( + KnowledgePanelPanelGroupElement instance) => + { + 'title': instance.title, + 'panel_ids': instance.panelIds, + }; + KnowledgePanelPanelIdElement _$KnowledgePanelPanelIdElementFromJson( Map json) => KnowledgePanelPanelIdElement( @@ -176,6 +191,10 @@ KnowledgePanelElement _$KnowledgePanelElementFromJson( ? null : KnowledgePanelPanelIdElement.fromJson( json['panel_element'] as Map), + panelGroupElement: json['panel_group'] == null + ? null + : KnowledgePanelPanelGroupElement.fromJson( + json['panel_group'] as Map), tableElement: json['tableElement'] == null ? null : KnowledgePanelTableElement.fromJson( @@ -189,6 +208,7 @@ Map _$KnowledgePanelElementToJson( 'textElement': instance.textElement, 'imageElement': instance.imageElement, 'panel_element': instance.panelElement, + 'panel_group': instance.panelGroupElement, 'tableElement': instance.tableElement, }; @@ -196,6 +216,7 @@ const _$KnowledgePanelElementTypeEnumMap = { KnowledgePanelElementType.TEXT: 'text', KnowledgePanelElementType.IMAGE: 'image', KnowledgePanelElementType.PANEL: 'panel', + KnowledgePanelElementType.PANEL_GROUP: 'panel_group', KnowledgePanelElementType.TABLE: 'table', KnowledgePanelElementType.UNKNOWN: 'UNKNOWN', }; From b98839e66ed9dca5f585a0e0908668b0e301c306 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Mon, 11 Oct 2021 21:32:28 +0200 Subject: [PATCH 12/33] Remove from KnowledgePanel and add a KnowledgePanelGroupElement to panels. --- lib/model/KnowledgePanelElement.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index 002395c0bc..fb21f3df92 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -79,8 +79,10 @@ class KnowledgePanelImageElement extends JsonObject { /// Element representing a Panel group that contains 1+ KnowledgePanels. @JsonSerializable() class KnowledgePanelPanelGroupElement extends JsonObject { + /// Title of the panel group. Example: "Carbon Footprint" or "Labels" etc. final String title; + /// List of panel ids that belong to this panel group. @JsonKey(name: 'panel_ids') final List panelIds; From 45bcdcd28f16b40e27363ce31809db87274cc271 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Mon, 11 Oct 2021 21:35:48 +0200 Subject: [PATCH 13/33] Remove unnecessary comments --- lib/model/KnowledgePanelElement.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index fb21f3df92..11ad3cb0b9 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -206,15 +206,12 @@ enum KnowledgePanelElementType { @JsonValue('image') IMAGE, - /// Disclaimer notes that the client may or may not choose to display. @JsonValue('panel') PANEL, - /// Disclaimer notes that the client may or may not choose to display. @JsonValue('panel_group') PANEL_GROUP, - /// Disclaimer notes that the client may or may not choose to display. @JsonValue('table') TABLE, UNKNOWN, From d7aaf8570a5c9d58ff806cefa4ae3358c4cb0aef Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Mon, 11 Oct 2021 22:37:43 +0200 Subject: [PATCH 14/33] Fix tests --- test/knowledge_panels_from_json_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/test/knowledge_panels_from_json_test.dart b/test/knowledge_panels_from_json_test.dart index da48fd75bf..e9af40f31e 100644 --- a/test/knowledge_panels_from_json_test.dart +++ b/test/knowledge_panels_from_json_test.dart @@ -258,7 +258,6 @@ void main() { ], 'evaluation': 'bad', 'level': 'info', - 'name': 'Carbon impact', 'parent_panel_id': 'root', 'title_element': { 'icon_color_from_evaluation': true, From ed4466db524a985ba2332eac235b8214d4ee1024 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Mon, 11 Oct 2021 22:45:39 +0200 Subject: [PATCH 15/33] Fix build --- lib/model/KnowledgePanel.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 2ba69d7ae1..4d3350caa3 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -109,7 +109,6 @@ class KnowledgePanel extends JsonObject { required this.titleElement, required this.level, required this.elements, - this.name, this.type, this.topics, this.grade, From a8c888cfc5a9ce9a355dba7f80eb8ff78ec79714 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 12 Oct 2021 10:56:04 +0200 Subject: [PATCH 16/33] Add a new KnowledgePanel type --- lib/model/KnowledgePanel.dart | 6 +++++- lib/model/KnowledgePanel.g.dart | 1 + lib/model/KnowledgePanels.dart | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 4d3350caa3..5fccf72c2d 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -18,6 +18,10 @@ enum KnowledgePanelType { /// Knowledge Panel with ecoscore LCA. @JsonValue('ecoscore_lca') ECOSCORE_LCA, + + /// Knowledge Panel which is rendered as a card on the UI. + @JsonValue('card') + CARD, UNKNOWN, } @@ -108,7 +112,7 @@ class KnowledgePanel extends JsonObject { required this.parentPanelId, required this.titleElement, required this.level, - required this.elements, + this.elements, this.type, this.topics, this.grade, diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 7bd32cac63..05c5491f27 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -87,6 +87,7 @@ const _$KnowledgePanelTypeEnumMap = { KnowledgePanelType.DO_YOU_KNOW: 'doyouknow', KnowledgePanelType.SCORE: 'score', KnowledgePanelType.ECOSCORE_LCA: 'ecoscore_lca', + KnowledgePanelType.CARD: 'card', KnowledgePanelType.UNKNOWN: 'UNKNOWN', }; diff --git a/lib/model/KnowledgePanels.dart b/lib/model/KnowledgePanels.dart index b9019c0386..0a3c30b790 100644 --- a/lib/model/KnowledgePanels.dart +++ b/lib/model/KnowledgePanels.dart @@ -8,6 +8,7 @@ class KnowledgePanels { const KnowledgePanels({required this.panelIdToPanelMap}); factory KnowledgePanels.fromJson(Map json) { + print(json); Map map = {}; for (var panelId in json.keys) { map[panelId] = KnowledgePanel.fromJson(json[panelId]); From d596e48192134d49e8577fefee7adce1a61f5a63 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 12 Oct 2021 10:57:25 +0200 Subject: [PATCH 17/33] Add a new KnowledgePanel type --- lib/model/KnowledgePanel.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 5fccf72c2d..1bbb158239 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -112,7 +112,7 @@ class KnowledgePanel extends JsonObject { required this.parentPanelId, required this.titleElement, required this.level, - this.elements, + required this.elements, this.type, this.topics, this.grade, From a0eae4a24b5cca8453cb730040ebb64cc483275c Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 12 Oct 2021 11:49:39 +0200 Subject: [PATCH 18/33] Make elements nullable --- lib/model/KnowledgePanel.dart | 2 +- lib/model/KnowledgePanel.g.dart | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 1bbb158239..36f476d6f1 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -89,7 +89,7 @@ class KnowledgePanel extends JsonObject { /// KnowledgePanelElement is a single unit of KnowledgePanel that can be /// rendered on the client. - final List elements; + final List? elements; final KnowledgePanelType? type; diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 05c5491f27..3af9384e61 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -13,8 +13,9 @@ KnowledgePanel _$KnowledgePanelFromJson(Map json) => TitleElement.fromJson(json['title_element'] as Map), level: _$enumDecode(_$LevelEnumMap, json['level'], unknownValue: Level.UNKNOWN), - elements: (json['elements'] as List) - .map((e) => KnowledgePanelElement.fromJson(e as Map)) + elements: (json['elements'] as List?) + ?.map( + (e) => KnowledgePanelElement.fromJson(e as Map)) .toList(), type: _$enumDecodeNullable(_$KnowledgePanelTypeEnumMap, json['type']), topics: From 5d1538d565cfbbe5a3ceaf6ab2f378754560d364 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 12 Oct 2021 11:50:14 +0200 Subject: [PATCH 19/33] Make elements nullable --- lib/model/KnowledgePanel.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 36f476d6f1..4aa36e3761 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -112,7 +112,7 @@ class KnowledgePanel extends JsonObject { required this.parentPanelId, required this.titleElement, required this.level, - required this.elements, + this.elements, this.type, this.topics, this.grade, From c27309f89e5ca0cc7dd2869ddd79ec58336d035d Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 12 Oct 2021 11:55:16 +0200 Subject: [PATCH 20/33] Cosmetic change --- test/knowledge_panels_from_json_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/knowledge_panels_from_json_test.dart b/test/knowledge_panels_from_json_test.dart index e9af40f31e..58d17c6164 100644 --- a/test/knowledge_panels_from_json_test.dart +++ b/test/knowledge_panels_from_json_test.dart @@ -171,7 +171,7 @@ void main() { 'element_type': 'text', 'text_element': { 'html': - "\n

The carbon emission figure comes from ADEME's Agribalyse database, for the category: \n Chocolate spread with hazelnuts\n

\n ", + "\n

The carbon emission figure comes from ADEME's Agribalyse database, for the category: \n Chocolate spread with hazelnuts\n

\n ", 'text_type': 'summary' } }, From 2724a34ccda430969aa4e033ac013d0277894405 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 12 Oct 2021 13:42:06 +0200 Subject: [PATCH 21/33] Remove print --- lib/model/KnowledgePanels.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/model/KnowledgePanels.dart b/lib/model/KnowledgePanels.dart index 0a3c30b790..b9019c0386 100644 --- a/lib/model/KnowledgePanels.dart +++ b/lib/model/KnowledgePanels.dart @@ -8,7 +8,6 @@ class KnowledgePanels { const KnowledgePanels({required this.panelIdToPanelMap}); factory KnowledgePanels.fromJson(Map json) { - print(json); Map map = {}; for (var panelId in json.keys) { map[panelId] = KnowledgePanel.fromJson(json[panelId]); From 3158b3b7872aa29df3943518bbaa304b15b89cf2 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 12 Oct 2021 13:50:48 +0200 Subject: [PATCH 22/33] Prepare release of version 1.3.7 --- CHANGELOG.md | 2 ++ pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a7e590d9b..0957ccccf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## [1.3.7] - 12.10.2021 +- Update KnowledgePanel API to comply to the latest Backend changes. ## [1.3.6] - 10.10.2021 - Fix issue with `Nutriments` JSON conversion related to microgram units - Support password reset diff --git a/pubspec.yaml b/pubspec.yaml index ef07c8d949..66dc5f1c25 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: openfoodfacts description: Dart package for the Open Food Facts API, a food products database made by everyone, for everyone. -version: 1.3.6 +version: 1.3.7 homepage: https://github.com/openfoodfacts/openfoodfacts-dart environment: From f650d9a74416dafc75343c072f1e9cf674ed4810 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 19 Oct 2021 19:29:20 +0200 Subject: [PATCH 23/33] Column should not have list text and type --- lib/model/KnowledgePanelElement.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index 11ad3cb0b9..1c11ae6e9b 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -153,9 +153,9 @@ class KnowledgePanelTableRowElement extends JsonObject { /// A descriptor that describes the type and label of each column. @JsonSerializable() class KnowledgePanelTableColumn extends JsonObject { - final List text; + final String text; - final List type; + final String type; const KnowledgePanelTableColumn({required this.text, required this.type}); From 5a716bf60d1028f9124623fdbc6723391c882f5a Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Wed, 20 Oct 2021 10:43:20 +0200 Subject: [PATCH 24/33] Column should not have list text and type --- lib/model/KnowledgePanelElement.dart | 4 ++-- lib/model/KnowledgePanelElement.g.dart | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index 1c11ae6e9b..921bce583c 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -178,7 +178,7 @@ class KnowledgePanelTableElement extends JsonObject { final String title; @JsonKey(name: 'columns') - final List columnsDescriptor; + final List column; final List rows; @@ -186,7 +186,7 @@ class KnowledgePanelTableElement extends JsonObject { required this.tableId, required this.tableType, required this.title, - required this.columnsDescriptor, + required this.column, required this.rows, }); diff --git a/lib/model/KnowledgePanelElement.g.dart b/lib/model/KnowledgePanelElement.g.dart index eb03f3325c..3047027160 100644 --- a/lib/model/KnowledgePanelElement.g.dart +++ b/lib/model/KnowledgePanelElement.g.dart @@ -137,8 +137,8 @@ Map _$KnowledgePanelTableRowElementToJson( KnowledgePanelTableColumn _$KnowledgePanelTableColumnFromJson( Map json) => KnowledgePanelTableColumn( - text: (json['text'] as List).map((e) => e as String).toList(), - type: (json['type'] as List).map((e) => e as String).toList(), + text: json['text'] as String, + type: json['type'] as String, ); Map _$KnowledgePanelTableColumnToJson( @@ -154,7 +154,7 @@ KnowledgePanelTableElement _$KnowledgePanelTableElementFromJson( tableId: json['table_id'] as String, tableType: json['table_type'] as String, title: json['title'] as String, - columnsDescriptor: (json['columns'] as List) + column: (json['columns'] as List) .map((e) => KnowledgePanelTableColumn.fromJson(e as Map)) .toList(), @@ -170,7 +170,7 @@ Map _$KnowledgePanelTableElementToJson( 'table_id': instance.tableId, 'table_type': instance.tableType, 'title': instance.title, - 'columns': instance.columnsDescriptor, + 'columns': instance.column, 'rows': instance.rows, }; From d6ba22649680d7aafefe1a057631e337dfa78c4d Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Wed, 20 Oct 2021 14:14:54 +0200 Subject: [PATCH 25/33] Column should not have list text and type --- lib/model/KnowledgePanelElement.dart | 4 ++-- lib/model/KnowledgePanelElement.g.dart | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index 921bce583c..72043a0bfe 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -178,7 +178,7 @@ class KnowledgePanelTableElement extends JsonObject { final String title; @JsonKey(name: 'columns') - final List column; + final List columns; final List rows; @@ -186,7 +186,7 @@ class KnowledgePanelTableElement extends JsonObject { required this.tableId, required this.tableType, required this.title, - required this.column, + required this.columns, required this.rows, }); diff --git a/lib/model/KnowledgePanelElement.g.dart b/lib/model/KnowledgePanelElement.g.dart index 3047027160..5e28ca61e5 100644 --- a/lib/model/KnowledgePanelElement.g.dart +++ b/lib/model/KnowledgePanelElement.g.dart @@ -154,7 +154,7 @@ KnowledgePanelTableElement _$KnowledgePanelTableElementFromJson( tableId: json['table_id'] as String, tableType: json['table_type'] as String, title: json['title'] as String, - column: (json['columns'] as List) + columns: (json['columns'] as List) .map((e) => KnowledgePanelTableColumn.fromJson(e as Map)) .toList(), @@ -170,7 +170,7 @@ Map _$KnowledgePanelTableElementToJson( 'table_id': instance.tableId, 'table_type': instance.tableType, 'title': instance.title, - 'columns': instance.column, + 'columns': instance.columns, 'rows': instance.rows, }; From 6b824014c39b92512a90824d8c78b97150b42d79 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Wed, 20 Oct 2021 17:18:40 +0200 Subject: [PATCH 26/33] Changes to KnowledgePanel API to comply to the server response --- lib/model/KnowledgePanel.dart | 3 ++ lib/model/KnowledgePanel.g.dart | 2 + lib/model/KnowledgePanelElement.dart | 25 ++++++++----- lib/model/KnowledgePanelElement.g.dart | 51 ++++++++++++++++++-------- 4 files changed, 55 insertions(+), 26 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 4aa36e3761..4c583d30ba 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -87,6 +87,8 @@ class KnowledgePanel extends JsonObject { @JsonKey(unknownEnumValue: Level.UNKNOWN) final Level level; + final bool? expanded; + /// KnowledgePanelElement is a single unit of KnowledgePanel that can be /// rendered on the client. final List? elements; @@ -112,6 +114,7 @@ class KnowledgePanel extends JsonObject { required this.parentPanelId, required this.titleElement, required this.level, + this.expanded, this.elements, this.type, this.topics, diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 3af9384e61..05ae4fc250 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -13,6 +13,7 @@ KnowledgePanel _$KnowledgePanelFromJson(Map json) => TitleElement.fromJson(json['title_element'] as Map), level: _$enumDecode(_$LevelEnumMap, json['level'], unknownValue: Level.UNKNOWN), + expanded: json['expanded'] as bool?, elements: (json['elements'] as List?) ?.map( (e) => KnowledgePanelElement.fromJson(e as Map)) @@ -31,6 +32,7 @@ Map _$KnowledgePanelToJson(KnowledgePanel instance) => 'parent_panel_id': instance.parentPanelId, 'title_element': instance.titleElement, 'level': _$LevelEnumMap[instance.level], + 'expanded': instance.expanded, 'elements': instance.elements, 'type': _$KnowledgePanelTypeEnumMap[instance.type], 'topics': instance.topics, diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index 72043a0bfe..06116a520c 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -1,4 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; +import 'package:openfoodfacts/model/KnowledgePanel.dart'; import '../interface/JsonObject.dart'; part 'KnowledgePanelElement.g.dart'; @@ -33,9 +34,9 @@ class KnowledgePanelTextElement extends JsonObject { @JsonKey( name: 'text_type', unknownEnumValue: KnowledgePanelTextElementType.UNKNOWN) - final KnowledgePanelTextElementType type; + final KnowledgePanelTextElementType? type; - const KnowledgePanelTextElement({required this.html, required this.type}); + const KnowledgePanelTextElement({required this.html, this.type}); factory KnowledgePanelTextElement.fromJson(Map json) => _$KnowledgePanelTextElementFromJson(json); @@ -124,8 +125,12 @@ class KnowledgePanelTableCell extends JsonObject { @JsonKey(name: 'icon_url') final String? iconUrl; + /// Evaluation of the table cell. + @JsonKey(unknownEnumValue: Evaluation.UNKNOWN) + final Evaluation? evaluation; + const KnowledgePanelTableCell( - {required this.text, this.percent, this.iconUrl}); + {required this.text, this.percent, this.iconUrl, this.evaluation}); factory KnowledgePanelTableCell.fromJson(Map json) => _$KnowledgePanelTableCellFromJson(json); @@ -137,11 +142,9 @@ class KnowledgePanelTableCell extends JsonObject { /// A table row inside Table element of KonwledgePanel @JsonSerializable() class KnowledgePanelTableRowElement extends JsonObject { - final String id; - final List values; - const KnowledgePanelTableRowElement({required this.id, required this.values}); + const KnowledgePanelTableRowElement({required this.values}); factory KnowledgePanelTableRowElement.fromJson(Map json) => _$KnowledgePanelTableRowElementFromJson(json); @@ -169,10 +172,9 @@ class KnowledgePanelTableColumn extends JsonObject { /// Element representing a tabular data for the KnowledgePanel. @JsonSerializable() class KnowledgePanelTableElement extends JsonObject { - @JsonKey(name: 'table_id') - final String tableId; + final String id; - @JsonKey(name: 'table_type') + @JsonKey(name: 'type') final String tableType; final String title; @@ -183,7 +185,7 @@ class KnowledgePanelTableElement extends JsonObject { final List rows; const KnowledgePanelTableElement({ - required this.tableId, + required this.id, required this.tableType, required this.title, required this.columns, @@ -228,9 +230,11 @@ class KnowledgePanelElement extends JsonObject { final KnowledgePanelElementType elementType; /// Text description of the Knowledge panel. + @JsonKey(name: 'text_element') final KnowledgePanelTextElement? textElement; /// Image element of the Knowledge panel. + @JsonKey(name: 'image_element') final KnowledgePanelImageElement? imageElement; /// Id of a KnowledgePanel embedded inside [this] KnowledgePanel. @@ -241,6 +245,7 @@ class KnowledgePanelElement extends JsonObject { final KnowledgePanelPanelGroupElement? panelGroupElement; /// Id of a KnowledgePanel embedded inside [this] KnowledgePanel. + @JsonKey(name: 'table_element') final KnowledgePanelTableElement? tableElement; const KnowledgePanelElement({ diff --git a/lib/model/KnowledgePanelElement.g.dart b/lib/model/KnowledgePanelElement.g.dart index 5e28ca61e5..ce2f971788 100644 --- a/lib/model/KnowledgePanelElement.g.dart +++ b/lib/model/KnowledgePanelElement.g.dart @@ -10,7 +10,7 @@ KnowledgePanelTextElement _$KnowledgePanelTextElementFromJson( Map json) => KnowledgePanelTextElement( html: json['html'] as String, - type: _$enumDecode( + type: _$enumDecodeNullable( _$KnowledgePanelTextElementTypeEnumMap, json['text_type'], unknownValue: KnowledgePanelTextElementType.UNKNOWN), ); @@ -48,6 +48,17 @@ K _$enumDecode( ).key; } +K? _$enumDecodeNullable( + Map enumValues, + dynamic source, { + K? unknownValue, +}) { + if (source == null) { + return null; + } + return _$enumDecode(enumValues, source, unknownValue: unknownValue); +} + const _$KnowledgePanelTextElementTypeEnumMap = { KnowledgePanelTextElementType.SUMMARY: 'summary', KnowledgePanelTextElementType.WARNING: 'warning', @@ -107,6 +118,8 @@ KnowledgePanelTableCell _$KnowledgePanelTableCellFromJson( text: json['text'] as String, percent: (json['percent'] as num?)?.toDouble(), iconUrl: json['icon_url'] as String?, + evaluation: _$enumDecodeNullable(_$EvaluationEnumMap, json['evaluation'], + unknownValue: Evaluation.UNKNOWN), ); Map _$KnowledgePanelTableCellToJson( @@ -115,12 +128,19 @@ Map _$KnowledgePanelTableCellToJson( 'text': instance.text, 'percent': instance.percent, 'icon_url': instance.iconUrl, + 'evaluation': _$EvaluationEnumMap[instance.evaluation], }; +const _$EvaluationEnumMap = { + Evaluation.GOOD: 'good', + Evaluation.NEUTRAL: 'neutral', + Evaluation.BAD: 'bad', + Evaluation.UNKNOWN: 'UNKNOWN', +}; + KnowledgePanelTableRowElement _$KnowledgePanelTableRowElementFromJson( Map json) => KnowledgePanelTableRowElement( - id: json['id'] as String, values: (json['values'] as List) .map((e) => KnowledgePanelTableCell.fromJson(e as Map)) @@ -130,7 +150,6 @@ KnowledgePanelTableRowElement _$KnowledgePanelTableRowElementFromJson( Map _$KnowledgePanelTableRowElementToJson( KnowledgePanelTableRowElement instance) => { - 'id': instance.id, 'values': instance.values, }; @@ -151,8 +170,8 @@ Map _$KnowledgePanelTableColumnToJson( KnowledgePanelTableElement _$KnowledgePanelTableElementFromJson( Map json) => KnowledgePanelTableElement( - tableId: json['table_id'] as String, - tableType: json['table_type'] as String, + id: json['id'] as String, + tableType: json['type'] as String, title: json['title'] as String, columns: (json['columns'] as List) .map((e) => @@ -167,8 +186,8 @@ KnowledgePanelTableElement _$KnowledgePanelTableElementFromJson( Map _$KnowledgePanelTableElementToJson( KnowledgePanelTableElement instance) => { - 'table_id': instance.tableId, - 'table_type': instance.tableType, + 'id': instance.id, + 'type': instance.tableType, 'title': instance.title, 'columns': instance.columns, 'rows': instance.rows, @@ -179,14 +198,14 @@ KnowledgePanelElement _$KnowledgePanelElementFromJson( KnowledgePanelElement( elementType: _$enumDecode( _$KnowledgePanelElementTypeEnumMap, json['element_type']), - textElement: json['textElement'] == null + textElement: json['text_element'] == null ? null : KnowledgePanelTextElement.fromJson( - json['textElement'] as Map), - imageElement: json['imageElement'] == null + json['text_element'] as Map), + imageElement: json['image_element'] == null ? null : KnowledgePanelImageElement.fromJson( - json['imageElement'] as Map), + json['image_element'] as Map), panelElement: json['panel_element'] == null ? null : KnowledgePanelPanelIdElement.fromJson( @@ -195,21 +214,21 @@ KnowledgePanelElement _$KnowledgePanelElementFromJson( ? null : KnowledgePanelPanelGroupElement.fromJson( json['panel_group'] as Map), - tableElement: json['tableElement'] == null + tableElement: json['table_element'] == null ? null : KnowledgePanelTableElement.fromJson( - json['tableElement'] as Map), + json['table_element'] as Map), ); Map _$KnowledgePanelElementToJson( KnowledgePanelElement instance) => { 'element_type': _$KnowledgePanelElementTypeEnumMap[instance.elementType], - 'textElement': instance.textElement, - 'imageElement': instance.imageElement, + 'text_element': instance.textElement, + 'image_element': instance.imageElement, 'panel_element': instance.panelElement, 'panel_group': instance.panelGroupElement, - 'tableElement': instance.tableElement, + 'table_element': instance.tableElement, }; const _$KnowledgePanelElementTypeEnumMap = { From 8ba12e139bf0c43b21d8736c0a36574d9f280f7f Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Wed, 20 Oct 2021 17:34:55 +0200 Subject: [PATCH 27/33] Changes to KnowledgePanel API to comply to the server response --- lib/model/KnowledgePanelElement.dart | 4 ++-- lib/model/KnowledgePanelElement.g.dart | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index 06116a520c..c8e91eb946 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -175,7 +175,7 @@ class KnowledgePanelTableElement extends JsonObject { final String id; @JsonKey(name: 'type') - final String tableType; + final String type; final String title; @@ -186,7 +186,7 @@ class KnowledgePanelTableElement extends JsonObject { const KnowledgePanelTableElement({ required this.id, - required this.tableType, + required this.type, required this.title, required this.columns, required this.rows, diff --git a/lib/model/KnowledgePanelElement.g.dart b/lib/model/KnowledgePanelElement.g.dart index ce2f971788..a4e24e758d 100644 --- a/lib/model/KnowledgePanelElement.g.dart +++ b/lib/model/KnowledgePanelElement.g.dart @@ -171,7 +171,7 @@ KnowledgePanelTableElement _$KnowledgePanelTableElementFromJson( Map json) => KnowledgePanelTableElement( id: json['id'] as String, - tableType: json['type'] as String, + type: json['type'] as String, title: json['title'] as String, columns: (json['columns'] as List) .map((e) => @@ -187,7 +187,7 @@ Map _$KnowledgePanelTableElementToJson( KnowledgePanelTableElement instance) => { 'id': instance.id, - 'type': instance.tableType, + 'type': instance.type, 'title': instance.title, 'columns': instance.columns, 'rows': instance.rows, From 1e7e1139d7c43fd3b0a4042465b81dc716b6d042 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Thu, 21 Oct 2021 17:16:05 +0200 Subject: [PATCH 28/33] Fix tests --- test/knowledge_panels_from_json_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/knowledge_panels_from_json_test.dart b/test/knowledge_panels_from_json_test.dart index 58d17c6164..e1e6a3221b 100644 --- a/test/knowledge_panels_from_json_test.dart +++ b/test/knowledge_panels_from_json_test.dart @@ -149,7 +149,7 @@ void main() { ] } ], - 'table_type': 'percents', + 'type': 'percents', 'title': 'Details of the impacts by stages of the life cycle' } } @@ -251,7 +251,7 @@ void main() { ] } ], - 'table_type': 'percents', + 'type': 'percents', 'title': 'Details of the impacts by stages of the life cycle' } } From 2eb95a31dbafc3792ef20063650560a92ffe9eab Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 16 Nov 2021 11:15:44 +0100 Subject: [PATCH 29/33] Update KP --- lib/model/KnowledgePanel.dart | 75 +++++++++++--------------- lib/model/KnowledgePanel.g.dart | 62 ++++++++++----------- lib/model/KnowledgePanelElement.dart | 46 +++++++++------- lib/model/KnowledgePanelElement.g.dart | 24 +++++---- 4 files changed, 100 insertions(+), 107 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 4c583d30ba..675b0ba071 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -5,26 +5,6 @@ import 'KnowledgePanelElement.dart'; part 'KnowledgePanel.g.dart'; -/// Type of the KnowledgePanel. -enum KnowledgePanelType { - /// Do you know types informative Knowledge Panels. - @JsonValue('doyouknow') - DO_YOU_KNOW, - - /// Knowledge Panel with ecoscore information. - @JsonValue('score') - SCORE, - - /// Knowledge Panel with ecoscore LCA. - @JsonValue('ecoscore_lca') - ECOSCORE_LCA, - - /// Knowledge Panel which is rendered as a card on the UI. - @JsonValue('card') - CARD, - UNKNOWN, -} - /// Level of information conveyed by this KnowledgePanel. /// /// Client may choose to display the panel based on the level. @@ -58,13 +38,21 @@ enum Grade { /// Evaluation of the panel, depicting whether the content of the panel is /// good/bad/neutral for the topic to which the panel applies. enum Evaluation { - @JsonValue('good') - GOOD, - @JsonValue('neutral') - NEUTRAL, - @JsonValue('bad') - BAD, - UNKNOWN, +@JsonValue('good') +GOOD, +@JsonValue('average') +AVERAGE, +@JsonValue('bad') +BAD, +UNKNOWN, +} + +/// Type of title element. +enum TitleElementType { + // Title Element depicts a grade like 'Ecoscore' or 'Nutriscore'. +@JsonValue('grade') +GRADE, +UNKNOWN, } /// KnowledgePanels are a standardized and generic units of information that @@ -74,10 +62,6 @@ enum Evaluation { // NOTE: This is WIP, do not use and expect changes. @JsonSerializable() class KnowledgePanel extends JsonObject { - /// Panel id of the parent panel. - @JsonKey(name: 'parent_panel_id') - final String parentPanelId; - /// Title of the KnowledgePanel. @JsonKey(name: 'title_element') final TitleElement titleElement; @@ -85,7 +69,7 @@ class KnowledgePanel extends JsonObject { /// Level of this KnowledgePanel. Client may choose to display the panel based /// on the level. @JsonKey(unknownEnumValue: Level.UNKNOWN) - final Level level; + final Level? level; final bool? expanded; @@ -93,32 +77,20 @@ class KnowledgePanel extends JsonObject { /// rendered on the client. final List? elements; - final KnowledgePanelType? type; - /// The topics discussed in this knowledge panel, example: 'Environment'. final List? topics; - /// Grade of the panel, depicting the level of impact the product has for the - /// corresponding topics. Client can choose to color code the panel depending - /// on how good/bad the grade is. - /// Scale: 'A' -> 'E' - @JsonKey(unknownEnumValue: Grade.UNKNOWN) - final Grade? grade; - /// Evaluation of the panel, depicting whether the content of the panel is /// good/bad/neutral for the topic to which the panel applies. @JsonKey(unknownEnumValue: Evaluation.UNKNOWN) final Evaluation? evaluation; const KnowledgePanel({ - required this.parentPanelId, required this.titleElement, - required this.level, + this.level, this.expanded, this.elements, - this.type, this.topics, - this.grade, this.evaluation, }); @@ -139,6 +111,17 @@ class TitleElement extends JsonObject { /// Subtitle of the panel. Example - 'High environmental impact'. final String? subtitle; + /// Grade of the panel, depicting the level of impact the product has for the + /// corresponding topics. Client can choose to color code the panel depending + /// on how good/bad the grade is. + /// Scale: 'A' -> 'E' + @JsonKey(unknownEnumValue: Grade.UNKNOWN) + final Grade? grade; + + /// Type of the TitleElement. + @JsonKey(unknownEnumValue: TitleElementType.UNKNOWN) + final TitleElementType? type; + /// URL of an icon representing the Panel. @JsonKey(name: 'icon_url') final String? iconUrl; @@ -152,6 +135,8 @@ class TitleElement extends JsonObject { const TitleElement({ required this.title, this.subtitle, + this.grade, + this.type, this.iconUrl, this.iconColorFromEvaluation, }); diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 05ae4fc250..134d25a10f 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -8,35 +8,28 @@ part of 'KnowledgePanel.dart'; KnowledgePanel _$KnowledgePanelFromJson(Map json) => KnowledgePanel( - parentPanelId: json['parent_panel_id'] as String, titleElement: TitleElement.fromJson(json['title_element'] as Map), - level: _$enumDecode(_$LevelEnumMap, json['level'], + level: _$enumDecodeNullable(_$LevelEnumMap, json['level'], unknownValue: Level.UNKNOWN), expanded: json['expanded'] as bool?, elements: (json['elements'] as List?) ?.map( (e) => KnowledgePanelElement.fromJson(e as Map)) .toList(), - type: _$enumDecodeNullable(_$KnowledgePanelTypeEnumMap, json['type']), topics: (json['topics'] as List?)?.map((e) => e as String).toList(), - grade: _$enumDecodeNullable(_$GradeEnumMap, json['grade'], - unknownValue: Grade.UNKNOWN), evaluation: _$enumDecodeNullable(_$EvaluationEnumMap, json['evaluation'], unknownValue: Evaluation.UNKNOWN), ); Map _$KnowledgePanelToJson(KnowledgePanel instance) => { - 'parent_panel_id': instance.parentPanelId, 'title_element': instance.titleElement, 'level': _$LevelEnumMap[instance.level], 'expanded': instance.expanded, 'elements': instance.elements, - 'type': _$KnowledgePanelTypeEnumMap[instance.type], 'topics': instance.topics, - 'grade': _$GradeEnumMap[instance.grade], 'evaluation': _$EvaluationEnumMap[instance.evaluation], }; @@ -66,15 +59,6 @@ K _$enumDecode( ).key; } -const _$LevelEnumMap = { - Level.TRIVIA: 'trivia', - Level.INFO: 'info', - Level.HELPFUL: 'helpful', - Level.WARNING: 'warning', - Level.ALERT: 'alert', - Level.UNKNOWN: 'UNKNOWN', -}; - K? _$enumDecodeNullable( Map enumValues, dynamic source, { @@ -86,26 +70,18 @@ K? _$enumDecodeNullable( return _$enumDecode(enumValues, source, unknownValue: unknownValue); } -const _$KnowledgePanelTypeEnumMap = { - KnowledgePanelType.DO_YOU_KNOW: 'doyouknow', - KnowledgePanelType.SCORE: 'score', - KnowledgePanelType.ECOSCORE_LCA: 'ecoscore_lca', - KnowledgePanelType.CARD: 'card', - KnowledgePanelType.UNKNOWN: 'UNKNOWN', -}; - -const _$GradeEnumMap = { - Grade.A: 'A', - Grade.B: 'B', - Grade.C: 'C', - Grade.D: 'D', - Grade.E: 'E', - Grade.UNKNOWN: 'UNKNOWN', +const _$LevelEnumMap = { + Level.TRIVIA: 'trivia', + Level.INFO: 'info', + Level.HELPFUL: 'helpful', + Level.WARNING: 'warning', + Level.ALERT: 'alert', + Level.UNKNOWN: 'UNKNOWN', }; const _$EvaluationEnumMap = { Evaluation.GOOD: 'good', - Evaluation.NEUTRAL: 'neutral', + Evaluation.AVERAGE: 'average', Evaluation.BAD: 'bad', Evaluation.UNKNOWN: 'UNKNOWN', }; @@ -113,6 +89,10 @@ const _$EvaluationEnumMap = { TitleElement _$TitleElementFromJson(Map json) => TitleElement( title: json['title'] as String, subtitle: json['subtitle'] as String?, + grade: _$enumDecodeNullable(_$GradeEnumMap, json['grade'], + unknownValue: Grade.UNKNOWN), + type: _$enumDecodeNullable(_$TitleElementTypeEnumMap, json['type'], + unknownValue: TitleElementType.UNKNOWN), iconUrl: json['icon_url'] as String?, iconColorFromEvaluation: json['icon_color_from_evaluation'] as bool? ?? false, @@ -122,6 +102,22 @@ Map _$TitleElementToJson(TitleElement instance) => { 'title': instance.title, 'subtitle': instance.subtitle, + 'grade': _$GradeEnumMap[instance.grade], + 'type': _$TitleElementTypeEnumMap[instance.type], 'icon_url': instance.iconUrl, 'icon_color_from_evaluation': instance.iconColorFromEvaluation, }; + +const _$GradeEnumMap = { + Grade.A: 'A', + Grade.B: 'B', + Grade.C: 'C', + Grade.D: 'D', + Grade.E: 'E', + Grade.UNKNOWN: 'UNKNOWN', +}; + +const _$TitleElementTypeEnumMap = { + TitleElementType.GRADE: 'grade', + TitleElementType.UNKNOWN: 'UNKNOWN', +}; diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index c8e91eb946..c667e87b0c 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -6,21 +6,31 @@ part 'KnowledgePanelElement.g.dart'; /// The type of Knowledge panel text description. enum KnowledgePanelTextElementType { - /// The description summarizes the knowledge panel. - @JsonValue('summary') - SUMMARY, +/// The description summarizes the knowledge panel. +@JsonValue('summary') +SUMMARY, - @JsonValue('warning') - WARNING, +@JsonValue('warning') +WARNING, - /// Disclaimer notes that the client may or may not choose to display. - @JsonValue('notes') - NOTES, +/// Disclaimer notes that the client may or may not choose to display. +@JsonValue('notes') +NOTES, - /// Default type of the text element, this is just a normal description. - @JsonValue('notes') - DEFAULT, - UNKNOWN, +/// Default type of the text element, this is just a normal description. +@JsonValue('notes') +DEFAULT, +} + +/// The type of Knowledge panel table column. +enum KnowledgePanelColumnType { +/// The column contains text elements. +@JsonValue('text') +TEXT, + +/// The column has percentages. +@JsonValue('percent') +PERCENT, } /// Description element of the Knowledge panel. @@ -33,7 +43,7 @@ class KnowledgePanelTextElement extends JsonObject { /// depending upon the type. @JsonKey( name: 'text_type', - unknownEnumValue: KnowledgePanelTextElementType.UNKNOWN) + unknownEnumValue: KnowledgePanelTextElementType.DEFAULT) final KnowledgePanelTextElementType? type; const KnowledgePanelTextElement({required this.html, this.type}); @@ -158,7 +168,9 @@ class KnowledgePanelTableRowElement extends JsonObject { class KnowledgePanelTableColumn extends JsonObject { final String text; - final String type; + @JsonKey( + unknownEnumValue: KnowledgePanelColumnType.TEXT) + final KnowledgePanelColumnType? type; const KnowledgePanelTableColumn({required this.text, required this.type}); @@ -174,9 +186,6 @@ class KnowledgePanelTableColumn extends JsonObject { class KnowledgePanelTableElement extends JsonObject { final String id; - @JsonKey(name: 'type') - final String type; - final String title; @JsonKey(name: 'columns') @@ -186,7 +195,6 @@ class KnowledgePanelTableElement extends JsonObject { const KnowledgePanelTableElement({ required this.id, - required this.type, required this.title, required this.columns, required this.rows, @@ -241,7 +249,7 @@ class KnowledgePanelElement extends JsonObject { @JsonKey(name: 'panel_element') final KnowledgePanelPanelIdElement? panelElement; - @JsonKey(name: 'panel_group') + @JsonKey(name: 'panel_group_element') final KnowledgePanelPanelGroupElement? panelGroupElement; /// Id of a KnowledgePanel embedded inside [this] KnowledgePanel. diff --git a/lib/model/KnowledgePanelElement.g.dart b/lib/model/KnowledgePanelElement.g.dart index a4e24e758d..56599817b6 100644 --- a/lib/model/KnowledgePanelElement.g.dart +++ b/lib/model/KnowledgePanelElement.g.dart @@ -12,7 +12,7 @@ KnowledgePanelTextElement _$KnowledgePanelTextElementFromJson( html: json['html'] as String, type: _$enumDecodeNullable( _$KnowledgePanelTextElementTypeEnumMap, json['text_type'], - unknownValue: KnowledgePanelTextElementType.UNKNOWN), + unknownValue: KnowledgePanelTextElementType.DEFAULT), ); Map _$KnowledgePanelTextElementToJson( @@ -64,7 +64,6 @@ const _$KnowledgePanelTextElementTypeEnumMap = { KnowledgePanelTextElementType.WARNING: 'warning', KnowledgePanelTextElementType.NOTES: 'notes', KnowledgePanelTextElementType.DEFAULT: 'notes', - KnowledgePanelTextElementType.UNKNOWN: 'UNKNOWN', }; KnowledgePanelImageElement _$KnowledgePanelImageElementFromJson( @@ -133,7 +132,7 @@ Map _$KnowledgePanelTableCellToJson( const _$EvaluationEnumMap = { Evaluation.GOOD: 'good', - Evaluation.NEUTRAL: 'neutral', + Evaluation.AVERAGE: 'average', Evaluation.BAD: 'bad', Evaluation.UNKNOWN: 'UNKNOWN', }; @@ -157,21 +156,27 @@ KnowledgePanelTableColumn _$KnowledgePanelTableColumnFromJson( Map json) => KnowledgePanelTableColumn( text: json['text'] as String, - type: json['type'] as String, + type: _$enumDecodeNullable( + _$KnowledgePanelColumnTypeEnumMap, json['type'], + unknownValue: KnowledgePanelColumnType.TEXT), ); Map _$KnowledgePanelTableColumnToJson( KnowledgePanelTableColumn instance) => { 'text': instance.text, - 'type': instance.type, + 'type': _$KnowledgePanelColumnTypeEnumMap[instance.type], }; +const _$KnowledgePanelColumnTypeEnumMap = { + KnowledgePanelColumnType.TEXT: 'text', + KnowledgePanelColumnType.PERCENT: 'percent', +}; + KnowledgePanelTableElement _$KnowledgePanelTableElementFromJson( Map json) => KnowledgePanelTableElement( id: json['id'] as String, - type: json['type'] as String, title: json['title'] as String, columns: (json['columns'] as List) .map((e) => @@ -187,7 +192,6 @@ Map _$KnowledgePanelTableElementToJson( KnowledgePanelTableElement instance) => { 'id': instance.id, - 'type': instance.type, 'title': instance.title, 'columns': instance.columns, 'rows': instance.rows, @@ -210,10 +214,10 @@ KnowledgePanelElement _$KnowledgePanelElementFromJson( ? null : KnowledgePanelPanelIdElement.fromJson( json['panel_element'] as Map), - panelGroupElement: json['panel_group'] == null + panelGroupElement: json['panel_group_element'] == null ? null : KnowledgePanelPanelGroupElement.fromJson( - json['panel_group'] as Map), + json['panel_group_element'] as Map), tableElement: json['table_element'] == null ? null : KnowledgePanelTableElement.fromJson( @@ -227,7 +231,7 @@ Map _$KnowledgePanelElementToJson( 'text_element': instance.textElement, 'image_element': instance.imageElement, 'panel_element': instance.panelElement, - 'panel_group': instance.panelGroupElement, + 'panel_group_element': instance.panelGroupElement, 'table_element': instance.tableElement, }; From 3e31210c6cbef2fe654fcd2bcf2058633909a6d3 Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 16 Nov 2021 11:16:44 +0100 Subject: [PATCH 30/33] Update KP --- lib/model/KnowledgePanel.dart | 20 +++++++-------- lib/model/KnowledgePanelElement.dart | 37 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 675b0ba071..4e12658147 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -38,21 +38,21 @@ enum Grade { /// Evaluation of the panel, depicting whether the content of the panel is /// good/bad/neutral for the topic to which the panel applies. enum Evaluation { -@JsonValue('good') -GOOD, -@JsonValue('average') -AVERAGE, -@JsonValue('bad') -BAD, -UNKNOWN, + @JsonValue('good') + GOOD, + @JsonValue('average') + AVERAGE, + @JsonValue('bad') + BAD, + UNKNOWN, } /// Type of title element. enum TitleElementType { // Title Element depicts a grade like 'Ecoscore' or 'Nutriscore'. -@JsonValue('grade') -GRADE, -UNKNOWN, + @JsonValue('grade') + GRADE, + UNKNOWN, } /// KnowledgePanels are a standardized and generic units of information that diff --git a/lib/model/KnowledgePanelElement.dart b/lib/model/KnowledgePanelElement.dart index c667e87b0c..5784a53941 100644 --- a/lib/model/KnowledgePanelElement.dart +++ b/lib/model/KnowledgePanelElement.dart @@ -6,31 +6,31 @@ part 'KnowledgePanelElement.g.dart'; /// The type of Knowledge panel text description. enum KnowledgePanelTextElementType { -/// The description summarizes the knowledge panel. -@JsonValue('summary') -SUMMARY, + /// The description summarizes the knowledge panel. + @JsonValue('summary') + SUMMARY, -@JsonValue('warning') -WARNING, + @JsonValue('warning') + WARNING, -/// Disclaimer notes that the client may or may not choose to display. -@JsonValue('notes') -NOTES, + /// Disclaimer notes that the client may or may not choose to display. + @JsonValue('notes') + NOTES, -/// Default type of the text element, this is just a normal description. -@JsonValue('notes') -DEFAULT, + /// Default type of the text element, this is just a normal description. + @JsonValue('notes') + DEFAULT, } /// The type of Knowledge panel table column. enum KnowledgePanelColumnType { -/// The column contains text elements. -@JsonValue('text') -TEXT, + /// The column contains text elements. + @JsonValue('text') + TEXT, -/// The column has percentages. -@JsonValue('percent') -PERCENT, + /// The column has percentages. + @JsonValue('percent') + PERCENT, } /// Description element of the Knowledge panel. @@ -168,8 +168,7 @@ class KnowledgePanelTableRowElement extends JsonObject { class KnowledgePanelTableColumn extends JsonObject { final String text; - @JsonKey( - unknownEnumValue: KnowledgePanelColumnType.TEXT) + @JsonKey(unknownEnumValue: KnowledgePanelColumnType.TEXT) final KnowledgePanelColumnType? type; const KnowledgePanelTableColumn({required this.text, required this.type}); From abd8663b58b35ccbdc315734673b3faa6c6509cf Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 16 Nov 2021 15:16:40 +0100 Subject: [PATCH 31/33] Fix KP --- lib/model/KnowledgePanel.dart | 4 ++-- lib/model/KnowledgePanel.g.dart | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 4e12658147..6fca132e45 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -64,7 +64,7 @@ enum TitleElementType { class KnowledgePanel extends JsonObject { /// Title of the KnowledgePanel. @JsonKey(name: 'title_element') - final TitleElement titleElement; + final TitleElement? titleElement; /// Level of this KnowledgePanel. Client may choose to display the panel based /// on the level. @@ -86,7 +86,7 @@ class KnowledgePanel extends JsonObject { final Evaluation? evaluation; const KnowledgePanel({ - required this.titleElement, + this.titleElement, this.level, this.expanded, this.elements, diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index 134d25a10f..fefd83fab9 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -8,8 +8,10 @@ part of 'KnowledgePanel.dart'; KnowledgePanel _$KnowledgePanelFromJson(Map json) => KnowledgePanel( - titleElement: - TitleElement.fromJson(json['title_element'] as Map), + titleElement: json['title_element'] == null + ? null + : TitleElement.fromJson( + json['title_element'] as Map), level: _$enumDecodeNullable(_$LevelEnumMap, json['level'], unknownValue: Level.UNKNOWN), expanded: json['expanded'] as bool?, From b53b43064a79cca790e1cdebb88acbdadbd514de Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 16 Nov 2021 16:40:52 +0100 Subject: [PATCH 32/33] Fix KP --- lib/model/KnowledgePanel.dart | 2 ++ lib/model/KnowledgePanel.g.dart | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 6fca132e45..82df4ef352 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -41,6 +41,8 @@ enum Evaluation { @JsonValue('good') GOOD, @JsonValue('average') + NEUTRAL, + @JsonValue('average') AVERAGE, @JsonValue('bad') BAD, diff --git a/lib/model/KnowledgePanel.g.dart b/lib/model/KnowledgePanel.g.dart index fefd83fab9..b19d4c2721 100644 --- a/lib/model/KnowledgePanel.g.dart +++ b/lib/model/KnowledgePanel.g.dart @@ -83,6 +83,7 @@ const _$LevelEnumMap = { const _$EvaluationEnumMap = { Evaluation.GOOD: 'good', + Evaluation.NEUTRAL: 'average', Evaluation.AVERAGE: 'average', Evaluation.BAD: 'bad', Evaluation.UNKNOWN: 'UNKNOWN', From 11e100dfa6ff8201b289220cd64bdf412e372abd Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Tue, 16 Nov 2021 16:41:20 +0100 Subject: [PATCH 33/33] Fix KP --- lib/model/KnowledgePanel.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/model/KnowledgePanel.dart b/lib/model/KnowledgePanel.dart index 82df4ef352..e8d8635dda 100644 --- a/lib/model/KnowledgePanel.dart +++ b/lib/model/KnowledgePanel.dart @@ -40,7 +40,7 @@ enum Grade { enum Evaluation { @JsonValue('good') GOOD, - @JsonValue('average') + @JsonValue('neutral') NEUTRAL, @JsonValue('average') AVERAGE,