Skip to content

Commit

Permalink
bugfix - Disable end date to be before start date
Browse files Browse the repository at this point in the history
  • Loading branch information
taleksovska committed Feb 2, 2024
1 parent 4b6ab4f commit 1e8dad2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
21 changes: 21 additions & 0 deletions ckanext/scheming/templates/scheming/form_snippets/date.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,24 @@
%}
{%- snippet 'scheming/form_snippets/help_text.html', field=field -%}
{% endcall %}


<script>

document.getElementById("field-dataset_start_date").addEventListener("input", updateEndDateMin);

function updateEndDateMin() {
// Get the value of the start date input
const startDateInput = document.getElementById("field-dataset_start_date");
const startDateValue = startDateInput.value;

// Set the minimum allowed value for the end date input
const endDateInput = document.getElementById("field-dataset_end_date");
endDateInput.min = startDateValue;

// Enable the end date input
endDateInput.disabled = false;
}


</script>
24 changes: 12 additions & 12 deletions ckanext/scheming/templates/scheming/form_snippets/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@

}

function removeVersionField(){
var txcVersionField = document.getElementById('field-txc_version');
var transXChangeVersionElement = document.querySelector("#dataset-edit > div:nth-child(15)");
var wholeField = document.querySelector("#dataset-edit > div:nth-child(16)");
// function removeVersionField(){
// var txcVersionField = document.getElementById('field-txc_version');
// var transXChangeVersionElement = document.querySelector("#dataset-edit > div:nth-child(15)");
// var wholeField = document.querySelector("#dataset-edit > div:nth-child(16)");

wholeField.style.display = 'none';
txcVersionField.style.display = 'none';
transXChangeVersionElement.style.display = 'none';
}
// wholeField.style.display = 'none';
// txcVersionField.style.display = 'none';
// transXChangeVersionElement.style.display = 'none';
// }


function toggleFields() {
Expand All @@ -85,13 +85,13 @@
if (selectedOption === 'txc_data') {
// No fields to hide for TransXChange Data
statusField.style.display = 'block';
txcVersionField.style.display = 'none';
txcVersionField.style.display = 'block';
metadataValidationField.style.display = 'block';
visibleToLAElement.style.display = 'block';


statusElement.style.display = 'block';
transXChangeVersionElement.style.display = 'none';
transXChangeVersionElement.style.display = 'block';
metadataValidationElement.style.display = 'block';
visibleToLAField.style.display = 'block';

Expand All @@ -118,12 +118,12 @@

if(selectedOption === null || selectedOption === ''){
document.getElementById('field-type_of_dataset').addEventListener('change', toggleFields);
removeVersionField();
//removeVersionField();
toggleFields();
}
else {
disableDropdown();
removeVersionField();
//removeVersionField();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
{%- endif -%}
{%- endfor -%}
{% if h.check_access('package_update',{'id':pkg_dict.id}) %}
<tr>
<!-- <tr>
<th scope="row" class="dataset-label">{{ _("State") }}</th>
<td class="dataset-details">{{ _(pkg_dict.state) }}</td>
</tr>
</tr> -->
{% endif %}
{% if pkg_dict.extras %}
{% for extra in pkg_dict.extras %}
Expand Down

0 comments on commit 1e8dad2

Please sign in to comment.