From d058237ba724c3fee842d90c04b1950c9efaadc0 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 13 Jul 2021 20:29:53 -0400 Subject: Duplicate scope check all models (#1810) * Add duplicateScopeCheckAllModels option to createNote * Add duplicateScopeCheckAllModels option * Add setting --- ext/data/schemas/options-schema.json | 5 +++++ ext/js/data/anki-note-builder.js | 4 +++- ext/js/data/options-util.js | 4 ++++ ext/js/display/display-anki.js | 5 ++++- ext/settings.html | 22 ++++++++++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/data/schemas/options-schema.json b/ext/data/schemas/options-schema.json index 9bdf8747..52e5fa1f 100644 --- a/ext/data/schemas/options-schema.json +++ b/ext/data/schemas/options-schema.json @@ -812,6 +812,7 @@ "terms", "kanji", "duplicateScope", + "duplicateScopeCheckAllModels", "checkForDuplicates", "fieldTemplates", "suspendNewCards", @@ -910,6 +911,10 @@ "default": "collection", "enum": ["collection", "deck", "deck-root"] }, + "duplicateScopeCheckAllModels": { + "type": "boolean", + "default": false + }, "checkForDuplicates": { "type": "boolean", "default": true diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index 621816d4..4bb3ddcb 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -41,6 +41,7 @@ class AnkiNoteBuilder { requirements=[], checkForDuplicates=true, duplicateScope='collection', + duplicateScopeCheckAllModels=false, resultOutputMode='split', glossaryLayoutMode='default', compactTags=false, @@ -98,7 +99,8 @@ class AnkiNoteBuilder { duplicateScope, duplicateScopeOptions: { deckName: duplicateScopeDeckName, - checkChildren: duplicateScopeCheckChildren + checkChildren: duplicateScopeCheckChildren, + checkAllModels: duplicateScopeCheckAllModels } } }; diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 36630e2f..d131d0c6 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -856,7 +856,11 @@ class OptionsUtil { // Handlebars templates updated to use new media format. // Added {selection-text} field marker. // Added {sentence-furigana} field marker. + // Added anki.duplicateScopeCheckAllModels. await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v13.handlebars'); + for (const profile of options.profiles) { + profile.options.anki.duplicateScopeCheckAllModels = false; + } return options; } } diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js index b08dc952..b2ed9ec3 100644 --- a/ext/js/display/display-anki.js +++ b/ext/js/display/display-anki.js @@ -42,6 +42,7 @@ class DisplayAnki { this._glossaryLayoutMode = 'default'; this._displayTags = 'never'; this._duplicateScope = 'collection'; + this._duplicateScopeCheckAllModels = false; this._screenshotFormat = 'png'; this._screenshotQuality = 100; this._scanLength = 10; @@ -142,7 +143,7 @@ class DisplayAnki { _onOptionsUpdated({options}) { const { general: {resultOutputMode, glossaryLayoutMode, compactTags}, - anki: {tags, duplicateScope, suspendNewCards, checkForDuplicates, displayTags, kanji, terms, screenshot: {format, quality}}, + anki: {tags, duplicateScope, duplicateScopeCheckAllModels, suspendNewCards, checkForDuplicates, displayTags, kanji, terms, screenshot: {format, quality}}, scanning: {length: scanLength} } = options; @@ -153,6 +154,7 @@ class DisplayAnki { this._glossaryLayoutMode = glossaryLayoutMode; this._displayTags = displayTags; this._duplicateScope = duplicateScope; + this._duplicateScopeCheckAllModels = duplicateScopeCheckAllModels; this._screenshotFormat = format; this._screenshotQuality = quality; this._scanLength = scanLength; @@ -561,6 +563,7 @@ class DisplayAnki { tags: this._noteTags, checkForDuplicates: this._checkForDuplicates, duplicateScope: this._duplicateScope, + duplicateScopeCheckAllModels: this._duplicateScopeCheckAllModels, resultOutputMode: this._resultOutputMode, glossaryLayoutMode: this._glossaryLayoutMode, compactTags: this._compactTags, diff --git a/ext/settings.html b/ext/settings.html index d392b0c0..7380b753 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -1494,6 +1494,28 @@