From b075bbc5debc0010f1d469a4f83d9283d28fb113 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Tue, 5 Sep 2023 13:22:59 +0000 Subject: [PATCH] CLASSROOMIO-T-129:Implemented the Add lesson modal CLASSROOMIO-T-129:Removed some unused variable and removed the scroll behaviour from the modal CLASSROOMIO-T-129:did some cleanup CLASSROOMIO-T-129:Added validation for an empty input CLASSROOMIO-T-129:Added validation for an empty input CLASSROOMIO-T-129:Updated the code CLASSROOMIO-T-129:Removed unused console logs and comments CLASSROOMIO-T-129:Removed unused console logs and comments CLASSROOMIO-T-129:Implemented the add lesson modal Merge branch 'main' into CLASSROOMIO-T-129 CLASSROOMIO-T-129:Working on the Add Lesson modal Co-authored-by: Ifeanyi Nwosu Merge-request: CLASSROOMIO-MR-63 Merged-by: Best Admin --- .../components/Lesson/AddLessonModal.svelte | 129 ++++++++++++++++++ .../Course/components/Lesson/store/lessons.ts | 13 +- src/routes/courses/[id]/lessons/+page.svelte | 19 +-- 3 files changed, 135 insertions(+), 26 deletions(-) create mode 100644 src/lib/components/Course/components/Lesson/AddLessonModal.svelte diff --git a/src/lib/components/Course/components/Lesson/AddLessonModal.svelte b/src/lib/components/Course/components/Lesson/AddLessonModal.svelte new file mode 100644 index 00000000..8dd45939 --- /dev/null +++ b/src/lib/components/Course/components/Lesson/AddLessonModal.svelte @@ -0,0 +1,129 @@ + + + (openModal = false)} + bind:open={openModal} + width="w-[60%]" + containerClass="overflow-hidden" + modalHeading="Add New Lesson" +> +
+
+ +
+ +
+
+ + + + +
+ +
+
+ +
+ +
+ +
+
+
+
+ +
diff --git a/src/lib/components/Course/components/Lesson/store/lessons.ts b/src/lib/components/Course/components/Lesson/store/lessons.ts index f93e20ae..3a70b23c 100644 --- a/src/lib/components/Course/components/Lesson/store/lessons.ts +++ b/src/lib/components/Course/components/Lesson/store/lessons.ts @@ -78,18 +78,7 @@ export async function handleSaveLesson(lesson: Lesson, course_id: Course['id']) newLessonData = data; } - - lessons.update((l) => - l.map((_lesson) => { - if (!_lesson.id && newLessonData) { - _lesson.id = newLessonData[0].id; - } else if (typeof lesson.id === 'string' && lesson.id === _lesson.id) { - return { ..._lesson, is_complete: lesson.is_complete }; - } - - return _lesson; - }) - ); + return newLessonData; } export async function handleUpdateLessonMaterials(lesson: any, lessonId: Lesson['id']) { diff --git a/src/routes/courses/[id]/lessons/+page.svelte b/src/routes/courses/[id]/lessons/+page.svelte index f4130525..f30b6954 100644 --- a/src/routes/courses/[id]/lessons/+page.svelte +++ b/src/routes/courses/[id]/lessons/+page.svelte @@ -22,7 +22,6 @@ import { profile } from '$lib/utils/store/user'; import { lessons, - handleAddLesson, handleSaveLesson, handleDelete } from '$lib/components/Course/components/Lesson/store/lessons'; @@ -30,13 +29,14 @@ import PageBody from '$lib/components/PageBody/index.svelte'; import TextChip from '$lib/components/Chip/Text.svelte'; import Avatar from '$lib/components/Apps/components/Poll/components/Avatar.svelte'; + import AddLessonModal from '$lib/components/Course/components/Lesson/AddLessonModal.svelte'; import { exerciseMode } from '$lib/components/Course/components/Lesson/Exercise/store'; export let data; const { courseId } = data; let lessonEditing; - let ref; let isStudent = true; + let openModal = false; const flipDurationMs = 300; @@ -52,17 +52,7 @@ // TODO: CRUD of lessons function addLesson() { - handleAddLesson(); - setTimeout(() => { - lessonEditing = $lessons.length - 1; - if (ref) { - ref.scrollIntoView({ - block: 'start', - behavior: 'smooth', - inline: 'nearest' - }); - } - }, 100); + openModal = true; } function handleDndConsider(e) { @@ -115,6 +105,8 @@ } + +
@@ -141,7 +133,6 @@ > {#each $lessons as lesson (lesson.id)}