Skip to content

Add ability to sort models by record count#866

Merged
RobbieTheWagner merged 1 commit intoemberjs:masterfrom
nlfurniss:order-models-by-count
Sep 5, 2018
Merged

Add ability to sort models by record count#866
RobbieTheWagner merged 1 commit intoemberjs:masterfrom
nlfurniss:order-models-by-count

Conversation

@nlfurniss
Copy link
Copy Markdown
Contributor

It would be nice to be able to sort models by their record count as well as alphabetically (current option).

This PR

  • Adds ability to sort models by record count

  • Adds test for new sort functionality

  • DRYs up the code to get, set, and remove model sorting keys from Storage

Feature in action

screen shot 2018-09-01 at 12 13 05 pm

Copy link
Copy Markdown
Member

@RobbieTheWagner RobbieTheWagner left a comment

Choose a reason for hiding this comment

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

This looks awesome @nlfurniss! Thanks for the PR 😄. I just had one question.

Comment thread app/controllers/model-types.js Outdated
application: controller(),
navWidth: 180,
sortProperties: ['name'],
sortByNameProp: Object.freeze(['name']),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm curious what this Object.freeze is for?

Copy link
Copy Markdown
Contributor Author

@nlfurniss nlfurniss Sep 3, 2018

Choose a reason for hiding this comment

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

It’s a force of habit, more info available here.

But I guess that since this is a controller and not a component, the worry about leaking state/memory is less pronounced.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I typically do like the link you posted says and do like this.foo = [] in init. Should we do that here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure I can make those changes. There prob should be some standardize, see Ember.sort docs using Object.Freeze

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

@nlfurniss nlfurniss force-pushed the order-models-by-count branch from c72a282 to 53fc4de Compare September 4, 2018 18:56
@RobbieTheWagner RobbieTheWagner merged commit 6ad8edb into emberjs:master Sep 5, 2018
@nlfurniss nlfurniss deleted the order-models-by-count branch September 12, 2018 03:21
cyril-sf pushed a commit to cyril-sf/ember-inspector that referenced this pull request Mar 30, 2022
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.

2 participants