This commit is contained in:
Andras Bacsai
2023-05-04 15:45:53 +02:00
parent ec0e560bac
commit d5b332fc59
16 changed files with 149 additions and 43 deletions

View File

@@ -2,11 +2,17 @@
document.addEventListener('alpine:init', () => {
Alpine.data('confirmModal', () => ({
open: false,
confirmAction: null,
message: 'Are you sure?',
toggleConfirmModal(customMessage) {
toggleConfirmModal(customMessage, confirmAction) {
this.confirmAction = confirmAction
this.message = customMessage
this.open = !this.open
},
confirmed() {
this.open = false
this.$dispatch(this.confirmAction)
}
}))
})
</script>
@@ -16,7 +22,7 @@
<div class="flex flex-col items-center justify-center h-full">
<div class="pb-5 text-white" x-text="message"></div>
<div>
<x-inputs.button isWarning x-on:click="$dispatch('confirm')">Confirm</x-inputs.button>
<x-inputs.button isWarning x-on:click='confirmed()'>Confirm</x-inputs.button>
<x-inputs.button x-on:click="open = false">Cancel</x-inputs.button>
</div>
</div>

View File

@@ -15,10 +15,10 @@
wire:loading.delay.class.remove="{{ $defaultClass }} {{ $attributes->whereStartsWith('class')->first() }}"
@endif
@isset($confirm)
x-on:click="toggleConfirmModal('{{ $confirm }}')"
x-on:click="toggleConfirmModal('{{ $confirm }}', '{{ explode('(', $confirmAction)[0] }}')"
@endisset
@isset($confirmAction)
@confirm.window="$wire.{{ $confirmAction }}()"
x-on:{{ explode('(', $confirmAction)[0] }}.window="$wire.{{ explode('(', $confirmAction)[0] }}"
@endisset>
{{ $slot }}
</button>

View File

@@ -27,7 +27,7 @@
<textarea {{ $attributes }} type={{ $type }} id={{ $id }} wire:model.defer={{ $id }}></textarea>
@else
<input {{ $attributes }} type={{ $type }} id={{ $id }}
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $id }} @endif />
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $value ?? $id }} @endif />
@endif
@error($id)

View File

@@ -73,6 +73,9 @@
console.log('Update initiated. Waiting for server to be dead...')
checkIfIamDead();
})
Livewire.on('reloadWindow', () => {
window.location.reload();
})
</script>
@endauth
</body>