Skip to content

Commit

Permalink
Update dataset tab with ssb components (#260)
Browse files Browse the repository at this point in the history
* Fix/get old commit (#232)

* new class

* Changed properties in display_dataset

---------

Co-authored-by: Jan Sander <[email protected]>

* Feat/dpmeta 128 add unique key (#228)

* Added dataset input field that uses ssb input

* Updated builder for dataset input filed

* Add DatasetDropdownField - change datatype DISPLAY_DATASET - temp commented out code

* Change datatypes for Datasetidentifiers - som dropdowns ok - test red

* DatasetDisplayTypes list

* Dropdown options ok dataset

* remove comment

* Possible Const id for dataset

* Changed tests to be compatible with new display dataset functions

* Add unique dict id for Form

* Add section_id to make Form ID unique

* Ruff temporary commented out code

---------

Co-authored-by: rlj <[email protected]>

* Display and save metadata in dataset tab (#235)

* Reading metadata dataset

* Change className - update comment - values are displayed too late

* add language id

* Trigger dataset tab on button click and dynamic id on edit section

* Revert changes in callback

* Add Input from button click and return no_update when no click. Is working, but is not tested in every aspect

* Update names dataset

* Update and write docstrings

* Remove commented out code

* Refactor and comment

* Remove comments as notes

* Refactor build dataset edit section

* fix merge

* fix cirkular import

* Update and add styling to dataset tab (#241)

* workspace title

* class names for workspace - update css

* refactor variables tab semantics and type content in Tab

* Add tests for build dataset edit section (#240)

* Test assert return html.Section

* Remove unnecessary code

* Add tests

* details test

* Tests

* datasetInputField

* Update tests minus atypical options-getters

* Organize and check tests - all ok

* Rename

* correct id

* Keyword should not be excluded from the tests - not same issue as dropdowns from external sources (#242)

* Added validation to the date picker in the dataset tab (#243)

* Added validation to the date picker in the dataset tab

* Updated dataset date tests

* Fixed types for dataset tab dates

---------

Co-authored-by: rlj <[email protected]>

* Add method for get date metadata and stringify (#245)

* Refactor Input and Dropdown

* min should not be deleted

* Changing metadata type

* Changing type back to BaseModel

* fix datetime format variables for display date (#254)

* Refactor period field for dataset and variable (#255)

* fix datetime format variables for display date

* Add id_type to component

* One periodField

* update test

* Added comments for noqas

* Chore/dpmeta 137 remove unused methods and classes (#257)

* Remove unused VariablesInputField and VariablesDropdownField

* Remove input_kwargs

* Move unused classes to bottom of file

* Rename checkboxField

* Change name from VariablesFieldTypes to MetadataFieldTypes

* Correct name (#259)

* Remove fontsize header - add margin-top buttons and rename css file

---------

Co-authored-by: Jorgen-5 <[email protected]>
Co-authored-by: Cecilie Seim <[email protected]>
Co-authored-by: rlj <[email protected]>
Co-authored-by: rlj <[email protected]>
  • Loading branch information
5 people authored Apr 2, 2024
1 parent 70d6011 commit 8f51411
Show file tree
Hide file tree
Showing 14 changed files with 808 additions and 383 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}

.ssb-btn.secondary-btn.file-open-button,.ssb-btn.secondary-btn.file-save-button{
margin-top: 0.5rem;
margin-top: 1.5rem;
}

.progress-bar-wrapper{
Expand Down
1 change: 0 additions & 1 deletion src/datadoc/assets/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
.ssb-title.main-title {
color: #274247;
padding: 0;
font-size: 2rem;
margin-left: 1rem;
}
Original file line number Diff line number Diff line change
@@ -1,68 +1,53 @@
.page-wrapper{
.workspace-page-wrapper{
display: flex;
flex-wrap: wrap;
flex-direction: row;
padding: 0;
}

.content-wrapper{
display: flex;
width: 100%;
gap: 1rem;
}

.main-content{
width: 100%;
display: flex;
flex-direction: column;
gap: 1rem;
}


.variables-header{
.workspace-header{
width: 100%;
display:flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
}

.ssb-title.variables-title{
.ssb-title.workspace-title{
margin-top: 1rem;
width: 100%;
}

.ssb-input{
margin-bottom: 1rem;
}
.accordion-wrapper{
.workspace-content{
width: 100%;
display: flex;
flex-direction: column;
gap: 1rem;
}

.ssb-accordion.variable-accordion{
border: 2px solid #62919A;
padding: 0.5rem;
.ssb-accordion.variable-accordion > .accordion-body {
padding: 1rem;
}

.ssb-accordion.variable-accordion > .accordion-body {
.edit-section{
display: flex;
flex-direction: column;
gap: 1rem;
width: 100%;
}

.edit-section.dataset-edit-section{
padding: 1rem;
}

.variables-input-group{
.edit-section-form{
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: flex-start;
gap: 1rem;
gap: 2rem;
padding-top: 1rem;
}

/*.input-section{
margin: 1rem;
}*/

.alert-section{
display: flex;
flex-wrap: wrap;
Expand All @@ -71,13 +56,19 @@
padding-top: 1rem;
}

.ssb-title.input-section-title{
.ssb-title.edit-section-title{
border-bottom: 2px solid #62919A;
margin-bottom: 1rem;
padding-bottom: 1rem;

}

.ssb-input.input-component{
max-width: 500px;
width: 100%;
}

.ssb-input.variable-input{
.ssb-dropdown.dropdown-component {
max-width: 500px;
width: 100%;
}
Expand All @@ -86,6 +77,10 @@
align-self: center;
}

.form-check{
padding-left: 0;
}

/*Target child selector (label) of variable-dropdown*/
.ssb-dropdown.variable-dropdown > .dropdown-label{
margin-bottom: 0.6rem;
Expand Down
79 changes: 59 additions & 20 deletions src/datadoc/frontend/callbacks/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,6 @@ def process_special_cases(
str,
):
updated_value = process_keyword(value)
elif metadata_identifier == DatasetIdentifiers.CONTAINS_DATA_FROM.value:
updated_value, _ = parse_and_validate_dates(
str(value),
getattr(
state.metadata.dataset,
DatasetIdentifiers.CONTAINS_DATA_UNTIL.value,
),
)
if updated_value:
updated_value = updated_value.isoformat()
elif metadata_identifier == DatasetIdentifiers.CONTAINS_DATA_UNTIL.value:
_, updated_value = parse_and_validate_dates(
getattr(
state.metadata.dataset,
DatasetIdentifiers.CONTAINS_DATA_FROM.value,
),
str(value),
)
if updated_value:
updated_value = updated_value.isoformat()
elif metadata_identifier == DatasetIdentifiers.VERSION.value:
updated_value = str(value)
elif metadata_identifier in MULTIPLE_LANGUAGE_DATASET_METADATA and isinstance(
Expand Down Expand Up @@ -203,3 +183,62 @@ def change_language_dataset_metadata(
*(e.options_getter(language) for e in DISPLAYED_DROPDOWN_DATASET_METADATA),
update_dataset_metadata_language(),
)


def accept_dataset_metadata_date_input(
dataset_identifier: DatasetIdentifiers,
contains_data_from: str | None,
contains_data_until: str | None,
) -> tuple[bool, str, bool, str]:
"""Validate and save date range inputs."""
try:
(
parsed_contains_data_from,
parsed_contains_data_until,
) = parse_and_validate_dates(
str(contains_data_from),
str(contains_data_until),
)

if parsed_contains_data_from:
state.metadata.dataset.contains_data_from = (
parsed_contains_data_from.isoformat()
)

if parsed_contains_data_until:
state.metadata.dataset.contains_data_until = (
parsed_contains_data_until.isoformat()
)

except (ValidationError, ValueError) as e:
logger.exception(
"Validation failed for %s, %s, %s: %s, %s",
dataset_identifier,
"contains_data_from",
contains_data_from,
"contains_data_until",
contains_data_until,
)
message: str | None = str(e)
else:
logger.debug(
"Successfully updated %s, %s, %s: %s, %s",
dataset_identifier,
"contains_data_from",
contains_data_from,
"contains_data_until",
contains_data_until,
)
message = None

no_error = (False, "")
if not message:
# No error to display.
return no_error + no_error

error = (True, message)
return (
error + no_error
if dataset_identifier == DatasetIdentifiers.CONTAINS_DATA_FROM
else no_error + error
)
Loading

0 comments on commit 8f51411

Please sign in to comment.