From 36a1942a1ab2aafe1303bb34f4dff275906f99dc Mon Sep 17 00:00:00 2001 From: tilen1976 <68303562+tilen1976@users.noreply.github.com> Date: Thu, 18 Jan 2024 17:36:00 +0100 Subject: [PATCH] Numbered Variables-accordionItems for better organization of workspace for the user. A temp file for testdata in components folder --- src/datadoc/frontend/components/builders.py | 7 +++- .../frontend/components/dataset_tab.py | 3 +- .../frontend/components/test_data_cbi.py | 31 +++++++++++++++ .../frontend/components/variables_tab_cbi2.py | 39 ++++--------------- 4 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 src/datadoc/frontend/components/test_data_cbi.py diff --git a/src/datadoc/frontend/components/builders.py b/src/datadoc/frontend/components/builders.py index 9c7bec8e..ff1f9329 100644 --- a/src/datadoc/frontend/components/builders.py +++ b/src/datadoc/frontend/components/builders.py @@ -115,7 +115,7 @@ def build_ssb_secondary_button( ) -def build_info_section(header: str) -> html.Section: +def build_info_section(header: str, num: int) -> html.Section: """Create section for.""" return html.Section( [ @@ -125,6 +125,11 @@ def build_info_section(header: str) -> html.Section: html.P("Info om datasett, variabler og hva man skal/kan gjøre"), ), ), + dbc.Row( + dbc.Col( + "Antall variabler i datasettet: " + f"{num}", + ), + ), ], className="ssb-section", style={"padding": "1rem", "paddingLeft": "0"}, diff --git a/src/datadoc/frontend/components/dataset_tab.py b/src/datadoc/frontend/components/dataset_tab.py index 4033d1ac..75d46e56 100644 --- a/src/datadoc/frontend/components/dataset_tab.py +++ b/src/datadoc/frontend/components/dataset_tab.py @@ -7,6 +7,7 @@ from datadoc.frontend.components.builders import build_info_section from datadoc.frontend.components.builders import build_ssb_styled_tab +from datadoc.frontend.components.test_data_cbi import num_variables from datadoc.frontend.fields.display_dataset import NON_EDITABLE_DATASET_METADATA from datadoc.frontend.fields.display_dataset import OBLIGATORY_EDITABLE_DATASET_METADATA from datadoc.frontend.fields.display_dataset import OPTIONAL_DATASET_METADATA @@ -57,7 +58,7 @@ def build_dataset_tab() -> dbc.Tab: "Datasett", dbc.Container( [ - build_info_section(header), + build_info_section(header, num_variables), dbc.Accordion( always_open=True, children=[ diff --git a/src/datadoc/frontend/components/test_data_cbi.py b/src/datadoc/frontend/components/test_data_cbi.py new file mode 100644 index 00000000..dec54470 --- /dev/null +++ b/src/datadoc/frontend/components/test_data_cbi.py @@ -0,0 +1,31 @@ +test_variabels = [ + "Fødselsnummer", + "Tidspunkt", + "Sivilstand", + "Sykepenger", + "Inntekt", + "Beregnet bruttoformue", + "Fullført utdanning", + "Hoveddiagnose", +] + +test_variabel_details = [ + "Navn ", + "Datatype ", + "Variabelens rolle ", + "Definition URI ", + "DPI ", + "Datakilde ", + "Populasjon ", + "Kommentar ", + "Temporalitetstype ", + "Måleenhet ", + "Format ", + "Kodeverkets URI ", + "Spesialverdienes URI ", + "Ugyldige verdier ", + "Inneholder data f.o.m. ", + "Inneholder data t.o.m. ", +] + +num_variables = len(test_variabels) diff --git a/src/datadoc/frontend/components/variables_tab_cbi2.py b/src/datadoc/frontend/components/variables_tab_cbi2.py index faf38cfd..32377620 100644 --- a/src/datadoc/frontend/components/variables_tab_cbi2.py +++ b/src/datadoc/frontend/components/variables_tab_cbi2.py @@ -7,38 +7,11 @@ from datadoc.frontend.components.builders import build_info_section from datadoc.frontend.components.builders import build_ssb_styled_tab +from datadoc.frontend.components.test_data_cbi import num_variables +from datadoc.frontend.components.test_data_cbi import test_variabel_details +from datadoc.frontend.components.test_data_cbi import test_variabels header = html.H2("Variabel detaljer", className="ssb-title", disable_n_clicks=True) -# Test data -test_variabels = [ - "Fødselsnummer", - "Tidspunkt", - "Sivilstand", - "Sykepenger", - "Inntekt", - "Beregnet bruttoformue", - "Fullført utdanning", - "Hoveddiagnose", -] - -test_variabel_details = [ - "Navn ", - "Datatype ", - "Variabelens rolle ", - "Definition URI ", - "DPI ", - "Datakilde ", - "Populasjon ", - "Kommentar ", - "Temporalitetstype ", - "Måleenhet ", - "Format ", - "Kodeverkets URI ", - "Spesialverdienes URI ", - "Ugyldige verdier ", - "Inneholder data f.o.m. ", - "Inneholder data t.o.m. ", -] def build_variables_tab() -> dbc.Tab: @@ -47,7 +20,7 @@ def build_variables_tab() -> dbc.Tab: "Variabler", dbc.Container( children=[ - build_info_section(header), + build_info_section(header, num_variables), html.Section( [ dbc.Accordion( @@ -67,7 +40,9 @@ def build_variables_tab() -> dbc.Tab: ) for x in test_variabel_details ], - title=variabel_name, + title=str(test_variabels.index(variabel_name) + 1) + + " - " + + variabel_name, ) for variabel_name in test_variabels ],