From 0f4890cdfe3ed5d54b2e49ae78382a080e114e92 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Fri, 24 Jul 2026 20:56:05 +0000 Subject: [PATCH] Replace native confirms with Ladill custom dialogs. --- resources/js/ladill-modals.js | 13 +- .../views/components/app-layout.blade.php | 1 + .../components/hosting-panel-layout.blade.php | 1 + .../views/components/user-layout.blade.php | 1 + .../views/links/campaigns/show.blade.php | 2 +- resources/views/links/domains/index.blade.php | 2 +- resources/views/links/show.blade.php | 2 +- .../views/partials/confirm-prompt.blade.php | 248 ++++++++++++++---- 8 files changed, 216 insertions(+), 54 deletions(-) diff --git a/resources/js/ladill-modals.js b/resources/js/ladill-modals.js index eb2bf74..0eda97a 100644 --- a/resources/js/ladill-modals.js +++ b/resources/js/ladill-modals.js @@ -33,6 +33,10 @@ export function ladillNeedsTopup(balance, price) { return normalizedBalance <= 0 || normalizedBalance < normalizedPrice; } +/** + * Alpine store mirrors window.ladillConfirm (defined in partials/confirm-prompt). + * Prefer window.ladillConfirm for new code — it works without Alpine and powers data-confirm forms. + */ export function registerLadillConfirmStore(Alpine) { Alpine.store('ladillConfirm', { open: false, @@ -44,6 +48,11 @@ export function registerLadillConfirmStore(Alpine) { _resolve: null, ask(options = {}) { + // Delegate to the global custom dialog when available (no double UI). + if (typeof window.ladillConfirm === 'function' && window.__ladillConfirmInstalled) { + return window.ladillConfirm(options); + } + return new Promise((resolve) => { this.title = options.title || 'Are you sure?'; this.message = options.message || ''; @@ -65,7 +74,9 @@ export function registerLadillConfirmStore(Alpine) { }, }); - window.ladillConfirm = (options = {}) => Alpine.store('ladillConfirm').ask(options); + if (typeof window.ladillConfirm !== 'function') { + window.ladillConfirm = (options = {}) => Alpine.store('ladillConfirm').ask(options); + } } export function registerLadillModalHelpers() { diff --git a/resources/views/components/app-layout.blade.php b/resources/views/components/app-layout.blade.php index 96a7909..dd13f70 100644 --- a/resources/views/components/app-layout.blade.php +++ b/resources/views/components/app-layout.blade.php @@ -29,5 +29,6 @@ @auth @include('partials.afia') @endauth + @include('partials.confirm-prompt') diff --git a/resources/views/components/hosting-panel-layout.blade.php b/resources/views/components/hosting-panel-layout.blade.php index 978ac9e..e5e68e6 100644 --- a/resources/views/components/hosting-panel-layout.blade.php +++ b/resources/views/components/hosting-panel-layout.blade.php @@ -69,5 +69,6 @@ @stack('scripts') + @include('partials.confirm-prompt') diff --git a/resources/views/components/user-layout.blade.php b/resources/views/components/user-layout.blade.php index 96a7909..dd13f70 100644 --- a/resources/views/components/user-layout.blade.php +++ b/resources/views/components/user-layout.blade.php @@ -29,5 +29,6 @@ @auth @include('partials.afia') @endauth + @include('partials.confirm-prompt') diff --git a/resources/views/links/campaigns/show.blade.php b/resources/views/links/campaigns/show.blade.php index e506b24..421a357 100644 --- a/resources/views/links/campaigns/show.blade.php +++ b/resources/views/links/campaigns/show.blade.php @@ -30,7 +30,7 @@

{{ $campaign->description }}

@endif -
+ @csrf @method('DELETE')
diff --git a/resources/views/links/domains/index.blade.php b/resources/views/links/domains/index.blade.php index 4080a85..627a6c6 100644 --- a/resources/views/links/domains/index.blade.php +++ b/resources/views/links/domains/index.blade.php @@ -73,7 +73,7 @@ @endif -
+ @csrf @method('DELETE')
diff --git a/resources/views/links/show.blade.php b/resources/views/links/show.blade.php index 41db38f..2b1ad0b 100644 --- a/resources/views/links/show.blade.php +++ b/resources/views/links/show.blade.php @@ -19,7 +19,7 @@

@if ($link->is_managed_here) -
+ @csrf @method('DELETE')
diff --git a/resources/views/partials/confirm-prompt.blade.php b/resources/views/partials/confirm-prompt.blade.php index c519339..2b0af65 100644 --- a/resources/views/partials/confirm-prompt.blade.php +++ b/resources/views/partials/confirm-prompt.blade.php @@ -1,65 +1,213 @@ -
-
+{{-- + Ladill custom confirm dialog (replaces native window.confirm for app UX). -
+ Usage: + 1) Forms:
+ 2) JS: const ok = await window.ladillConfirm({ title, message, confirmLabel, variant }) + + Bottom sheet on mobile, centered card on desktop — same pattern as x-modal. +--}} +