anki/ts/deckoptions/DailyLimits.svelte

78 lines
2.5 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 marked from "marked";
import * as tr from "lib/i18n";
2021-05-27 23:19:05 +02:00
import TitledContainer from "./TitledContainer.svelte";
import Row from "./Row.svelte";
import Col from "./Col.svelte";
import HelpPopup from "./HelpPopup.svelte";
import Warnings from "./Warnings.svelte";
import SpinBox from "./SpinBox.svelte";
2021-05-28 23:59:20 +02:00
import RevertButton from "./RevertButton.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;
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-27 23:19:05 +02:00
<TitledContainer title={tr.deckConfigDailyLimits()}>
<Row>
<Col size={7}>
{tr.schedulingNewCardsday()}<HelpPopup
html={marked(tr.deckConfigNewLimitTooltip() + v3Extra)}
/>
</Col>
<Col size={5}>
2021-05-28 23:59:20 +02:00
<SpinBox min={0} bind:value={$config.newPerDay} />
<RevertButton
defaultValue={defaults.newPerDay}
bind:value={$config.newPerDay}
/>
</Col>
</Row>
<Warnings warnings={[newCardsGreaterThanParent]} />
<Row>
<Col size={7}>
{tr.schedulingMaximumReviewsday()}<HelpPopup
html={marked(tr.deckConfigReviewLimitTooltip() + v3Extra)}
/>
</Col>
<Col size={5}>
2021-05-28 23:59:20 +02:00
<SpinBox min={0} bind:value={$config.reviewsPerDay} />
<RevertButton
defaultValue={defaults.reviewsPerDay}
bind:value={$config.reviewsPerDay}
/>
</Col>
</Row>
<Warnings warnings={[reviewsTooLow]} />
2021-05-27 23:19:05 +02:00
</TitledContainer>