Skip to content

Commit

Permalink
Fix value refresh in dataset workspace (#283)
Browse files Browse the repository at this point in the history
* Fix value refresh in dataset workspace

* Correct name of app to Datadoc
  • Loading branch information
mmwinther authored Apr 11, 2024
1 parent a0c8489 commit 647bbac
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
61 changes: 34 additions & 27 deletions src/datadoc/frontend/callbacks/register_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from dash import Output
from dash import State
from dash import ctx
from dash import no_update

from datadoc import state
from datadoc.enums import SupportedLanguages
Expand Down Expand Up @@ -162,7 +161,7 @@ def callback_populate_variables_workspace(
@app.callback(
Output(SECTION_WRAPPER_ID, "children"),
Input("language-dropdown", "value"),
Input("open-button", "n_clicks"),
State("open-button", "n_clicks"),
prevent_initial_call=True,
)
def callback_populate_dataset_workspace(
Expand All @@ -171,32 +170,40 @@ def callback_populate_dataset_workspace(
) -> list:
"""Create dataset workspace with sections."""
update_global_language_state(SupportedLanguages(language))

logger.debug("Populating dataset workspace")
if n_clicks:
return [
build_dataset_edit_section(
"Obligatorisk",
OBLIGATORY_EDITABLE_DATASET_METADATA,
state.current_metadata_language,
state.metadata.dataset,
{"type": "dataset-edit-section", "id": f"obligatory-{language}"},
),
build_dataset_edit_section(
"Anbefalt",
OPTIONAL_DATASET_METADATA,
state.current_metadata_language,
state.metadata.dataset,
{"type": "dataset-edit-section", "id": f"recommended-{language}"},
),
build_dataset_edit_section(
"Maskingenerert",
NON_EDITABLE_DATASET_METADATA,
state.current_metadata_language,
state.metadata.dataset,
{"type": "dataset-edit-section", "id": f"machine-{language}"},
),
]
return no_update
return [
build_dataset_edit_section(
"Obligatorisk",
OBLIGATORY_EDITABLE_DATASET_METADATA,
state.current_metadata_language,
state.metadata.dataset,
{
"type": "dataset-edit-section",
"id": f"obligatory-{language}-{n_clicks}",
},
),
build_dataset_edit_section(
"Anbefalt",
OPTIONAL_DATASET_METADATA,
state.current_metadata_language,
state.metadata.dataset,
{
"type": "dataset-edit-section",
"id": f"recommended-{language}-{n_clicks}",
},
),
build_dataset_edit_section(
"Maskingenerert",
NON_EDITABLE_DATASET_METADATA,
state.current_metadata_language,
state.metadata.dataset,
{
"type": "dataset-edit-section",
"id": f"machine-{language}-{n_clicks}",
},
),
]

@app.callback(
Output(
Expand Down
2 changes: 1 addition & 1 deletion src/datadoc/frontend/components/control_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
COLORS = {"dark_1": "#F0F8F9", "green_1": "#ECFEED", "green_4": "#00824D"}

header = ssb.Header(
[ssb.Title("DataDoc", size=1, id="main-title", className="main-title")],
[ssb.Title("Datadoc", size=1, id="main-title", className="main-title")],
className="datadoc-header",
)

Expand Down
2 changes: 1 addition & 1 deletion src/datadoc/frontend/fields/display_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_comma_separated_string(metadata: BaseModel, identifier: str) -> str:
try:
return ", ".join(value)
except TypeError:
logger.exception("Type error")
# This just means we got None
return ""


Expand Down

0 comments on commit 647bbac

Please sign in to comment.