mirror of https://git.48k.eu/ogcp
Add different selection mode for the tree view
parent
1db12230f9
commit
efe9731753
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in New Issue