From 3f16293fea546303775364e2d1f7404815db74f3 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 12 Jun 2024 14:16:42 +0200 Subject: js: show only clients in the scope pills Exclude folders, centers servers and rooms from the scope pills so only clients are shown. --- ogcp/static/js/ogcp.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'ogcp/static/js') diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index b23c6e0..a52ff93 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -25,16 +25,18 @@ async function show_client_mac(pill_id) { function showSelectedClient(client_checkbox) { const container = $('#selected-clients'); const pill_id = 'pill-' + client_checkbox.name.replaceAll(/[. ()]/g, '_'); + const client_name = client_checkbox.name.replaceAll(/_\d+$/g, ''); + if (client_name === 'scope-room' || client_name === 'scope-center' || client_name === 'folder' || client_name === 'scope-server') { + return; + } if (client_checkbox.checked) { if (!($('#' + pill_id).length)) { - const client_name = client_checkbox.name.replaceAll(/_\d+$/g, ''); $(container).append('
' + client_name + '
' + client_checkbox.value + '
'); - if (client_name !== 'scope-room' && client_name !== 'scope-center' && client_name !== 'folder') { - show_client_mac(pill_id); - } + + show_client_mac(pill_id); } return; } @@ -46,11 +48,7 @@ function showSelectedClientsOnEvents() { const checkboxes = $('input:checkbox[form|="scopesForm"]'); const container = $('#selected-clients'); - const client_checkboxes = checkboxes.filter(function () { - return $(this).siblings().length == "1"; - }); - - client_checkboxes.on('change show-client', function () { + checkboxes.on('change show-client', function () { showSelectedClient(this); }); } @@ -401,7 +399,7 @@ function limitCheckboxes() { checkboxes.on('change', function () { const checked = this; checkboxes.filter((i, c) => c !== checked).prop('checked', false); - checkboxes.not('[name="scope-server"]').each(function() { + checkboxes.each(function() { showSelectedClient(this); }); checkScopeServer(); -- cgit v1.2.3-18-g5258