diff options
author | Kuuuube <61125188+Kuuuube@users.noreply.github.com> | 2024-05-14 12:59:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 16:59:44 +0000 |
commit | ba288277a5e73026f7b0c07d993aa00a5e66c332 (patch) | |
tree | 259509b3ccc07b8ef00e6c7d3ca8d449f02f9c54 /ext/js/pages/settings/anki-controller.js | |
parent | d60b010229cf9031029480b698e87f8b91fbf16f (diff) |
Update anki settings when Configure Anki card format button is clicked instead of requiring page refresh (#934)
* Update anki settings when Configure Anki card format is clicked instead of requiring page refresh
* Select by data-modal-action instead of id
Diffstat (limited to 'ext/js/pages/settings/anki-controller.js')
-rw-r--r-- | ext/js/pages/settings/anki-controller.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 7eb09c85..2d461336 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -582,6 +582,17 @@ class AnkiCardController { this._ankiCardFieldsContainer = this._node.querySelector('.anki-card-fields'); + /** @type {HTMLTextAreaElement} */ + const mainSettingsEntry = querySelectorNotNull(document, '[data-modal-action="show,anki-cards"]'); + mainSettingsEntry.addEventListener('click', (() => { + const updatedCardOptions = this._getCardOptions(ankiOptions, this._optionsType); + if (updatedCardOptions === null) { return; } + this._deckController.prepare(deckControllerSelect, updatedCardOptions.deck); + this._modelController.prepare(modelControllerSelect, updatedCardOptions.model); + this._fields = updatedCardOptions.fields; + void this.updateAnkiState(); + }).bind(this), false); + this._setupFields(); this._eventListeners.addEventListener(this._deckController.select, 'change', this._onCardDeckChange.bind(this), false); |