fix merge
This commit is contained in:
parent
770d06f0ca
commit
a7cc7053d3
|
@ -469,77 +469,57 @@ function initialize(api) {
|
||||||
.filter(({ assignee }) => assignee)
|
.filter(({ assignee }) => assignee)
|
||||||
.flat();
|
.flat();
|
||||||
|
|
||||||
if (assignedTo) {
|
if (!assignedTo) {
|
||||||
return assignedTo
|
return "";
|
||||||
.map(({ assignee, note }) => {
|
}
|
||||||
let assignedPath;
|
|
||||||
if (assignee.assignedToPostId) {
|
const createTagHtml = ({ assignee, note }) => {
|
||||||
assignedPath = `/p/${assignee.assignedToPostId}`;
|
let assignedPath;
|
||||||
} else {
|
if (assignee.assignedToPostId) {
|
||||||
assignedPath = `/t/${topic.id}`;
|
assignedPath = `/p/${assignee.assignedToPostId}`;
|
||||||
}
|
} else {
|
||||||
const icon = iconHTML(assignee.username ? "user-plus" : "group-plus");
|
assignedPath = `/t/${topic.id}`;
|
||||||
let name;
|
}
|
||||||
|
|
||||||
name =
|
const icon = iconHTML(assignee.username ? "user-plus" : "group-plus");
|
||||||
|
let name;
|
||||||
|
name =
|
||||||
siteSettings.prioritize_full_name_in_ux || !assignee.username
|
siteSettings.prioritize_full_name_in_ux || !assignee.username
|
||||||
? assignee.name || assignee.username
|
? assignee.name || assignee.username
|
||||||
: assignee.username;
|
: assignee.username;
|
||||||
|
|
||||||
const tagName = params.tagName || "a";
|
const tagName = params.tagName || "a";
|
||||||
const href =
|
const href =
|
||||||
tagName === "a"
|
tagName === "a"
|
||||||
? `href="${getURL(assignedPath)}" data-auto-route="true"`
|
? `href="${getURL(assignedPath)}" data-auto-route="true"`
|
||||||
: "";
|
: "";
|
||||||
return `<${tagName} class="assigned-to discourse-tag simple" ${href}>${icon}<span title="${escapeExpression(
|
|
||||||
note
|
return `<${tagName} class="assigned-to discourse-tag simple" ${href}>${icon}<span title="${escapeExpression(
|
||||||
)}">${name}</span></${tagName}>`;
|
note
|
||||||
})
|
)}">${name}</span></${tagName}>`;
|
||||||
.join("");
|
};
|
||||||
}
|
|
||||||
|
// is there's one assignment just return the tag
|
||||||
const createTagHtml = ({ assignee, note }) => {
|
if (assignedTo.length === 1) {
|
||||||
let assignedPath;
|
return createTagHtml(assignedTo[0]);
|
||||||
if (assignee.assignedToPostId) {
|
|
||||||
assignedPath = `/p/${assignee.assignedToPostId}`;
|
|
||||||
} else {
|
|
||||||
assignedPath = `/t/${topic.id}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const icon = iconHTML(assignee.username ? "user-plus" : "group-plus");
|
// join multiple assignments with a separator
|
||||||
const name = assignee.username || assignee.name;
|
let result = "";
|
||||||
const tagName = params.tagName || "a";
|
assignedTo.forEach((assignment, index) => {
|
||||||
const href =
|
result += createTagHtml(assignment);
|
||||||
tagName === "a"
|
|
||||||
? `href="${getURL(assignedPath)}" data-auto-route="true"`
|
// add separator if not the last tag
|
||||||
: "";
|
if (index < assignedTo.length - 1) {
|
||||||
|
const separator = applyValueTransformer("tag-separator", ",", {
|
||||||
return `<${tagName} class="assigned-to discourse-tag simple" ${href}>${icon}<span title="${escapeExpression(
|
topic,
|
||||||
note
|
index,
|
||||||
)}">${name}</span></${tagName}>`;
|
});
|
||||||
};
|
result += `<span class="discourse-tags__tag-separator">${separator}</span>`;
|
||||||
|
}
|
||||||
// is there's one assignment just return the tag
|
});
|
||||||
if (assignedTo.length === 1) {
|
|
||||||
return createTagHtml(assignedTo[0]);
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
// join multiple assignments with a separator
|
|
||||||
let result = "";
|
|
||||||
assignedTo.forEach((assignment, index) => {
|
|
||||||
result += createTagHtml(assignment);
|
|
||||||
|
|
||||||
// add separator if not the last tag
|
|
||||||
if (index < assignedTo.length - 1) {
|
|
||||||
const separator = applyValueTransformer("tag-separator", ",", {
|
|
||||||
topic,
|
|
||||||
index,
|
|
||||||
});
|
|
||||||
result += `<span class="discourse-tags__tag-separator">${separator}</span>`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
api.createWidget("assigned-to-post", {
|
api.createWidget("assigned-to-post", {
|
||||||
|
|
Loading…
Reference in New Issue