2021-05-24 10:25:17 +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-02-03 05:52:11 +01:00
|
|
|
import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
|
|
|
|
import Item from "../components/Item.svelte";
|
2022-02-04 09:36:34 +01: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";
|
2021-05-24 10:25:17 +02:00
|
|
|
import type { DeckOptionsState } from "./lib";
|
|
|
|
import { reviewMixChoices } from "./strings";
|
2022-02-04 09:36:34 +01:00
|
|
|
import TitledContainer from "./TitledContainer.svelte";
|
2021-05-24 10:25:17 +02:00
|
|
|
|
|
|
|
export let state: DeckOptionsState;
|
2021-05-29 17:32:12 +02:00
|
|
|
export let api: Record<string, never>;
|
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
const config = state.currentConfig;
|
|
|
|
const defaults = state.defaults;
|
2021-05-24 10:25:17 +02:00
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
const currentDeck = "\n\n" + tr.deckConfigDisplayOrderWillUseCurrentDeck();
|
2021-07-13 07:58:06 +02:00
|
|
|
|
2021-05-24 10:25:17 +02:00
|
|
|
const newGatherPriorityChoices = [
|
|
|
|
tr.deckConfigNewGatherPriorityDeck(),
|
2021-06-08 06:01:46 +02:00
|
|
|
tr.deckConfigNewGatherPriorityPositionLowestFirst(),
|
|
|
|
tr.deckConfigNewGatherPriorityPositionHighestFirst(),
|
2022-02-10 00:55:43 +01:00
|
|
|
tr.deckConfigNewGatherPriorityRandomNotes(),
|
|
|
|
tr.deckConfigNewGatherPriorityRandomCards(),
|
2021-05-24 10:25:17 +02:00
|
|
|
];
|
|
|
|
const newSortOrderChoices = [
|
2021-08-20 04:03:32 +02:00
|
|
|
tr.deckConfigSortOrderTemplateThenGather(),
|
|
|
|
tr.deckConfigSortOrderGather(),
|
2022-02-10 00:55:43 +01:00
|
|
|
tr.deckConfigSortOrderCardTemplateThenRandom(),
|
|
|
|
tr.deckConfigSortOrderRandomNoteThenTemplate(),
|
|
|
|
tr.deckConfigSortOrderRandom(),
|
2021-05-24 10:25:17 +02:00
|
|
|
];
|
|
|
|
const reviewOrderChoices = [
|
|
|
|
tr.deckConfigSortOrderDueDateThenRandom(),
|
2021-06-01 05:22:39 +02:00
|
|
|
tr.deckConfigSortOrderDueDateThenDeck(),
|
|
|
|
tr.deckConfigSortOrderDeckThenDueDate(),
|
2021-05-24 10:25:17 +02:00
|
|
|
tr.deckConfigSortOrderAscendingIntervals(),
|
|
|
|
tr.deckConfigSortOrderDescendingIntervals(),
|
2021-08-22 03:07:00 +02:00
|
|
|
tr.deckConfigSortOrderAscendingEase(),
|
|
|
|
tr.deckConfigSortOrderDescendingEase(),
|
2022-04-09 05:20:09 +02:00
|
|
|
tr.deckConfigSortOrderRelativeOverdueness(),
|
2021-05-24 10:25:17 +02:00
|
|
|
];
|
2022-02-10 00:55:43 +01:00
|
|
|
|
|
|
|
const GatherOrder = DeckConfig.DeckConfig.Config.NewCardGatherPriority;
|
|
|
|
const SortOrder = DeckConfig.DeckConfig.Config.NewCardSortOrder;
|
|
|
|
let disabledNewSortOrders: number[] = [];
|
|
|
|
$: {
|
|
|
|
switch ($config.newCardGatherPriority) {
|
|
|
|
case GatherOrder.NEW_CARD_GATHER_PRIORITY_RANDOM_NOTES:
|
|
|
|
disabledNewSortOrders = [
|
|
|
|
// same as NEW_CARD_SORT_ORDER_TEMPLATE
|
|
|
|
SortOrder.NEW_CARD_SORT_ORDER_TEMPLATE_THEN_RANDOM,
|
|
|
|
// same as NEW_CARD_SORT_ORDER_NO_SORT
|
|
|
|
SortOrder.NEW_CARD_SORT_ORDER_RANDOM_NOTE_THEN_TEMPLATE,
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
case GatherOrder.NEW_CARD_GATHER_PRIORITY_RANDOM_CARDS:
|
|
|
|
disabledNewSortOrders = [
|
|
|
|
// same as NEW_CARD_SORT_ORDER_TEMPLATE
|
|
|
|
SortOrder.NEW_CARD_SORT_ORDER_TEMPLATE_THEN_RANDOM,
|
|
|
|
// not useful if siblings are not gathered together
|
|
|
|
SortOrder.NEW_CARD_SORT_ORDER_RANDOM_NOTE_THEN_TEMPLATE,
|
|
|
|
// same as NEW_CARD_SORT_ORDER_NO_SORT
|
|
|
|
SortOrder.NEW_CARD_SORT_ORDER_RANDOM_CARD,
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
disabledNewSortOrders = [];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// disabled options aren't deselected automatically
|
|
|
|
if (disabledNewSortOrders.includes($config.newCardSortOrder)) {
|
|
|
|
// default option should never be disabled
|
|
|
|
$config.newCardSortOrder = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for invalid index from previous version
|
|
|
|
if (!($config.newCardSortOrder in SortOrder)) {
|
|
|
|
$config.newCardSortOrder = 0;
|
|
|
|
}
|
|
|
|
}
|
2021-05-24 10:25:17 +02:00
|
|
|
</script>
|
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<TitledContainer title={tr.deckConfigOrderingTitle()}>
|
|
|
|
<DynamicallySlottable slotHost={Item} {api}>
|
|
|
|
<Item>
|
|
|
|
<EnumSelectorRow
|
|
|
|
bind:value={$config.newCardGatherPriority}
|
|
|
|
defaultValue={defaults.newCardGatherPriority}
|
|
|
|
choices={newGatherPriorityChoices}
|
2022-02-10 00:55:43 +01:00
|
|
|
markdownTooltip={tr.deckConfigNewGatherPriorityTooltip_2() +
|
|
|
|
currentDeck}
|
2022-02-03 05:52:11 +01:00
|
|
|
>
|
|
|
|
{tr.deckConfigNewGatherPriority()}
|
|
|
|
</EnumSelectorRow>
|
|
|
|
</Item>
|
2021-05-24 10:25:17 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<EnumSelectorRow
|
|
|
|
bind:value={$config.newCardSortOrder}
|
|
|
|
defaultValue={defaults.newCardSortOrder}
|
|
|
|
choices={newSortOrderChoices}
|
2022-02-10 00:55:43 +01:00
|
|
|
disabled={disabledNewSortOrders}
|
|
|
|
markdownTooltip={tr.deckConfigNewCardSortOrderTooltip_2() + currentDeck}
|
2022-02-03 05:52:11 +01:00
|
|
|
>
|
|
|
|
{tr.deckConfigNewCardSortOrder()}
|
|
|
|
</EnumSelectorRow>
|
|
|
|
</Item>
|
2021-05-24 10:25:17 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<EnumSelectorRow
|
|
|
|
bind:value={$config.newMix}
|
|
|
|
defaultValue={defaults.newMix}
|
|
|
|
choices={reviewMixChoices()}
|
|
|
|
markdownTooltip={tr.deckConfigNewReviewPriorityTooltip() + currentDeck}
|
|
|
|
>
|
|
|
|
{tr.deckConfigNewReviewPriority()}
|
|
|
|
</EnumSelectorRow>
|
|
|
|
</Item>
|
2021-05-24 10:25:17 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<EnumSelectorRow
|
|
|
|
bind:value={$config.interdayLearningMix}
|
|
|
|
defaultValue={defaults.interdayLearningMix}
|
|
|
|
choices={reviewMixChoices()}
|
|
|
|
markdownTooltip={tr.deckConfigInterdayStepPriorityTooltip() +
|
|
|
|
currentDeck}
|
|
|
|
>
|
|
|
|
{tr.deckConfigInterdayStepPriority()}
|
|
|
|
</EnumSelectorRow>
|
|
|
|
</Item>
|
2021-05-24 10:25:17 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
<Item>
|
|
|
|
<EnumSelectorRow
|
|
|
|
bind:value={$config.reviewOrder}
|
|
|
|
defaultValue={defaults.reviewOrder}
|
|
|
|
choices={reviewOrderChoices}
|
|
|
|
markdownTooltip={tr.deckConfigReviewSortOrderTooltip() + currentDeck}
|
|
|
|
>
|
|
|
|
{tr.deckConfigReviewSortOrder()}
|
|
|
|
</EnumSelectorRow>
|
|
|
|
</Item>
|
|
|
|
</DynamicallySlottable>
|
2021-06-12 10:40:47 +02:00
|
|
|
</TitledContainer>
|