-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Added sorting BREAD as tree view if BREAD have column - menu_parent #4671
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handful of code style changes.
- You've moved all of the presentation logic into the controller. We have historically maintained it at the view tier, including the logic used to include other views. I'd like to hear opinions from @emptynick or @MrCrayon, but I'm thinking I'd like to see that pattern maintained.
- When committing to open source projects (or really anything you didnt create yourself), please follow existing code styling. Specifically, methods are
camelCase
, notsnake_case
, among others(indentation, brace/bracket placement, etc... though StyleCI should catch and fix most of that stuff). - Large collections of functionality/methods like this are perfect candidates for traits. Resolving Creating Accounts #1 will likely reduce the number of methods and make this less relevant.
- Tests. We need some kind of test submitted with this as proof that it actually works. We don't expect 100% test coverage(though it'd be nice), but we simply can't accept it with nothing.
Thanks!
About 1. |
IMHO that's presentation logic and in MVC that should stay in the view. Adding to what @fletch3555 said, at first glance, I'd like to add:
I'll have a better look at this PR as soon as I can. If we can figure it out all details it could be a nice feature, thanks. P.S. |
Before you make further changes you should rebase your branch because: You should always be aware of what changes are in your PR, if there is something not related check what's happening like here: - if ($model && in_array(SoftDeletes::class, class_uses_recursive($model))) {
+ if ($model && in_array(SoftDeletes::class, class_uses($model))) { |
@dzianisyaukhuta please check #4675 I put you as Co-Author. I understand you put a lot of effort in this PR and we surely appreciate this and hope you'll keep contributing but there was a bit too much to change. You can see leaving the presentation logic in the view we only needed to make the listing part a partial that can be recursively included when there are children. If you have time we still need to implement tests and documentation and I left out the buttons that could also be implemented. Fill free to contact me in Voyager slack group. |
Guys. I am not programmer. I am designer with some skills in programming. Can you help me? Or just complete my work? @MrCrayon , can you end my work? Or another. We all need that reorder. I think my knowledge is not enough to complete this PR :( |
@dzianisyaukhuta #4675 already works, but it can't be merged without tests. I can close this one and we can move the discussion in the other PR. |
I did a great job so that we can sort our BREAD resources in a tree view.
If BREAD have column named as menu_parent and isset Order column - you get functional for reorder with tree view.
VoyagerBaseController
VoyagerBaseController order() updated:
VoyagerBaseController - order_results_tree_array() added:
New recursive function that builds a tree array from resources, which is called in the order()
VoyagerBaseController - order_results_tree_build() added:
New recursive function that builds a view output from view templates, which is called in the order()
VoyagerBaseController - update_order() updated:
Therefore, I added a new function reverseArray() which reverses the multidimensional array and saves it later as needed.
VoyagerBaseController - reverseArray() added:
New function. Used in update_order() for reverse multidimensional array.
VoyagerBaseController - update_order_tree() added:
New Recursive function called in update_order() to update tree resources
View Templates
All new and updated view templates called and used as renders in controller.
bread/order.blade.php updated
bread/order-tree-wrapper-without-childs.blade.php added
New view template as Wrapper for results item without childrens (not tree view).
bread/order-tree-wrapper-with-childs.blade.php added
New view template as Wrapper for results item with childrens (tree view).
order-tree-item.blade.php added
New view template as item of results.
Attention to enable functionality in BREAD reorder:
Dzianis Yaukhuta
dzianisyaukhuta@gmail.com