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