summaryrefslogtreecommitdiffstats
path: root/ogcp/static/js/ogcp.js
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-06-13 13:07:49 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-06-14 09:25:36 +0200
commit5d9780e8d80df941000230a7ba3e2d9e96f44756 (patch)
tree0751917070641e52d5ae570a66b4e7a1286e51b9 /ogcp/static/js/ogcp.js
parent37ae1bc5a218d0901431f6ab319f766b105c0773 (diff)
js: allow selection of multiple clients in scopes sidebar
Allow the selection of multiple client checkboxes if they belong to the same room. Each checkbox input in the DOM has a "data-parent-room" attribute whose value is the value of the "name" attribute of its parent room scope component. To check if a checkbox is a client and a sibling of the one being checked we check if "data-parent-room" is available for both nodes and if they have the same value.
Diffstat (limited to 'ogcp/static/js/ogcp.js')
-rw-r--r--ogcp/static/js/ogcp.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js
index 5c15b30..b57fca7 100644
--- a/ogcp/static/js/ogcp.js
+++ b/ogcp/static/js/ogcp.js
@@ -399,8 +399,21 @@ function limitCheckboxes(context) {
const checkboxes = $('input:checkbox[form|="scopesForm"]');
checkboxes.on('change', function () {
- const checked = this;
- checkboxes.filter((i, c) => c !== checked).prop('checked', false);
+ const currentCheckbox = $(this);
+ const currentParentRoom = currentCheckbox.attr('data-parent-room');
+
+ checkboxes.each(function () {
+ const checkbox = $(this);
+ const checkboxParentRoom = checkbox.attr('data-parent-room');
+
+ if (currentCheckbox.is(checkbox)) {
+ return;
+ }
+ const isSibling = currentParentRoom && checkboxParentRoom && checkboxParentRoom === currentParentRoom;
+ if (!isSibling) {
+ checkbox.prop('checked', false);
+ }
+ });
checkScopeServer();