FEATURE: displays tags in search menu results when enabled (#7819)

This commit is contained in:
Joffrey JAFFEUX
2019-06-27 19:26:14 +02:00
committed by GitHub
parent 5cf5e73536
commit a61147d838
6 changed files with 60 additions and 7 deletions

View File

@@ -21,6 +21,7 @@ export default function(topic, params) {
let tags = topic.tags;
let buffer = "";
let tagsForUser = null;
let tagName;
const isPrivateMessage = topic.get("isPrivateMessage");
if (params) {
@@ -30,6 +31,9 @@ export default function(topic, params) {
if (params.tagsForUser) {
tagsForUser = params.tagsForUser;
}
if (params.tagName) {
tagName = params.tagName;
}
}
let customHtml = null;
@@ -50,7 +54,8 @@ export default function(topic, params) {
buffer = "<div class='discourse-tags'>";
if (tags) {
for (let i = 0; i < tags.length; i++) {
buffer += renderTag(tags[i], { isPrivateMessage, tagsForUser }) + " ";
buffer +=
renderTag(tags[i], { isPrivateMessage, tagsForUser, tagName }) + " ";
}
}

View File

@@ -0,0 +1,10 @@
import RawHtml from "discourse/widgets/raw-html";
import renderTags from "discourse/lib/render-tags";
// Right now it's RawHTML. Eventually it should emit nodes
export default class DiscourseTags extends RawHtml {
constructor(attrs) {
attrs.html = renderTags(attrs.topic, attrs);
super(attrs);
}
}

View File

@@ -147,14 +147,23 @@ createSearchResult({
linkField: "url",
builder(result, term) {
const topic = result.topic;
const link = h("span.topic", [
const linkContent = [
this.attach("topic-status", { topic, disableActions: true }),
h("span.topic-title", new Highlighted(topic.get("fancyTitle"), term)),
h("span.topic-title", new Highlighted(topic.fancyTitle, term)),
this.attach("category-link", {
category: topic.get("category"),
category: topic.category,
link: false
})
]);
];
if (Discourse.SiteSettings.tagging_enabled) {
linkContent.push(
this.attach("discourse-tags", { topic, tagName: "span" })
);
}
const link = h("span.topic", linkContent);
return postResult.call(this, result, link, term);
}

View File

@@ -68,7 +68,7 @@
.menu-panel {
li,
li.heading {
a {
a.widget-link {
padding: 0.25em 0.5em;
display: block;
&:hover,
@@ -140,6 +140,10 @@
overflow: hidden;
text-overflow: ellipsis;
}
div.discourse-tags {
font-size: $font-down-1;
}
}
.user-menu {