anki/ts/deck-options/DeckOptionsPage.svelte
RumovZ cc929687ae
Deck-specific Limits (#1955)
* Add deck-specific limits to DeckNormal

* Add deck-specific limits to schema11

* Add DeckLimitsDialog

* deck_limits_qt6.py needs to be a symlink

* Clear duplicate deck setting keys on downgrade

* Export deck limits when exporting with scheduling

* Revert "deck_limits_qt6.py needs to be a symlink"

This reverts commit 4ee7be1e10c4e8c49bb20de3bf45ac18b5e2d4f6.

* Revert "Add DeckLimitsDialog"

This reverts commit eb0e2a62d33df0b518d9204a27b09e97966ce82a.

* Add day limits to DeckNormal

* Add deck and day limits mock to deck options

* Revert "Add deck and day limits mock to deck options"

This reverts commit 0775814989e8cb486483d06727b1af266bb4513a.

* Add Tabs component for daily limits

* Add borders to tabs component

* Revert "Add borders to tabs component"

This reverts commit aaaf5538932540f944d92725c63bb04cfe97ea14.

* Implement tabbed limits properly

* Add comment to translations

* Update rslib/src/decks/limits.rs

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* Fix camel case in clear_other_duplicates()

* day_limit → current_limit

* Also import day limits

* Remember last used day limits

* Add day limits to schema 11

* Tweak comment (dae)

* Exclude day limit in export (dae)

* Tweak tab wording (dae)

* Update preset limits on preset change

* Explain tabs in tooltip (dae)

* Omit deck and today limits if v2 is enabled

* Preserve deck limit when switching to today limit
2022-07-19 18:27:25 +10:00

156 lines
4.5 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 type { Writable } from "svelte/store";
import Container from "../components/Container.svelte";
import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte";
import Row from "../components/Row.svelte";
import type { DynamicSvelteComponent } from "../sveltelib/dynamicComponent";
import Addons from "./Addons.svelte";
import AdvancedOptions from "./AdvancedOptions.svelte";
import AudioOptions from "./AudioOptions.svelte";
import BuryOptions from "./BuryOptions.svelte";
import ConfigSelector from "./ConfigSelector.svelte";
import DailyLimits from "./DailyLimits.svelte";
import DisplayOrder from "./DisplayOrder.svelte";
import HtmlAddon from "./HtmlAddon.svelte";
import LapseOptions from "./LapseOptions.svelte";
import type { DeckOptionsState } from "./lib";
import NewOptions from "./NewOptions.svelte";
import TimerOptions from "./TimerOptions.svelte";
export let state: DeckOptionsState;
const addons = state.addonComponents;
export function auxData(): Writable<Record<string, unknown>> {
return state.currentAuxData;
}
export function addSvelteAddon(component: DynamicSvelteComponent): void {
$addons = [...$addons, component];
}
export function addHtmlAddon(html: string, mounted: () => void): void {
$addons = [
...$addons,
{
component: HtmlAddon,
html,
mounted,
},
];
}
export const options = {};
export const dailyLimits = {};
export const newOptions = {};
export const lapseOptions = {};
export const buryOptions = {};
export const displayOrder = {};
export const timerOptions = {};
export const audioOptions = {};
export const advancedOptions = {};
let onPresetChange: () => void;
</script>
<ConfigSelector {state} on:presetchange={onPresetChange} />
<div class="deck-options-page">
<Container
breakpoint="sm"
--gutter-inline="0.25rem"
--gutter-block="0.5rem"
class="container-columns"
>
<DynamicallySlottable slotHost={Item} api={options}>
<Item>
<Row class="row-columns">
<DailyLimits {state} api={dailyLimits} bind:onPresetChange />
</Row>
</Item>
<Item>
<Row class="row-columns">
<NewOptions {state} api={newOptions} />
</Row>
</Item>
<Item>
<Row class="row-columns">
<LapseOptions {state} api={lapseOptions} />
</Row>
</Item>
{#if state.v3Scheduler}
<Item>
<Row class="row-columns">
<DisplayOrder {state} api={displayOrder} />
</Row>
</Item>
{/if}
<Item>
<Row class="row-columns">
<TimerOptions {state} api={timerOptions} />
</Row>
</Item>
<Item>
<Row class="row-columns">
<BuryOptions {state} api={buryOptions} />
</Row>
</Item>
<Item>
<Row class="row-columns">
<AudioOptions {state} api={audioOptions} />
</Row>
</Item>
<Item>
<Row class="row-columns">
<Addons {state} />
</Row>
</Item>
<Item>
<Row class="row-columns">
<AdvancedOptions {state} api={advancedOptions} />
</Row>
</Item>
</DynamicallySlottable>
</Container>
</div>
<style lang="scss">
@use "sass/breakpoints" as bp;
.deck-options-page {
overflow-x: hidden;
@include bp.with-breakpoint("lg") {
:global(.container) {
display: block;
}
:global(.container-columns) {
column-count: 2;
column-gap: 5em;
:global(.container) {
break-inside: avoid;
}
}
:global(.row-columns) {
display: block;
}
}
}
</style>