diff --git a/src/lib/homework/CreateHomeworkAssignment.svelte b/src/lib/homework/CreateHomeworkAssignment.svelte index b222228..a3850fa 100644 --- a/src/lib/homework/CreateHomeworkAssignment.svelte +++ b/src/lib/homework/CreateHomeworkAssignment.svelte @@ -19,10 +19,12 @@ export let allAssignments: Assignment[]; export let fromDate: CustomDate; + export let canUseTimetable = true; + let fromAbbr: WeekDay = getWeekdayAbbreviationByDate(fromDate); let dueWeekday = nextWeekdayForSubject(fromAbbr, subject); - let inputModified = false; + let inputModified = true; const inputModifiedFalse = () => (inputModified = false); $: { @@ -31,14 +33,17 @@ } $: { - fromAbbr = getWeekdayAbbreviationByDate(fromDate); - dueWeekday = nextWeekdayForSubject(fromAbbr, subject); + (() => { + if (!canUseTimetable) return; + fromAbbr = getWeekdayAbbreviationByDate(fromDate); + dueWeekday = nextWeekdayForSubject(fromAbbr, subject); - if (!inputModified) { - due = nextCustomDateForWeekday(dueWeekday, fromDate); - } else { - inputModifiedFalse(); - } + if (!inputModified) { + due = nextCustomDateForWeekday(dueWeekday, fromDate); + } else { + inputModifiedFalse(); + } + })(); } let autocompleteSubjects = $settings.useTimeTableForAutcomplete @@ -51,7 +56,8 @@ : subjectsSortetCapitalized; } - const generateFullAssignment: () => Assignment = () => ({ subject, description, due }); + type ReturnAssignment = () => Assignment; + const generateFullAssignment: ReturnAssignment = () => ({ subject, description, due });
@@ -86,6 +92,9 @@ { + canUseTimetable = true; + }} placeholder={i('homework.add.subject')} class="w-full outline-1 outline-gray-400 outline rounded-sm p-1" list={`subjects-${fromAbbr}`} diff --git a/src/lib/homework/CreateHomeworkInner.svelte b/src/lib/homework/CreateHomeworkInner.svelte index bdee538..b5f014f 100644 --- a/src/lib/homework/CreateHomeworkInner.svelte +++ b/src/lib/homework/CreateHomeworkInner.svelte @@ -6,6 +6,8 @@ export let date: CustomDate; + export let canUseTimetable = true; + const emptyAssignment: Assignment = { subject: '', description: '', @@ -23,6 +25,7 @@ bind:description={assignment.description} bind:due={assignment.due} bind:allAssignments={assignments} + {canUseTimetable} fromDate={date} /> diff --git a/src/lib/homework/DataBoxAssignment.svelte b/src/lib/homework/DataBoxAssignment.svelte index 3dfc105..36ff462 100644 --- a/src/lib/homework/DataBoxAssignment.svelte +++ b/src/lib/homework/DataBoxAssignment.svelte @@ -6,10 +6,11 @@ import { getIconForSubject, iconExistsForSubject } from '../../constants/subjecticons'; import { subjectColors } from '../../stores'; import type { Assignment } from '../../types/homework'; - import { localstorage } from 'svocal'; - import { SvocalKeys } from '../../enums/svocal'; - import { translate } from '$lib/translate/index'; import Loader from '$lib/Loader.svelte'; + import { translate } from '$lib/translate/index'; + import { SvocalKeys } from '../../enums/svocal'; + import { localstorage } from 'svocal'; + import { get } from 'svelte/store'; export let assignment: Assignment; @@ -30,13 +31,6 @@ : ''; }); - let libretranslateUrl = localstorage( - SvocalKeys.LIBRETRANSLATE_URL, - 'https://libretranslate.com/' - ); - let libretranslateToken = localstorage(SvocalKeys.LIBRETRANSLATE_TOKEN, ''); - let useLibreTranslate = localstorage(SvocalKeys.LIBRETRANSLATE_ENABLE, false); - $: isOverdue = dateIsInPast(assignment.due); $: { subjColor = $subjectColors.filter( @@ -63,7 +57,7 @@

{assignment.subject}

- {#if $useLibreTranslate} + {#if get(localstorage(SvocalKeys.LIBRETRANSLATE_ENABLE, false))} {#await translate(assignment.description)} diff --git a/src/lib/homework/DataBoxInner.svelte b/src/lib/homework/DataBoxInner.svelte index 416aa7d..9db7714 100644 --- a/src/lib/homework/DataBoxInner.svelte +++ b/src/lib/homework/DataBoxInner.svelte @@ -76,7 +76,11 @@
{#if editMode} - + {:else}