Allow spaces in tag fields

pull/3473/merge
Alex Gleason 2016-02-07 20:01:25 -05:00 zatwierdzone przez Matt Westcott
rodzic eb9cc639d2
commit bbdbf3fd81
5 zmienionych plików z 20 dodań i 4 usunięć

Wyświetl plik

@ -21,6 +21,7 @@ Changelog
* Added `WAGTAILADMIN_RECENT_EDITS_LIMIT` setting to to define the number of your most recent edits on the dashboard (Maarten Kling)
* Creating / editing users through the Wagtail admin no longer modifies the `is_staff` flag (Matt Westcott)
* Added link to the full Elasticsearch setup documentation from the Performance page (Matt Westcott)
* Tag input fields now accept spaces in tags by default, and can be overridden with the `TAG_SPACES_ALLOWED` setting (Kees Hink, Alex Gleason)
* Fix: Marked 'Date from' / 'Date to' strings in wagtailforms for translation (Vorlif)
* Fix: "File" field label on image edit form is now translated (Stein Strindhaug)
* Fix: Unreliable preview is now reliable by always opening in a new window (Kjartan Sverrisson)

Wyświetl plik

@ -327,6 +327,15 @@ Case-Insensitive Tags
Tags are case-sensitive by default ('music' and 'Music' are treated as distinct tags). In many cases the reverse behaviour is preferable.
Multi-word tags
---------------
.. code-block:: python
TAG_SPACES_ALLOWED = False
Tags can only consist of a single word, no spaces allowed. The default setting is ``True`` (spaces in tags are allowed).
Unicode Page Slugs
------------------

Wyświetl plik

@ -28,6 +28,7 @@ Other features
* Added support for displaying ``non_field_errors`` when validation fails in the page editor (Matt Westcott)
* Added `WAGTAILADMIN_RECENT_EDITS_LIMIT` setting to to define the number of your most recent edits on the dashboard (Maarten Kling)
* Added link to the full Elasticsearch setup documentation from the Performance page (Matt Westcott)
* Tag input fields now accept spaces in tags by default, and can be overridden with the ``TAG_SPACES_ALLOWED`` setting (Kees Hink, Alex Gleason)
Bug fixes

Wyświetl plik

@ -21,7 +21,7 @@ function escapeHtml(text) {
});
}
function initTagField(id, autocompleteUrl) {
function initTagField(id, autocompleteUrl, allowSpaces) {
$('#' + id).tagit({
autocomplete: {source: autocompleteUrl},
preprocessTag: function(val) {
@ -32,7 +32,9 @@ function initTagField(id, autocompleteUrl) {
}
return val;
}
},
allowSpaces: allowSpaces
});
}

Wyświetl plik

@ -4,6 +4,7 @@ import itertools
import json
from functools import total_ordering
from django.conf import settings
from django.core.urlresolvers import reverse
from django.forms import widgets
from django.forms.utils import flatatt
@ -68,9 +69,11 @@ class AdminDateTimeInput(WidgetWithScript, widgets.DateTimeInput):
class AdminTagWidget(WidgetWithScript, TagWidget):
def render_js_init(self, id_, name, value):
return "initTagField({0}, {1});".format(
return "initTagField({0}, {1}, {2});".format(
json.dumps(id_),
json.dumps(reverse('wagtailadmin_tag_autocomplete')))
json.dumps(reverse('wagtailadmin_tag_autocomplete')),
'true' if getattr(settings, 'TAG_SPACES_ALLOWED', True) else 'false',
)
class AdminChooser(WidgetWithScript, widgets.Input):