anki/ts/deckoptions/NewOptions.svelte

79 lines
2.5 KiB
Svelte
Raw Normal View History

<!--
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";
import StepsInputRow from "./StepsInputRow.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte";
import EnumSelectorRow from "./EnumSelectorRow.svelte";
2021-05-29 12:29:22 +02:00
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;
let config = state.currentConfig;
let defaults = state.defaults;
const newInsertOrderChoices = [
tr.deckConfigNewInsertionOrderSequential(),
tr.deckConfigNewInsertionOrderRandom(),
];
let stepsExceedGraduatingInterval: string;
$: {
const lastLearnStepInDays = $config.learnSteps.length
? $config.learnSteps[$config.learnSteps.length - 1] / 60 / 24
: 0;
stepsExceedGraduatingInterval =
lastLearnStepInDays > $config.graduatingIntervalGood
? tr.deckConfigLearningStepAboveGraduatingInterval()
: "";
}
$: goodExceedsEasy =
$config.graduatingIntervalGood > $config.graduatingIntervalEasy
? tr.deckConfigGoodAboveEasy()
: "";
</script>
2021-05-27 23:19:05 +02:00
<TitledContainer title={tr.schedulingNewCards()}>
<StepsInputRow
bind:value={$config.learnSteps}
defaultValue={defaults.learnSteps}
markdownTooltip={tr.deckConfigLearningStepsTooltip()}
>
{tr.deckConfigLearningSteps()}
</StepsInputRow>
<SpinBoxRow
bind:value={$config.graduatingIntervalGood}
defaultValue={defaults.graduatingIntervalGood}
markdownTooltip={tr.deckConfigGraduatingIntervalTooltip()}
>
{tr.schedulingGraduatingInterval()}
</SpinBoxRow>
2021-05-29 12:29:22 +02:00
<Warning warning={stepsExceedGraduatingInterval} />
<SpinBoxRow
bind:value={$config.graduatingIntervalEasy}
defaultValue={defaults.graduatingIntervalEasy}
markdownTooltip={tr.deckConfigEasyIntervalTooltip()}
>
{tr.schedulingEasyInterval()}
</SpinBoxRow>
2021-05-29 12:29:22 +02:00
<Warning warning={goodExceedsEasy} />
<EnumSelectorRow
bind:value={$config.newCardInsertOrder}
defaultValue={defaults.newCardInsertOrder}
choices={newInsertOrderChoices}
breakpoint={"md"}
markdownTooltip={tr.deckConfigNewInsertionOrderTooltip()}
>
{tr.deckConfigNewInsertionOrder()}
</EnumSelectorRow>
2021-05-27 23:19:05 +02:00
</TitledContainer>