|
4 | 4 | import { ButtonGroup, Button, Toggle } from 'svelte-5-ui-lib'; |
5 | 5 |
|
6 | 6 | import { taskGradesByWorkBookTypeStore } from '$lib/stores/task_grades_by_workbook_type'; |
| 7 | + import { replenishmentWorkBooksStore } from '$lib/stores/replenishment_workbook.svelte'; |
7 | 8 | import { canRead } from '$lib/utils/authorship'; |
8 | 9 | import { WorkBookType, type WorkbookList, type WorkbooksList } from '$lib/types/workbook'; |
9 | 10 | import { getTaskGradeLabel } from '$lib/utils/task'; |
|
57 | 58 | }), |
58 | 59 | ); |
59 | 60 |
|
60 | | - let isShowReplenishment: boolean = $state(false); |
61 | | -
|
62 | 61 | function countReadableWorkbooks(workbooks: WorkbooksList): number { |
63 | 62 | const results = workbooks.reduce((count, workbook: WorkbookList) => { |
64 | 63 | const hasReadPermission = canRead(workbook.isPublished, userId, workbook.authorId); |
|
103 | 102 | <!-- TODO: 「ユーザ作成」の問題集には、検索機能を追加 --> |
104 | 103 | {#if workbookType === WorkBookType.CURRICULUM} |
105 | 104 | <div class="mb-6"> |
106 | | - <div class="flex flex-col md:flex-row items-start md:items-center justify-between"> |
107 | | - <div class="flex items-center space-x-4"> |
108 | | - <ButtonGroup> |
109 | | - {#each AVAILABLE_GRADES as grade} |
110 | | - <Button |
111 | | - onclick={() => filterByGradeMode(grade)} |
112 | | - class={selectedGrade === grade ? 'text-primary-700' : 'text-gray-900'} |
113 | | - > |
114 | | - {getTaskGradeLabel(grade)} |
115 | | - </Button> |
116 | | - {/each} |
117 | | - </ButtonGroup> |
118 | | - |
119 | | - <TooltipWrapper |
120 | | - tooltipContent="問題集のグレードを指定します(最頻値。2つ以上ある場合は、最も易しいグレードに掲載)" |
121 | | - /> |
122 | | - </div> |
123 | | - |
124 | | - <div class="mt-4 md:mt-0"> |
125 | | - <Toggle bind:checked={isShowReplenishment}>「補充」があれば表示</Toggle> |
126 | | - </div> |
| 105 | + <div class="flex items-center space-x-4"> |
| 106 | + <ButtonGroup> |
| 107 | + {#each AVAILABLE_GRADES as grade} |
| 108 | + <Button |
| 109 | + onclick={() => filterByGradeMode(grade)} |
| 110 | + class={selectedGrade === grade ? 'text-primary-700' : 'text-gray-900'} |
| 111 | + > |
| 112 | + {getTaskGradeLabel(grade)} |
| 113 | + </Button> |
| 114 | + {/each} |
| 115 | + </ButtonGroup> |
| 116 | + |
| 117 | + <TooltipWrapper |
| 118 | + tooltipContent="問題集のグレードを指定します(最頻値。2つ以上ある場合は、最も易しいグレードに掲載)" |
| 119 | + /> |
127 | 120 | </div> |
128 | 121 | </div> |
129 | 122 | {/if} |
|
144 | 137 | /> |
145 | 138 | </div> |
146 | 139 |
|
147 | | - <!-- カリキュラムの場合、かつ、公開されている【補充】問題集があるときだけ表示 --> |
148 | | - {#if workbookType === WorkBookType.CURRICULUM && readableReplenishedWorkbooksCount() && isShowReplenishment} |
| 140 | + <!-- カリキュラム、かつ、公開されている【補充】問題集があるときのみ --> |
| 141 | + {#if workbookType === WorkBookType.CURRICULUM && readableReplenishedWorkbooksCount()} |
149 | 142 | <div class="mt-12"> |
150 | | - <div class="flex items-center space-x-3 pb-4"> |
151 | | - <div class="text-2xl dark:text-white">補充</div> |
152 | | - |
153 | | - <LabelWithTooltips |
154 | | - labelName="" |
155 | | - tooltipId="tooltip-for-replenished-workbooks" |
156 | | - tooltipContents={[ |
157 | | - '(任意)', |
158 | | - '特定の課題を持つ人向けの問題集です。', |
159 | | - '苦手意識があれば、挑戦してみましょう。', |
160 | | - ]} |
161 | | - /> |
| 143 | + <!-- 見出しと説明文、表示の切り替え用ボタンを常に表示 --> |
| 144 | + <div class="flex flex-col md:flex-row items-start md:items-center md:space-x-6"> |
| 145 | + <div class="flex items-center space-x-1 pb-0 md:pb-4"> |
| 146 | + <div class="text-2xl dark:text-white">補充</div> |
| 147 | + |
| 148 | + <LabelWithTooltips |
| 149 | + labelName="" |
| 150 | + tooltipId="tooltip-for-replenished-workbooks" |
| 151 | + tooltipContents={[ |
| 152 | + '(任意)', |
| 153 | + '特定の課題(数学的素養や実装力など)を持つ人向けの問題集です。', |
| 154 | + '苦手意識があれば、挑戦してみましょう。', |
| 155 | + ]} |
| 156 | + /> |
| 157 | + </div> |
| 158 | + |
| 159 | + <div class="mt-4 md:mt-0 pb-4"> |
| 160 | + <Toggle |
| 161 | + checked={replenishmentWorkBooksStore.canView()} |
| 162 | + onclick={replenishmentWorkBooksStore.toggleView} |
| 163 | + aria-label="Toggle visibility of replenishment workbooks for curriculum" |
| 164 | + > |
| 165 | + 問題集を表示 |
| 166 | + </Toggle> |
| 167 | + </div> |
162 | 168 | </div> |
163 | 169 |
|
164 | | - <WorkBookBaseTable |
165 | | - {workbookType} |
166 | | - workbooks={replenishedWorkbooks} |
167 | | - {workbookGradeModes} |
168 | | - {userId} |
169 | | - {role} |
170 | | - taskResults={taskResultsWithWorkBookId} |
171 | | - /> |
| 170 | + {#if replenishmentWorkBooksStore.canView()} |
| 171 | + <WorkBookBaseTable |
| 172 | + {workbookType} |
| 173 | + workbooks={replenishedWorkbooks} |
| 174 | + {workbookGradeModes} |
| 175 | + {userId} |
| 176 | + {role} |
| 177 | + taskResults={taskResultsWithWorkBookId} |
| 178 | + /> |
| 179 | + {/if} |
172 | 180 | </div> |
173 | 181 | {/if} |
174 | 182 | {:else} |
|
0 commit comments