alanvardy/exzeitable

A mechanism to pass through assigns when creating a new table

Closed this issue · 2 comments

I would like to be able to pass my own map of custom assigns.

That could be referenced in any of the function fields.

Something along the lines of (in my template):

<%= MateTable.live_table(@conn, assigns: %{current_user: get_current_user(@conn)) %>

And then in my table


  use Exzeitable,
    repo: MyApp.Repo,
    routes: Routes,
    path: :mate_path,
    fields: [
      stuff: [function: true]
    ],
    query: preload(Mate, :user),
    action_buttons: []

  def stuff(socket, mate) do
    # I need Socket{assigns: %{current_user: current_user }} to be present.
    View.render("_actions.html", %{socket: socket, mate: mate})
  end

Thank you, kind sir!

Great! Will implement on next release.

Bear in mind that anything you put in assigns will be passed everywhere... so much better to use user_id than %User{}