Skip to content

Commit 1bc496a

Browse files
committed
Update RDL_MDE.html
1 parent 844388f commit 1bc496a

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

_static/RDL_MDE.html

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,11 @@ <h5 class="modal-title" id="githubConfigModalLabel">GitHub Configuration</h5>
25782578
"convective_storm": ["tornado"]
25792579
};
25802580
}
2581-
2581+
2582+
// Reset form data when switching schema versions
2583+
currentFormData = {};
2584+
fieldValidationStatus.clear();
2585+
25822586
updateSchemaStatus(`✓ RDLS ${version} loaded`, 'text-success');
25832587
generateForm();
25842588
} catch (error) {
@@ -2622,7 +2626,11 @@ <h5 class="modal-title" id="githubConfigModalLabel">GitHub Configuration</h5>
26222626
} else if (isV20) {
26232627
statusMessage = '✓ RDLS v2.0 schema loaded';
26242628
}
2625-
2629+
2630+
// Reset form data when loading custom schema
2631+
currentFormData = {};
2632+
fieldValidationStatus.clear();
2633+
26262634
updateSchemaStatus(statusMessage, 'text-success');
26272635
generateForm();
26282636
} catch (error) {
@@ -3614,7 +3622,7 @@ <h5 class="modal-title" id="githubConfigModalLabel">GitHub Configuration</h5>
36143622
function updatePreview() {
36153623
const filteredData = getFilteredFormData();
36163624

3617-
// Get the current schema version for the package
3625+
// Get the current schema version
36183626
const version = document.getElementById('schemaVersionSelect').value;
36193627
const versionMap = {
36203628
'0.2': '0__2__0',
@@ -3623,9 +3631,28 @@ <h5 class="modal-title" id="githubConfigModalLabel">GitHub Configuration</h5>
36233631
const schemaVersion = versionMap[version] || '0__3__0';
36243632
const schemaUrl = `https://docs.riskdatalibrary.org/en/${schemaVersion}/rdls_schema.json`;
36253633

3634+
// Ensure links array exists and has the schema reference
3635+
if (!filteredData.links) {
3636+
filteredData.links = [];
3637+
}
3638+
3639+
// Check if describedby link already exists
3640+
const hasDescribedBy = filteredData.links.some(link => link.rel === 'describedby');
3641+
3642+
if (!hasDescribedBy) {
3643+
// Add schema reference as first link with rel="describedby"
3644+
filteredData.links.unshift({
3645+
href: schemaUrl,
3646+
rel: 'describedby'
3647+
});
3648+
} else {
3649+
// Update existing describedby link to current schema version
3650+
const describedByIndex = filteredData.links.findIndex(link => link.rel === 'describedby');
3651+
filteredData.links[describedByIndex].href = schemaUrl;
3652+
}
3653+
36263654
// Show preview as a complete package (matching export format)
36273655
const previewData = {
3628-
schema: schemaUrl,
36293656
datasets: [filteredData]
36303657
};
36313658

@@ -4018,7 +4045,7 @@ <h5 class="modal-title" id="githubConfigModalLabel">GitHub Configuration</h5>
40184045
// Get the current schema version
40194046
const version = document.getElementById('schemaVersionSelect').value;
40204047

4021-
// Map version to schema URL format (used in package schema reference)
4048+
// Map version to schema URL format
40224049
const versionMap = {
40234050
'0.2': '0__2__0',
40244051
'0.3': '0__3__0'
@@ -4032,6 +4059,26 @@ <h5 class="modal-title" id="githubConfigModalLabel">GitHub Configuration</h5>
40324059
datasetMetadata.id = generateDatasetId(datasetMetadata.title);
40334060
}
40344061

4062+
// Ensure links array exists and has the schema reference as first item
4063+
if (!datasetMetadata.links) {
4064+
datasetMetadata.links = [];
4065+
}
4066+
4067+
// Check if describedby link already exists
4068+
const hasDescribedBy = datasetMetadata.links.some(link => link.rel === 'describedby');
4069+
4070+
if (!hasDescribedBy) {
4071+
// Add schema reference as first link with rel="describedby"
4072+
datasetMetadata.links.unshift({
4073+
href: schemaUrl,
4074+
rel: 'describedby'
4075+
});
4076+
} else {
4077+
// Update existing describedby link to current schema version
4078+
const describedByIndex = datasetMetadata.links.findIndex(link => link.rel === 'describedby');
4079+
datasetMetadata.links[describedByIndex].href = schemaUrl;
4080+
}
4081+
40354082
// Reorder fields according to schema
40364083
const schemaFieldOrder = [
40374084
'id', 'title', 'description', 'risk_data_type', 'version', 'purpose',
@@ -4056,9 +4103,8 @@ <h5 class="modal-title" id="githubConfigModalLabel">GitHub Configuration</h5>
40564103
}
40574104
});
40584105

4059-
// Create the package structure with schema reference
4106+
// Create the package structure (datasets only, no top-level schema field)
40604107
const packagedData = {
4061-
schema: schemaUrl,
40624108
datasets: [orderedMetadata]
40634109
};
40644110

0 commit comments

Comments
 (0)