fix: replace all native confirm() dialogs with styled modal macros
Some checks failed
CI / ruff (push) Successful in 9s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has been cancelled

Migrated ~68 native browser confirm() calls across 74 files to use the
project's confirm_modal/confirm_modal_dynamic Jinja2 macros, providing
consistent styled confirmation dialogs instead of plain browser popups.

Modules updated: core, tenancy, cms, marketplace, messaging, billing,
customers, orders, cart. Uses danger/warning/info variants and
double-confirm pattern for destructive delete operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 16:56:25 +01:00
parent 182610283d
commit 167bb50f4f
74 changed files with 939 additions and 436 deletions

View File

@@ -16,6 +16,10 @@ function adminUsers() {
users: [],
loading: false,
error: null,
showToggleStatusModal: false,
showDeleteModal: false,
userToToggle: null,
userToDelete: null,
filters: {
search: '',
role: '',
@@ -171,15 +175,15 @@ function adminUsers() {
// Load statistics
async loadStats() {
usersLog.info('Loading user statistics...');
try {
const url = '/admin/users/stats';
window.LogConfig.logApiCall('GET', url, null, 'request');
const response = await apiClient.get(url); // ✅ Fixed: lowercase apiClient
window.LogConfig.logApiCall('GET', url, response, 'response');
if (response) {
this.stats = response;
usersLog.debug('Stats loaded:', this.stats);
@@ -242,23 +246,18 @@ function adminUsers() {
async toggleUserStatus(user) {
const action = user.is_active ? 'deactivate' : 'activate';
usersLog.info(`Toggle user status: ${action}`, user.username);
if (!confirm(`Are you sure you want to ${action} ${user.username}?`)) {
usersLog.info('Status toggle cancelled by user');
return;
}
try {
const url = `/admin/users/${user.id}/status`;
window.LogConfig.logApiCall('PUT', url, { is_active: !user.is_active }, 'request');
await apiClient.put(url, { // ✅ Fixed: lowercase apiClient
is_active: !user.is_active
});
Utils.showToast(`User ${action}d successfully`, 'success');
usersLog.info(`User ${action}d successfully`);
await this.loadUsers();
await this.loadStats();
} catch (error) {
@@ -269,21 +268,16 @@ function adminUsers() {
async deleteUser(user) {
usersLog.warn('Delete user requested:', user.username);
if (!confirm(`Are you sure you want to delete ${user.username}? This action cannot be undone.`)) {
usersLog.info('Delete cancelled by user');
return;
}
try {
const url = `/admin/users/${user.id}`;
window.LogConfig.logApiCall('DELETE', url, null, 'request');
await apiClient.delete(url); // ✅ Fixed: lowercase apiClient
Utils.showToast(I18n.t('tenancy.messages.user_deleted_successfully'), 'success');
usersLog.info('User deleted successfully');
await this.loadUsers();
await this.loadStats();
} catch (error) {
@@ -299,4 +293,4 @@ function adminUsers() {
};
}
usersLog.info('Users module loaded');
usersLog.info('Users module loaded');