diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-09-16 13:57:31 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-09-16 13:57:31 +0200 |
commit | 053519beae0cb380864773a0cca6dd3d009a5899 (patch) | |
tree | 49b8450f9c9ce579ca38589698c802cb03aec9ea /ogcp/static/js/ogcp.js | |
parent | 2ca2215ed6653dc7bf2cfaf320fee811b376ece8 (diff) |
templates: save checkbox state in images and repos
Store the checked checkboxes of the sidebar in Images and Repos.
Autoselect the correct server after updating the checkboxes.
Diffstat (limited to 'ogcp/static/js/ogcp.js')
-rw-r--r-- | ogcp/static/js/ogcp.js | 55 |
1 files changed, 16 insertions, 39 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index f70f77c..96bf3d9 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -298,41 +298,6 @@ function updateScopes(scopes) { return hasLiveChildren; } -function checkImageServer() { - const images = $('input:checkbox[form|="imagesForm"][name!="image-server"]') - - images.on('change', function() { - const selectedServer = $('#' + $.escapeSelector(this.dataset.server)); - const serversSelector = 'input:checkbox[name|="image-server"]'; - const nonSelectedServers = $(serversSelector).not(selectedServer); - - selectedServer.prop('checked', true); - - nonSelectedServers.each(function() { - $(this).prop('checked', false); - const checkboxes = $('input:checkbox[data-server|="' + this.id + '"]'); - checkboxes.prop('checked', false); - }); - }); -} - -function checkRepoServer() { - const repos = $('input:checkbox[form|="reposForm"][name!="repos-server"]') - repos.on('change', function() { - const selectedServer = $('#' + $.escapeSelector(this.dataset.server)); - const serversSelector = 'input:checkbox[name|="repos-server"]'; - const nonSelectedServers = $(serversSelector).not(selectedServer); - - selectedServer.prop('checked', true); - - nonSelectedServers.each(function() { - $(this).prop('checked', false); - const checkboxes = $('input:checkbox[data-server|="' + this.id + '"]'); - checkboxes.prop('checked', false); - }); - }); -} - function checkFolderParent(context) { const folder = $('#sidebar input:checkbox[name="folder"]') folder.on('change', function() { @@ -362,7 +327,7 @@ function limitCheckboxes(context) { } }); - checkScopeServer(); + checkCheckbox('scope-server'); checkboxes.each(function() { storeCheckboxStatus(this, context); @@ -371,9 +336,9 @@ function limitCheckboxes(context) { }); } -function checkScopeServer() { - const servers = $('#sidebar input:checkbox[name="scope-server"]'); - servers.each(function() { +function checkCheckbox(inputName) { + const checkboxes = $('#sidebar input:checkbox[name="' + inputName + '"]'); + checkboxes.each(function() { const checkbox = this; const checkboxChildren = $('input:checkbox', this.parentNode).not(this); if (checkboxChildren.length == 0) return; @@ -382,3 +347,15 @@ function checkScopeServer() { checkbox.checked = checkedChildren.length > 0; }); } + +function checkOnChange(inputName) { + const checkboxes = $('#sidebar input:checkbox') + + checkboxes.on('change', function (event) { + checkCheckbox(inputName); + }); + + checkboxes.each(function () { + checkCheckbox(inputName) + }); +} |