From f2833b6e764ede492955b7f508d843e293ebe911 Mon Sep 17 00:00:00 2001 From: rr- Date: Thu, 19 May 2016 23:32:23 +0200 Subject: [PATCH] views/tags: automatically add implied tags --- client/js/views/tag_input_control.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/js/views/tag_input_control.js b/client/js/views/tag_input_control.js index 15498dd..f608efa 100644 --- a/client/js/views/tag_input_control.js +++ b/client/js/views/tag_input_control.js @@ -68,8 +68,6 @@ class TagInputControl { return; } - // TODO: add implications - if (this.tags.map(tag => tag.toLowerCase()) .includes(text.toLowerCase())) { this._getWrapperFromTag(text).classList.add('duplicate'); @@ -93,6 +91,13 @@ class TagInputControl { targetWrapperNode.setAttribute('data-tag', text); this._editAreaNode.insertBefore(targetWrapperNode, sourceWrapperNode); this._editAreaNode.insertBefore(this._createSpace(), sourceWrapperNode); + + const actualTag = tags.getTagByName(text); + if (actualTag) { + for (let otherTag of (actualTag.implications || [])) { + this.addTag(otherTag, sourceNode); + } + } } deleteTag(tag) {