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 ConfigEditor from "./ConfigEditor.svelte";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import { registerShortcut } from "lib/shortcuts";
|
||||
import type { Writable } from "svelte/store";
|
||||
import HtmlAddon from "./HtmlAddon.svelte";
|
||||
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>
|
||||
|
||||
<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 DropdownDivider from "components/DropdownDivider.svelte";
|
||||
import WithDropdownMenu from "components/WithDropdownMenu.svelte";
|
||||
import WithShortcut from "components/WithShortcut.svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let state: DeckOptionsState;
|
||||
|
||||
function commitEditing(): void {
|
||||
if (document.activeElement instanceof HTMLElement) {
|
||||
document.activeElement.blur();
|
||||
}
|
||||
}
|
||||
|
||||
function removeConfig(): void {
|
||||
// show pop-up after dropdown has gone away
|
||||
setTimeout(() => {
|
||||
@ -27,8 +34,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
alert(tr.schedulingTheDefaultConfigurationCantBeRemoved());
|
||||
return;
|
||||
}
|
||||
// fixme: move tr.qt_misc schema mod msg into core
|
||||
// fixme: include name of deck in msg
|
||||
const msg =
|
||||
(state.removalWilLForceFullSync()
|
||||
? 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 {
|
||||
commitEditing();
|
||||
state.save(applyToChildDecks);
|
||||
}
|
||||
</script>
|
||||
|
||||
<ButtonGroup>
|
||||
<ButtonGroupItem>
|
||||
<LabelButton theme="primary" on:click={() => save(false)}
|
||||
>{tr.deckConfigSaveButton()}</LabelButton
|
||||
>
|
||||
<WithShortcut shortcut={"Control+Enter"} let:createShortcut let:shortcutLabel>
|
||||
<LabelButton
|
||||
theme="primary"
|
||||
on:click={() => save(false)}
|
||||
tooltip={shortcutLabel}
|
||||
on:mount={createShortcut}>{tr.deckConfigSaveButton()}</LabelButton
|
||||
>
|
||||
</WithShortcut>
|
||||
</ButtonGroupItem>
|
||||
|
||||
<ButtonGroupItem>
|
||||
|
Loading…
Reference in New Issue
Block a user