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 /web-ui/app/js/mixins | |
parent | d7f522acd0b97da86522841968b05c60ee5de289 (diff) |
Only suggest tags that are not already part of the mail.
- Fixup for issue #52
Diffstat (limited to 'web-ui/app/js/mixins')
-rw-r--r-- | web-ui/app/js/mixins/with_mail_tagging.js | 9 |
1 files changed, 7 insertions, 2 deletions
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 } }); |