Skip to content

Add bulk-action for submitting via POST form #168

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

Conversation

Nerian
Copy link
Contributor

@Nerian Nerian commented Mar 30, 2022

Hello,

This PR add support for using a POST with a form submission when using bulk-actions. This is useful for when you need to send several thousand ids.

@matt-riemer
Copy link
Member

I like the idea of this PR. Could you update the indenting on those if statements so it reads better? I'm confused what code actually gets executed :)

This is kind of a standard form POST that will refresh the entire page, instead of an AJAX response like the GET or the file download (which is a post). Maybe this is another kind of bulk operation? what do you think? :)

@matt-riemer
Copy link
Member

Hey sorry we haven't upgraded to bootstrap5 yet, it's coming.

And FYI, make sure you know about that newer Download feature:

https://github.com/code-and-effect/effective_datatables#download

So you can one-click download the entire datatable collection instead of the "what you're looking at" view

@Nerian
Copy link
Contributor Author

Nerian commented Apr 2, 2022

I like the idea of this PR. Could you update the indenting on those if statements so it reads better? I'm confused what code actually gets executed :)

Sorry, I am not sure what you mean about the indenting. Do you want me to add the if/else? I agree it has become quite long :) Maybe some refactoring would be nice.

This is kind of a standard form POST that will refresh the entire page, instead of an AJAX response like the GET or the file download (which is a post). Maybe this is another kind of bulk operation? what do you think? :)

In my case I use like this: The user will use filters to narrow down a number of expedients, and then select a few or all. He will then click on the bulk action and do a POST to some action. The action will receive a list of ids, and render a form for further options for processing the selected expedients; the expedient ids will be rendered in the form via hidden fields. It's sort of a wizard pattern.

Maybe we could re-categorise all the options. Right now we differentiate between GET and POST and then another modifier. Maybe we should try to just provide one category.

From this:

data: { method: :get }
data: { 'payload-mode' => 'local-storage', method: :get }
data: { 'payload-mode' => 'cookie', method: :get }
data: { 'payload-mode' => 'form', method: :post }

To this:

data: { 'effective-mode' => 'ajax-get' }.
data: { 'effective-mode' => 'ajax-post' }.
data: { 'effective-mode' => 'redirect-get' }.
data: { 'effective-mode' => 'redirect-local-storage' }
data: { 'effective-mode' => 'redirect-cookie' }
data: { 'effective-mode' => 'redirect-form' }

That would streamline the if/else cluster.

@matt-riemer matt-riemer closed this Aug 8, 2022
@Nerian
Copy link
Contributor Author

Nerian commented Aug 10, 2022

Hi,

Why close it? Do I need to rework anything? My last comment included some questions about what we could do it. Let me know.

@matt-riemer matt-riemer reopened this Aug 10, 2022
@matt-riemer
Copy link
Member

I don't want to make changes here because I have many legacy apps that would need updating.

I don't like the original code, or the new code 'cause it's too complex, basically unreadable and has no testing :(

@Nerian
Copy link
Contributor Author

Nerian commented Aug 25, 2022

👌 Will try to refactor the code

@Nerian
Copy link
Contributor Author

Nerian commented Mar 5, 2023

👋 Feel free to close this PR. I will find a different way to implement this own code.

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.

3 participants