|
13 | 13 | import { type TaskResult, type TaskResults, TaskGrade } from '$lib/types/task'; |
14 | 14 |
|
15 | 15 | import ThermometerProgressBar from '$lib/components/ThermometerProgressBar.svelte'; |
16 | | - import UpdatingModal from '$lib/components/SubmissionStatus/UpdatingModal.svelte'; |
17 | | - import SubmissionStatusImage from '$lib/components/SubmissionStatus/SubmissionStatusImage.svelte'; |
18 | | - import ExternalLinkWrapper from '$lib/components/ExternalLinkWrapper.svelte'; |
19 | 16 | import AcceptedCounter from '$lib/components/SubmissionStatus/AcceptedCounter.svelte'; |
| 17 | + import SubmissionStatusTableBodyCell from '$lib/components/SubmissionStatus/SubmissionStatusInTableBodyCell.svelte'; |
| 18 | + import ExternalLinkWrapper from '$lib/components/ExternalLinkWrapper.svelte'; |
20 | 19 |
|
21 | 20 | import { getBackgroundColorFrom } from '$lib/services/submission_status'; |
22 | 21 |
|
|
33 | 32 |
|
34 | 33 | let { grade, gradeColor, taskResults, isAdmin, isLoggedIn }: Props = $props(); |
35 | 34 |
|
36 | | - // TODO: 他のコンポーネントでも利用できるようにする。 |
37 | | - let updatingModal: UpdatingModal | null = null; |
| 35 | + function updateTaskResult(updatedTask: TaskResult): void { |
| 36 | + const newTaskResults = [...taskResults]; |
| 37 | +
|
| 38 | + const index = newTaskResults.findIndex( |
| 39 | + (task: TaskResult) => task.task_id === updatedTask.task_id, |
| 40 | + ); |
38 | 41 |
|
39 | | - function openModal(taskResult: TaskResult): void { |
40 | | - if (updatingModal) { |
41 | | - updatingModal.openModal(taskResult); |
42 | | - } else { |
43 | | - console.error('Failed to initialize UpdatingModal component.'); |
| 42 | + if (index !== -1) { |
| 43 | + newTaskResults[index] = updatedTask; |
44 | 44 | } |
| 45 | +
|
| 46 | + taskResults = newTaskResults; |
45 | 47 | } |
46 | 48 | </script> |
47 | 49 |
|
|
66 | 68 | </span> |
67 | 69 | {/snippet} |
68 | 70 |
|
69 | | - <!-- FIXME: clickを1回実行するとactionsが2回実行されてしまう。原因と修正方法が分かっていない。 --> |
70 | 71 | <!-- TODO: 問題が多くなってきたら、ページネーションを導入する --> |
71 | 72 | <!-- TODO: 回答状況に応じて、フィルタリングできるようにする --> |
72 | 73 | <div class="overflow-auto rounded-md border"> |
|
90 | 91 | id={taskResult.contest_id + '-' + taskResult.task_id} |
91 | 92 | class={getBackgroundColorFrom(taskResult.status_name)} |
92 | 93 | > |
93 | | - <TableBodyCell |
94 | | - class="justify-center w-20 px-1 sm:px-3 pt-1 sm:pt-3 pb-0.5 sm:pb-1" |
95 | | - onclick={() => openModal(taskResult)} |
96 | | - > |
97 | | - <div class="flex items-center justify-center w-full h-full"> |
98 | | - <SubmissionStatusImage {taskResult} {isLoggedIn} /> |
99 | | - </div> |
100 | | - </TableBodyCell> |
| 94 | + <div class="px-1 sm:px-3"> |
| 95 | + <SubmissionStatusTableBodyCell |
| 96 | + {taskResult} |
| 97 | + {isLoggedIn} |
| 98 | + onupdate={(updatedTask: TaskResult) => updateTaskResult(updatedTask)} |
| 99 | + /> |
| 100 | + </div> |
| 101 | + |
101 | 102 | <TableBodyCell class="w-1/2 text-left truncate pl-0 sm:pl-6"> |
102 | 103 | <ExternalLinkWrapper |
103 | 104 | url={getTaskUrl(taskResult.contest_id, taskResult.task_id)} |
|
135 | 136 | </div> |
136 | 137 | </AccordionItem> |
137 | 138 | </Accordion> |
138 | | - |
139 | | -<UpdatingModal bind:this={updatingModal} {isLoggedIn} /> |
0 commit comments