avo icon indicating copy to clipboard operation
avo copied to clipboard

Bulk update back-end

Open adrianthedev opened this issue 1 year ago • 2 comments

Context

We'd like to enable users to bulk-update records from the Index page. We need a back-end for it.

Approach

Create a BulkUpdateController which will take in a payload and update those records accordingly.

  • execute field validation from the model (Rails should do it for us)
  • accepted params should be verified
    • fields marked as disabled should not be updated
  • ensure the values are updated through fill_field method for every field

Possible payload this controller action can take:

{
  payload: [
    {
      param: "user_12o3211o3i3h" # or just the id
      resource_type: Avo::Resources::User,
      body: {
        first_name: "John",
        age: 33
      }
    },
    {
      param: "user_k3k6no2i" # or just the id
      resource_type: Avo::Resources::User,
      body: {
        first_name: "John",
        age: 33
      }
    },
    {
      param: 123
      resource_type: Avo::Resources::Post,
      body: {
        title: "What a great day",
        body: "# Lorem ipsum"
        user_id: "user_12o3211o3i3h"
      }
    }
  ]
}

Approach video: https://www.loom.com/share/f41a28048b8d4b80a3296e80d85fab41?sid=f1ba9ce6-41e2-48c0-9d3b-b4734169317f

adrianthedev avatar Feb 21 '25 08:02 adrianthedev

Comment for assignment, I will give it a try.

Nevelito avatar Feb 22 '25 12:02 Nevelito

Some inspiration:

  • https://x.com/bradgessler/status/1887187002459877425
  • https://superails.com/posts/ruby-on-rails-86-bulk-actions-edit-multiple-selected-records

adrianthedev avatar Mar 03 '25 14:03 adrianthedev