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 buttonsStartWith and buttonsEndWith methods #5693

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dimer47
Copy link
Contributor

@dimer47 dimer47 commented Oct 16, 2024

Introduced two new methods to reorder buttons: buttonsStartWith and buttonsEndWith. 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 the abortIfNotExist parameter. Updated orderButtons to accommodate the new abortIfNotExist 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:

CRUD::buttonsStartWith('line', ['show', 'update'], false);
CRUD::buttonsEndWith('line', ['delete', 'trash', 'destroy'], false);

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:

CRUD::buttonsStartWith('line', ['update', 'show'], false);
CRUD::buttonsEndWith('line', ['delete', 'trash', 'destroy'], false);

Introduced two new methods to reorder buttons: `buttonsStartWith` and `buttonsEndWith`. 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 the `abortIfNotExist` parameter. Updated `orderButtons` to accommodate the new `abortIfNotExist` parameter.
@jcastroa87
Copy link
Member

Hello @dimer47

Thanks a lot for this PR, I will ask @pxpm to check it.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Testing, Review or Docs
Development

Successfully merging this pull request may close these issues.

3 participants