Simplify how anki templates are reset

This commit is contained in:
toasted-nutbread 2019-12-01 21:08:46 -05:00
parent 767a480a84
commit 3e1b080cd3

View File

@ -22,22 +22,14 @@ function onAnkiFieldTemplatesReset(e) {
$('#field-template-reset-modal').modal('show'); $('#field-template-reset-modal').modal('show');
} }
async function onAnkiFieldTemplatesResetConfirm(e) { function onAnkiFieldTemplatesResetConfirm(e) {
try {
e.preventDefault(); e.preventDefault();
$('#field-template-reset-modal').modal('hide'); $('#field-template-reset-modal').modal('hide');
const optionsContext = getOptionsContext(); const element = document.querySelector('#field-templates');
const options = await apiOptionsGet(optionsContext); element.value = profileOptionsGetDefaultFieldTemplates();
const fieldTemplates = profileOptionsGetDefaultFieldTemplates(); element.dispatchEvent(new Event('change'));
options.anki.fieldTemplates = fieldTemplates;
$('#field-templates').val(fieldTemplates);
onAnkiTemplatesValidateCompile();
await settingsSaveOptions();
} catch (error) {
ankiErrorShow(error);
}
} }
function ankiTemplatesInitialize() { function ankiTemplatesInitialize() {