ensure changes to current field are saved before saving deck opts
https://forums.ankiweb.net/t/anki-2-1-45-alpha/10061/70
This commit is contained in:
parent
e124f935a5
commit
6eac76bc8a
@ -6,8 +6,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
import ConfigSelector from "./ConfigSelector.svelte";
|
import ConfigSelector from "./ConfigSelector.svelte";
|
||||||
import ConfigEditor from "./ConfigEditor.svelte";
|
import ConfigEditor from "./ConfigEditor.svelte";
|
||||||
import type { DeckOptionsState } from "./lib";
|
import type { DeckOptionsState } from "./lib";
|
||||||
import { onMount, onDestroy } from "svelte";
|
|
||||||
import { registerShortcut } from "lib/shortcuts";
|
|
||||||
import type { Writable } from "svelte/store";
|
import type { Writable } from "svelte/store";
|
||||||
import HtmlAddon from "./HtmlAddon.svelte";
|
import HtmlAddon from "./HtmlAddon.svelte";
|
||||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||||
@ -33,12 +31,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
let registerCleanup: () => void;
|
|
||||||
onMount(() => {
|
|
||||||
registerCleanup = registerShortcut(() => state.save(false), "Control+Enter");
|
|
||||||
});
|
|
||||||
onDestroy(() => registerCleanup?.());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ConfigSelector {state} />
|
<ConfigSelector {state} />
|
||||||
|
@ -15,11 +15,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
import DropdownItem from "components/DropdownItem.svelte";
|
import DropdownItem from "components/DropdownItem.svelte";
|
||||||
import DropdownDivider from "components/DropdownDivider.svelte";
|
import DropdownDivider from "components/DropdownDivider.svelte";
|
||||||
import WithDropdownMenu from "components/WithDropdownMenu.svelte";
|
import WithDropdownMenu from "components/WithDropdownMenu.svelte";
|
||||||
|
import WithShortcut from "components/WithShortcut.svelte";
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
export let state: DeckOptionsState;
|
export let state: DeckOptionsState;
|
||||||
|
|
||||||
|
function commitEditing(): void {
|
||||||
|
if (document.activeElement instanceof HTMLElement) {
|
||||||
|
document.activeElement.blur();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeConfig(): void {
|
function removeConfig(): void {
|
||||||
// show pop-up after dropdown has gone away
|
// show pop-up after dropdown has gone away
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -27,8 +34,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
alert(tr.schedulingTheDefaultConfigurationCantBeRemoved());
|
alert(tr.schedulingTheDefaultConfigurationCantBeRemoved());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// fixme: move tr.qt_misc schema mod msg into core
|
|
||||||
// fixme: include name of deck in msg
|
|
||||||
const msg =
|
const msg =
|
||||||
(state.removalWilLForceFullSync()
|
(state.removalWilLForceFullSync()
|
||||||
? tr.deckConfigWillRequireFullSync() + " "
|
? tr.deckConfigWillRequireFullSync() + " "
|
||||||
@ -45,15 +50,21 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save(applyToChildDecks: boolean): void {
|
function save(applyToChildDecks: boolean): void {
|
||||||
|
commitEditing();
|
||||||
state.save(applyToChildDecks);
|
state.save(applyToChildDecks);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<ButtonGroupItem>
|
<ButtonGroupItem>
|
||||||
<LabelButton theme="primary" on:click={() => save(false)}
|
<WithShortcut shortcut={"Control+Enter"} let:createShortcut let:shortcutLabel>
|
||||||
>{tr.deckConfigSaveButton()}</LabelButton
|
<LabelButton
|
||||||
|
theme="primary"
|
||||||
|
on:click={() => save(false)}
|
||||||
|
tooltip={shortcutLabel}
|
||||||
|
on:mount={createShortcut}>{tr.deckConfigSaveButton()}</LabelButton
|
||||||
>
|
>
|
||||||
|
</WithShortcut>
|
||||||
</ButtonGroupItem>
|
</ButtonGroupItem>
|
||||||
|
|
||||||
<ButtonGroupItem>
|
<ButtonGroupItem>
|
||||||
|
Loading…
Reference in New Issue
Block a user