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