Skip to content

Commit

Permalink
DYN-7206: Improve list of selected ids when long (#15366)
Browse files Browse the repository at this point in the history
  • Loading branch information
twastvedt authored Aug 19, 2024
1 parent 5dc7213 commit 4426ba4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions src/Libraries/CoreNodeModels/Selection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected SelectionBase(
public override string ToString()
{
return SelectionResults.Any()
? string.Format("{0} : {1}", Prefix, FormatSelectionText(SelectionResults))
? string.Format("{0}: {1}", Prefix, FormatSelectionText(SelectionResults))
: Resources.SelectionNodeNothingSelected;
}

Expand Down Expand Up @@ -236,9 +236,19 @@ public bool CanBeginSelect()

protected virtual string FormatSelectionText<T>(IEnumerable<T> elements)
{
return elements.Any()
? System.String.Join(" ", SelectionResults.Take(20).Select(x=>x.ToString()))
: "";
if (elements.Any())
{
string text = string.Join(", ", elements.Take(20).Select(x => x.ToString()));

if (elements.Count() > 20)
{
text += "...";
}

return text;
}

return string.Empty;
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
Expand Down Expand Up @@ -138,7 +138,7 @@ public void ToStringTest()
//Checks ToString result for the selected element
toStringResult = selection.ToString();
string nodeType = testNode.GetType().ToString();
string expected = $"testPrefix : {nodeType}";
string expected = $"testPrefix: {nodeType}";
Assert.AreEqual(expected, toStringResult);

selectionHelperMock.VerifyAll();
Expand Down

0 comments on commit 4426ba4

Please sign in to comment.