This commit is contained in:
parent
9855fc9b6d
commit
5b6b4faa14
@ -224,18 +224,6 @@
|
||||
form.submit();
|
||||
}
|
||||
|
||||
if (window.jQuery && window.$ && $.confirm) {
|
||||
$.confirm({
|
||||
title: '確認ダイアログ。',
|
||||
content: '登録してよろしいですか? はい/いいえ',
|
||||
buttons: {
|
||||
ok: { text: 'はい', btnClass: 'btn-primary', action: submitNow },
|
||||
いいえ: function () {}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (confirm('登録してよろしいですか?')) submitNow();
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
@ -159,17 +159,17 @@
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
// 全選択
|
||||
// ▼ 全選択チェックボックスの処理
|
||||
document.getElementById('check-all')?.addEventListener('change', function(e){
|
||||
document.querySelectorAll('input[name="ids[]"]').forEach(function(el){ el.checked = e.target.checked; });
|
||||
});
|
||||
|
||||
// 共通: 未選択アラート
|
||||
// ▼ 共通:削除対象が未選択の場合のアラート表示
|
||||
function showNoSelection(){
|
||||
if (window.jQuery && window.$ && $.confirm) {
|
||||
$.confirm({
|
||||
title: '確認ダイアログ。',
|
||||
content: '!削除対象が選択されていません。はい/いいえ',
|
||||
content: '削除対象が選択されていません。',
|
||||
buttons: {
|
||||
ok: { text: 'はい', btnClass: 'btn-primary' },
|
||||
いいえ: function () {}
|
||||
@ -180,12 +180,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 共通: 削除確認ダイアログ
|
||||
// ▼ 共通:削除確認ダイアログ表示
|
||||
function showDeleteConfirm(onYes){
|
||||
if (window.jQuery && window.$ && $.confirm) {
|
||||
$.confirm({
|
||||
title: '削除ダイアログ',
|
||||
content: '!削除してよろしいですか?',
|
||||
title: '削除確認',
|
||||
content: '削除してよろしいですか?',
|
||||
buttons: {
|
||||
ok: { text: 'はい', btnClass: 'btn-primary', action: function(){ if (typeof onYes==='function') onYes(); } },
|
||||
いいえ: function () {}
|
||||
@ -196,9 +196,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 削除ボタン(#delete_edit)— 選択確認 → ダイアログ → 提出
|
||||
document.getElementById('delete_edit')?.addEventListener('click', function(e){
|
||||
// ▼ 削除ボタン(#delete_edit)のクリックイベント処理
|
||||
// ①選択チェック → ②確認ダイアログ → ③削除フォーム送信
|
||||
const delBtn = document.getElementById('delete_edit');
|
||||
if (delBtn && delBtn.dataset.bound !== '1') {
|
||||
delBtn.dataset.bound = '1'; // 二重バインド防止
|
||||
|
||||
// 捕捉段階で処理を実行し、他のリスナーによる重複ダイアログを防止
|
||||
delBtn.addEventListener('click', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (e.stopImmediatePropagation) e.stopImmediatePropagation();
|
||||
|
||||
const checked = document.querySelectorAll('input[name="ids[]"]:checked').length;
|
||||
if (!checked) return showNoSelection();
|
||||
|
||||
@ -206,14 +215,20 @@
|
||||
if (!form) return;
|
||||
|
||||
showDeleteConfirm(function(){
|
||||
// jQuery 側の submit イベントを回避して、ネイティブでフォーム送信
|
||||
form.submit();
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
|
||||
// フラッシュ自動閉じ
|
||||
// ▼ フラッシュメッセージ(成功/エラー)を5秒後に自動で非表示化
|
||||
setTimeout(function(){
|
||||
document.querySelectorAll('.alert-dismissible')?.forEach(function(el){ el.classList.remove('show'); el.style.display='none'; });
|
||||
document.querySelectorAll('.alert-dismissible')?.forEach(function(el){
|
||||
el.classList.remove('show');
|
||||
el.style.display='none';
|
||||
});
|
||||
}, 5000);
|
||||
})();
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
||||
Loading…
Reference in New Issue
Block a user