2021-04-12 06:18:30 +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">
|
2022-10-25 08:18:50 +02:00
|
|
|
import type Carousel from "bootstrap/js/dist/carousel";
|
|
|
|
import type Modal from "bootstrap/js/dist/modal";
|
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
|
|
|
|
import Item from "../components/Item.svelte";
|
2021-10-07 15:31:49 +02:00
|
|
|
import * as tr from "../lib/ftl";
|
2022-02-10 00:55:43 +01:00
|
|
|
import { DeckConfig } from "../lib/proto";
|
2022-02-04 09:36:34 +01:00
|
|
|
import EnumSelectorRow from "./EnumSelectorRow.svelte";
|
2022-10-25 08:18:50 +02:00
|
|
|
import HelpModal from "./HelpModal.svelte";
|
2022-02-04 09:36:34 +01:00
|
|
|
import type { DeckOptionsState } from "./lib";
|
2022-10-25 08:18:50 +02:00
|
|
|
import SettingTitle from "./SettingTitle.svelte";
|
2022-02-04 09:36:34 +01:00
|
|
|
import SpinBoxRow from "./SpinBoxRow.svelte";
|
|
|
|
import StepsInputRow from "./StepsInputRow.svelte";
|
|
|
|
import TitledContainer from "./TitledContainer.svelte";
|
2022-10-25 08:18:50 +02:00
|
|
|
import type { DeckOption } from "./types";
|
2022-02-04 09:36:34 +01:00
|
|
|
import Warning from "./Warning.svelte";
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2021-04-25 10:40:02 +02:00
|
|
|
export let state: DeckOptionsState;
|
2021-05-29 17:32:12 +02:00
|
|
|
export let api = {};
|
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
const config = state.currentConfig;
|
|
|
|
const defaults = state.defaults;
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2021-05-15 12:09:50 +02:00
|
|
|
const newInsertOrderChoices = [
|
2021-05-13 07:23:16 +02:00
|
|
|
tr.deckConfigNewInsertionOrderSequential(),
|
|
|
|
tr.deckConfigNewInsertionOrderRandom(),
|
|
|
|
];
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2021-04-17 14:53:47 +02:00
|
|
|
let stepsExceedGraduatingInterval: string;
|
2021-04-12 06:18:30 +02:00
|
|
|
$: {
|
2021-04-16 15:29:21 +02:00
|
|
|
const lastLearnStepInDays = $config.learnSteps.length
|
|
|
|
? $config.learnSteps[$config.learnSteps.length - 1] / 60 / 24
|
2021-04-12 06:18:30 +02:00
|
|
|
: 0;
|
|
|
|
stepsExceedGraduatingInterval =
|
2021-04-17 14:53:47 +02:00
|
|
|
lastLearnStepInDays > $config.graduatingIntervalGood
|
2021-04-25 15:03:23 +02:00
|
|
|
? tr.deckConfigLearningStepAboveGraduatingInterval()
|
2021-04-17 14:53:47 +02:00
|
|
|
: "";
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
|
2021-04-16 15:29:21 +02:00
|
|
|
$: goodExceedsEasy =
|
2021-04-17 14:53:47 +02:00
|
|
|
$config.graduatingIntervalGood > $config.graduatingIntervalEasy
|
2021-04-25 15:03:23 +02:00
|
|
|
? tr.deckConfigGoodAboveEasy()
|
2021-04-17 14:53:47 +02:00
|
|
|
: "";
|
2022-02-10 00:55:43 +01:00
|
|
|
|
|
|
|
$: insertionOrderRandom =
|
|
|
|
state.v3Scheduler &&
|
|
|
|
$config.newCardInsertOrder ==
|
|
|
|
DeckConfig.DeckConfig.Config.NewCardInsertOrder.NEW_CARD_INSERT_ORDER_RANDOM
|
|
|
|
? tr.deckConfigNewInsertionOrderRandomWithV3()
|
|
|
|
: "";
|
2022-10-25 08:18:50 +02:00
|
|
|
|
|
|
|
const settings = {
|
|
|
|
learningSteps: {
|
|
|
|
title: tr.deckConfigLearningSteps(),
|
|
|
|
help: tr.deckConfigLearningStepsTooltip(),
|
|
|
|
url: "https://docs.ankiweb.net/deck-options.html#learning-steps",
|
|
|
|
},
|
|
|
|
graduatingInterval: {
|
|
|
|
title: tr.schedulingGraduatingInterval(),
|
|
|
|
help: tr.deckConfigGraduatingIntervalTooltip(),
|
|
|
|
url: "https://docs.ankiweb.net/deck-options.html#graduating-interval",
|
|
|
|
},
|
|
|
|
easyInterval: {
|
|
|
|
title: tr.schedulingEasyInterval(),
|
|
|
|
help: tr.deckConfigEasyIntervalTooltip(),
|
|
|
|
url: "https://docs.ankiweb.net/deck-options.html#easy-interval",
|
|
|
|
},
|
|
|
|
insertionOrder: {
|
|
|
|
title: tr.deckConfigNewInsertionOrder(),
|
|
|
|
help: tr.deckConfigNewInsertionOrderTooltip(),
|
|
|
|
url: "https://docs.ankiweb.net/deck-options.html#insertion-order",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const helpSections = Object.values(settings) as DeckOption[];
|
|
|
|
|
|
|
|
let modal: Modal;
|
|
|
|
let carousel: Carousel;
|
|
|
|
|
|
|
|
function openHelpModal(index: number): void {
|
|
|
|
modal.show();
|
|
|
|
carousel.to(index);
|
|
|
|
}
|
2021-04-12 06:18:30 +02:00
|
|
|
</script>
|
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<TitledContainer title={tr.schedulingNewCards()}>
|
2022-10-25 08:18:50 +02:00
|
|
|
<HelpModal
|
|
|
|
title={tr.schedulingNewCards()}
|
|
|
|
url="https://docs.ankiweb.net/deck-options.html#new-cards"
|
|
|
|
slot="tooltip"
|
|
|
|
{helpSections}
|
|
|
|
on:mount={(e) => {
|
|
|
|
modal = e.detail.modal;
|
|
|
|
carousel = e.detail.carousel;
|
|
|
|
}}
|
|
|
|
/>
|
2022-02-03 05:52:11 +01:00
|
|
|
<DynamicallySlottable slotHost={Item} {api}>
|
|
|
|
<Item>
|
|
|
|
<StepsInputRow
|
|
|
|
bind:value={$config.learnSteps}
|
|
|
|
defaultValue={defaults.learnSteps}
|
|
|
|
>
|
2022-10-25 08:18:50 +02:00
|
|
|
<SettingTitle
|
|
|
|
on:click={() =>
|
|
|
|
openHelpModal(Object.keys(settings).indexOf("learningSteps"))}
|
|
|
|
>{settings.learningSteps.title}</SettingTitle
|
|
|
|
>
|
2022-02-03 05:52:11 +01:00
|
|
|
</StepsInputRow>
|
|
|
|
</Item>
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<SpinBoxRow
|
|
|
|
bind:value={$config.graduatingIntervalGood}
|
|
|
|
defaultValue={defaults.graduatingIntervalGood}
|
|
|
|
>
|
2022-10-25 08:18:50 +02:00
|
|
|
<SettingTitle
|
|
|
|
on:click={() =>
|
|
|
|
openHelpModal(
|
|
|
|
Object.keys(settings).indexOf("graduatingInterval"),
|
|
|
|
)}>{settings.graduatingInterval.title}</SettingTitle
|
|
|
|
>
|
2022-02-03 05:52:11 +01:00
|
|
|
</SpinBoxRow>
|
|
|
|
</Item>
|
2021-05-24 10:25:17 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<Warning warning={stepsExceedGraduatingInterval} />
|
|
|
|
</Item>
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<SpinBoxRow
|
|
|
|
bind:value={$config.graduatingIntervalEasy}
|
|
|
|
defaultValue={defaults.graduatingIntervalEasy}
|
|
|
|
>
|
2022-10-25 08:18:50 +02:00
|
|
|
<SettingTitle
|
|
|
|
on:click={() =>
|
|
|
|
openHelpModal(Object.keys(settings).indexOf("easyInterval"))}
|
|
|
|
>{settings.easyInterval.title}</SettingTitle
|
|
|
|
>
|
2022-02-03 05:52:11 +01:00
|
|
|
</SpinBoxRow>
|
|
|
|
</Item>
|
2021-05-28 00:52:49 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<Warning warning={goodExceedsEasy} />
|
|
|
|
</Item>
|
2021-05-28 00:52:49 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<EnumSelectorRow
|
|
|
|
bind:value={$config.newCardInsertOrder}
|
|
|
|
defaultValue={defaults.newCardInsertOrder}
|
|
|
|
choices={newInsertOrderChoices}
|
|
|
|
breakpoint={"md"}
|
|
|
|
>
|
2022-10-25 08:18:50 +02:00
|
|
|
<SettingTitle
|
|
|
|
on:click={() =>
|
|
|
|
openHelpModal(Object.keys(settings).indexOf("insertionOrder"))}
|
|
|
|
>{settings.insertionOrder.title}</SettingTitle
|
|
|
|
>
|
2022-02-03 05:52:11 +01:00
|
|
|
</EnumSelectorRow>
|
|
|
|
</Item>
|
2022-02-10 00:55:43 +01:00
|
|
|
|
|
|
|
<Item>
|
|
|
|
<Warning warning={insertionOrderRandom} />
|
|
|
|
</Item>
|
2022-02-03 05:52:11 +01:00
|
|
|
</DynamicallySlottable>
|
2021-05-27 23:19:05 +02:00
|
|
|
</TitledContainer>
|