From c1d3cfdd23cdf26b97b6dcd62aaca2684bf38b18 Mon Sep 17 00:00:00 2001 From: Belissimo_T Date: Sat, 4 Nov 2023 15:24:55 +0100 Subject: [PATCH 1/5] include teacher surname in App dropdown --- client/src/App.svelte | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/client/src/App.svelte b/client/src/App.svelte index cc6f0d5..79d2230 100644 --- a/client/src/App.svelte +++ b/client/src/App.svelte @@ -30,7 +30,7 @@ let all_revisions; let plan_type; let plan_value; - let teacher_list; + let teacher_dict; let all_rooms; let grouped_forms; let api_base; @@ -62,7 +62,7 @@ all_revisions = [".newest"]; plan_type = null; plan_value = null; - teacher_list = []; + teacher_dict = {}; all_rooms = null; grouped_forms = []; api_base = null; @@ -91,7 +91,7 @@ } meta = data[0]; all_rooms = meta.rooms; - teacher_list = Object.keys(meta.teachers); + teacher_dict = meta.teachers; grouped_forms = meta.forms.grouped_forms; enabled_dates = Object.keys(meta.dates); if(!date) { @@ -202,10 +202,17 @@ } } - function gen_teacher_arr(teacher_list) { + function gen_teacher_arr(teacher_dict) { teacher_arr = []; - for(let teacher of teacher_list) { - teacher_arr.push({"id": teacher, "display_name": teacher}); + for(let teacher of Object.values(teacher_dict)) { + let long_name = teacher.full_surname || teacher.plan_long; + let display_name = teacher.plan_short; + + if (long_name != null) { + display_name += ` (${long_name})`; + } + + teacher_arr.push({"id": teacher.plan_short, "display_name": display_name}); } } @@ -319,7 +326,7 @@ $: selected_form && set_plan("forms", selected_form); $: gen_form_arr(grouped_forms); $: selected_teacher && set_plan("teachers", selected_teacher); - $: gen_teacher_arr(teacher_list); + $: gen_teacher_arr(teacher_dict); $: selected_room && set_plan("rooms", selected_room); $: gen_room_arr(grouped_rooms); $: gen_revision_arr(all_revisions); From 4759285b3784c230c96b6ad7b151a8b9c3b005f0 Mon Sep 17 00:00:00 2001 From: OfficialFreak Date: Sat, 4 Nov 2023 18:06:00 +0100 Subject: [PATCH 2/5] Acceptable Favourite Design --- client/src/components/Favourites.svelte | 124 +++++++++++++++--------- client/src/components/Navbar.svelte | 31 +++--- 2 files changed, 95 insertions(+), 60 deletions(-) diff --git a/client/src/components/Favourites.svelte b/client/src/components/Favourites.svelte index 6d1278c..9477ba8 100644 --- a/client/src/components/Favourites.svelte +++ b/client/src/components/Favourites.svelte @@ -10,6 +10,7 @@ import { onMount } from "svelte"; let cur_favourites = []; + let loading = true; let all_schools = {}; let authorized_school_ids = []; let school_nums = []; @@ -72,12 +73,14 @@ - duplicated courses are unified: for each course c1 that already exists as course c0, the pair c1: c0 is put into an object -> later, the check-value of c1 is set to that of c0 */ function load_favourites() { + loading = true; // change preferences to dict let temp_fav = $favourites; console.log(temp_fav); temp_fav = temp_fav.map(item => ({ ...item, preferences: (item.preferences || []).reduce((obj, preference) => ({ ...obj, [preference]: false }), {}) })); cur_favourites = temp_fav; console.log(cur_favourites); + loading = false; } function save_favourites() { let new_favourites = []; @@ -243,7 +246,6 @@
- @@ -255,51 +257,40 @@ {#each Object.entries( get_subjects(favourite, all_meta) ).sort(([subj1, _], [subj2, __]) => subj1.localeCompare(subj2)).sort(([_, courses1], [__, courses2]) => courses2.length - courses1.length) as [subject, courses]} - {#if courses.length === 1} -
  • {subject}: - {courses[0].class_number} - {courses[0].teacher} | - {courses[0].subject} - {#if courses[0].group != null} - ({courses[0].group}) - {/if} -
  • - {:else} -
  • - {subject} - {#if courses.length > 2} - - - {/if} -
  • -
      - {#each courses as course} -
    • - - {course.class_number} - {course.teacher} | - {course.subject} - {#if course.group != null} - ({course.group}) - {/if} -
    • - {/each} -
    - {/if} +
    +

    {subject}

    + {#if courses.length > 2} + + + {/if} +
    +
      + {#each courses as course} +
    • + + + {#if course.group != null} + {course.group} + {:else} + {courses[0].subject} + {/if} + | {courses[0].teacher} +
    • + {/each} +
    {:else} Wähle eine Klasse um die Kurse für sie zu wählen {/each} @@ -311,6 +302,12 @@
    + {:else} + {#if loading} + + + + {/if} {/each} @@ -381,5 +378,40 @@ border-radius: 5px; padding: 10px; border: 2px solid rgba(255, 255, 255, 0.1); + font-size: var(--font-size-base); + } + + .rotating { + animation: rotating .75s linear infinite; + transform-origin: 50% 48%; + } + + @keyframes rotating { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } + } + + .horizontal-align { + display: flex; + flex-direction: row; + gap: 10px; + align-items: center; + justify-content: flex-start; + } + + .margin-bottom { + margin-bottom: 5px; + } + + .subject-heading { + margin-bottom: 0px !important; + } + + .course-list { + margin-bottom: 15px; } \ No newline at end of file diff --git a/client/src/components/Navbar.svelte b/client/src/components/Navbar.svelte index 4746d4f..3af9dc2 100644 --- a/client/src/components/Navbar.svelte +++ b/client/src/components/Navbar.svelte @@ -15,6 +15,15 @@ notifications.danger(error.message); }); } + + let favourite_icon_map = { + "forms": "school", + "teachers": "elderly", + "rooms": "sensor_door", + "room_overview": "nest_multi_room" + } + + $: console.log($favourites);