@@ -23,6 +23,7 @@ import BulkActionsAssignUser from "../components/bulk-actions/bulk-assign-user";
2323import EditTopicAssignments from "../components/modal/edit-topic-assignments" ;
2424import TopicLevelAssignMenu from "../components/topic-level-assign-menu" ;
2525import { extendTopicModel } from "../models/topic" ;
26+ import { applyValueTransformer } from "discourse/lib/transformer" ;
2627
2728const DEPENDENT_KEYS = [
2829 "topic.assigned_to_user" ,
@@ -467,28 +468,52 @@ function initialize(api) {
467468 . filter ( ( { assignee } ) => assignee )
468469 . flat ( ) ;
469470
470- if ( assignedTo ) {
471- return assignedTo
472- . map ( ( { assignee, note } ) => {
473- let assignedPath ;
474- if ( assignee . assignedToPostId ) {
475- assignedPath = `/p/${ assignee . assignedToPostId } ` ;
476- } else {
477- assignedPath = `/t/${ topic . id } ` ;
478- }
479- const icon = iconHTML ( assignee . username ? "user-plus" : "group-plus" ) ;
480- const name = assignee . username || assignee . name ;
481- const tagName = params . tagName || "a" ;
482- const href =
483- tagName === "a"
484- ? `href="${ getURL ( assignedPath ) } " data-auto-route="true"`
485- : "" ;
486- return `<${ tagName } class="assigned-to discourse-tag simple" ${ href } >${ icon } <span title="${ escapeExpression (
487- note
488- ) } ">${ name } </span></${ tagName } >`;
489- } )
490- . join ( "" ) ;
471+ if ( ! assignedTo ) {
472+ return "" ;
473+ }
474+
475+ const createTagHtml = ( { assignee, note } ) => {
476+ let assignedPath ;
477+ if ( assignee . assignedToPostId ) {
478+ assignedPath = `/p/${ assignee . assignedToPostId } ` ;
479+ } else {
480+ assignedPath = `/t/${ topic . id } ` ;
481+ }
482+
483+ const icon = iconHTML ( assignee . username ? "user-plus" : "group-plus" ) ;
484+ const name = assignee . username || assignee . name ;
485+ const tagName = params . tagName || "a" ;
486+ const href =
487+ tagName === "a"
488+ ? `href="${ getURL ( assignedPath ) } " data-auto-route="true"`
489+ : "" ;
490+
491+ return `<${ tagName } class="assigned-to discourse-tag simple" ${ href } >${ icon } <span title="${ escapeExpression (
492+ note
493+ ) } ">${ name } </span></${ tagName } >`;
494+ } ;
495+
496+ // is there's one assignment just return the tag
497+ if ( assignedTo . length === 1 ) {
498+ return createTagHtml ( assignedTo [ 0 ] ) ;
491499 }
500+
501+ // join multiple assignments with a separator
502+ let result = "" ;
503+ assignedTo . forEach ( ( assignment , index ) => {
504+ result += createTagHtml ( assignment ) ;
505+
506+ // add separator if not the last tag
507+ if ( index < assignedTo . length - 1 ) {
508+ const separator = applyValueTransformer ( "tag-separator" , "," , {
509+ topic,
510+ index,
511+ } ) ;
512+ result += `<span class="discourse-tags__tag-separator">${ separator } </span>` ;
513+ }
514+ } ) ;
515+
516+ return result ;
492517 } ) ;
493518
494519 api . createWidget ( "assigned-to-post" , {
0 commit comments