2023-12-03 18:05:11 +03:00
|
|
|
<script lang="ts">
|
2025-12-22 02:36:48 +01:00
|
|
|
import { LessonsPage } from '$features/course/pages';
|
|
|
|
|
import { Button } from '@cio/ui/base/button';
|
2026-03-18 23:39:12 +01:00
|
|
|
import { RefreshPageData, RoleBasedSecurity } from '$features/ui';
|
2025-12-22 02:36:48 +01:00
|
|
|
import * as Page from '@cio/ui/base/page';
|
2025-01-04 05:55:14 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
2026-03-09 11:18:22 +01:00
|
|
|
import { contentCreateStoreUtils, contentEditingStore } from '$features/course/components/content/store';
|
|
|
|
|
import { courseApi } from '$features/course/api';
|
2026-03-18 23:39:12 +01:00
|
|
|
import { profile } from '$lib/utils/store/user';
|
2021-07-10 19:16:10 +00:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
let { data } = $props();
|
2023-09-30 10:43:13 +01:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
let reorder = $state(false);
|
2021-09-13 14:02:18 +03:00
|
|
|
|
2026-03-09 11:18:22 +01:00
|
|
|
function addContent() {
|
|
|
|
|
const contentGroupingEnabled = courseApi.course?.metadata?.isContentGroupingEnabled ?? true;
|
|
|
|
|
if (contentGroupingEnabled) {
|
|
|
|
|
contentCreateStoreUtils.openSection();
|
|
|
|
|
} else {
|
|
|
|
|
contentCreateStoreUtils.openDefault();
|
|
|
|
|
}
|
2021-09-14 07:01:44 +03:00
|
|
|
}
|
2021-07-10 19:16:10 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-03-09 11:18:22 +01:00
|
|
|
<Page.Root class="mx-auto flex w-[90%] px-4 md:max-w-2xl lg:max-w-3xl">
|
2025-12-22 02:36:48 +01:00
|
|
|
<Page.Header>
|
|
|
|
|
<Page.HeaderContent>
|
|
|
|
|
<Page.Title>
|
2026-03-09 11:18:22 +01:00
|
|
|
{$t('course.navItem.lessons.heading_v2')}
|
2025-12-22 02:36:48 +01:00
|
|
|
</Page.Title>
|
|
|
|
|
</Page.HeaderContent>
|
|
|
|
|
<Page.Action>
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="flex w-full justify-end gap-2">
|
|
|
|
|
<RoleBasedSecurity allowedRoles={[1, 2]}>
|
2026-03-09 11:18:22 +01:00
|
|
|
<Button variant="outline" onclick={() => (reorder = !reorder)} disabled={!!$contentEditingStore}>
|
2025-12-22 02:36:48 +01:00
|
|
|
{$t(`course.navItem.lessons.add_lesson.${reorder ? 'end_reorder' : 'start_reorder'}`)}
|
|
|
|
|
</Button>
|
2026-03-09 11:18:22 +01:00
|
|
|
<Button onclick={addContent} disabled={!!$contentEditingStore}
|
|
|
|
|
>{$t('course.navItem.lessons.add_content')}</Button
|
|
|
|
|
>
|
2025-11-01 15:49:29 +01:00
|
|
|
</RoleBasedSecurity>
|
2026-03-18 23:39:12 +01:00
|
|
|
<RefreshPageData onRefresh={() => courseApi.refreshCourse(data.courseId, $profile.id)} />
|
2025-11-01 15:49:29 +01:00
|
|
|
</div>
|
2025-12-22 02:36:48 +01:00
|
|
|
</Page.Action>
|
|
|
|
|
</Page.Header>
|
|
|
|
|
|
|
|
|
|
<Page.Body>
|
|
|
|
|
{#snippet child()}
|
2026-03-09 11:18:22 +01:00
|
|
|
<LessonsPage courseId={data.courseId} bind:reorder />
|
2025-11-01 15:49:29 +01:00
|
|
|
{/snippet}
|
2025-12-22 02:36:48 +01:00
|
|
|
</Page.Body>
|
2026-03-09 11:18:22 +01:00
|
|
|
</Page.Root>
|