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 ordering to menu items #2939

Merged
merged 3 commits into from
Nov 22, 2018

Conversation

jacobherrington
Copy link
Contributor

This change allows menu items to be ordered. If the order value is nil
the menu item will come at the end of the list.

After:
b63a27f7-a7f5-449f-b233-3c4d964d3bd9

@kennyadsl
Copy link
Member

Hey I think it's a good idea but how can the menu be reordered by a user? For example what should I do in my app to put a new entry after the Products item? What about an overridable method that returns the order of the items instead?

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Thanks. Genrally I like that feature.

Could we not introduce the ordering feature and moving of menu items in the same commit?

Also I think we should not name the sort value order but position instead.

This change allows menu items to be ordered. If the order value is nil
the menu item will come at the end of the list.
@jacobherrington jacobherrington force-pushed the feature/order-menu-items branch from 195dc7a to fea32b8 Compare November 11, 2018 18:56
@jacobherrington
Copy link
Contributor Author

@tvdeyen Changes made, does that work for you?

@kennyadsl I added some comments to explain how the position attribute should be used. In most cases, the value doesn't need to be present and the behavior will be exactly the same as it currently is in Solidus. However, if someone wants to alter the ordering they simply add or change the position attribute to match the order they would like the menu to display. Does that make sense, or do I need further changes?

@kennyadsl
Copy link
Member

@jacobherrington I got how you can add new items but I still don't get how you can change existing (in solidus backend) menu items positions into your own app, maybe it's simpler than what I think but can you please provide a simple example?

@jacobherrington
Copy link
Contributor Author

jacobherrington commented Nov 11, 2018

@kennyadsl for example Spree::Backend::Config.menu_items.find { |i| i.label == :promotions }.position = 0 would make promotions first. Do you think there is a better way to achieve this?

edit: realized I forgot to commit the attr_accessor that makes this possible.

@jacobherrington
Copy link
Contributor Author

@kennyadsl @tvdeyen please let me know if you have any more thoughts on this one!

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Yes, thanks.

@kennyadsl I think this feature is more for new tabs instead of for reordering existing ones (that still is possible)

Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

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

Thanks!

@kennyadsl kennyadsl merged commit 717a800 into solidusio:master Nov 22, 2018
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.

4 participants