dynamic bulk actions and/or bulk action form #505
Replies: 5 comments 2 replies
-
I do think the current way is adequate but you're free to make a PR. My issue is the codebase has grown so rapidly so fast without proper tests that I'm up to a point where merging a PR causes other issues, but I might not find them right away because there are no tests. I'm probably at the point where I should take what we have and start from scratch for v2, but I just don't have the time right now. |
Beta Was this translation helpful? Give feedback.
-
Hmmm, I might be able to stick with lifecycle hooks if I go for the first option. Or, are you saying this is already a solved problem? The docs only show a static list of bulkActions that directly reference a method on the component. Is there already a way to add user input to bulk actions? |
Beta Was this translation helpful? Give feedback.
-
Not that I can remember, though that might be a good idea for a PR. But I'm not sure how we would pass data off the top of my head. |
Beta Was this translation helpful? Give feedback.
-
I will think on the input ideas. In the mean time I will try solving with lifecycle hooks before modifying $bulkActions |
Beta Was this translation helpful? Give feedback.
-
Okay, here is what I ended up doing for the time being. I did have to submit #506 to patch a minor issue with primaryKey used on bulkActions, but other that I didn't modify the source. I used mount on the component to set bulkActions, which allows me to set bulkActions dynamically.
Note, because the bulk action is passed to wire:click, we can pass arguments as would normally on a livewire event (i.e. embed it in the string). This makes it relatively easy to setup our bulk action with some basic input.
|
Beta Was this translation helpful? Give feedback.
-
@rappasoft,
I am looking to add some functionality, but I wanted your feedback before starting. What I am looking to add is either a dynamic list of bulk actions, or I am looking to add a form / option select to a bulk action.
My use case is that I need to assign a row to a user. The list of users is fairly small, so I am thinking of adding a dynamic list of bulk actions (e.g. Assign User 1, Assign User 2, ... ). If I were to go this route I think I would want to mimic the pattern used for columns (i.e. a method which defaults to the property) and refactoring to the bulkActions() method. I can then handle the actions in a number of ways without any other change to the code base.
The other approach, which I am sure you have thought about, is to add a form of some kind for bulk actions. That's going to probably require more changes to accomodate.
Are you opposed to me submitting a PR for either of these features?
Beta Was this translation helpful? Give feedback.
All reactions