fix linting issues

This commit is contained in:
Juan David Martinez 2025-03-07 20:39:04 -05:00
parent a7cc7053d3
commit d35e5082e5
No known key found for this signature in database
GPG Key ID: FE50F4B983E68D5B
1 changed files with 49 additions and 49 deletions

View File

@ -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 createTagHtml = ({ assignee, note }) => { const icon = iconHTML(assignee.username ? "user-plus" : "group-plus");
let assignedPath; let name;
if (assignee.assignedToPostId) { name =
assignedPath = `/p/${assignee.assignedToPostId}`; siteSettings.prioritize_full_name_in_ux || !assignee.username
} else { ? assignee.name || assignee.username
assignedPath = `/t/${topic.id}`; : assignee.username;
}
const icon = iconHTML(assignee.username ? "user-plus" : "group-plus"); const tagName = params.tagName || "a";
let name; const href =
name = tagName === "a"
siteSettings.prioritize_full_name_in_ux || !assignee.username ? `href="${getURL(assignedPath)}" data-auto-route="true"`
? assignee.name || assignee.username : "";
: assignee.username;
const tagName = params.tagName || "a"; return `<${tagName} class="assigned-to discourse-tag simple" ${href}>${icon}<span title="${escapeExpression(
const href = note
tagName === "a" )}">${name}</span></${tagName}>`;
? `href="${getURL(assignedPath)}" data-auto-route="true"` };
: "";
return `<${tagName} class="assigned-to discourse-tag simple" ${href}>${icon}<span title="${escapeExpression( // is there's one assignment just return the tag
note if (assignedTo.length === 1) {
)}">${name}</span></${tagName}>`; return createTagHtml(assignedTo[0]);
}; }
// is there's one assignment just return the tag // join multiple assignments with a separator
if (assignedTo.length === 1) { let result = "";
return createTagHtml(assignedTo[0]); 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>`;
} }
});
// join multiple assignments with a separator return result;
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", {