mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 02:01:33 +00:00
Fix inline scripts usage
This commit is contained in:
@@ -4269,7 +4269,94 @@ function initAdminDeletedUsers() {
|
||||
});
|
||||
}
|
||||
|
||||
// Bulk action confirmation
|
||||
// Update selectAll state when individual checkboxes change
|
||||
const userCheckboxes = document.querySelectorAll('.user-checkbox');
|
||||
userCheckboxes.forEach(checkbox => {
|
||||
checkbox.addEventListener('change', function() {
|
||||
const allChecked = Array.from(userCheckboxes).every(cb => cb.checked);
|
||||
const someChecked = Array.from(userCheckboxes).some(cb => cb.checked);
|
||||
if (selectAllCheckbox) {
|
||||
selectAllCheckbox.checked = allChecked;
|
||||
selectAllCheckbox.indeterminate = someChecked && !allChecked;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Bulk action form submit handler
|
||||
const bulkActionForm = document.getElementById('bulkActionForm');
|
||||
if (bulkActionForm) {
|
||||
bulkActionForm.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const action = document.getElementById('bulkAction')?.value;
|
||||
const checkedBoxes = document.querySelectorAll('.user-checkbox:checked');
|
||||
const validationError = document.getElementById('validationError');
|
||||
const validationErrorMessage = document.getElementById('validationErrorMessage');
|
||||
|
||||
// Hide any previous validation errors
|
||||
if (validationError) {
|
||||
validationError.classList.add('hidden');
|
||||
}
|
||||
|
||||
// Validate action selected
|
||||
if (!action) {
|
||||
if (validationError && validationErrorMessage) {
|
||||
validationErrorMessage.textContent = 'Please select an action from the dropdown.';
|
||||
validationError.classList.remove('hidden');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate at least one user selected
|
||||
if (checkedBoxes.length === 0) {
|
||||
if (validationError && validationErrorMessage) {
|
||||
validationErrorMessage.textContent = 'Please select at least one user.';
|
||||
validationError.classList.remove('hidden');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const count = checkedBoxes.length;
|
||||
const actionText = action === 'restore' ? 'restore' : 'permanently delete';
|
||||
const type = action === 'restore' ? 'success' : 'danger';
|
||||
const title = action === 'restore' ? 'Restore Users' : 'Delete Users';
|
||||
|
||||
showConfirm({
|
||||
title: title,
|
||||
message: `Are you sure you want to ${actionText} ${count} user${count > 1 ? 's' : ''}?`,
|
||||
type: type,
|
||||
confirmText: action === 'restore' ? 'Restore' : 'Delete',
|
||||
onConfirm: function() {
|
||||
bulkActionForm.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Event delegation for restore buttons
|
||||
document.addEventListener('click', function(e) {
|
||||
const restoreBtn = e.target.closest('.restore-user-btn');
|
||||
if (restoreBtn) {
|
||||
e.preventDefault();
|
||||
const userId = restoreBtn.dataset.userId;
|
||||
const username = restoreBtn.dataset.username;
|
||||
if (userId && username) {
|
||||
restoreUser(userId, username);
|
||||
}
|
||||
}
|
||||
|
||||
const deleteBtn = e.target.closest('.delete-user-btn');
|
||||
if (deleteBtn) {
|
||||
e.preventDefault();
|
||||
const userId = deleteBtn.dataset.userId;
|
||||
const username = deleteBtn.dataset.username;
|
||||
if (userId && username) {
|
||||
permanentDeleteUser(userId, username);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bulk action confirmation (kept for backward compatibility)
|
||||
window.confirmBulkAction = function(event) {
|
||||
event?.preventDefault();
|
||||
|
||||
@@ -4347,6 +4434,7 @@ window.permanentDeleteUser = function(userId, username) {
|
||||
const form = document.getElementById('individualActionForm');
|
||||
if (form) {
|
||||
const baseUrl = window.location.origin;
|
||||
// Use the correct route: permanent-delete
|
||||
form.action = `${baseUrl}/admin/deleted-users/permanent-delete/${userId}`;
|
||||
form.submit();
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@
|
||||
<option value="delete">Permanently Delete Selected</option>
|
||||
</select>
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-blue-600 dark:bg-blue-700 text-white rounded-md hover:bg-blue-700"
|
||||
onclick="confirmBulkAction(event)">
|
||||
id="bulkActionBtn"
|
||||
class="px-4 py-2 bg-blue-600 dark:bg-blue-700 text-white rounded-md hover:bg-blue-700">
|
||||
<i class="fa fa-check mr-2"></i>Apply
|
||||
</button>
|
||||
</div>
|
||||
@@ -215,15 +215,17 @@
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||
<div class="flex gap-2">
|
||||
<button type="button"
|
||||
class="text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 bg-transparent border-0 p-0 cursor-pointer"
|
||||
class="restore-user-btn text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 bg-transparent border-0 p-0 cursor-pointer"
|
||||
title="Restore User"
|
||||
onclick="restoreUser({{ $user->id }}, '{{ addslashes($user->username) }}')">
|
||||
data-user-id="{{ $user->id }}"
|
||||
data-username="{{ $user->username }}">
|
||||
<i class="fa fa-undo"></i>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 bg-transparent border-0 p-0 cursor-pointer"
|
||||
class="delete-user-btn text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 bg-transparent border-0 p-0 cursor-pointer"
|
||||
title="Permanently Delete"
|
||||
onclick="permanentDeleteUser({{ $user->id }}, '{{ addslashes($user->username) }}')">
|
||||
data-user-id="{{ $user->id }}"
|
||||
data-username="{{ $user->username }}">
|
||||
<i class="fa fa-trash-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -250,7 +252,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Hidden form for individual actions -->
|
||||
<form id="individualActionForm" method="POST" style="display: none;">
|
||||
<form id="individualActionForm" method="POST" class="hidden">
|
||||
@csrf
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user