File tree Expand file tree Collapse file tree 3 files changed +17
-13
lines changed
Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 22 import { TableBodyCell } from ' svelte-5-ui-lib' ;
33
44 import type { WorkbookList } from ' $lib/types/workbook' ;
5+
6+ import { getUrlSlugFrom } from ' $lib/utils/workbooks' ;
57 import PublicationStatusLabel from ' $lib/components/WorkBooks/PublicationStatusLabel.svelte' ;
68
79 interface Props {
1012 }
1113
1214 let { paddingLeft = ' pl-2 xs:pl-4' , workbook }: Props = $props ();
13-
14- function getUrlSlugFrom(workbook : WorkbookList ): string {
15- const slug = workbook .urlSlug ;
16-
17- return slug ? slug : workbook .id .toString ();
18- }
1915 </script >
2016
2117<TableBodyCell class ="w-2/5 {paddingLeft } pr-4" >
Original file line number Diff line number Diff line change 1010 TableHeadCell ,
1111 } from ' svelte-5-ui-lib' ;
1212
13- import { WorkBookType , type WorkbooksList , type WorkbookList } from ' $lib/types/workbook' ;
13+ import { WorkBookType , type WorkbooksList } from ' $lib/types/workbook' ;
1414 import { TaskGrade , type TaskResults } from ' $lib/types/task' ;
1515 import type { Roles } from ' $lib/types/user' ;
1616
2222 import AcceptedCounter from ' $lib/components/SubmissionStatus/AcceptedCounter.svelte' ;
2323
2424 import { canRead , canEdit , canDelete } from ' $lib/utils/authorship' ;
25+ import { getUrlSlugFrom } from ' $lib/utils/workbooks' ;
2526
2627 interface Props {
2728 workbookType: WorkBookType ;
4142 function getTaskResult(workbookId : number ): TaskResults {
4243 return taskResults ?.get (workbookId ) ?? [];
4344 }
44-
45- function getUrlSlugFrom(workbook : WorkbookList ): string {
46- const slug = workbook .urlSlug ;
47-
48- return slug ? slug : workbook .id .toString ();
49- }
5045 </script >
5146
5247<!-- FIXME: 問題集の種類別にコンポーネントを分ける -->
Original file line number Diff line number Diff line change 11import { Roles } from '$lib/types/user' ;
22import { isAdmin } from '$lib/utils/authorship' ;
3+ import { type WorkbookList } from '$lib/types/workbook' ;
34
45// 管理者 + ユーザ向けに公開されている場合
56export function canViewWorkBook ( role : Roles , isPublished : boolean ) {
67 return isAdmin ( role ) || isPublished ;
78}
9+
10+ /**
11+ * Gets the URL slug for a workbook, falling back to the workbook ID if no slug is available.
12+ *
13+ * @param workbook - The workbook object containing urlSlug and id properties
14+ * @returns The URL slug if available, otherwise the workbook ID as a string
15+ */
16+ export function getUrlSlugFrom ( workbook : WorkbookList ) : string {
17+ const slug = workbook . urlSlug ;
18+
19+ return slug ? slug : workbook . id . toString ( ) ;
20+ }
You can’t perform that action at this time.
0 commit comments