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 2
2
import { TableBodyCell } from ' svelte-5-ui-lib' ;
3
3
4
4
import type { WorkbookList } from ' $lib/types/workbook' ;
5
+
6
+ import { getUrlSlugFrom } from ' $lib/utils/workbooks' ;
5
7
import PublicationStatusLabel from ' $lib/components/WorkBooks/PublicationStatusLabel.svelte' ;
6
8
7
9
interface Props {
10
12
}
11
13
12
14
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
- }
19
15
</script >
20
16
21
17
<TableBodyCell class ="w-2/5 {paddingLeft } pr-4" >
Original file line number Diff line number Diff line change 10
10
TableHeadCell ,
11
11
} from ' svelte-5-ui-lib' ;
12
12
13
- import { WorkBookType , type WorkbooksList , type WorkbookList } from ' $lib/types/workbook' ;
13
+ import { WorkBookType , type WorkbooksList } from ' $lib/types/workbook' ;
14
14
import { TaskGrade , type TaskResults } from ' $lib/types/task' ;
15
15
import type { Roles } from ' $lib/types/user' ;
16
16
22
22
import AcceptedCounter from ' $lib/components/SubmissionStatus/AcceptedCounter.svelte' ;
23
23
24
24
import { canRead , canEdit , canDelete } from ' $lib/utils/authorship' ;
25
+ import { getUrlSlugFrom } from ' $lib/utils/workbooks' ;
25
26
26
27
interface Props {
27
28
workbookType: WorkBookType ;
41
42
function getTaskResult(workbookId : number ): TaskResults {
42
43
return taskResults ?.get (workbookId ) ?? [];
43
44
}
44
-
45
- function getUrlSlugFrom(workbook : WorkbookList ): string {
46
- const slug = workbook .urlSlug ;
47
-
48
- return slug ? slug : workbook .id .toString ();
49
- }
50
45
</script >
51
46
52
47
<!-- FIXME: 問題集の種類別にコンポーネントを分ける -->
Original file line number Diff line number Diff line change 1
1
import { Roles } from '$lib/types/user' ;
2
2
import { isAdmin } from '$lib/utils/authorship' ;
3
+ import { type WorkbookList } from '$lib/types/workbook' ;
3
4
4
5
// 管理者 + ユーザ向けに公開されている場合
5
6
export function canViewWorkBook ( role : Roles , isPublished : boolean ) {
6
7
return isAdmin ( role ) || isPublished ;
7
8
}
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