Skip to content

Commit

Permalink
Customize visibility based on the selected option
Browse files Browse the repository at this point in the history
  • Loading branch information
taleksovska committed Feb 29, 2024
1 parent beea847 commit b2a0376
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions ckanext/scheming/templates/scheming/form_snippets/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
field.style.display = 'block';
});

// if this fileName is null, then it is create dataset page
// if this fileId is null, then it is create dataset page
// in other hand it is update dataset page
var fileName = document.getElementById('field-file_name').value;
var fileId = document.getElementById('field-id').value;


if(fileName === null || fileName === ''){
if(fileId === null || fileId === ''){

// Customize visibility based on the selected option
if (selectedOption === 'txc_data'){
Expand All @@ -72,7 +72,7 @@
}
if (selectedOption === 'financial_data') {
// Hide specific fields for Financial Data
document.querySelector("#dataset-edit > div:nth-child(12)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(12)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(15)").style.display = 'block';
document.querySelector("#dataset-edit > div:nth-child(17)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(19)").style.display = 'none';
Expand All @@ -87,27 +87,25 @@
document.getElementById('field-type_of_dataset').disabled=true;

if (selectedOption === 'txc_data'){
document.querySelector("#dataset-edit > div:nth-child(14)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(15)").style.display = 'none';

}
if (selectedOption != 'txc_data'){
document.querySelector("#dataset-edit > div:nth-child(22)").style.display = 'none';

}



// Customize visibility based on the selected option
if (selectedOption === 'financial_data') {
// Hide specific fields for Financial Data
document.querySelector("#dataset-edit > div:nth-child(11)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(14)").style.display = 'block';
document.querySelector("#dataset-edit > div:nth-child(16)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(18)").style.display = 'none';
if (selectedOption === 'financial_data'){
document.querySelector("#dataset-edit > div:nth-child(12)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(15)").style.display = 'block';
document.querySelector("#dataset-edit > div:nth-child(17)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(19)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(23)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(25)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(24)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(26)").style.display = 'none';

}
document.querySelector("#dataset-edit > div:nth-child(11)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(16)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(18)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(22)").style.display = 'none';
document.querySelector("#dataset-edit > div:nth-child(25)").style.display = 'none';
}

}
}
toggleFields();
Expand Down

0 comments on commit b2a0376

Please sign in to comment.