Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-7206: Improve list of selected ids when long #15366

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 += "...";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if these extra dots will not go well with whatever processing someone is doing with the resulting string :).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Right. @mjkkirschner / @QilongTang , do we consider this a breaking change? If so I'll hold off, this is not a critical fix, just a nice-to-have in Player. We could perhaps also fix it in Player, but in my opinion it makes sense to fix here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is going to be part of the selection node value passed to e.g. watch node then yes, if the ... is only part of the selection display then this should not impact IMHO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This does not affect the value - that's always the full list of elements. This affects Selection's Text property, which is used in the node's display in canvas, and also by Dynamo Player to send a display value to Player client.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But Selection.Text is public, and this changes its output.

Copy link
Contributor

@QilongTang QilongTang Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I realize that this change is not what I thought it would be. I was thinking if this change would affect the display text of e,g, Family Types node so each selection displayed will be more concise
image

Does not look like Dynamo side is impacted by this though, if you have a screenshot of UI change, please share

Copy link
Contributor Author

@twastvedt twastvedt Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, not that. Here's what it looks like
image
I also realized changes are needed in DynamoRevit since this method is overridden there. Please see DynamoDS/DynamoRevit#3080 (I'm not able to add reviewers to DynamoRevit PRs)

}

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
Loading