From c1d08df31d5135fe43c26ea32b5998ad30645162 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 19 Jul 2024 20:33:19 +0200 Subject: ogcp: improve sidebar logic in Commands Disable all checkboxes of scopes of level higher than room in the $(window).on('pageshow', function) callback. Set checkboxes as "indeterminate" when not every children is selected but have some of its children selected. [x] center [x] room1 [x] client1 [x] client1 [-] center [ ] room1 [-] room2 [ ] client1 [x] client1 Send all selected sidebar fields as form fields. This requires setting disabled to false and replacing indeterminate = true to checked = true in the .on('submit', function) callback. When a checkbox is clicked: 1. Find the room branch of the checked input. [ ] center [ ] room1 [ ] room2 <- root of the room branch [ ] client1 <-- clicked item 2. Uncheck all the checkboxes outside of the room branch. 3. Set all the children of the clicked item to the same value as the clicked item. 4. Set the parent checked or indeterminate values. 5. Save checkbox status. --- ogcp/templates/macros.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'ogcp/templates/macros.html') diff --git a/ogcp/templates/macros.html b/ogcp/templates/macros.html index 077bad5..4f18265 100644 --- a/ogcp/templates/macros.html +++ b/ogcp/templates/macros.html @@ -13,8 +13,7 @@ keepScopesTreeState(); let context = {{ selection_mode | tojson | safe }}; {% if selection_mode == 'commands' %} - checkChildrenCheckboxes(context); - checkParentsCheckboxes(); + configureCommandCheckboxes(context); {% elif selection_mode == 'scopes' %} limitCheckboxes(context); checkFolderParent(context); @@ -41,7 +40,6 @@ value="{{ scope["id"] }}" {% if state %}style="filter: grayscale(100%);" onclick="return false;"{% endif %} {% if scope.get("selected", False) %}checked{% endif %} - {% if selection_mode == "commands" %}disabled="disabled"{% endif %} name="scope-center" /> {% elif scope["type"] == "room" %} {% set parent_room = scope.name + "-" + scope.id|string %} -- cgit v1.2.3-18-g5258