Skip to content

Commit

Permalink
Populate variables information text (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmwinther authored Mar 11, 2024
1 parent 8fcdc17 commit 8303467
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
16 changes: 14 additions & 2 deletions src/datadoc/frontend/callbacks/register_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from datadoc.frontend.components.builders import build_ssb_accordion
from datadoc.frontend.components.dataset_tab import DATASET_METADATA_INPUT
from datadoc.frontend.components.dataset_tab import build_dataset_metadata_accordion
from datadoc.frontend.components.variables_tab import ACCORDION_WRAPPER_ID
from datadoc.frontend.components.variables_tab import VARIABLES_INFORMATION_ID
from datadoc.frontend.fields.display_base import VARIABLES_METADATA_DATE_INPUT
from datadoc.frontend.fields.display_base import VARIABLES_METADATA_INPUT
from datadoc.frontend.fields.display_dataset import DISPLAYED_DROPDOWN_DATASET_METADATA
Expand Down Expand Up @@ -161,11 +163,21 @@ def callback_clear_accordion_values(n_clicks: int) -> list[dbc.AccordionItem]:
return no_update

@app.callback(
Output("accordion-wrapper", "children"),
Output(VARIABLES_INFORMATION_ID, "children"),
Input("language-dropdown", "value"),
prevent_initial_call=True,
)
def callback_populate_new_variables_workspace(
def callback_populate_variables_info_section(
language: str, # noqa: ARG001 Dash requires arguments for all Inputs
) -> str:
return f"Datasettet inneholder {len(state.metadata.variables)} variabler."

@app.callback(
Output(ACCORDION_WRAPPER_ID, "children"),
Input("language-dropdown", "value"),
prevent_initial_call=True,
)
def callback_populate_variables_workspace(
language: str,
) -> list:
"""Create variable workspace with accordions for variables."""
Expand Down
5 changes: 0 additions & 5 deletions src/datadoc/frontend/components/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ def build_ssb_button(text: str, icon_class: str, button_id: str) -> dbc.Button:
)


info_section = (
"Informasjon om hvordan jobbe i Datadoc, antall variabler i datasettet: osv.."
)


def build_input_field_section(
metadata_fields: list[VariablesFieldTypes],
variable: model.Variable,
Expand Down
9 changes: 5 additions & 4 deletions src/datadoc/frontend/components/variables_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from dash import html

from datadoc.frontend.components.builders import build_ssb_styled_tab
from datadoc.frontend.components.builders import info_section

VARIABLES_INFORMATION_ID = "variables-information"
ACCORDION_WRAPPER_ID = "accordion-wrapper"


def build_variables_tab() -> dbc.Tab:
Expand All @@ -24,8 +26,7 @@ def build_variables_tab() -> dbc.Tab:
className="variables-title",
),
ssb.Paragraph(
info_section,
id="variables-information",
id=VARIABLES_INFORMATION_ID,
),
ssb.Input(
label="Søk i variabler",
Expand All @@ -40,7 +41,7 @@ def build_variables_tab() -> dbc.Tab:
className="variables-header",
),
html.Main(
id="accordion-wrapper",
id=ACCORDION_WRAPPER_ID,
className="main-content",
),
],
Expand Down

0 comments on commit 8303467

Please sign in to comment.