move daily limits into separate section; add extra warning+tweak formatting

This commit is contained in:
Damien Elmes 2021-04-18 00:01:53 +10:00
parent 460ff354da
commit 6e3eff9f44
5 changed files with 71 additions and 36 deletions

View File

@ -3,6 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import DailyLimits from "./DailyLimits.svelte";
import NewOptions from "./NewOptions.svelte"; import NewOptions from "./NewOptions.svelte";
import ReviewOptions from "./ReviewOptions.svelte"; import ReviewOptions from "./ReviewOptions.svelte";
import LapseOptions from "./LapseOptions.svelte"; import LapseOptions from "./LapseOptions.svelte";
@ -19,6 +20,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</style> </style>
<div> <div>
<DailyLimits {state} />
<NewOptions {state} /> <NewOptions {state} />
<ReviewOptions {state} /> <ReviewOptions {state} />
<LapseOptions {state} /> <LapseOptions {state} />

View File

@ -23,7 +23,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<style lang="scss"> <style lang="scss">
.form-select { .form-select {
display: inline-block; display: inline-block;
width: 30em; width: 70%;
} }
.outer { .outer {
@ -35,11 +35,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
color: var(--text-fg); color: var(--text-fg);
background: var(--window-bg); background: var(--window-bg);
padding: 0.5em; padding: 0.5em;
display: flex;
justify-content: center;
} }
.inner { .inner {
display: flex; display: flex;
justify-content: center; flex-wrap: wrap;
width: 35em;
& > :global(*) { & > :global(*) {
padding-left: 0.5em; padding-left: 0.5em;
@ -48,26 +51,24 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
.padding { .padding {
height: 2.5em; height: 3em;
} }
</style> </style>
<div class="outer"> <div class="outer">
<div class="inner"> <div class="inner">
<div> <div>{tr.actionsOptionsFor({ val: state.currentDeck.name })}</div>
<div>{tr.actionsOptionsFor({ val: state.currentDeck.name })}</div>
<!-- svelte-ignore a11y-no-onchange --> <!-- svelte-ignore a11y-no-onchange -->
<select class="form-select" on:change={myblur}> <select class="form-select" on:change={myblur}>
{#each $configList as entry} {#each $configList as entry}
<option value={entry.idx} selected={entry.current}> <option value={entry.idx} selected={entry.current}>
{configLabel(entry)} {configLabel(entry)}
</option> </option>
{/each} {/each}
</select> </select>
<OptionsDropdown {state} /> <OptionsDropdown {state} />
</div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,53 @@
<!--
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 "anki/i18n";
import SpinBox from "./SpinBox.svelte";
import type { DeckConfigState } from "./lib";
export let state: DeckConfigState;
let config = state.currentConfig;
let defaults = state.defaults;
let parentLimits = state.parentLimits;
$: newCardsGreaterThanParent =
$config.newPerDay > $parentLimits.newCards
? `Daily limit will be capped to parent limit of ${$parentLimits.newCards}.`
: "";
$: reviewsGreaterThanParent =
$config.reviewsPerDay > $parentLimits.reviews
? `Daily limit will be capped to parent limit of ${$parentLimits.reviews}.`
: "";
$: reviewsTooLow =
$config.newPerDay * 10 > $config.reviewsPerDay
? `If adding ${
$config.newPerDay
} new cards each day, your review limit should be at least ${
$config.newPerDay * 10
}`
: "";
</script>
<div>
<h2>Daily Limits</h2>
<SpinBox
label={tr.schedulingNewCardsday()}
subLabel="The maximum number of new cards to introduce in a day."
min={0}
warnings={[newCardsGreaterThanParent]}
defaultValue={defaults.newPerDay}
bind:value={$config.newPerDay} />
<SpinBox
label={tr.schedulingMaximumReviewsday()}
subLabel="The maximum number of reviews cards to show in a day."
min={0}
warnings={[reviewsTooLow, reviewsGreaterThanParent]}
defaultValue={defaults.reviewsPerDay}
bind:value={$config.reviewsPerDay} />
</div>

View File

@ -14,18 +14,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let state: DeckConfigState; export let state: DeckConfigState;
let config = state.currentConfig; let config = state.currentConfig;
let defaults = state.defaults; let defaults = state.defaults;
let parentLimits = state.parentLimits;
const newOrderChoices = [ const newOrderChoices = [
tr.schedulingShowNewCardsInOrderAdded(), tr.schedulingShowNewCardsInOrderAdded(),
tr.schedulingShowNewCardsInRandomOrder(), tr.schedulingShowNewCardsInRandomOrder(),
]; ];
$: newCardsGreaterThanParent =
$config.newPerDay > $parentLimits.newCards
? `Daily limit will be capped to parent limit of ${$parentLimits.newCards}`
: "";
let stepsExceedGraduatingInterval: string; let stepsExceedGraduatingInterval: string;
$: { $: {
const lastLearnStepInDays = $config.learnSteps.length const lastLearnStepInDays = $config.learnSteps.length
@ -60,14 +54,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
defaultValue={defaults.newCardOrder} defaultValue={defaults.newCardOrder}
bind:value={$config.newCardOrder} /> bind:value={$config.newCardOrder} />
<SpinBox
label={tr.schedulingNewCardsday()}
subLabel="The maximum number of new cards to introduce in a day."
min={0}
warnings={[newCardsGreaterThanParent]}
defaultValue={defaults.newPerDay}
bind:value={$config.newPerDay} />
<SpinBox <SpinBox
label={tr.schedulingGraduatingInterval()} label={tr.schedulingGraduatingInterval()}
subLabel="Days to wait after answering Good on the last learning step." subLabel="Days to wait after answering Good on the last learning step."

View File

@ -17,13 +17,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<div> <div>
<h2>Reviews</h2> <h2>Reviews</h2>
<SpinBox
label={tr.schedulingMaximumReviewsday()}
subLabel="The maximum number of reviews cards to show in a day."
min={0}
defaultValue={defaults.reviewsPerDay}
bind:value={$config.reviewsPerDay} />
<SpinBoxFloat <SpinBoxFloat
label={tr.schedulingEasyBonus()} label={tr.schedulingEasyBonus()}
subLabel="Extra multiplier applied when answering Easy on a review card." subLabel="Extra multiplier applied when answering Easy on a review card."