fix: replace all native confirm() dialogs with styled modal macros
Some checks failed
Some checks failed
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:
@@ -28,6 +28,8 @@ function adminMyMenuConfig() {
|
||||
|
||||
// Data
|
||||
menuConfig: null,
|
||||
showShowAllModal: false,
|
||||
showHideAllModal: false,
|
||||
|
||||
// Computed grouped items
|
||||
get groupedItems() {
|
||||
@@ -143,10 +145,6 @@ function adminMyMenuConfig() {
|
||||
},
|
||||
|
||||
async showAll() {
|
||||
if (!confirm(I18n.t('core.confirmations.show_all_menu_items'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
@@ -165,10 +163,6 @@ function adminMyMenuConfig() {
|
||||
},
|
||||
|
||||
async resetToDefaults() {
|
||||
if (!confirm(I18n.t('core.confirmations.hide_all_menu_items'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
|
||||
@@ -80,6 +80,8 @@ function adminSettings() {
|
||||
sendingTestEmail: false,
|
||||
testEmailError: null,
|
||||
testEmailSuccess: null,
|
||||
showResetEmailModal: false,
|
||||
showCleanupLogsModal: false,
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
@@ -194,10 +196,6 @@ function adminSettings() {
|
||||
},
|
||||
|
||||
async cleanupOldLogs() {
|
||||
if (!confirm(`This will delete all logs older than ${this.logSettings.db_log_retention_days} days. Continue?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
|
||||
@@ -439,10 +437,6 @@ function adminSettings() {
|
||||
},
|
||||
|
||||
async resetEmailSettings() {
|
||||
if (!confirm(I18n.t('core.confirmations.reset_email_settings'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% from 'shared/macros/alerts.html' import alert_dynamic, error_state %}
|
||||
{% from 'shared/macros/headers.html' import page_header %}
|
||||
{% from 'shared/macros/modals.html' import confirm_modal %}
|
||||
|
||||
{% block title %}My Menu{% endblock %}
|
||||
|
||||
@@ -68,7 +69,7 @@
|
||||
</p>
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
@click="showAll()"
|
||||
@click="showShowAllModal = true"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-600"
|
||||
>
|
||||
@@ -76,7 +77,7 @@
|
||||
Show All
|
||||
</button>
|
||||
<button
|
||||
@click="resetToDefaults()"
|
||||
@click="showHideAllModal = true"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-600"
|
||||
>
|
||||
@@ -167,6 +168,31 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Confirmation Modals -->
|
||||
{{ confirm_modal(
|
||||
'showAllModal',
|
||||
'Show All Menu Items',
|
||||
'This will make all menu items visible in your sidebar. Are you sure?',
|
||||
'showAll()',
|
||||
'showShowAllModal',
|
||||
'Show All',
|
||||
'Cancel',
|
||||
'info',
|
||||
'eye'
|
||||
) }}
|
||||
|
||||
{{ confirm_modal(
|
||||
'hideAllModal',
|
||||
'Hide All Menu Items',
|
||||
'This will hide all non-mandatory menu items from your sidebar. Are you sure?',
|
||||
'resetToDefaults()',
|
||||
'showHideAllModal',
|
||||
'Hide All',
|
||||
'Cancel',
|
||||
'warning',
|
||||
'eye-off'
|
||||
) }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
{% from 'shared/macros/headers.html' import page_header_refresh %}
|
||||
{% from 'shared/macros/tabs.html' import tabs_nav, tab_button %}
|
||||
{% from 'shared/macros/inputs.html' import number_stepper %}
|
||||
{% from 'shared/macros/modals.html' import confirm_modal, confirm_modal_dynamic %}
|
||||
|
||||
{% block title %}Platform Settings{% endblock %}
|
||||
|
||||
@@ -208,7 +209,7 @@
|
||||
View Logs
|
||||
</a>
|
||||
<button
|
||||
@click="cleanupOldLogs()"
|
||||
@click="showCleanupLogsModal = true"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 transition-colors duration-150 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:shadow-outline-gray"
|
||||
>
|
||||
<span x-html="$icon('delete', 'w-4 h-4 mr-2')"></span>
|
||||
@@ -355,7 +356,7 @@
|
||||
<template x-if="emailSettings.has_db_overrides">
|
||||
<div class="mt-4">
|
||||
<button
|
||||
@click="resetEmailSettings()"
|
||||
@click="showResetEmailModal = true"
|
||||
:disabled="saving"
|
||||
class="px-4 py-2 text-sm font-medium text-red-600 dark:text-red-400 bg-white dark:bg-gray-700 border border-red-300 dark:border-red-600 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50"
|
||||
>
|
||||
@@ -775,6 +776,30 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Confirmation Modals -->
|
||||
{{ confirm_modal(
|
||||
'resetEmailModal',
|
||||
'Reset Email Settings',
|
||||
'This will remove all database overrides and revert email configuration to .env defaults. Are you sure?',
|
||||
'resetEmailSettings()',
|
||||
'showResetEmailModal',
|
||||
'Reset to Defaults',
|
||||
'Cancel',
|
||||
'warning',
|
||||
'refresh'
|
||||
) }}
|
||||
|
||||
{{ confirm_modal_dynamic(
|
||||
'cleanupLogsModal',
|
||||
'Cleanup Old Logs',
|
||||
"'This will permanently delete all logs older than ' + logSettings.db_log_retention_days + ' days. This action cannot be undone.'",
|
||||
'cleanupOldLogs()',
|
||||
'showCleanupLogsModal',
|
||||
'Delete Old Logs',
|
||||
'Cancel',
|
||||
'danger'
|
||||
) }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
|
||||
Reference in New Issue
Block a user