mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
expose scheduler js option in deck config
This commit is contained in:
parent
943f2b0287
commit
0b697f5161
10 changed files with 71 additions and 0 deletions
|
@ -173,6 +173,8 @@ deck-config-interval-modifier-tooltip =
|
||||||
deck-config-hard-interval-tooltip = The multiplier applied to a review interval when answering `Hard`.
|
deck-config-hard-interval-tooltip = The multiplier applied to a review interval when answering `Hard`.
|
||||||
deck-config-new-interval-tooltip = The multiplier applied to a review interval when answering `Again`.
|
deck-config-new-interval-tooltip = The multiplier applied to a review interval when answering `Again`.
|
||||||
deck-config-minimum-interval-tooltip = The minimum interval given to a review card after answering `Again`.
|
deck-config-minimum-interval-tooltip = The minimum interval given to a review card after answering `Again`.
|
||||||
|
deck-config-custom-scheduling = Custom scheduling
|
||||||
|
deck-config-custom-scheduling-tooltip = Affects the entire collection. Use at your own risk!
|
||||||
|
|
||||||
## Adding/renaming
|
## Adding/renaming
|
||||||
|
|
||||||
|
|
|
@ -965,6 +965,8 @@ message DeckConfigsForUpdate {
|
||||||
bool schema_modified = 4;
|
bool schema_modified = 4;
|
||||||
bool v3_scheduler = 5;
|
bool v3_scheduler = 5;
|
||||||
bool have_addons = 6;
|
bool have_addons = 6;
|
||||||
|
// only applies to v3 scheduler
|
||||||
|
string card_state_customizer = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UpdateDeckConfigsRequest {
|
message UpdateDeckConfigsRequest {
|
||||||
|
@ -974,6 +976,7 @@ message UpdateDeckConfigsRequest {
|
||||||
repeated DeckConfig configs = 2;
|
repeated DeckConfig configs = 2;
|
||||||
repeated int64 removed_config_ids = 3;
|
repeated int64 removed_config_ids = 3;
|
||||||
bool apply_to_children = 4;
|
bool apply_to_children = 4;
|
||||||
|
string card_state_customizer = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SetTagCollapsedRequest {
|
message SetTagCollapsedRequest {
|
||||||
|
@ -1470,6 +1473,7 @@ message Config {
|
||||||
SET_DUE_BROWSER = 0;
|
SET_DUE_BROWSER = 0;
|
||||||
SET_DUE_REVIEWER = 1;
|
SET_DUE_REVIEWER = 1;
|
||||||
DEFAULT_SEARCH_TEXT = 2;
|
DEFAULT_SEARCH_TEXT = 2;
|
||||||
|
CARD_STATE_CUSTOMIZER = 3;
|
||||||
}
|
}
|
||||||
Key key = 1;
|
Key key = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ impl From<StringKeyProto> for StringKey {
|
||||||
StringKeyProto::SetDueBrowser => StringKey::SetDueBrowser,
|
StringKeyProto::SetDueBrowser => StringKey::SetDueBrowser,
|
||||||
StringKeyProto::SetDueReviewer => StringKey::SetDueReviewer,
|
StringKeyProto::SetDueReviewer => StringKey::SetDueReviewer,
|
||||||
StringKeyProto::DefaultSearchText => StringKey::DefaultSearchText,
|
StringKeyProto::DefaultSearchText => StringKey::DefaultSearchText,
|
||||||
|
StringKeyProto::CardStateCustomizer => StringKey::CardStateCustomizer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,7 @@ impl From<pb::UpdateDeckConfigsRequest> for UpdateDeckConfigsRequest {
|
||||||
configs: c.configs.into_iter().map(Into::into).collect(),
|
configs: c.configs.into_iter().map(Into::into).collect(),
|
||||||
removed_config_ids: c.removed_config_ids.into_iter().map(Into::into).collect(),
|
removed_config_ids: c.removed_config_ids.into_iter().map(Into::into).collect(),
|
||||||
apply_to_children: c.apply_to_children,
|
apply_to_children: c.apply_to_children,
|
||||||
|
card_state_customizer: c.card_state_customizer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub enum StringKey {
|
||||||
SetDueBrowser,
|
SetDueBrowser,
|
||||||
SetDueReviewer,
|
SetDueReviewer,
|
||||||
DefaultSearchText,
|
DefaultSearchText,
|
||||||
|
CardStateCustomizer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Collection {
|
impl Collection {
|
||||||
|
|
|
@ -11,6 +11,7 @@ use std::{
|
||||||
use crate::{
|
use crate::{
|
||||||
backend_proto as pb,
|
backend_proto as pb,
|
||||||
backend_proto::deck_configs_for_update::{ConfigWithExtra, CurrentDeck},
|
backend_proto::deck_configs_for_update::{ConfigWithExtra, CurrentDeck},
|
||||||
|
config::StringKey,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ pub struct UpdateDeckConfigsRequest {
|
||||||
pub configs: Vec<DeckConfig>,
|
pub configs: Vec<DeckConfig>,
|
||||||
pub removed_config_ids: Vec<DeckConfigId>,
|
pub removed_config_ids: Vec<DeckConfigId>,
|
||||||
pub apply_to_children: bool,
|
pub apply_to_children: bool,
|
||||||
|
pub card_state_customizer: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Collection {
|
impl Collection {
|
||||||
|
@ -39,6 +41,7 @@ impl Collection {
|
||||||
.schema_changed_since_sync(),
|
.schema_changed_since_sync(),
|
||||||
v3_scheduler: self.get_config_bool(BoolKey::Sched2021),
|
v3_scheduler: self.get_config_bool(BoolKey::Sched2021),
|
||||||
have_addons: false,
|
have_addons: false,
|
||||||
|
card_state_customizer: self.get_config_string(StringKey::CardStateCustomizer),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +181,8 @@ impl Collection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.set_config_string_inner(StringKey::CardStateCustomizer, &input.card_state_customizer)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,6 +204,9 @@ mod test {
|
||||||
col.add_note(&mut note, DeckId(1))?;
|
col.add_note(&mut note, DeckId(1))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add the key so it doesn't trigger a change below
|
||||||
|
col.set_config_string_inner(StringKey::CardStateCustomizer, "")?;
|
||||||
|
|
||||||
// pretend we're in sync
|
// pretend we're in sync
|
||||||
let stamps = col.storage.get_collection_timestamps()?;
|
let stamps = col.storage.get_collection_timestamps()?;
|
||||||
col.storage.set_last_sync(stamps.schema_change)?;
|
col.storage.set_last_sync(stamps.schema_change)?;
|
||||||
|
@ -228,6 +236,7 @@ mod test {
|
||||||
.collect(),
|
.collect(),
|
||||||
removed_config_ids: vec![],
|
removed_config_ids: vec![],
|
||||||
apply_to_children: false,
|
apply_to_children: false,
|
||||||
|
card_state_customizer: "".to_string(),
|
||||||
};
|
};
|
||||||
assert!(!col.update_deck_configs(input.clone())?.changes.had_change());
|
assert!(!col.update_deck_configs(input.clone())?.changes.had_change());
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import SpinBoxRow from "./SpinBoxRow.svelte";
|
import SpinBoxRow from "./SpinBoxRow.svelte";
|
||||||
import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
|
import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
|
||||||
import type { DeckOptionsState } from "./lib";
|
import type { DeckOptionsState } from "./lib";
|
||||||
|
import CardStateCustomizer from "./CardStateCustomizer.svelte";
|
||||||
|
|
||||||
export let state: DeckOptionsState;
|
export let state: DeckOptionsState;
|
||||||
export let api: Record<string, never>;
|
export let api: Record<string, never>;
|
||||||
|
|
||||||
let config = state.currentConfig;
|
let config = state.currentConfig;
|
||||||
let defaults = state.defaults;
|
let defaults = state.defaults;
|
||||||
|
let cardStateCustomizer = state.cardStateCustomizer;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<TitledContainer title={tr.deckConfigAdvancedTitle()} {api}>
|
<TitledContainer title={tr.deckConfigAdvancedTitle()} {api}>
|
||||||
|
@ -88,4 +90,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
{tr.schedulingNewInterval()}
|
{tr.schedulingNewInterval()}
|
||||||
</SpinBoxFloatRow>
|
</SpinBoxFloatRow>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
|
{#if state.v3Scheduler}
|
||||||
|
<Item>
|
||||||
|
<CardStateCustomizer bind:value={$cardStateCustomizer} />
|
||||||
|
</Item>
|
||||||
|
{/if}
|
||||||
</TitledContainer>
|
</TitledContainer>
|
||||||
|
|
37
ts/deckoptions/CardStateCustomizer.svelte
Normal file
37
ts/deckoptions/CardStateCustomizer.svelte
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<!--
|
||||||
|
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 "lib/i18n";
|
||||||
|
import TooltipLabel from "./TooltipLabel.svelte";
|
||||||
|
import RevertButton from "./RevertButton.svelte";
|
||||||
|
import Row from "./Row.svelte";
|
||||||
|
import Col from "./Col.svelte";
|
||||||
|
|
||||||
|
export let value: string;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
<div class="text">
|
||||||
|
<TooltipLabel markdownTooltip={tr.deckConfigCustomSchedulingTooltip()}>
|
||||||
|
{tr.deckConfigCustomScheduling()}:</TooltipLabel
|
||||||
|
>
|
||||||
|
<RevertButton bind:value defaultValue="" />
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<textarea bind:value />
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.text {
|
||||||
|
min-height: 2em;
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
height: 10em;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -44,3 +44,8 @@ $tooltip-max-width: 300px;
|
||||||
color: #ffaaaa;
|
color: #ffaaaa;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
color: var(--text-fg);
|
||||||
|
background-color: var(--frame-bg);
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ export class DeckOptionsState {
|
||||||
readonly currentAuxData: Writable<Record<string, unknown>>;
|
readonly currentAuxData: Writable<Record<string, unknown>>;
|
||||||
readonly configList: Readable<ConfigListEntry[]>;
|
readonly configList: Readable<ConfigListEntry[]>;
|
||||||
readonly parentLimits: Readable<ParentLimits>;
|
readonly parentLimits: Readable<ParentLimits>;
|
||||||
|
readonly cardStateCustomizer: Writable<string>;
|
||||||
readonly currentDeck: pb.BackendProto.DeckConfigsForUpdate.CurrentDeck;
|
readonly currentDeck: pb.BackendProto.DeckConfigsForUpdate.CurrentDeck;
|
||||||
readonly defaults: ConfigInner;
|
readonly defaults: ConfigInner;
|
||||||
readonly addonComponents: Writable<DynamicSvelteComponent[]>;
|
readonly addonComponents: Writable<DynamicSvelteComponent[]>;
|
||||||
|
@ -88,6 +89,7 @@ export class DeckOptionsState {
|
||||||
);
|
);
|
||||||
this.v3Scheduler = data.v3Scheduler;
|
this.v3Scheduler = data.v3Scheduler;
|
||||||
this.haveAddons = data.haveAddons;
|
this.haveAddons = data.haveAddons;
|
||||||
|
this.cardStateCustomizer = writable(data.cardStateCustomizer);
|
||||||
|
|
||||||
// decrement the use count of the starting item, as we'll apply +1 to currently
|
// decrement the use count of the starting item, as we'll apply +1 to currently
|
||||||
// selected one at display time
|
// selected one at display time
|
||||||
|
@ -210,6 +212,7 @@ export class DeckOptionsState {
|
||||||
removedConfigIds: this.removedConfigs,
|
removedConfigIds: this.removedConfigs,
|
||||||
configs,
|
configs,
|
||||||
applyToChildren,
|
applyToChildren,
|
||||||
|
cardStateCustomizer: get(this.cardStateCustomizer),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue