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

Add GroupingChooserModel.setDimensions() #3743

Merged
merged 12 commits into from
Aug 30, 2024

Conversation

Ryanseanlee
Copy link
Contributor

@Ryanseanlee Ryanseanlee commented Jul 31, 2024

Hoist P/R Checklist

Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry, or determined not required.
  • Reviewed for breaking changes, added breaking-change label + CHANGELOG if so.
  • Updated doc comments / prop-types, or determined not required.
  • Reviewed and tested on Mobile, or determined not required.
  • Created Toolbox branch / PR, or determined not required.

If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.

Pull request reviewers: when merging this P/R, please consider using a squash commit to
collapse multiple intermediate commits into a single commit representing the overall feature
change. This helps keep the commit log clean and easy to scan across releases. PRs containing a
single commit should be rebased when possible.

@Ryanseanlee Ryanseanlee linked an issue Jul 31, 2024 that may be closed by this pull request
cmp/grouping/GroupingChooserModel.ts Show resolved Hide resolved
cmp/grouping/GroupingChooserModel.ts Show resolved Hide resolved
@@ -308,7 +319,7 @@ export class GroupingChooserModel extends HoistModel {
return sortBy(
this.favorites.map(value => ({
value,
label: this.getValueLabel(value)
label: this.getValueLabel(value) ?? value
Copy link
Member

Choose a reason for hiding this comment

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

Why not have getValueLabel handle the edge case ?

Ryanseanlee and others added 5 commits August 1, 2024 10:12
+ Early-out if all dims remained in place
+ Make dimensionNames private - did not look like this was anything that needed to be a public property, ensures this stays in sync with dimensions, only settable from within `setDimensions()`
cmp/grouping/GroupingChooserModel.ts Outdated Show resolved Hide resolved
cmp/grouping/GroupingChooserModel.ts Outdated Show resolved Hide resolved
cmp/grouping/GroupingChooserModel.ts Show resolved Hide resolved
@amcclain amcclain changed the title Mutable dimensions for Grouping Chooser Add GroupingChooserModel.setDimensions() Aug 5, 2024
cmp/grouping/GroupingChooserModel.ts Outdated Show resolved Hide resolved
cmp/grouping/GroupingChooserModel.ts Outdated Show resolved Hide resolved
- Return DimensionSpec array when calling get DimensionSpec to be consistent with value passed to setDimentions
- Allow component to render/instantiate if enabled allowEmpty and empty dimensions
Copy link
Member

@haynesjm42 haynesjm42 left a comment

Choose a reason for hiding this comment

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

Tested this out for my use case and worked perfectly.

Am now able to create the GroupingChooserModel as a readonly member of my model with no dimensions, and I can set the dimensions when I load initial state in my model or when the relevant state changes to determine the dimensions - no more re-creating models and much less/simpler code!

@haynesjm42
Copy link
Member

@Ryanseanlee I think we just need a changelog entry and this can be merged

@amcclain
Copy link
Member

Great thanks much - I'll add that in now and merge it. 🚀

@amcclain amcclain merged commit 2bcf8ba into develop Aug 30, 2024
1 check passed
@amcclain amcclain deleted the mutableGroupingChooserDimensions branch August 30, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GroupingChooserModel.dimensions should be settable/updatable
3 participants