From 5d9ad78ed3a89b4c60c179012fd7b38b22da2b96 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Mon, 31 Jan 2022 11:47:40 +0100 Subject: 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. --- ogcp/static/js/ogcp.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ogcp/static') 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"]') -- cgit v1.2.3-18-g5258