From 16321a1f8c9902be100b01067e1593694fa51341 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 8 Nov 2020 16:25:07 -0500 Subject: Add duplicate check option (#1012) * Add anki.checkForDuplicates option * Use checkForDuplicates for button display * Add property to card creation --- ext/bg/data/options-schema.json | 5 +++++ ext/bg/js/anki-note-builder.js | 2 ++ ext/bg/js/options.js | 4 ++++ ext/bg/settings.html | 5 +++++ ext/mixed/js/display.js | 28 +++++++++++++++++++++++++--- 5 files changed, 41 insertions(+), 3 deletions(-) (limited to 'ext') diff --git a/ext/bg/data/options-schema.json b/ext/bg/data/options-schema.json index 159ca009..edb30074 100644 --- a/ext/bg/data/options-schema.json +++ b/ext/bg/data/options-schema.json @@ -671,6 +671,7 @@ "terms", "kanji", "duplicateScope", + "checkForDuplicates", "fieldTemplates" ], "properties": { @@ -771,6 +772,10 @@ "default": "collection", "enum": ["collection", "deck", "deck-root"] }, + "checkForDuplicates": { + "type": "boolean", + "default": true + }, "fieldTemplates": { "type": ["string", "null"], "default": null diff --git a/ext/bg/js/anki-note-builder.js b/ext/bg/js/anki-note-builder.js index aa76ecd9..4ac597da 100644 --- a/ext/bg/js/anki-note-builder.js +++ b/ext/bg/js/anki-note-builder.js @@ -31,6 +31,7 @@ class AnkiNoteBuilder { context, templates, tags=[], + checkForDuplicates=true, duplicateScope='collection', resultOutputMode='split', compactGlossaries=false, @@ -60,6 +61,7 @@ class AnkiNoteBuilder { deckName: deck, modelName: model, options: { + allowDuplicate: !checkForDuplicates, duplicateScope, duplicateScopeOptions: { deckName: duplicateScopeDeckName, diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 0edbb82a..bb90e655 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -613,8 +613,12 @@ class OptionsUtil { // Version 6 changes: // Updated handlebars templates to include "conjugation" definition. // Added global option showPopupPreview. + // Added anki.checkForDuplicates. await this._addFieldTemplatesToOptions(options, '/bg/data/anki-field-templates-upgrade-v6.handlebars'); options.global.showPopupPreview = false; + for (const profile of options.profiles) { + profile.options.anki.checkForDuplicates = true; + } return options; } } diff --git a/ext/bg/settings.html b/ext/bg/settings.html index 67a2d75c..6ec89269 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -921,6 +921,11 @@ +
+
+
+
+