From c491baf4bda68c09285ef15727e05099e1c1ee42 Mon Sep 17 00:00:00 2001 From: Hatim Dinia Date: Wed, 28 Feb 2024 13:54:48 +0100 Subject: [PATCH] refactor(areas): remove areas UI form fields (#1955) --- .../business/areas/properties_management.py | 34 ------------------- tests/integration/test_integration.py | 9 ----- webapp/public/locales/en/main.json | 2 -- webapp/public/locales/fr/main.json | 2 -- .../Modelization/Areas/Properties/Fields.tsx | 18 ---------- 5 files changed, 65 deletions(-) diff --git a/antarest/study/business/areas/properties_management.py b/antarest/study/business/areas/properties_management.py index 1c18ca2b45..7b09a08cf4 100644 --- a/antarest/study/business/areas/properties_management.py +++ b/antarest/study/business/areas/properties_management.py @@ -13,28 +13,12 @@ AREA_PATH = "input/areas/{area}" THERMAL_PATH = "input/thermal/areas/{field}/{{area}}" -UI_PATH = f"{AREA_PATH}/ui/ui" OPTIMIZATION_PATH = f"{AREA_PATH}/optimization" NODAL_OPTIMIZATION_PATH = f"{OPTIMIZATION_PATH}/nodal optimization" FILTERING_PATH = f"{OPTIMIZATION_PATH}/filtering" # Keep the order FILTER_OPTIONS = ["hourly", "daily", "weekly", "monthly", "annual"] DEFAULT_FILTER_VALUE = FILTER_OPTIONS -DEFAULT_UI = { - "color_r": 230, - "color_g": 108, - "color_b": 44, -} - - -def encode_color(ui: Dict[str, Any]) -> str: - data = {**DEFAULT_UI, **ui} - return f"{data['color_r']},{data['color_g']},{data['color_b']}" - - -def decode_color(encoded_color: str, current_ui: Optional[Dict[str, int]]) -> Dict[str, Any]: - r, g, b = map(int, encoded_color.split(",")) - return {**(current_ui or {}), "color_r": r, "color_g": g, "color_b": b} def sort_filter_options(options: Iterable[str]) -> List[str]: @@ -60,9 +44,6 @@ class AdequacyPatchMode(EnumIgnoreCase): class PropertiesFormFields(FormFieldsBaseModel): - color: Optional[str] = Field(regex="^\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*$") - pos_x: Optional[float] - pos_y: Optional[float] energy_cost_unsupplied: Optional[float] energy_cost_spilled: Optional[float] non_dispatch_power: Optional[bool] @@ -89,21 +70,6 @@ def validation(cls, values: Dict[str, Any]) -> Dict[str, Any]: FIELDS_INFO: Dict[str, FieldInfo] = { - # `color` must be before `pos_x` and `pos_y`, because they are include in the `decode_color`'s return dict value - "color": { - "path": UI_PATH, - "encode": encode_color, - "decode": decode_color, - "default_value": encode_color(DEFAULT_UI), - }, - "pos_x": { - "path": f"{UI_PATH}/x", - "default_value": 0.0, - }, - "pos_y": { - "path": f"{UI_PATH}/y", - "default_value": 0.0, - }, "energy_cost_unsupplied": { "path": THERMAL_PATH.format(field="unserverdenergycost"), "default_value": 0.0, diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index ffa4d4a91d..1dc1b385ae 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -1095,9 +1095,6 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id: res_properties_config_json["filterSynthesis"] = set(res_properties_config_json["filterSynthesis"]) res_properties_config_json["filterByYear"] = set(res_properties_config_json["filterByYear"]) assert res_properties_config_json == { - "color": "230,108,44", - "posX": 0.0, - "posY": 0.0, "energyCostUnsupplied": 0.0, "energyCostSpilled": 0.0, "nonDispatchPower": True, @@ -1112,9 +1109,6 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id: f"/v1/studies/{study_id}/areas/area 1/properties/form", headers=admin_headers, json={ - "color": "123,108,96", - "posX": 3.4, - "posY": 9.0, "energyCostUnsupplied": 2.0, "energyCostSpilled": 4.0, "nonDispatchPower": False, @@ -1130,9 +1124,6 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id: res_properties_config_json["filterSynthesis"] = set(res_properties_config_json["filterSynthesis"]) res_properties_config_json["filterByYear"] = set(res_properties_config_json["filterByYear"]) assert res_properties_config_json == { - "color": "123,108,96", - "posX": 3.4, - "posY": 9.0, "energyCostUnsupplied": 2.0, "energyCostSpilled": 4.0, "nonDispatchPower": False, diff --git a/webapp/public/locales/en/main.json b/webapp/public/locales/en/main.json index 81b9935f03..d70a1fc810 100644 --- a/webapp/public/locales/en/main.json +++ b/webapp/public/locales/en/main.json @@ -373,8 +373,6 @@ "study.configuration.geographicTrimmingAreas": "Geographic Trimming (areas)", "study.configuration.geographicTrimmingLinks": "Geographic Trimming (links)", "study.modelization.properties": "Properties", - "study.modelization.properties.posX": "Position X", - "study.modelization.properties.posY": "Position Y", "study.modelization.properties.energyCost": "Energy cost (€/Wh)", "study.modelization.properties.unsupplied": "Unsupplied", "study.modelization.properties.spilled": "Spilled", diff --git a/webapp/public/locales/fr/main.json b/webapp/public/locales/fr/main.json index 0f1f06ad45..17492deeb5 100644 --- a/webapp/public/locales/fr/main.json +++ b/webapp/public/locales/fr/main.json @@ -373,8 +373,6 @@ "study.configuration.geographicTrimmingAreas": "Filtre géographique (zones)", "study.configuration.geographicTrimmingLinks": "Filtre géographique (liens)", "study.modelization.properties": "Propriétés", - "study.modelization.properties.posX": "Position X", - "study.modelization.properties.posY": "Position Y", "study.modelization.properties.energyCost": "Coût de l'énergie", "study.modelization.properties.unsupplied": "Non distribuée", "study.modelization.properties.spilled": "Non évacuée", diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Properties/Fields.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Properties/Fields.tsx index 2ec3ec8df9..01a98538be 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Properties/Fields.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Properties/Fields.tsx @@ -3,7 +3,6 @@ import { useOutletContext } from "react-router"; import { useMemo } from "react"; import SelectFE from "../../../../../../common/fieldEditors/SelectFE"; import Fieldset from "../../../../../../common/Fieldset"; -import ColorPickerFE from "../../../../../../common/fieldEditors/ColorPickerFE"; import SwitchFE from "../../../../../../common/fieldEditors/SwitchFE"; import NumberFE from "../../../../../../common/fieldEditors/NumberFE"; import { useFormContextPlus } from "../../../../../../common/Form"; @@ -27,23 +26,6 @@ function Fields() { return ( <> -
- - - -