0.10.0
Added
- It is now possible to set global options for the components in your config.
config :flop_phoenix,
pagination: [opts: {MyApp.ViewHelpers, :pagination_opts}],
table: [opts: {MyApp.ViewHelpers, :table_opts}]
Changed
- The
for
,event
andtarget
options moved from theopts
assign to the
root. Theopts
assign is now exclusively used for customization options
that modify the appearance, which are usually set globally for a
project and are not related to the specific data or view. - The
row_func/2
function passed to thetable
component receives the new
row_opts
assign now instead of theopts
assign. - The pagination and table components only pass the
for
option to the query
builder, instead of allopts
. - The
path_helper
andpath_helper_args
assigns are now optional if an
event
is passed. A descriptive error is raised if neither of them are
passed. - The
opts
assign for the pagination and table components is now optional. - Aria labels were added to the links to the first and last page.
- The
aria-sort
attribute was added to the table headers.
How to upgrade
- Remove the
for
,event
andtarget
from theopts
assign and add them
as regular assigns at the root level. - Move any key/value pairs that are needed by your
row_func
fromopts
to
row_opts
.
For example, if your row_func
looks like this:
def table_row(%Pet{id: id, name: name}, opts) do
socket = Keyword.fetch!(opts, :socket)
[name, link("show", to: Routes.pet_path(socket, :show, id))]
end
Update your template like this:
<Flop.Phoenix.sortable_table
row_func={&table_row/2}
- opts={[
- container: true,
- for: Pet,
- event: "sort-table",
- target: @myself,
- socket: @socket
- ]}
+ row_opts={[socket: @socket]}
+ for={Pet}
+ event="sort-table"
+ target={@myself}
+ opts={[container: true]}
/>
<Flop.Phoenix.pagination
- opts={[
- for: Pet,
- event: "paginate",
- target: @myself,
- page_links: {:ellipsis, 7}
- ]}
+ for={Pet}
+ event="paginate"
+ target={@myself}
+ opts={[page_links: {:ellipsis, 7}]}
/>