e63b4b9927
Prettier by default tries to preserve whitespace around inline tags, which can prevent problems such as a space before the period in '<a>text</a>.': https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting Unfortunately only standard HTML block elements are excluded from this behaviour, so all of our Svelte components are treated the same way, even if they are block-based, or used in a way where the extra whitespace doesn't matter. This makes the code somewhat harder to read. Changing this option does carry the risk that rogue spaces will creep into our UI in the future as code is formatted, but as there don't appear to be any such issues with this initial reformat, I think the improved readability may justify the relatively small risk.
152 lines
5.0 KiB
Svelte
152 lines
5.0 KiB
Svelte
<!--
|
|
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 "@tslib/ftl";
|
|
import { HelpPage } from "@tslib/help-page";
|
|
import type Carousel from "bootstrap/js/dist/carousel";
|
|
import type Modal from "bootstrap/js/dist/modal";
|
|
|
|
import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
|
|
import Item from "../components/Item.svelte";
|
|
import TitledContainer from "../components/TitledContainer.svelte";
|
|
import EnumSelectorRow from "./EnumSelectorRow.svelte";
|
|
import HelpModal from "./HelpModal.svelte";
|
|
import type { DeckOptionsState } from "./lib";
|
|
import SettingTitle from "./SettingTitle.svelte";
|
|
import SpinBoxRow from "./SpinBoxRow.svelte";
|
|
import StepsInputRow from "./StepsInputRow.svelte";
|
|
import type { DeckOption } from "./types";
|
|
import Warning from "./Warning.svelte";
|
|
|
|
export let state: DeckOptionsState;
|
|
export let api = {};
|
|
|
|
const config = state.currentConfig;
|
|
const defaults = state.defaults;
|
|
|
|
let stepsExceedMinimumInterval: string;
|
|
$: {
|
|
const lastRelearnStepInDays = $config.relearnSteps.length
|
|
? $config.relearnSteps[$config.relearnSteps.length - 1] / 60 / 24
|
|
: 0;
|
|
stepsExceedMinimumInterval =
|
|
lastRelearnStepInDays > $config.minimumLapseInterval
|
|
? tr.deckConfigRelearningStepsAboveMinimumInterval()
|
|
: "";
|
|
}
|
|
|
|
const leechChoices = [tr.actionsSuspendCard(), tr.schedulingTagOnly()];
|
|
|
|
const settings = {
|
|
relearningSteps: {
|
|
title: tr.deckConfigRelearningSteps(),
|
|
help: tr.deckConfigRelearningStepsTooltip(),
|
|
url: HelpPage.DeckOptions.relearningSteps,
|
|
},
|
|
minimumInterval: {
|
|
title: tr.schedulingMinimumInterval(),
|
|
help: tr.deckConfigMinimumIntervalTooltip(),
|
|
url: HelpPage.DeckOptions.minimumInterval,
|
|
},
|
|
leechThreshold: {
|
|
title: tr.schedulingLeechThreshold(),
|
|
help: tr.deckConfigLeechThresholdTooltip(),
|
|
url: HelpPage.Leeches.leeches,
|
|
},
|
|
leechAction: {
|
|
title: tr.schedulingLeechAction(),
|
|
help: tr.deckConfigLeechActionTooltip(),
|
|
url: HelpPage.Leeches.waiting,
|
|
},
|
|
};
|
|
const helpSections = Object.values(settings) as DeckOption[];
|
|
|
|
let modal: Modal;
|
|
let carousel: Carousel;
|
|
|
|
function openHelpModal(index: number): void {
|
|
modal.show();
|
|
carousel.to(index);
|
|
}
|
|
</script>
|
|
|
|
<TitledContainer title={tr.schedulingLapses()}>
|
|
<HelpModal
|
|
title={tr.schedulingLapses()}
|
|
url={HelpPage.DeckOptions.lapses}
|
|
slot="tooltip"
|
|
{helpSections}
|
|
on:mount={(e) => {
|
|
modal = e.detail.modal;
|
|
carousel = e.detail.carousel;
|
|
}}
|
|
/>
|
|
<DynamicallySlottable slotHost={Item} {api}>
|
|
<Item>
|
|
<StepsInputRow
|
|
bind:value={$config.relearnSteps}
|
|
defaultValue={defaults.relearnSteps}
|
|
>
|
|
<SettingTitle
|
|
on:click={() =>
|
|
openHelpModal(Object.keys(settings).indexOf("relearningSteps"))}
|
|
>
|
|
{settings.relearningSteps.title}
|
|
</SettingTitle>
|
|
</StepsInputRow>
|
|
</Item>
|
|
|
|
<Item>
|
|
<SpinBoxRow
|
|
bind:value={$config.minimumLapseInterval}
|
|
defaultValue={defaults.minimumLapseInterval}
|
|
min={1}
|
|
>
|
|
<SettingTitle
|
|
on:click={() =>
|
|
openHelpModal(Object.keys(settings).indexOf("minimumInterval"))}
|
|
>
|
|
{settings.minimumInterval.title}
|
|
</SettingTitle>
|
|
</SpinBoxRow>
|
|
</Item>
|
|
|
|
<Item>
|
|
<Warning warning={stepsExceedMinimumInterval} />
|
|
</Item>
|
|
|
|
<Item>
|
|
<SpinBoxRow
|
|
bind:value={$config.leechThreshold}
|
|
defaultValue={defaults.leechThreshold}
|
|
min={1}
|
|
>
|
|
<SettingTitle
|
|
on:click={() =>
|
|
openHelpModal(Object.keys(settings).indexOf("leechThreshold"))}
|
|
>
|
|
{settings.leechThreshold.title}
|
|
</SettingTitle>
|
|
</SpinBoxRow>
|
|
</Item>
|
|
|
|
<Item>
|
|
<EnumSelectorRow
|
|
bind:value={$config.leechAction}
|
|
defaultValue={defaults.leechAction}
|
|
choices={leechChoices}
|
|
breakpoint="md"
|
|
>
|
|
<SettingTitle
|
|
on:click={() =>
|
|
openHelpModal(Object.keys(settings).indexOf("leechAction"))}
|
|
>
|
|
{settings.leechAction.title}
|
|
</SettingTitle>
|
|
</EnumSelectorRow>
|
|
</Item>
|
|
</DynamicallySlottable>
|
|
</TitledContainer>
|