From 7941b0b51f0664b6698289d752bab975aa81ac33 Mon Sep 17 00:00:00 2001 From: Ibitoye Rotimi Best Date: Thu, 8 Jul 2021 09:44:16 +0300 Subject: [PATCH] CRUD* Lecture --- .../Course/components/CourseNav.svelte | 55 +++--- .../components/Lecture/Home/index.svelte | 145 +++++++++++++- .../Course/components/Lecture/index.svelte | 3 +- .../components/Lecture/store/lessons.js | 187 ++++++++++++++++++ .../Course/components/People.svelte | 6 +- src/components/Expandable/index.svelte | 2 +- src/components/Form/Select.svelte | 3 +- src/components/Form/TextField.svelte | 2 + src/components/PageBody/index.svelte | 7 +- src/components/PageNav/index.svelte | 1 + src/components/Tailwindcss.svelte | 4 +- src/components/UserCard/index.svelte | 35 ++-- src/routes/courses/[...id]/index.svelte | 7 +- 13 files changed, 391 insertions(+), 66 deletions(-) create mode 100644 src/components/Course/components/Lecture/store/lessons.js diff --git a/src/components/Course/components/CourseNav.svelte b/src/components/Course/components/CourseNav.svelte index ef038895..99f82bcd 100644 --- a/src/components/Course/components/CourseNav.svelte +++ b/src/components/Course/components/CourseNav.svelte @@ -1,5 +1,6 @@
@@ -105,16 +84,24 @@ isGroupActive={$page.path === navItem.to} hideSortIcon={navItem.hideSortIcon} > - {#if Array.isArray(navItem.items)} - {#each navItem.items as item, index} + {#if navItem.isLecture} + {#each $lessons as item, index} {getLectureNo(index + 1)} {item.title} + {#if item.isComplete} + + + + {:else} + 🔒 + {/if} {/each} {/if} @@ -146,13 +133,15 @@ height: 90vh; display: flex; flex-direction: column; - width: 360px; + min-width: 360px; + max-width: 360px; position: sticky; top: 0; border-right: 1px solid var(--border-color); &.hide { - width: 0px; + min-width: 0px; + max-width: 0px; } } diff --git a/src/components/Course/components/Lecture/Home/index.svelte b/src/components/Course/components/Lecture/Home/index.svelte index 2dab847b..43b49669 100644 --- a/src/components/Course/components/Lecture/Home/index.svelte +++ b/src/components/Course/components/Lecture/Home/index.svelte @@ -1,8 +1,149 @@ - + +
+ +
+
-All lecture will be here + +
+ {#each $lessons as lecture, index} +
+ +
+ (lecture.isComplete = !lecture.isComplete)} + > + {#if lecture.isComplete} + + {:else} + 🔒 + {/if} + +
+ + +
+ {#if lectureEditing === index} + (lectureEditing = null)}> + + + {:else} + (lectureEditing = index)}> + + + {/if} +
+ +
+

{index + 1}

+
+
+ {#if lectureEditing === index} + + {:else} +

+ + {lecture.title} + +

+ {/if} +
+
+ {lecture.resources.map((r) => `${r.value} ${r.label}`).join(", ")} +
+
+ +
+ {#if lectureEditing === index} + (lecture.date = e.target.value)} + /> + {:else} + +

+ {new Date(lecture.date).toDateString()} +

+ {/if} +
+
+
+
+ {/each} +
+ + + diff --git a/src/components/Course/components/Lecture/index.svelte b/src/components/Course/components/Lecture/index.svelte index fabc2292..737cf5ee 100644 --- a/src/components/Course/components/Lecture/index.svelte +++ b/src/components/Course/components/Lecture/index.svelte @@ -7,11 +7,12 @@ export let path; export let tab; + // export let lectureId; export let showLectureHome; {#if showLectureHome} - + {:else}
{ + return [ + ..._lessons, + { + title: 'Untitled lesson', + to: "/courses/1/lecture/" + (_lessons.length + 1), + resources, + lecturer: { + userId: 1, + avatar: "https://picsum.photos/32/32/?random", + name: "", + }, + date: new Date() + } + ] + }) +} \ No newline at end of file diff --git a/src/components/Course/components/People.svelte b/src/components/Course/components/People.svelte index be4335cc..bec26c4e 100644 --- a/src/components/Course/components/People.svelte +++ b/src/components/Course/components/People.svelte @@ -54,7 +54,8 @@ avatarUrl={teacher.avatar} title={teacher.title} telegramLink={teacher.telegramLink} - mailLink={teacher.mailLink} /> + mailLink={teacher.mailLink} + /> {/each}
@@ -68,7 +69,8 @@ + title={student.title} + /> {/each} diff --git a/src/components/Expandable/index.svelte b/src/components/Expandable/index.svelte index 092af264..ab080627 100644 --- a/src/components/Expandable/index.svelte +++ b/src/components/Expandable/index.svelte @@ -9,7 +9,7 @@ // export let subMenuItems = []; function onClick() { - isExpanded = !isExpanded; + // isExpanded = !isExpanded; handleClick(); } diff --git a/src/components/Form/Select.svelte b/src/components/Form/Select.svelte index 5f6ca30f..e815217d 100644 --- a/src/components/Form/Select.svelte +++ b/src/components/Form/Select.svelte @@ -2,13 +2,14 @@ export let label; export let value; export let options = []; + export let valueKey = "id";