From efe97317534942c97bfbc132e096655b8191105f Mon Sep 17 00:00:00 2001 From: Daniel GarcĂ­a Moreno Date: Tue, 13 Sep 2022 12:01:23 +0200 Subject: Add different selection mode for the tree view --- ogcp/static/js/ogcp.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ogcp/static') diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index d5615b8..e72bc83 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -265,3 +265,28 @@ function checkImageServer() { }); }); } + +function limitCheckboxes() { + const checkboxes = $('input:checkbox[form|="scopesForm"]'); + + checkboxes.on('change', function () { + const checked = this; + checkboxes.filter((i, c) => c !== checked).prop('checked', false); + checkboxes.each(function() { + showSelectedClient(this); + }); + checkScopeServer(); + }); +} + +function checkScopeServer() { + const servers = $('input:checkbox[form|="scopesForm"][name="scope-server"]'); + servers.each(function() { + const checkbox = this; + const checkboxChildren = $('input:checkbox', this.parentNode).not(this); + if (checkboxChildren.length == 0) return; + + const checkedChildren = checkboxChildren.filter(":checked"); + checkbox.checked = checkedChildren.length > 0; + }); +} -- cgit v1.2.3-18-g5258