limit custom study to 100 tags
The hard limit from sqlite may be larger, but things slow down as more tags are selected. https://forums.ankiweb.net/t/unable-to-create-custom-test/10467 There are a number of things that could be improved here: - we should show a live count so users are aware of the limit - we should be filling in the parent tags when they're not explicitly listed on a card - we should reconsider disabling the 'tags to include' by default It may make sense to defer these changes until we can move this screen into Svelte/handle the processing in the backend.
This commit is contained in:
parent
6e992752ca
commit
0f5627bb7a
@ -3,3 +3,7 @@ errors-invalid-input-details = Invalid input: { $details }
|
||||
errors-parse-number-fail = A number was invalid or out of range.
|
||||
errors-filtered-parent-deck = Filtered decks can not have child decks.
|
||||
errors-filtered-deck-required = This action can only be used on a filtered deck.
|
||||
errors-100-tags-max =
|
||||
A maximum of 100 tags can be selected. Listing the
|
||||
tags you want instead of the ones you don't want is usually simpler, and there
|
||||
is no need to select child tags if you have selected a parent tag.
|
||||
|
@ -211,3 +211,7 @@ def is_rtl(lang: str) -> bool:
|
||||
# for testing purposes
|
||||
def without_unicode_isolation(s: str) -> str:
|
||||
return s.replace("\u2068", "").replace("\u2069", "")
|
||||
|
||||
|
||||
def with_collapsed_whitespace(s: str) -> str:
|
||||
return re.sub(r"\s+", " ", s)
|
||||
|
@ -3,10 +3,11 @@
|
||||
from typing import List, Optional
|
||||
|
||||
import aqt
|
||||
from anki.lang import with_collapsed_whitespace
|
||||
from aqt.customstudy import CustomStudy
|
||||
from aqt.main import AnkiQt
|
||||
from aqt.qt import *
|
||||
from aqt.utils import disable_help_button, restoreGeom, saveGeom
|
||||
from aqt.utils import disable_help_button, restoreGeom, saveGeom, showWarning, tr
|
||||
|
||||
|
||||
class TagLimit(QDialog):
|
||||
@ -73,7 +74,6 @@ class TagLimit(QDialog):
|
||||
QDialog.reject(self)
|
||||
|
||||
def accept(self) -> None:
|
||||
self.hide()
|
||||
# gather yes/no tags
|
||||
yes = []
|
||||
no = []
|
||||
@ -89,6 +89,10 @@ class TagLimit(QDialog):
|
||||
idx = self.dialog.inactiveList.indexFromItem(item)
|
||||
if self.dialog.inactiveList.selectionModel().isSelected(idx):
|
||||
no.append(self.tags_list[c])
|
||||
if (len(yes) + len(no)) > 100:
|
||||
showWarning(with_collapsed_whitespace(tr.errors_100_tags_max()))
|
||||
return
|
||||
self.hide()
|
||||
# save in the deck for future invocations
|
||||
self.deck["activeTags"] = yes
|
||||
self.deck["inactiveTags"] = no
|
||||
|
Loading…
Reference in New Issue
Block a user