From 26cd64f2927de0fff5d2c46e1090b2c95b515b8e Mon Sep 17 00:00:00 2001 From: Miles Mason Winther <42948872+mmwinther@users.noreply.github.com> Date: Thu, 7 Mar 2024 12:53:48 +0100 Subject: [PATCH] Display existing values in the frontend (#204) --- poetry.lock | 18 +++--- pyproject.toml | 2 +- src/datadoc/frontend/callbacks/dataset.py | 5 +- .../frontend/callbacks/register_callbacks.py | 16 +++-- src/datadoc/frontend/callbacks/utils.py | 5 +- src/datadoc/frontend/callbacks/variables.py | 6 ++ .../resources_test_new_variables.py | 19 +++--- src/datadoc/frontend/fields/display_base.py | 63 ++++++++++++------- .../frontend/fields/display_new_variables.py | 49 +++++++-------- .../callbacks/test_dataset_callbacks.py | 1 + 10 files changed, 109 insertions(+), 75 deletions(-) diff --git a/poetry.lock b/poetry.lock index 2e1776bc..bdb34408 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "aiohttp" @@ -1226,12 +1226,12 @@ files = [ google-auth = ">=2.14.1,<3.0.dev0" googleapis-common-protos = ">=1.56.2,<2.0.dev0" grpcio = [ - {version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, {version = ">=1.33.2,<2.0dev", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""}, + {version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, ] grpcio-status = [ - {version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, {version = ">=1.33.2,<2.0.dev0", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""}, + {version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, ] protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0.dev0" requests = ">=2.18.0,<3.0.0.dev0" @@ -1318,8 +1318,8 @@ grpc-google-iam-v1 = ">=0.12.4,<1.0.0dev" grpcio = ">=1.51.3,<2.0dev" grpcio-status = ">=1.33.2" proto-plus = [ - {version = ">=1.22.2,<2.0.0dev", markers = "python_version >= \"3.11\""}, {version = ">=1.22.0,<2.0.0dev", markers = "python_version < \"3.11\""}, + {version = ">=1.22.2,<2.0.0dev", markers = "python_version >= \"3.11\""}, ] protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0dev" @@ -2595,9 +2595,9 @@ files = [ [package.dependencies] lxml = {version = ">=4.9.2", optional = true, markers = "extra == \"xml\""} numpy = [ + {version = ">=1.22.4,<2", markers = "python_version < \"3.11\""}, {version = ">=1.23.2,<2", markers = "python_version == \"3.11\""}, {version = ">=1.26.0,<2", markers = "python_version >= \"3.12\""}, - {version = ">=1.22.4,<2", markers = "python_version < \"3.11\""}, ] odfpy = {version = ">=1.4.1", optional = true, markers = "extra == \"excel\""} openpyxl = {version = ">=3.1.0", optional = true, markers = "extra == \"excel\""} @@ -4125,13 +4125,13 @@ sqlcipher = ["sqlcipher3_binary"] [[package]] name = "ssb-dash-components" -version = "0.4.1" +version = "0.5.2" description = "Dash Component library for SSB" optional = false python-versions = ">=3.9,<4.0" files = [ - {file = "ssb_dash_components-0.4.1-py3-none-any.whl", hash = "sha256:005149c1e3eba37fc4c2a2139d23d15d750c60bd3a9e135896a790eea3dae21a"}, - {file = "ssb_dash_components-0.4.1.tar.gz", hash = "sha256:0d1416b6181cd1ee889ab90c13cf6c26e0d62244eeb4bb694d024a7bc5c11f40"}, + {file = "ssb_dash_components-0.5.2-py3-none-any.whl", hash = "sha256:b247a84aea0b3990ae355d32adcb30c18ac10f4e292504bcf87643b7b7b87969"}, + {file = "ssb_dash_components-0.5.2.tar.gz", hash = "sha256:7175c275697ec484d31edc47238473e08e364dee0264e26e1b021a3f4b900899"}, ] [package.dependencies] @@ -4675,4 +4675,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.10,<4.0" -content-hash = "76358066a497e342d515bd98d8ace7cd022b03e569ef3e5902857ad05e82c39c" +content-hash = "c110d6b039fdbe5f89e8a98886b8361ead519d0a1621cb91672c72a719b86f47" diff --git a/pyproject.toml b/pyproject.toml index 95e4011f..8d76e9f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ beautifulsoup4 = ">=4.12.3" cloudpathlib = { extras = ["gs"], version = ">=0.17.0" } pyjwt = ">=2.8.0" ssb-klass-python = ">=0.0.9" -ssb-dash-components = ">=0.4.1" +ssb-dash-components = ">=0.5.2" [tool.poetry.group.dev.dependencies] mypy = ">=0.950" diff --git a/src/datadoc/frontend/callbacks/dataset.py b/src/datadoc/frontend/callbacks/dataset.py index a6d4b365..c23f6f2c 100644 --- a/src/datadoc/frontend/callbacks/dataset.py +++ b/src/datadoc/frontend/callbacks/dataset.py @@ -44,7 +44,10 @@ def open_file(file_path: str | None = None) -> DataDocMetadata: dataset = file_path or get_dataset_path() logger.info("Opening dataset %s", dataset) - return DataDocMetadata(state.statistic_subject_mapping, dataset_path=str(dataset)) + return DataDocMetadata( + state.statistic_subject_mapping, + dataset_path=str(dataset) if dataset else None, + ) def open_dataset_handling( diff --git a/src/datadoc/frontend/callbacks/register_callbacks.py b/src/datadoc/frontend/callbacks/register_callbacks.py index 24ae8232..5fb5563b 100644 --- a/src/datadoc/frontend/callbacks/register_callbacks.py +++ b/src/datadoc/frontend/callbacks/register_callbacks.py @@ -22,6 +22,7 @@ from datadoc.frontend.callbacks.dataset import accept_dataset_metadata_input from datadoc.frontend.callbacks.dataset import change_language_dataset_metadata from datadoc.frontend.callbacks.dataset import open_dataset_handling +from datadoc.frontend.callbacks.utils import update_global_language_state from datadoc.frontend.callbacks.variables import ( accept_variable_datatable_metadata_input, ) @@ -217,14 +218,19 @@ def register_new_variables_tab_callbacks(app: Dash) -> None: prevent_initial_call=True, ) def callback_populate_new_variables_workspace( - language: str, # noqa: ARG001 + language: str, ) -> list: """Create variable workspace with accordions for variables.""" + update_global_language_state(SupportedLanguages(language)) + logger.info("Populating new variables workspace") return [ build_ssb_accordion( - variable, - {"type": "variables-accordion", "id": variable}, - variable, + variable.short_name, + { + "type": "variables-accordion", + "id": f"{variable.short_name}-{language}", + }, + variable.short_name, children=[ build_edit_section( OBLIGATORY_VARIABLES_METADATA, @@ -240,7 +246,7 @@ def callback_populate_new_variables_workspace( ), ], ) - for variable in list(state.metadata.variables_lookup.keys()) + for variable in list(state.metadata.variables) ] @app.callback( diff --git a/src/datadoc/frontend/callbacks/utils.py b/src/datadoc/frontend/callbacks/utils.py index 33ed5d53..5aa26214 100644 --- a/src/datadoc/frontend/callbacks/utils.py +++ b/src/datadoc/frontend/callbacks/utils.py @@ -34,8 +34,9 @@ def update_global_language_state(language: SupportedLanguages) -> None: """Update global language state.""" - logger.debug("Updating language: %s", language.name) - state.current_metadata_language = language + if state.current_metadata_language != language: + logger.debug("Updating language: %s", language.name) + state.current_metadata_language = language def get_language_strings_enum( diff --git a/src/datadoc/frontend/callbacks/variables.py b/src/datadoc/frontend/callbacks/variables.py index f0f31390..20926bd7 100644 --- a/src/datadoc/frontend/callbacks/variables.py +++ b/src/datadoc/frontend/callbacks/variables.py @@ -223,6 +223,12 @@ def accept_variable_metadata_input( Returns an error message if an exception was raised, otherwise returns None. """ + logger.debug( + "Updating %s, %s with %s", + metadata_field, + variable_short_name, + value, + ) try: if metadata_field in MULTIPLE_LANGUAGE_VARIABLES_METADATA: new_value = handle_multi_language_metadata( diff --git a/src/datadoc/frontend/components/resources_test_new_variables.py b/src/datadoc/frontend/components/resources_test_new_variables.py index 2d626145..ffa63004 100644 --- a/src/datadoc/frontend/components/resources_test_new_variables.py +++ b/src/datadoc/frontend/components/resources_test_new_variables.py @@ -10,9 +10,9 @@ from dash import html if TYPE_CHECKING: - from datadoc.frontend.fields.display_new_variables import ( - DisplayNewVariablesMetadata, - ) + from datadoc_model import model + + from datadoc.frontend.fields.display_new_variables import VariablesInputField logger = logging.getLogger(__name__) @@ -23,11 +23,9 @@ VARIABLES_METADATA_INPUT = "variables-metadata-input" -# section of Inputs: Input, checkbox or dropdown - -# It is hard to separate between DisplayNewVariablesMetatdata and NewVariablesMetadataDropddown - with NewVariablesMetadataDropddown in type hint it's temporary solved def build_input_field_section( - metadata_inputs: list[DisplayNewVariablesMetadata], - variable_short_name: str, + metadata_inputs: list[VariablesInputField], + variable: model.Variable, language: str, ) -> dbc.Form: """Create input fields.""" @@ -36,10 +34,11 @@ def build_input_field_section( i.render( { "type": VARIABLES_METADATA_INPUT, - "variable_short_name": variable_short_name, + "variable_short_name": variable.short_name, "id": i.identifier, }, language, + variable, ) for i in metadata_inputs ], @@ -52,7 +51,7 @@ def build_input_field_section( def build_edit_section( metadata_inputs: list, title: str, - variable_short_name: str, + variable: model.Variable, language: str, ) -> html.Section: """Create input section.""" @@ -60,7 +59,7 @@ def build_edit_section( id={"type": "edit-section", "title": title}, children=[ ssb.Title(title, size=3, className="input-section-title"), - build_input_field_section(metadata_inputs, variable_short_name, language), + build_input_field_section(metadata_inputs, variable, language), ], className="input-section", ) diff --git a/src/datadoc/frontend/fields/display_base.py b/src/datadoc/frontend/fields/display_base.py index f8b285e0..9622f4d8 100644 --- a/src/datadoc/frontend/fields/display_base.py +++ b/src/datadoc/frontend/fields/display_base.py @@ -20,6 +20,7 @@ from collections.abc import Callable from dash.development.base_component import Component + from datadoc_model import model from datadoc_model.model import LanguageStringType from pydantic import BaseModel @@ -56,15 +57,15 @@ def new_input_kwargs_factory() -> dict[str, t.Any]: def get_standard_metadata(metadata: BaseModel, identifier: str) -> MetadataInputTypes: """Get a metadata value from the model.""" - value = metadata.model_dump()[identifier] - if value is None: - return None - return str(value) + return getattr(metadata, identifier) -def get_metadata_and_stringify(metadata: BaseModel, identifier: str) -> str: +def get_metadata_and_stringify(metadata: BaseModel, identifier: str) -> str | None: """Get a metadata value from the model and cast to string.""" - return str(get_standard_metadata(metadata, identifier)) + value = get_standard_metadata(metadata, identifier) + if value is None: + return None + return str(value) def get_multi_language_metadata(metadata: BaseModel, identifier: str) -> str | None: @@ -117,7 +118,7 @@ class DisplayDatasetMetadata(DisplayMetadata): extra_kwargs: dict[str, Any] = field(default_factory=input_kwargs_factory) component: type[Component] = dcc.Input - value_getter: Callable[[BaseModel, str], Any] = get_standard_metadata + value_getter: Callable[[BaseModel, str], Any] = get_metadata_and_stringify @dataclass @@ -131,63 +132,81 @@ class DisplayDatasetMetadataDropdown(DisplayDatasetMetadata): component: type[Component] = dcc.Dropdown -# New design for variables - Input , dropdown, checkbox -# Language for Input and Checkbox is not used, but trigger error if not handled when render @dataclass -class DisplayNewVariablesMetadata(DisplayMetadata): +class VariablesInputField(DisplayMetadata): """Controls for how a given metadata field should be displayed. Specific to variable fields. """ extra_kwargs: dict[str, Any] = field(default_factory=new_input_kwargs_factory) - value_getter: Callable[[BaseModel, str], Any] = get_standard_metadata + value_getter: Callable[[BaseModel, str], Any] = get_metadata_and_stringify type: str = "text" - def render(self, variable_id: dict, language: str) -> ssb.Input: - """Build Input component with props.""" - self.language = language + def render( + self, + variable_id: dict, + language: str, # noqa: ARG002 + variable: model.Variable, + ) -> ssb.Input: + """Build Input component.""" + value = self.value_getter(variable, self.identifier) return ssb.Input( label=self.display_name, id=variable_id, debounce=self.type != "date", type=self.type, disabled=not self.editable, + value=value, ) @dataclass -class DisplayNewVariablesMetadataDropdown(DisplayNewVariablesMetadata): +class VariablesDropdownField(DisplayMetadata): """Control how a Dropdown should be displayed.""" + extra_kwargs: dict[str, Any] = field(default_factory=new_input_kwargs_factory) + value_getter: Callable[[BaseModel, str], Any] = get_metadata_and_stringify # fmt: off options_getter: Callable[[SupportedLanguages], list[dict[str, str]]] = lambda _: [] # noqa: E731 # fmt: on - extra_kwargs: dict[str, Any] = field(default_factory=new_input_kwargs_factory) - def render(self, variable_id: dict, language: str) -> ssb.Dropdown: - """Build Dropdown component with props.""" + def render( + self, + variable_id: dict, + language: str, + variable: model.Variable, + ) -> ssb.Dropdown: + """Build Dropdown component.""" + value = self.value_getter(variable, self.identifier) return ssb.Dropdown( header=self.display_name, id=variable_id, items=self.options_getter(SupportedLanguages(language)), + value=value, ) @dataclass -class DisplayNewVariablesMetadataCheckbox(DisplayNewVariablesMetadata): +class VariablesCheckboxField(DisplayMetadata): """Controls for how a checkbox metadata field should be displayed.""" extra_kwargs: dict[str, Any] = field(default_factory=input_kwargs_factory) value_getter: Callable[[BaseModel, str], Any] = get_standard_metadata - def render(self, variable_id: dict, language: str) -> dbc.Checkbox: - """Build Dropdown component with props.""" - self.language = language + def render( + self, + variable_id: dict, + language: str, # noqa: ARG002 + variable: model.Variable, + ) -> dbc.Checkbox: + """Build Checkbox component.""" + value = self.value_getter(variable, self.identifier) return dbc.Checkbox( label=self.display_name, id=variable_id, disabled=not self.editable, label_class_name="ssb-checkbox checkbox-label", class_name="ssb-checkbox", + value=value, ) diff --git a/src/datadoc/frontend/fields/display_new_variables.py b/src/datadoc/frontend/fields/display_new_variables.py index 3e259b5b..5eb02c8c 100644 --- a/src/datadoc/frontend/fields/display_new_variables.py +++ b/src/datadoc/frontend/fields/display_new_variables.py @@ -9,9 +9,9 @@ from datadoc import enums from datadoc.frontend.callbacks.utils import get_language_strings_enum -from datadoc.frontend.fields.display_base import DisplayNewVariablesMetadata -from datadoc.frontend.fields.display_base import DisplayNewVariablesMetadataCheckbox -from datadoc.frontend.fields.display_base import DisplayNewVariablesMetadataDropdown +from datadoc.frontend.fields.display_base import VariablesCheckboxField +from datadoc.frontend.fields.display_base import VariablesDropdownField +from datadoc.frontend.fields.display_base import VariablesInputField from datadoc.frontend.fields.display_base import get_multi_language_metadata if TYPE_CHECKING: @@ -59,16 +59,16 @@ class NewVariableIdentifiers(str, Enum): DISPLAY_VARIABLES: dict[ NewVariableIdentifiers, - DisplayNewVariablesMetadata, + VariablesInputField | VariablesDropdownField | VariablesCheckboxField, ] = { - NewVariableIdentifiers.SHORT_NAME: DisplayNewVariablesMetadata( + NewVariableIdentifiers.SHORT_NAME: VariablesInputField( identifier=NewVariableIdentifiers.SHORT_NAME.value, display_name="Kortnavn", description="Fysisk navn på variabelen i datasettet. Bør tilsvare anbefalt kortnavn.", obligatory=True, editable=False, ), - NewVariableIdentifiers.NAME: DisplayNewVariablesMetadata( + NewVariableIdentifiers.NAME: VariablesInputField( identifier=NewVariableIdentifiers.NAME.value, display_name="Navn", description="Variabelnavn kan arves fra VarDef, men kan også dokumenteres/endres her.", @@ -76,7 +76,7 @@ class NewVariableIdentifiers(str, Enum): multiple_language_support=True, type="text", ), - NewVariableIdentifiers.DATA_TYPE: DisplayNewVariablesMetadataDropdown( + NewVariableIdentifiers.DATA_TYPE: VariablesDropdownField( identifier=NewVariableIdentifiers.DATA_TYPE.value, display_name="Datatype", description="Datatype", @@ -86,7 +86,7 @@ class NewVariableIdentifiers(str, Enum): enums.DataType, ), ), - NewVariableIdentifiers.VARIABLE_ROLE: DisplayNewVariablesMetadataDropdown( + NewVariableIdentifiers.VARIABLE_ROLE: VariablesDropdownField( identifier=NewVariableIdentifiers.VARIABLE_ROLE.value, display_name="Variabelens rolle", description="Variabelens rolle i datasett", @@ -96,7 +96,7 @@ class NewVariableIdentifiers(str, Enum): enums.VariableRole, ), ), - NewVariableIdentifiers.DEFINITION_URI: DisplayNewVariablesMetadata( + NewVariableIdentifiers.DEFINITION_URI: VariablesInputField( identifier=NewVariableIdentifiers.DEFINITION_URI.value, display_name="Definition URI", description="En lenke (URI) til variabelens definisjon i SSB (Vardok/VarDef)", @@ -104,79 +104,78 @@ class NewVariableIdentifiers(str, Enum): obligatory=True, type="url", ), - NewVariableIdentifiers.DIRECT_PERSON_IDENTIFYING: DisplayNewVariablesMetadataCheckbox( + NewVariableIdentifiers.DIRECT_PERSON_IDENTIFYING: VariablesCheckboxField( identifier=NewVariableIdentifiers.DIRECT_PERSON_IDENTIFYING.value, display_name="Direkte personidentifiserende informasjon", description="Direkte personidentifiserende informasjon (DPI)", obligatory=True, ), - NewVariableIdentifiers.DATA_SOURCE: DisplayNewVariablesMetadata( + NewVariableIdentifiers.DATA_SOURCE: VariablesInputField( identifier=NewVariableIdentifiers.DATA_SOURCE.value, display_name="Datakilde", description="Datakilde. Settes på datasettnivå, men kan overstyres på variabelforekomstnivå.", multiple_language_support=True, type="text", ), - NewVariableIdentifiers.POPULATION_DESCRIPTION: DisplayNewVariablesMetadata( + NewVariableIdentifiers.POPULATION_DESCRIPTION: VariablesInputField( identifier=NewVariableIdentifiers.POPULATION_DESCRIPTION.value, display_name="Populasjonen", description="Populasjonen variabelen beskriver kan spesifiseres nærmere her. Settes på datasettnivå, men kan overstyres på variabelforekomstnivå.", multiple_language_support=True, type="text", ), - NewVariableIdentifiers.COMMENT: DisplayNewVariablesMetadata( + NewVariableIdentifiers.COMMENT: VariablesInputField( identifier=NewVariableIdentifiers.COMMENT.value, display_name="Kommentar", description="Ytterligere presiseringer av variabeldefinisjon", multiple_language_support=True, type="text", ), - NewVariableIdentifiers.MEASUREMENT_UNIT: DisplayNewVariablesMetadata( + NewVariableIdentifiers.MEASUREMENT_UNIT: VariablesInputField( identifier=NewVariableIdentifiers.MEASUREMENT_UNIT.value, display_name="Måleenhet", description="Måleenhet. Eksempel: NOK eller USD for valuta, KG eller TONN for vekt. Se også forslag til SSBs måletyper/måleenheter.", - multiple_language_support=True, type="text", ), - NewVariableIdentifiers.FORMAT: DisplayNewVariablesMetadata( + NewVariableIdentifiers.FORMAT: VariablesInputField( identifier=NewVariableIdentifiers.FORMAT.value, display_name="Format", description="Verdienes format (fysisk format eller regulært uttrykk) i maskinlesbar form ifm validering. Dette kan benyttes som en ytterligere presisering av datatypen (dataType) i de tilfellene hvor dette er relevant. ", ), - NewVariableIdentifiers.CLASSIFICATION_URI: DisplayNewVariablesMetadata( + NewVariableIdentifiers.CLASSIFICATION_URI: VariablesInputField( identifier=NewVariableIdentifiers.CLASSIFICATION_URI.value, display_name="Kodeverkets URI", description="Lenke (URI) til gyldige kodeverk (klassifikasjon eller kodeliste) i KLASS", url=True, type="url", ), - NewVariableIdentifiers.SENTINEL_VALUE_URI: DisplayNewVariablesMetadata( + NewVariableIdentifiers.SENTINEL_VALUE_URI: VariablesInputField( identifier=NewVariableIdentifiers.SENTINEL_VALUE_URI.value, display_name="Spesialverdienes URI", description="En lenke (URI) til en oversikt over 'spesialverdier' som inngår i variabelen.", url=True, type="url", ), - NewVariableIdentifiers.INVALID_VALUE_DESCRIPTION: DisplayNewVariablesMetadata( + NewVariableIdentifiers.INVALID_VALUE_DESCRIPTION: VariablesInputField( identifier=NewVariableIdentifiers.INVALID_VALUE_DESCRIPTION.value, display_name="Ugyldige verdier", description="En beskrivelse av ugyldige verdier som inngår i variabelen dersom spesialverdiene ikke er tilstrekkelige eller ikke kan benyttes.", multiple_language_support=True, ), - NewVariableIdentifiers.IDENTIFIER: DisplayNewVariablesMetadata( + NewVariableIdentifiers.IDENTIFIER: VariablesInputField( identifier=NewVariableIdentifiers.IDENTIFIER.value, display_name="Unik ID", description="Unik SSB identifikator for variabelforekomsten i datasettet", obligatory=False, editable=False, ), - NewVariableIdentifiers.CONTAINS_DATA_FROM: DisplayNewVariablesMetadata( + NewVariableIdentifiers.CONTAINS_DATA_FROM: VariablesInputField( identifier=NewVariableIdentifiers.CONTAINS_DATA_FROM.value, display_name="Inneholder data f.o.m.", description="Variabelforekomsten i datasettet inneholder data fra og med denne dato.", type="date", ), - NewVariableIdentifiers.CONTAINS_DATA_UNTIL: DisplayNewVariablesMetadata( + NewVariableIdentifiers.CONTAINS_DATA_UNTIL: VariablesInputField( identifier=NewVariableIdentifiers.CONTAINS_DATA_UNTIL.value, display_name="Inneholder data t.o.m.", description="Variabelforekomsten i datasettet inneholder data til og med denne dato.", @@ -203,9 +202,9 @@ class NewVariableIdentifiers(str, Enum): ] # Copied from dataset_tab - not in use - should we use this? -DISPLAYED_VARIABLES_METADATA: list[DisplayNewVariablesMetadata] = ( - OBLIGATORY_VARIABLES_METADATA + OPTIONAL_VARIABLES_METADATA -) +DISPLAYED_VARIABLES_METADATA: list[ + VariablesInputField | VariablesDropdownField | VariablesCheckboxField +] = (OBLIGATORY_VARIABLES_METADATA + OPTIONAL_VARIABLES_METADATA) # Copied from dataset_tab - not in use - should we use this? OBLIGATORY_VARIABLES_METADATA_IDENTIFIERS: list[str] = [ diff --git a/tests/frontend/callbacks/test_dataset_callbacks.py b/tests/frontend/callbacks/test_dataset_callbacks.py index 562beec4..d5e029b5 100644 --- a/tests/frontend/callbacks/test_dataset_callbacks.py +++ b/tests/frontend/callbacks/test_dataset_callbacks.py @@ -249,6 +249,7 @@ def test_change_language_dataset_metadata_options_enums( language: SupportedLanguages, ): state.metadata = metadata + state.current_metadata_language = SupportedLanguages.NORSK_BOKMÅL state.statistic_subject_mapping = subject_mapping_fake_statistical_structure state.unit_types = unit_types_fake_structure value = change_language_dataset_metadata(language)