mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Display the default weights as a placeholder
This commit is contained in:
parent
50c8a1ba9f
commit
93499d4182
4 changed files with 25 additions and 7 deletions
|
@ -11,6 +11,7 @@ use anki_proto::deck_config::deck_configs_for_update::current_deck::Limits;
|
|||
use anki_proto::deck_config::deck_configs_for_update::ConfigWithExtra;
|
||||
use anki_proto::deck_config::deck_configs_for_update::CurrentDeck;
|
||||
use anki_proto::decks::deck::normal::DayLimit;
|
||||
use fsrs::DEFAULT_WEIGHTS;
|
||||
|
||||
use crate::config::StringKey;
|
||||
use crate::decks::NormalDeck;
|
||||
|
@ -38,10 +39,12 @@ impl Collection {
|
|||
&mut self,
|
||||
deck: DeckId,
|
||||
) -> Result<anki_proto::deck_config::DeckConfigsForUpdate> {
|
||||
let mut defaults = DeckConfig::default();
|
||||
defaults.inner.fsrs_weights = DEFAULT_WEIGHTS.into();
|
||||
Ok(anki_proto::deck_config::DeckConfigsForUpdate {
|
||||
all_config: self.get_deck_config_with_extra_for_update()?,
|
||||
current_deck: Some(self.get_current_deck_for_update(deck)?),
|
||||
defaults: Some(DeckConfig::default().into()),
|
||||
defaults: Some(defaults.into()),
|
||||
schema_modified: self
|
||||
.storage
|
||||
.get_collection_timestamps()?
|
||||
|
|
|
@ -214,7 +214,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
</SpinBoxFloatRow>
|
||||
|
||||
<div class="ms-1 me-1">
|
||||
<WeightsInputRow bind:value={$config.fsrsWeights} defaultValue={[]}>
|
||||
<WeightsInputRow
|
||||
bind:value={$config.fsrsWeights}
|
||||
defaultValue={[]}
|
||||
defaults={defaults.fsrsWeights}
|
||||
>
|
||||
<SettingTitle>{tr.deckConfigWeights()}</SettingTitle>
|
||||
</WeightsInputRow>
|
||||
</div>
|
||||
|
|
|
@ -4,9 +4,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
-->
|
||||
<script lang="ts">
|
||||
export let value: number[];
|
||||
export let defaults: number[];
|
||||
|
||||
let stringValue: string;
|
||||
$: stringValue = value.map((v) => v.toFixed(4)).join(", ");
|
||||
$: stringValue = render(value);
|
||||
|
||||
function render(weights: number[]): string {
|
||||
return weights.map((v) => v.toFixed(4)).join(", ");
|
||||
}
|
||||
|
||||
function update(this: HTMLInputElement): void {
|
||||
value = this.value
|
||||
|
@ -17,4 +22,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
</script>
|
||||
|
||||
<textarea value={stringValue} on:blur={update} class="w-100" />
|
||||
<textarea
|
||||
value={stringValue}
|
||||
on:blur={update}
|
||||
class="w-100"
|
||||
placeholder={render(defaults)}
|
||||
/>
|
||||
|
|
|
@ -7,12 +7,13 @@
|
|||
import RevertButton from "../components/RevertButton.svelte";
|
||||
import WeightsInput from "./WeightsInput.svelte";
|
||||
|
||||
export let value: any;
|
||||
export let defaultValue: any;
|
||||
export let value: number[];
|
||||
export let defaultValue: number[];
|
||||
export let defaults: number[];
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
<ConfigInput>
|
||||
<WeightsInput bind:value />
|
||||
<WeightsInput bind:value {defaults} />
|
||||
<RevertButton slot="revert" bind:value {defaultValue} />
|
||||
</ConfigInput>
|
||||
|
|
Loading…
Reference in a new issue