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

Update launcher to support multiple schema versions #84

Merged
merged 11 commits into from
Jul 29, 2024
21 changes: 15 additions & 6 deletions static/javascript/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,12 @@ function updateSDSDropdown() {
const surveyId = schemaSurveyId;
const periodId = document.getElementById("period_id")?.value;

const supplementaryDataSection = document.querySelector(
"#supplementary_data",
);
const supplementaryDataSection = document.querySelector("#sds_id");
rmccar marked this conversation as resolved.
Show resolved Hide resolved
const sdsDatasetIdElement = document.querySelector("#sds_dataset_id");
loadSDSDatasetMetadata(surveyId, periodId)
.then((sds_metadata_response) => {
if (sds_metadata_response?.length) {
document.querySelector("#supplementary_data").innerHTML = "";
document.querySelector("#sds_id").innerHTML = "";
supplementaryDataSets = sds_metadata_response;
showMetadataAccordion("sds", true);
setTabIndex("sds_metadata_detail", 0);
Expand Down Expand Up @@ -528,10 +526,11 @@ function loadSupplementaryDataInfo() {
"sds_dataset_version",
];

const sdsMetadataSection = document.querySelector("#supplementary_data");
const sdsMetadataSection = document.querySelector("#sds_data");
const sdsMetadataField = (key) =>
`<div class="ons-field ons-field--inline">${getLabelFor(key)}${getInputField(key, "text", selectedDataset[key], true)}</div>`;
`<div class="ons-field ons-field--inline sds_data">${getLabelFor(key)}${getInputField(key, "text", selectedDataset[key], true)}</div>`;
rmccar marked this conversation as resolved.
Show resolved Hide resolved

clearSDSMetadata();
if (sdsMetadataSection.contains(document.querySelector("#sds_dataset_id"))) {
sdsMetadataSection.innerHTML += sdsDatasetMetadataKeys
.map(sdsMetadataField)
Expand All @@ -543,6 +542,16 @@ function loadSupplementaryDataInfo() {
}
}

function clearSDSMetadata() {
let dataset = document.querySelectorAll("#sds_data > div");
rmccar marked this conversation as resolved.
Show resolved Hide resolved
let div_array = [...dataset];
for (let i = 0; i < div_array.length; i++) {
if (div_array[i].classList.contains("sds-data")) {
rmccar marked this conversation as resolved.
Show resolved Hide resolved
div_array[i].remove();
}
}
}

function uuid(el_id) {
document.querySelector(`#${el_id}`).value = uuidv4();
}
Expand Down
5 changes: 4 additions & 1 deletion templates/launch.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ <h2 class="ons-details__title">Supplementary Data</h2>
<div id="sds-metadata-accordion-content"
class="ons-details__content ons-js-details-content ons-u-mb-m">
<div class="supplementary-data">
<div id="supplementary_data"></div>
<div id="supplementary_data">
<div id="sds_id" class="ons-u-mb-m"></div>
rmccar marked this conversation as resolved.
Show resolved Hide resolved
<div id="sds_data"></div>
</div>
</div>
</div>
</div>
Expand Down
Loading