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.
This commit is contained in:
Shyam Sunder 2020-08-23 13:03:23 -04:00
parent 3e69edc117
commit 1bbcaf11f7
2 changed files with 23 additions and 6 deletions

View file

@ -182,7 +182,7 @@
.hint
display: none
input[name=tag]
width: 12em
width: 24em
@media (max-width: 1000px)
display: block
width: 100%

View file

@ -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) =>