diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-01-31 11:47:40 +0100 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-01-31 16:28:53 +0100 |
commit | 5d9ad78ed3a89b4c60c179012fd7b38b22da2b96 (patch) | |
tree | db7c7d768b2fb3c2a7ab7fbe9d3e13ebe8729f41 | |
parent | 9a6508c686edc2ca6de90f4563c0ade0b51014e4 (diff) |
Check scopes checkboxes recursively
Otherwise, nested scopes are not checked and mislead users.
When a scope is checked, we search all its children and check them too.
-rw-r--r-- | ogcp/static/js/ogcp.js | 13 | ||||
-rw-r--r-- | ogcp/templates/macros.html | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index f05d7f5..8a6db02 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -9,6 +9,19 @@ function storeCheckboxStatus(checkbox) { localStorage.removeItem(checkbox.name); } +function checkChildrenCheckboxes() { + const checkboxes = $('input:checkbox[form|="scopesForm"]') + + checkboxes.on('change', function () { + const checked = this.checked + const children = $('input:checkbox', this.parentNode).not(this) + children.each(function () { + this.checked = checked; + storeCheckboxStatus(this); + }); + }); +} + function keepSelectedClients() { const checkboxes = $('input:checkbox[form|="scopesForm"]') diff --git a/ogcp/templates/macros.html b/ogcp/templates/macros.html index 3d28d05..a1b5ebb 100644 --- a/ogcp/templates/macros.html +++ b/ogcp/templates/macros.html @@ -11,6 +11,7 @@ updateScopeState(); keepScopesTreeState(); keepSelectedClients(); + checkChildrenCheckboxes(); } }); </script> |