mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -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::ConfigWithExtra;
|
||||||
use anki_proto::deck_config::deck_configs_for_update::CurrentDeck;
|
use anki_proto::deck_config::deck_configs_for_update::CurrentDeck;
|
||||||
use anki_proto::decks::deck::normal::DayLimit;
|
use anki_proto::decks::deck::normal::DayLimit;
|
||||||
|
use fsrs::DEFAULT_WEIGHTS;
|
||||||
|
|
||||||
use crate::config::StringKey;
|
use crate::config::StringKey;
|
||||||
use crate::decks::NormalDeck;
|
use crate::decks::NormalDeck;
|
||||||
|
@ -38,10 +39,12 @@ impl Collection {
|
||||||
&mut self,
|
&mut self,
|
||||||
deck: DeckId,
|
deck: DeckId,
|
||||||
) -> Result<anki_proto::deck_config::DeckConfigsForUpdate> {
|
) -> Result<anki_proto::deck_config::DeckConfigsForUpdate> {
|
||||||
|
let mut defaults = DeckConfig::default();
|
||||||
|
defaults.inner.fsrs_weights = DEFAULT_WEIGHTS.into();
|
||||||
Ok(anki_proto::deck_config::DeckConfigsForUpdate {
|
Ok(anki_proto::deck_config::DeckConfigsForUpdate {
|
||||||
all_config: self.get_deck_config_with_extra_for_update()?,
|
all_config: self.get_deck_config_with_extra_for_update()?,
|
||||||
current_deck: Some(self.get_current_deck_for_update(deck)?),
|
current_deck: Some(self.get_current_deck_for_update(deck)?),
|
||||||
defaults: Some(DeckConfig::default().into()),
|
defaults: Some(defaults.into()),
|
||||||
schema_modified: self
|
schema_modified: self
|
||||||
.storage
|
.storage
|
||||||
.get_collection_timestamps()?
|
.get_collection_timestamps()?
|
||||||
|
|
|
@ -214,7 +214,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</SpinBoxFloatRow>
|
</SpinBoxFloatRow>
|
||||||
|
|
||||||
<div class="ms-1 me-1">
|
<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>
|
<SettingTitle>{tr.deckConfigWeights()}</SettingTitle>
|
||||||
</WeightsInputRow>
|
</WeightsInputRow>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,9 +4,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let value: number[];
|
export let value: number[];
|
||||||
|
export let defaults: number[];
|
||||||
|
|
||||||
let stringValue: string;
|
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 {
|
function update(this: HTMLInputElement): void {
|
||||||
value = this.value
|
value = this.value
|
||||||
|
@ -17,4 +22,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
}
|
}
|
||||||
</script>
|
</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 RevertButton from "../components/RevertButton.svelte";
|
||||||
import WeightsInput from "./WeightsInput.svelte";
|
import WeightsInput from "./WeightsInput.svelte";
|
||||||
|
|
||||||
export let value: any;
|
export let value: number[];
|
||||||
export let defaultValue: any;
|
export let defaultValue: number[];
|
||||||
|
export let defaults: number[];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
<ConfigInput>
|
<ConfigInput>
|
||||||
<WeightsInput bind:value />
|
<WeightsInput bind:value {defaults} />
|
||||||
<RevertButton slot="revert" bind:value {defaultValue} />
|
<RevertButton slot="revert" bind:value {defaultValue} />
|
||||||
</ConfigInput>
|
</ConfigInput>
|
||||||
|
|
Loading…
Reference in a new issue