Skip to content

Commit

Permalink
Numbered Variables-accordionItems for better organization of workspac…
Browse files Browse the repository at this point in the history
…e for the user. A temp file for testdata in components folder
  • Loading branch information
tilen1976 committed Jan 18, 2024
1 parent 5e89074 commit 36a1942
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 34 deletions.
7 changes: 6 additions & 1 deletion src/datadoc/frontend/components/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand All @@ -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"},
Expand Down
3 changes: 2 additions & 1 deletion src/datadoc/frontend/components/dataset_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=[
Expand Down
31 changes: 31 additions & 0 deletions src/datadoc/frontend/components/test_data_cbi.py
Original file line number Diff line number Diff line change
@@ -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)
39 changes: 7 additions & 32 deletions src/datadoc/frontend/components/variables_tab_cbi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand All @@ -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
],
Expand Down

0 comments on commit 36a1942

Please sign in to comment.