summaryrefslogtreecommitdiffstats
path: root/hyperkitty
diff options
context:
space:
mode:
Diffstat (limited to 'hyperkitty')
-rw-r--r--hyperkitty/static/css/hyperkitty-common.css3
-rw-r--r--hyperkitty/static/js/hyperkitty-thread.js5
-rw-r--r--hyperkitty/templates/threads/right_col.html4
-rw-r--r--hyperkitty/urls.py2
-rw-r--r--hyperkitty/views/thread.py12
5 files changed, 25 insertions, 1 deletions
diff --git a/hyperkitty/static/css/hyperkitty-common.css b/hyperkitty/static/css/hyperkitty-common.css
index daa925e..7b05127 100644
--- a/hyperkitty/static/css/hyperkitty-common.css
+++ b/hyperkitty/static/css/hyperkitty-common.css
@@ -276,3 +276,6 @@ a.thread-new strong {
display: block;
margin: 1em auto;
}
+.ui-autocomplete-loading {
+ background: white url('../img/ajax-loader.gif') right center no-repeat;
+}
diff --git a/hyperkitty/static/js/hyperkitty-thread.js b/hyperkitty/static/js/hyperkitty-thread.js
index e841f75..5b7765d 100644
--- a/hyperkitty/static/js/hyperkitty-thread.js
+++ b/hyperkitty/static/js/hyperkitty-thread.js
@@ -54,6 +54,11 @@ function setup_tags() {
e.preventDefault();
$(this).parents("form").first().submit();
});
+ // Autocomplete
+ $("#id_tag").autocomplete({
+ //minLength: 2,
+ source: $("#add-tag-form").attr("data-autocompleteurl")
+ });
}
diff --git a/hyperkitty/templates/threads/right_col.html b/hyperkitty/templates/threads/right_col.html
index c4fe161..5384d03 100644
--- a/hyperkitty/templates/threads/right_col.html
+++ b/hyperkitty/templates/threads/right_col.html
@@ -43,7 +43,9 @@
</div>
<div id="add-tag">
<form id="add-tag-form" name="addtag" method="post"
- action="{% url 'tags' mlist_fqdn=mlist.name threadid=threadid %}">
+ action="{% url 'tags' mlist_fqdn=mlist.name threadid=threadid %}"
+ data-autocompleteurl="{% url 'suggest_tags' mlist_fqdn=mlist.name threadid=threadid %}"
+ >
{% csrf_token %}
{{ addtag_form.as_p }}
</form>
diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py
index 2689413..9277922 100644
--- a/hyperkitty/urls.py
+++ b/hyperkitty/urls.py
@@ -79,6 +79,8 @@ urlpatterns = patterns('hyperkitty.views',
'thread.replies', name='thread_replies'),
url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/thread/(?P<threadid>\w+)/tags$',
'thread.tags', name='tags'),
+ url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/thread/(?P<threadid>\w+)/suggest-tags$',
+ 'thread.suggest_tags', name='suggest_tags'),
url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/thread/(?P<threadid>\w+)/favorite$',
'thread.favorite', name='favorite'),
diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py
index fa1b860..56f9f5c 100644
--- a/hyperkitty/views/thread.py
+++ b/hyperkitty/views/thread.py
@@ -245,6 +245,18 @@ def tags(request, mlist_fqdn, threadid):
return HttpResponse(json.dumps(response),
mimetype='application/javascript')
+def suggest_tags(request, mlist_fqdn, threadid):
+ term = request.GET.get("term")
+ current_tags = Tag.objects.filter(
+ list_address=mlist_fqdn, threadid=threadid
+ ).values_list("tag", flat=True)
+ if term:
+ tags = Tag.objects.filter(list_address=mlist_fqdn, tag__istartswith=term)
+ else:
+ tags = Tag.objects.all()
+ tags = tags.exclude(tag__in=current_tags).values_list("tag", flat=True)
+ tags = [ t.encode("utf8") for t in tags ]
+ return HttpResponse(json.dumps(tags), mimetype='application/javascript')
def favorite(request, mlist_fqdn, threadid):