summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/static/js/ogcp.js25
-rw-r--r--ogcp/templates/commands.html2
-rw-r--r--ogcp/templates/macros.html12
-rw-r--r--ogcp/templates/scopes.html2
4 files changed, 35 insertions, 6 deletions
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;
+ });
+}
diff --git a/ogcp/templates/commands.html b/ogcp/templates/commands.html
index dfcda91..c212600 100644
--- a/ogcp/templates/commands.html
+++ b/ogcp/templates/commands.html
@@ -12,7 +12,7 @@
{% endblock %}
{% block sidebar %}
- {{ macros.scopes_tree_collapse(scopes, sidebar_state) }}
+ {{ macros.scopes_tree_collapse(scopes, sidebar_state, 'commands') }}
{% endblock %}
{% block commands %}
diff --git a/ogcp/templates/macros.html b/ogcp/templates/macros.html
index 0283d26..a8e4f87 100644
--- a/ogcp/templates/macros.html
+++ b/ogcp/templates/macros.html
@@ -1,4 +1,4 @@
-{% macro scopes_tree_collapse(scopes, state='') -%}
+{% macro scopes_tree_collapse(scopes, state='', selection_mode='scopes') -%}
<ul id="scopes" class="nav flex-column nav-pills">
{{ scopes_tree_collapse_level(scopes["scope"], "", state) }}
@@ -11,9 +11,13 @@
showSelectedClientsOnEvents();
updateScopeState();
keepScopesTreeState();
- keepSelectedClients();
- checkChildrenCheckboxes();
- checkParentsCheckboxes();
+ {% if selection_mode == 'commands' %}
+ keepSelectedClients();
+ checkChildrenCheckboxes();
+ checkParentsCheckboxes();
+ {% elif selection_mode == 'scopes' %}
+ limitCheckboxes();
+ {% endif %}
}
});
</script>
diff --git a/ogcp/templates/scopes.html b/ogcp/templates/scopes.html
index 751272d..d07e7d3 100644
--- a/ogcp/templates/scopes.html
+++ b/ogcp/templates/scopes.html
@@ -12,7 +12,7 @@
{% endblock %}
{% block sidebar %}
- {{ macros.scopes_tree_collapse(scopes, sidebar_state) }}
+ {{ macros.scopes_tree_collapse(scopes, sidebar_state, 'scopes') }}
{% endblock %}
{% block commands %}