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:
@@ -42,6 +42,11 @@
|
||||
loaded: false,
|
||||
error: null,
|
||||
|
||||
// Limit reached modal state
|
||||
showLimitReachedConfirm: false,
|
||||
limitReachedMessage: '',
|
||||
limitReachedUpgradeUrl: null,
|
||||
|
||||
// Computed-like getters
|
||||
get hasLimitsApproaching() {
|
||||
return this.usage?.has_limits_approaching || false;
|
||||
@@ -193,18 +198,24 @@
|
||||
const limitName = limitNames[limitType] || limitType;
|
||||
const message = response.message || `You've reached your ${limitName} limit.`;
|
||||
|
||||
// Use browser confirm for simplicity - could be replaced with custom modal
|
||||
const shouldUpgrade = confirm(
|
||||
`${message}\n\n` +
|
||||
`Current: ${response.current}/${response.limit}\n\n` +
|
||||
const details = `${message} Current usage: ${response.current}/${response.limit}. ` +
|
||||
(response.upgrade_tier_name
|
||||
? `Upgrade to ${response.upgrade_tier_name} to get more ${limitName}.\n\nGo to billing page?`
|
||||
: 'Contact support for more capacity.')
|
||||
);
|
||||
? `Upgrade to ${response.upgrade_tier_name} to get more ${limitName}.`
|
||||
: 'Contact support for more capacity.');
|
||||
|
||||
if (shouldUpgrade && response.upgrade_tier_code) {
|
||||
window.location.href = this.getBillingUrl();
|
||||
this.limitReachedMessage = details;
|
||||
this.limitReachedUpgradeUrl = response.upgrade_tier_code ? this.getBillingUrl() : null;
|
||||
this.showLimitReachedConfirm = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle upgrade confirmation from limit reached modal
|
||||
*/
|
||||
confirmUpgrade() {
|
||||
if (this.limitReachedUpgradeUrl) {
|
||||
window.location.href = this.limitReachedUpgradeUrl;
|
||||
}
|
||||
this.showLimitReachedConfirm = false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,8 @@ function storeBilling() {
|
||||
showTiersModal: false,
|
||||
showAddonsModal: false,
|
||||
showCancelModal: false,
|
||||
showCancelAddonConfirm: false,
|
||||
pendingCancelAddon: null,
|
||||
showSuccessMessage: false,
|
||||
showCancelMessage: false,
|
||||
showAddonSuccessMessage: false,
|
||||
@@ -172,10 +174,6 @@ function storeBilling() {
|
||||
},
|
||||
|
||||
async cancelAddon(addon) {
|
||||
if (!confirm(`Are you sure you want to cancel ${addon.addon_name}?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await apiClient.delete(`/store/billing/addons/${addon.id}`);
|
||||
Utils.showToast(I18n.t('billing.messages.addon_cancelled_successfully'), 'success');
|
||||
|
||||
@@ -68,6 +68,11 @@ function storeInvoices() {
|
||||
status: ''
|
||||
},
|
||||
|
||||
// Update status confirm state
|
||||
showUpdateStatusConfirm: false,
|
||||
pendingStatusInvoice: null,
|
||||
pendingNewStatus: null,
|
||||
|
||||
// Create invoice modal
|
||||
showCreateModal: false,
|
||||
createForm: {
|
||||
@@ -291,16 +296,6 @@ function storeInvoices() {
|
||||
* Update invoice status
|
||||
*/
|
||||
async updateStatus(invoice, newStatus) {
|
||||
const statusLabels = {
|
||||
'issued': 'mark as issued',
|
||||
'paid': 'mark as paid',
|
||||
'cancelled': 'cancel'
|
||||
};
|
||||
|
||||
if (!confirm(`Are you sure you want to ${statusLabels[newStatus] || newStatus} this invoice?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await apiClient.put(`/store/invoices/${invoice.id}/status`, {
|
||||
status: newStatus
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{# app/modules/billing/templates/billing/merchant/subscription-detail.html #}
|
||||
{% extends "merchant/base.html" %}
|
||||
{% from 'shared/macros/modals.html' import confirm_modal %}
|
||||
|
||||
{% block title %}Subscription Details{% endblock %}
|
||||
|
||||
@@ -119,7 +120,7 @@
|
||||
<span class="inline-block mt-3 px-3 py-1 text-xs font-semibold text-purple-700 dark:text-purple-400 bg-purple-100 dark:bg-purple-900/30 rounded-full">Current Plan</span>
|
||||
</template>
|
||||
<template x-if="!t.is_current">
|
||||
<button @click="changeTier(t.code)"
|
||||
<button @click="pendingTierCode = t.code; showChangeTierConfirm = true"
|
||||
:disabled="changingTier"
|
||||
class="mt-3 inline-flex items-center px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors disabled:opacity-50"
|
||||
:class="t.can_upgrade ? 'bg-purple-600 hover:bg-purple-700' : 'bg-gray-600 hover:bg-gray-700'"
|
||||
@@ -133,6 +134,9 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Change Tier Confirm Modal -->
|
||||
{{ confirm_modal('changeTierConfirm', 'Change Plan', 'Are you sure you want to change your plan to this tier? Your billing will be adjusted accordingly.', 'changeTier(pendingTierCode)', 'showChangeTierConfirm', 'Change Plan', 'Cancel', 'warning') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
@@ -145,6 +149,8 @@ function merchantSubscriptionDetail() {
|
||||
subscription: null,
|
||||
availableTiers: [],
|
||||
changingTier: false,
|
||||
showChangeTierConfirm: false,
|
||||
pendingTierCode: null,
|
||||
|
||||
init() {
|
||||
this.loadSubscription();
|
||||
@@ -182,8 +188,6 @@ function merchantSubscriptionDetail() {
|
||||
},
|
||||
|
||||
async changeTier(tierCode) {
|
||||
if (!confirm(`Are you sure you want to change your plan to this tier?`)) return;
|
||||
|
||||
this.changingTier = true;
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{# app/templates/store/billing.html #}
|
||||
{% extends "store/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header %}
|
||||
{% from 'shared/macros/modals.html' import modal_simple %}
|
||||
{% from 'shared/macros/modals.html' import modal_simple, confirm_modal_dynamic %}
|
||||
|
||||
{% block title %}Billing & Subscription{% endblock %}
|
||||
|
||||
@@ -308,7 +308,7 @@
|
||||
<span x-text="addon.period_end ? `Renews ${formatDate(addon.period_end)}` : 'Active'"></span>
|
||||
</p>
|
||||
</div>
|
||||
<button @click="cancelAddon(addon)"
|
||||
<button @click="pendingCancelAddon = addon; showCancelAddonConfirm = true"
|
||||
class="px-3 py-1 text-sm font-medium text-red-600 bg-red-100 rounded-lg hover:bg-red-200 dark:bg-red-900/50 dark:text-red-400">
|
||||
Cancel
|
||||
</button>
|
||||
@@ -355,6 +355,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Cancel Add-on Confirm Modal -->
|
||||
{{ confirm_modal_dynamic('cancelAddonConfirm', 'Cancel Add-on', "'Are you sure you want to cancel ' + (pendingCancelAddon?.addon_name || 'this add-on') + '?'", 'cancelAddon(pendingCancelAddon)', 'showCancelAddonConfirm', 'Cancel Add-on', 'Keep', 'danger') }}
|
||||
|
||||
<!-- Cancel Subscription Modal -->
|
||||
<div x-show="showCancelModal"
|
||||
x-transition:enter="transition ease-out duration-150"
|
||||
|
||||
Reference in New Issue
Block a user