From 1bbcaf11f7b064f2a40245b79d392cbbf0324484 Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Sun, 23 Aug 2020 13:03:23 -0400 Subject: [PATCH] client/posts: add tag implications when autocompleting mass tag inputs Closes #334. This solution should function similar to single post tagging. Implications are automatically added but this also allows for them to review and manually remove any unwanted implications. --- client/css/post-list-view.styl | 2 +- client/js/views/posts_header_view.js | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/client/css/post-list-view.styl b/client/css/post-list-view.styl index 5297bb0c..8d4989b3 100644 --- a/client/css/post-list-view.styl +++ b/client/css/post-list-view.styl @@ -182,7 +182,7 @@ .hint display: none input[name=tag] - width: 12em + width: 24em @media (max-width: 1000px) display: block width: 100% diff --git a/client/js/views/posts_header_view.js b/client/js/views/posts_header_view.js index 81546a7e..7cbddf3d 100644 --- a/client/js/views/posts_header_view.js +++ b/client/js/views/posts_header_view.js @@ -6,6 +6,7 @@ const keyboard = require("../util/keyboard.js"); const misc = require("../util/misc.js"); const search = require("../util/search.js"); const views = require("../util/views.js"); +const TagList = require("../models/tag_list.js"); const TagAutoCompleteControl = require("../controls/tag_auto_complete_control.js"); const template = views.getTemplate("posts-header"); @@ -74,11 +75,27 @@ class BulkTagEditor extends BulkEditor { this._autoCompleteControl = new TagAutoCompleteControl( this._inputNode, { - confirm: (tag) => - this._autoCompleteControl.replaceSelectedText( - tag.names[0], - false - ), + confirm: (tag) => { + let tag_list = new TagList(); + tag_list + .addByName(tag.names[0], true) + .then( + () => { + return tag_list + .map((s) => s.names[0]) + .join(" "); + }, + (err) => { + return tag.names[0]; + } + ) + .then((tag_str) => { + this._autoCompleteControl.replaceSelectedText( + tag_str, + false + ); + }); + }, } ); this._hostNode.addEventListener("submit", (e) =>