mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
fix(tags): sixth audit: the tag box tells its rule, trims a paste; clear keeps the focus
- A name typed or pasted into the tag box that cannot be a tag shows the rule (letters a-z, digits, dots, dashes, underscores; at most 12 characters) instead of nothing; the spaces a paste brings are dropped; "constructor" is no longer taken for a tag there is. - "Clear the filters" hides with the message it is in: the search box takes the focus.
This commit is contained in:
parent
bc1894e4d8
commit
f6b1ee8985
9 changed files with 74 additions and 36 deletions
|
|
@ -33,8 +33,10 @@ class TagsWidget(forms.SelectMultiple):
|
|||
"""The tags there are and those given, to choose from or add to (Tom Select)."""
|
||||
|
||||
def __init__(self):
|
||||
# Tom Select's line for a new name typed (searchable_select.js)
|
||||
super().__init__(attrs={"data-tags": "", "data-add": _("Add tag %(tag)s")})
|
||||
# Tom Select's line for a new name typed, and for one that cannot be a tag (searchable_select.js)
|
||||
super().__init__(attrs={"data-tags": "", "data-add": _("Add tag %(tag)s"), "data-rule": _(
|
||||
"A new tag: letters a-z, digits, dots, dashes and underscores, beginning with a letter or digit; "
|
||||
"at most 12 characters")})
|
||||
|
||||
def optgroups(self, name, value, attrs=None):
|
||||
self.choices = [(n, n) for n in sorted(set(Tag.objects.values_list("name", flat=True)) | set(value))]
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ class TagsFieldTests(TestCase):
|
|||
with translation.override("tr"):
|
||||
html = TagsForm().as_p()
|
||||
self.assertIn('data-add="Etiket ekle: %(tag)s"', html)
|
||||
# and what a new name may be, shown when the one typed cannot be a tag
|
||||
self.assertIn('data-rule="Yeni etiket: a-z harfleri, rakamlar, nokta, tire ve alt çizgi, harf ya da rakamla başlar; '
|
||||
'en fazla 12 karakter"', html)
|
||||
|
||||
def test_the_tags_are_made_when_saved(self):
|
||||
Tag.objects.create(name="prod")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue