|
10 | 10 | isJapanese: boolean; |
11 | 11 | onSelect: (id: number) => void; |
12 | 12 | } = $props(); |
| 13 | +
|
| 14 | + let showConfirmation = $state(false); |
| 15 | + let selectedBoardId = $state<number | null>(null); |
| 16 | +
|
| 17 | + function handleLoadClick(id: number) { |
| 18 | + selectedBoardId = id; |
| 19 | + showConfirmation = true; |
| 20 | + } |
| 21 | +
|
| 22 | + function handleConfirmLoad() { |
| 23 | + if (selectedBoardId !== null) { |
| 24 | + onSelect(selectedBoardId); |
| 25 | + } |
| 26 | + showConfirmation = false; |
| 27 | + selectedBoardId = null; |
| 28 | + } |
13 | 29 | </script> |
14 | 30 |
|
15 | 31 | <dialog class="modal" open={manager.saveState.saving}> |
|
105 | 121 | <td class="text-right"> |
106 | 122 | <button |
107 | 123 | class="btn btn-sm btn-success text-black" |
108 | | - onclick={() => onSelect(item.id)} |
| 124 | + onclick={() => handleLoadClick(item.id)} |
109 | 125 | > |
110 | 126 | {isJapanese ? "ロード" : "Load"} |
111 | 127 | </button> |
|
125 | 141 | </div> |
126 | 142 | </dialog> |
127 | 143 |
|
| 144 | +<dialog class="modal modal-middle" open={showConfirmation}> |
| 145 | + <div class="modal-box"> |
| 146 | + <h3 class="font-bold text-lg"> |
| 147 | + {isJapanese ? "警告" : "Caution"} |
| 148 | + </h3> |
| 149 | + <p class="py-4"> |
| 150 | + {isJapanese |
| 151 | + ? "盤面に加え、コードも上書きされます。よろしいですか?" |
| 152 | + : "The current board and **CODE** will be overwritten. Are you sure?"} |
| 153 | + </p> |
| 154 | + <div class="modal-action"> |
| 155 | + <button class="btn btn-error" onclick={() => (showConfirmation = false)}> |
| 156 | + {isJapanese ? "いいえ" : "No"} |
| 157 | + </button> |
| 158 | + <button class="btn btn-success text-black" onclick={handleConfirmLoad}> |
| 159 | + {isJapanese ? "はい" : "Yes"} |
| 160 | + </button> |
| 161 | + </div> |
| 162 | + </div> |
| 163 | +</dialog> |
| 164 | + |
128 | 165 | <style> |
129 | 166 | .board-preview { |
130 | 167 | display: grid; |
|
0 commit comments