anki/ts/deckoptions/DailyLimits.svelte

66 lines
2.1 KiB
Svelte
Raw Normal View History

<!--
2021-05-27 23:19:05 +02:00
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "lib/i18n";
2021-05-27 23:19:05 +02:00
import TitledContainer from "./TitledContainer.svelte";
2021-05-29 17:32:12 +02:00
import SectionItem from "components/SectionItem.svelte";
2021-05-29 12:29:22 +02:00
import SpinBoxRow from "./SpinBoxRow.svelte";
import Warning from "./Warning.svelte";
2021-04-25 10:40:02 +02:00
import type { DeckOptionsState } from "./lib";
2021-04-25 10:40:02 +02:00
export let state: DeckOptionsState;
2021-05-29 17:32:12 +02:00
export let api: Record<string, never>;
let config = state.currentConfig;
let defaults = state.defaults;
let parentLimits = state.parentLimits;
const v3Extra = state.v3Scheduler
? "\n\n" +
tr.deckConfigLimitNewBoundByReviews() +
"\n\n" +
tr.deckConfigLimitDeckV3()
: "";
$: newCardsGreaterThanParent =
!state.v3Scheduler && $config.newPerDay > $parentLimits.newCards
? tr.deckConfigDailyLimitWillBeCapped({ cards: $parentLimits.newCards })
: "";
$: reviewsTooLow =
Math.min(9999, $config.newPerDay * 10) > $config.reviewsPerDay
? tr.deckConfigReviewsTooLow({
cards: $config.newPerDay,
expected: Math.min(9999, $config.newPerDay * 10),
})
: "";
</script>
2021-05-29 17:32:12 +02:00
<TitledContainer title={tr.deckConfigDailyLimits()} {api}>
<SectionItem>
<SpinBoxRow
bind:value={$config.newPerDay}
defaultValue={defaults.newPerDay}
markdownTooltip={tr.deckConfigNewLimitTooltip() + v3Extra}
>
{tr.schedulingNewCardsday()}
</SpinBoxRow>
<Warning warning={newCardsGreaterThanParent} />
</SectionItem>
<SectionItem>
<SpinBoxRow
bind:value={$config.reviewsPerDay}
defaultValue={defaults.reviewsPerDay}
markdownTooltip={tr.deckConfigReviewLimitTooltip() + v3Extra}
>
{tr.schedulingMaximumReviewsday()}
</SpinBoxRow>
<Warning warning={reviewsTooLow} />
</SectionItem>
2021-05-27 23:19:05 +02:00
</TitledContainer>