Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep null values in oemetadata #1541

Merged
merged 6 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion dataedit/static/metaedit/metaedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,26 @@ var MetaEdit = function (config) {

}

// Function to recursively convert empty strings to null
function convertEmptyStringsToNull(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'string' && obj[key] === '') {
obj[key] = null;
} else if (typeof obj[key] === 'object') {
convertEmptyStringsToNull(obj[key]);
}
}
}
}

function bindButtons() {
// download
$('#metaedit-download').bind('click', function downloadMetadata() {
var json = config.editor.getValue();
// create data url
convertEmptyStringsToNull(json);
console.log(json);
json = JSON.stringify(json, null, 1);
blob = new Blob([json], { type: "application/json" }),
dataUrl = URL.createObjectURL(blob);
Expand Down Expand Up @@ -296,7 +311,7 @@ var MetaEdit = function (config) {
array_controls_top: true,
no_additional_properties: true,
required_by_default: false,
remove_empty_properties: true, // don't remove, otherwise the metadata will not pass the validation on the server
remove_empty_properties: false, // don't remove, otherwise the metadata will not pass the validation on the server
}

config.editor = new JSONEditor(config.form[0], options);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# metaBuilder

The metaBuilder is a tool to create, edit and download metadata for the oeplatform.

## Create

## Download

We currently offer multiple download buttons on the OEP. You can either download the metadata while editing the metadata on a table or when you use the standalone version of the metaBuilder. It is also possible to download the metadata when you view the metadata on a table in the "meta information" tab.

When you download the metadata json file the empty fields are kept as "null" values.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ nav:
- install-and-documentation/oeplatform-code/web-api/oekg-api/index.md
- Features:
- install-and-documentation/oeplatform-code/features/index.md
- metaBuilder Metadata creation: install-and-documentation/oeplatform-code/features/metaBuilder/index.md
- Open Peer Review Process:
- install-and-documentation/oeplatform-code/features/open-peer-review-process/index.md
- Technical docs: install-and-documentation/oeplatform-code/features/open-peer-review-process/technical-docs.md
Expand Down
2 changes: 2 additions & 0 deletions versions/changelogs/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

- UI Feature for Publishing Draft Tables: Integrated JavaScript to handle publish actions, including schema selection and confirmation steps, ensuring a seamless user experience. [(PR#1526)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1526)

- The oemetadata on the oep is now stored including null / none values. Users reported that it otherwise is confusing and hinders there metadata workflow. This is related to the update in [omi v0.2.0](https://pypi.org/project/omi/0.2.0/) [(PR#1541)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1541)

### Features

- Add a htmx based page loading after initial page is visible to the user. [(#1503)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1503)
Expand Down
Loading