Add buttonsStartWith
and buttonsEndWith
methods
#5693
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduced two new methods to reorder buttons:
buttonsStartWith
andbuttonsEndWith
. These methods rearrange button collections by placing specified buttons at the beginning or end of the stack, respectively, with configurable behavior for handling missing buttons using theabortIfNotExist
parameter. UpdatedorderButtons
to accommodate the newabortIfNotExist
parameter.WHY
BEFORE - What was wrong? What was happening before this PR?
There was no option to define a priority order for buttons by specifying preferences. Previously, you had to directly define the button order among the buttons that were present in the stack. With this change, it is now possible to keep the stack as it is and simply specify which buttons should be at the beginning and which should be at the end of the stack, and the order is automatically adjusted.
I made this change to allow for easier modification of the button order, regardless of the buttons being used. In fact, I use the Laravel Pint linter, which automatically checks the use traits and forces me to reorder the buttons each time.
AFTER - What is happening after this PR?
It is now possible to specify which buttons you prefer to have at the beginning and end of the stack. Also, when using the move method, you can specify that it should not abort if it does not find the button.
HOW
How did you achieve that, in technical terms?
I added two methods: the first one is called buttonsStartWith, and the second one is called buttonsEndWith.
Here is an example of how they can be used:
Is it a breaking change?
No, this is not a breaking change. It is simply an additional feature to make the button order more flexible.
How can we test the before & after?
In the setupListOperation() function of a CRUD, add these two methods with a desired button order and test.
Example: