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:
@@ -49,6 +49,9 @@ function adminMessages(initialConversationId = null) {
|
||||
replyContent: '',
|
||||
attachedFiles: [],
|
||||
|
||||
// Close conversation confirm state
|
||||
showCloseConversationConfirm: false,
|
||||
|
||||
// Compose modal
|
||||
showComposeModal: false,
|
||||
compose: {
|
||||
@@ -304,8 +307,6 @@ function adminMessages(initialConversationId = null) {
|
||||
* Close conversation
|
||||
*/
|
||||
async closeConversation() {
|
||||
if (!confirm(I18n.t('messaging.confirmations.close_conversation_admin'))) return;
|
||||
|
||||
try {
|
||||
await apiClient.post(`/admin/messages/${this.selectedConversationId}/close`);
|
||||
|
||||
|
||||
@@ -67,6 +67,10 @@ function adminNotifications() {
|
||||
resolvingAlert: null,
|
||||
resolutionNotes: '',
|
||||
|
||||
// Delete notification confirm state
|
||||
showDeleteNotificationConfirm: false,
|
||||
pendingDeleteNotificationId: null,
|
||||
|
||||
/**
|
||||
* Initialize component
|
||||
*/
|
||||
@@ -163,10 +167,6 @@ function adminNotifications() {
|
||||
* Delete notification
|
||||
*/
|
||||
async deleteNotification(notificationId) {
|
||||
if (!confirm(I18n.t('messaging.confirmations.delete_notification'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await apiClient.delete(`/admin/notifications/${notificationId}`);
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ function storeEmailTemplates() {
|
||||
},
|
||||
reverting: false,
|
||||
|
||||
// Revert confirm state
|
||||
showRevertConfirm: false,
|
||||
|
||||
// Preview Modal
|
||||
showPreviewModal: false,
|
||||
previewData: null,
|
||||
@@ -184,10 +187,6 @@ function storeEmailTemplates() {
|
||||
async revertToDefault() {
|
||||
if (!this.editingTemplate) return;
|
||||
|
||||
if (!confirm(I18n.t('messaging.confirmations.delete_customization'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.reverting = true;
|
||||
|
||||
try {
|
||||
|
||||
@@ -46,6 +46,9 @@ function storeMessages(initialConversationId = null) {
|
||||
// Reply form
|
||||
replyContent: '',
|
||||
|
||||
// Close conversation confirm state
|
||||
showCloseConversationConfirm: false,
|
||||
|
||||
// Compose modal
|
||||
showComposeModal: false,
|
||||
compose: {
|
||||
@@ -279,8 +282,6 @@ function storeMessages(initialConversationId = null) {
|
||||
* Close conversation
|
||||
*/
|
||||
async closeConversation() {
|
||||
if (!confirm(I18n.t('messaging.confirmations.close_conversation'))) return;
|
||||
|
||||
try {
|
||||
await apiClient.post(`/store/messages/${this.selectedConversationId}/close`);
|
||||
|
||||
|
||||
@@ -42,6 +42,10 @@ function storeNotifications() {
|
||||
is_read: ''
|
||||
},
|
||||
|
||||
// Delete notification confirm state
|
||||
showDeleteNotificationConfirm: false,
|
||||
pendingDeleteNotificationId: null,
|
||||
|
||||
// Settings
|
||||
settings: null,
|
||||
showSettingsModal: false,
|
||||
@@ -153,10 +157,6 @@ function storeNotifications() {
|
||||
* Delete notification
|
||||
*/
|
||||
async deleteNotification(notificationId) {
|
||||
if (!confirm(I18n.t('messaging.confirmations.delete_notification'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await apiClient.delete(`/store/notifications/${notificationId}`);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header_flex %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
{% from 'shared/macros/modals.html' import form_modal %}
|
||||
{% from 'shared/macros/modals.html' import form_modal, confirm_modal %}
|
||||
|
||||
{% block title %}Messages{% endblock %}
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<template x-if="!selectedConversation.is_closed">
|
||||
<button @click="closeConversation()"
|
||||
<button @click="showCloseConversationConfirm = true"
|
||||
class="px-3 py-1.5 text-sm font-medium text-gray-600 bg-gray-100 rounded-lg hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600">
|
||||
Close
|
||||
</button>
|
||||
@@ -329,6 +329,9 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
<!-- Close Conversation Confirm Modal -->
|
||||
{{ confirm_modal('closeConversationConfirm', 'Close Conversation', 'Are you sure you want to close this conversation? You can reopen it later if needed.', 'closeConversation()', 'showCloseConversationConfirm', 'Close Conversation', 'Cancel', 'warning') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
{% from 'shared/macros/modals.html' import confirm_modal %}
|
||||
|
||||
{% block title %}Notifications{% endblock %}
|
||||
|
||||
@@ -213,7 +214,7 @@
|
||||
Mark read
|
||||
</button>
|
||||
</template>
|
||||
<button @click="deleteNotification(notif.id)"
|
||||
<button @click="pendingDeleteNotificationId = notif.id; showDeleteNotificationConfirm = true"
|
||||
class="p-1 text-gray-400 hover:text-red-500 transition-colors">
|
||||
<span x-html="$icon('trash', 'w-4 h-4')"></span>
|
||||
</button>
|
||||
@@ -354,6 +355,9 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Notification Confirm Modal -->
|
||||
{{ confirm_modal('deleteNotificationConfirm', 'Delete Notification', 'Are you sure you want to delete this notification? This action cannot be undone.', 'deleteNotification(pendingDeleteNotificationId)', 'showDeleteNotificationConfirm', 'Delete', 'Cancel', 'danger') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% extends "store/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header_flex %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
{% from 'shared/macros/modals.html' import modal_dialog %}
|
||||
{% from 'shared/macros/modals.html' import modal_dialog, confirm_modal %}
|
||||
|
||||
{% block title %}Email Templates{% endblock %}
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
<!-- Revert to Default Button -->
|
||||
<template x-if="templateSource === 'store_override'">
|
||||
<button
|
||||
@click="revertToDefault()"
|
||||
@click="showRevertConfirm = true"
|
||||
:disabled="reverting"
|
||||
class="px-4 py-2 text-sm font-medium text-red-600 hover:text-red-700 hover:bg-red-50 rounded-lg dark:text-red-400 dark:hover:bg-red-900/20"
|
||||
>
|
||||
@@ -323,6 +323,9 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
<!-- Revert to Default Confirm Modal -->
|
||||
{{ confirm_modal('revertConfirm', 'Revert to Platform Default', 'Are you sure you want to delete your customization and revert to the platform default template? This action cannot be undone.', 'revertToDefault()', 'showRevertConfirm', 'Revert', 'Cancel', 'danger') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% extends "store/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
{% from 'shared/macros/modals.html' import modal_simple %}
|
||||
{% from 'shared/macros/modals.html' import modal_simple, confirm_modal %}
|
||||
|
||||
{% block title %}Messages{% endblock %}
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<template x-if="!selectedConversation.is_closed">
|
||||
<button @click="closeConversation()"
|
||||
<button @click="showCloseConversationConfirm = true"
|
||||
class="px-3 py-1.5 text-sm font-medium text-gray-600 bg-gray-100 rounded-lg hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600">
|
||||
Close
|
||||
</button>
|
||||
@@ -272,6 +272,9 @@
|
||||
</div>
|
||||
</form>
|
||||
{% endcall %}
|
||||
|
||||
<!-- Close Conversation Confirm Modal -->
|
||||
{{ confirm_modal('closeConversationConfirm', 'Close Conversation', 'Are you sure you want to close this conversation? You can reopen it later if needed.', 'closeConversation()', 'showCloseConversationConfirm', 'Close Conversation', 'Cancel', 'warning') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{% from 'shared/macros/headers.html' import page_header_flex, refresh_button %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
{% from 'shared/macros/pagination.html' import pagination_simple %}
|
||||
{% from 'shared/macros/modals.html' import modal_simple %}
|
||||
{% from 'shared/macros/modals.html' import modal_simple, confirm_modal %}
|
||||
|
||||
{% block title %}Notifications{% endblock %}
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
Mark read
|
||||
</button>
|
||||
</template>
|
||||
<button @click="deleteNotification(notif.id)"
|
||||
<button @click="pendingDeleteNotificationId = notif.id; showDeleteNotificationConfirm = true"
|
||||
class="p-1 text-gray-400 hover:text-red-500 transition-colors">
|
||||
<span x-html="$icon('trash', 'w-4 h-4')"></span>
|
||||
</button>
|
||||
@@ -223,6 +223,9 @@
|
||||
</button>
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
<!-- Delete Notification Confirm Modal -->
|
||||
{{ confirm_modal('deleteNotificationConfirm', 'Delete Notification', 'Are you sure you want to delete this notification? This action cannot be undone.', 'deleteNotification(pendingDeleteNotificationId)', 'showDeleteNotificationConfirm', 'Delete', 'Cancel', 'danger') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
|
||||
Reference in New Issue
Block a user