Show the list of selected domains on toggle/delete confirmation (#7682)

* Show the list of selected domains on toggle/delete confirmation

* Update app_languages.php

* Update modal.php

* Update domains.php
This commit is contained in:
Alex
2025-12-29 14:09:53 -07:00
committed by GitHub
parent 07d2040ddc
commit 295db3b9c8
3 changed files with 94 additions and 6 deletions

View File

@@ -198,6 +198,32 @@
$document['title'] = $text['title-domains'];
require_once "resources/header.php";
//add the list of selected domains to the toggle/delete confirmation
if (permission_exists('domain_edit') || permission_exists('domain_delete')) {
?>
<script>
function get_selected_items(action) {
const selected_items = [];
const modal_message_element = document.querySelector('#modal-' + action + ' .modal-message');
if (!modal_message_element.hasAttribute('data-original-message')) {
modal_message_element.setAttribute('data-original-message', modal_message_element.innerHTML);
}
const original_message = modal_message_element.getAttribute('data-original-message');
document.querySelectorAll('input[type="checkbox"]:checked:not(#checkbox_all)').forEach(checkbox => {
selected_items.push(checkbox.dataset.itemName);
});
if (selected_items.length > 0) {
const item_list = selected_items.map(item => '<li>' + item + '</li>').join('');
modal_message_element.innerHTML = original_message + '<ul style="margin-top: 20px;">' + item_list + '</ul>';
}
}
</script>
<?php
}
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-domains']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
@@ -206,10 +232,10 @@
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'domain_edit.php']);
}
if (permission_exists('domain_edit') && $domains) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none;','onclick'=>"get_selected_items('toggle'); modal_open('modal-toggle','btn_toggle');"]);
}
if (permission_exists('domain_delete') && $domains) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete_domain');"]);
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"get_selected_items('delete'); modal_open('modal-delete','btn_delete_domain');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
@@ -224,10 +250,10 @@
echo "</div>\n";
if (permission_exists('domain_edit') && !empty($domains)) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
echo modal::create(['id'=>'modal-toggle','type'=>'toggle_items','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('domain_delete') && !empty($domains)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
echo modal::create(['id'=>'modal-delete','type'=>'delete_items','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['description-domains']."\n";
@@ -267,7 +293,7 @@
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('domain_edit') || permission_exists('domain_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='domains[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='checkbox' name='domains[$x][checked]' id='checkbox_".$x."' value='true' data-item-name='".escape($row['domain_name'])."' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='domains[$x][uuid]' value='".escape($row['domain_uuid'])."' />\n";
echo " </td>\n";
}