diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2014-10-09 10:12:17 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2014-10-09 10:12:40 +0200 |
commit | c77b5aeb93fb61c2ec67d89f7a1266418fff5a9a (patch) | |
tree | bb388afbba774ca828f26c02e4cffb368381605c | |
parent | d7f522acd0b97da86522841968b05c60ee5de289 (diff) |
Only suggest tags that are not already part of the mail.
- Fixup for issue #52
-rw-r--r-- | web-ui/app/js/mail_view/ui/mail_view.js | 2 | ||||
-rw-r--r-- | web-ui/app/js/mixins/with_mail_tagging.js | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js index bda0c4a9..fbf5c6ed 100644 --- a/web-ui/app/js/mail_view/ui/mail_view.js +++ b/web-ui/app/js/mail_view/ui/mail_view.js @@ -80,7 +80,7 @@ define( this.trigger(document, events.search.highlightResults, {where: '.subjectArea'}); this.trigger(document, events.search.highlightResults, {where: '.msg-header .recipients'}); - this.attachTagCompletion(); + this.attachTagCompletion(this.attr.mail); this.select('tags').on('click', function (event) { this.removeTag($(event.target).data('tag')); diff --git a/web-ui/app/js/mixins/with_mail_tagging.js b/web-ui/app/js/mixins/with_mail_tagging.js index f5bd7840..75a96ab8 100644 --- a/web-ui/app/js/mixins/with_mail_tagging.js +++ b/web-ui/app/js/mixins/with_mail_tagging.js @@ -26,17 +26,22 @@ define( this.trigger(document, events.mail.tags.update, {ident: mail.ident, tags: tags}); }; - this.attachTagCompletion = function() { + this.attachTagCompletion = function(mail) { if(!features.isEnabled('tags')) { return; } + this.tagFilter = function (parsedResult) { + var filtered = _.filter(parsedResult, function (tag) {return ! _.contains(mail.tags, tag.name); }); + return _.map(filtered, function(tag) { return {value: Handlebars.Utils.escapeExpression(tag.name)}; }); + } + this.tagCompleter = new Bloodhound({ datumTokenizer: function(d) { return [d.value]; }, queryTokenizer: function(q) { return [q.trim()]; }, remote: { url: '/tags?q=%QUERY', - filter: function(pr) { return _.map(pr, function(pp) { return {value: Handlebars.Utils.escapeExpression(pp.name)}; }); } + filter: this.tagFilter } }); |