削除確認モーダルのsubmit処理を変更

This commit is contained in:
shibafu 2020-08-07 22:35:49 +09:00
parent 2f928a29e1
commit 969bc79cbc
2 changed files with 20 additions and 17 deletions

View File

@ -16,14 +16,17 @@ $('.copy-to-clipboard').on('shown.bs.popover', function () {
setTimeout(() => $(this).popover('hide'), 3000);
});
const $deleteModal = $('#deleteIncomingWebhookModal');
$deleteModal.find('.btn-danger').on('click', function () {
const $form = $deleteModal.find('form');
$form.attr('action', $form.attr('action')?.replace('@', $deleteModal.data('id')) || null);
$form.submit();
});
$('[data-target="#deleteIncomingWebhookModal"]').on('click', function (event) {
event.preventDefault();
$deleteModal.data('id', $(this).data('id'));
$deleteModal.modal('show', this);
});
const deleteModal = document.getElementById('deleteIncomingWebhookModal');
if (deleteModal) {
let id: any = null;
deleteModal.querySelector('form')?.addEventListener('submit', function () {
this.action = this.action.replace('@', id);
});
document.querySelectorAll<HTMLElement>('[data-target="#deleteIncomingWebhookModal"]').forEach((el) => {
el.addEventListener('click', function (e) {
e.preventDefault();
id = this.dataset.id;
$(deleteModal).modal('show', this);
});
});
}

View File

@ -54,13 +54,13 @@
削除確認
@endslot
Webhookを削除してもよろしいですか
<form action="{{ route('setting.webhooks.destroy', ['webhook' => '@']) }}" method="post">
{{ csrf_field() }}
{{ method_field('DELETE') }}
</form>
@slot('footer')
<button type="button" class="btn btn-secondary" data-dismiss="modal">キャンセル</button>
<button type="button" class="btn btn-danger">削除</button>
<form action="{{ route('setting.webhooks.destroy', ['webhook' => '@']) }}" method="post">
{{ csrf_field() }}
{{ method_field('DELETE') }}
<button type="button" class="btn btn-secondary" data-dismiss="modal">キャンセル</button>
<button type="submit" class="btn btn-danger">削除</button>
</form>
@endslot
@endcomponent
@endsection