View Source Changelog
unreleased
Unreleased
0-14-2-2022-08-26
[0.14.2] - 2022-08-26
changed
Changed
- Support Flop
~> 0.17.0
.
0-14-1-2022-03-22
[0.14.1] - 2022-03-22
changed-1
Changed
- Support Flop
~> 0.16.0
.
0-14-0-2022-02-22
[0.14.0] - 2022-02-22
added
Added
symbol_unsorted
option for thetable
component.caption
assign for thetable
component.col_style
assign for the:col
slot of thetable
component.
changed-2
Changed
- Additional attributes passed to the
<:col>
slot will now be added as attributes to the<td>
tags.
0-13-0-2021-11-14
[0.13.0] - 2021-11-14
added-1
Added
- Add
cursor_pagination/1
component.
changed-3
Changed
- The pagination component adds the
disabled
class to thespan
that is displayed when the previous or next link is disabled now. Previously, thedisabled
attribute was set on thespan
. The class can be customized with the:disabled_class
option.
0-12-0-2021-11-08
[0.12.0] - 2021-11-08
added-2
Added
- Implement the
Phoenix.HTML.FormData
protocol forFlop.Meta
. This means you can pass the meta struct as:for
option to the Phoenixform_for
functions now. - Add the functions
filter_fields/1
,filter_input/1
andfilter_label/1
.
changed-4
Changed
- Remove
:for
option. The schema module is now automatically derived from the meta struct.
0-11-1-2021-10-31
[0.11.1] - 2021-10-31
added-3
Added
- Adds
hide
andshow
options to table:col
.
changed-5
Changed
- Passing a
label
to a table:col
is now optional.
0-11-0-2021-10-30
[0.11.0] - 2021-10-30
changed-6
Changed
- The
path_helper_args
assign has been removed in favor of passing mfa tuples aspath_helper
. - In the same vein,
Flop.Phoenix.build_path/4
has been replaced withFlop.Phoenix.build_path/3
, which also takes a tuple as the first argument. - The table component has been changed to use slots. The
headers
,footer
,row_func
androw_opts
assigns have been removed. Also, thetfoot_td_attrs
andtfoot_th_attrs
options have been removed. - The
live_view
version requirement has been changed to~> 0.17.0
. - Better error messages for invalid assigns have been added.
how-to-upgrade
How to upgrade
Update the path_helper
and path_helper_args
assigns set for the table
and pagination
component:
- path_helper={&Routes.pet_path/3}
- path_helper_args={[@socket, :index]}
+ path_helper={{Routes, :pet_path, [@socket, :index]}}
If you prefer, you can pass a function instead.
+ path_helper={{&Routes.pet_path/3, [@socket, :index]}}
Update any calls to Flop.Phoenix.build_path/4
:
- Flop.Phoenix.build_path(&Routes.pet_path/3, [@socket, :index], meta)
+ Flop.Phoenix.build_path({Routes, :pet_path, [@socket, :index]}, meta)
If you prefer, you can use a 2-tuple here as well:
+ Flop.Phoenix.build_path({&Routes.pet_path/3, [@socket, :index]}, meta)
Finally, update the tables in your templates:
<Flop.Phoenix.table
for={MyApp.Pet}
items={@pets}
meta={@meta}
- path_helper={&Routes.pet_path/3}
- path_helper_args={[@socket, :index]}
+ path_helper={{Routes, :pet_path, [@socket, :index]}}
- headers={[{"Name", :name}, {"Age", :age}]}
- row_func={fn pet, \_opts -> [pet.name, pet.age] end}
- footer={["", @average_age]}
- />
+ >
+ <:col let={pet} label="Name" field={:name}><%= pet.name %></:col>
+ <:col let={pet} label="Age" field={:age}><%= pet.age %></:col>
+ <:foot>
+ <tr>
+ <td></td>
+ <td><%= @average_age %></td>
+ </tr>
+ </:foot>
+ </Flop.Phoenix.table>
Also, you can remove tfoot_td_attrs
and tfoot_th_attrs
from the opts
assign (or opts provider function).
0-10-0-2021-10-24
[0.10.0] - 2021-10-24
added-4
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-7
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 newrow_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 anevent
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-1
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
torow_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}]}
/>
0-9-1-2021-10-22
[0.9.1] - 2021-10-22
changed-8
Changed
- Change
live_view
version requirement to~> 0.16.0 or ~> 0.17.0
.
0-9-0-2021-10-04
[0.9.0] - 2021-10-04
added-5
Added
- Add table foot option for sortable table.
0-8-1-2021-08-11
[0.8.1] - 2021-08-11
changed-9
Changed
- Loosen version requirement for Flop.
0-8-0-2021-08-11
[0.8.0] - 2021-08-11
added-6
Added
- New options
event
andtarget
for the pagination and sortable table component, which allow to emit pagination and sorting events in LiveView without patching the URL.
changed-10
Changed
- Use
HEEx
templates for both the pagination and the sortable table component. Refer to the Readme for usage examples. - Require
live_view ~> 0.16.0
. - Support safe HTML tuples in unsortable table headers.
- Improve documentation with examples for LiveView, HEEx templates and EEx templates.
0-7-0-2021-06-13
[0.7.0] - 2021-06-13
added-7
Added
- Add wrapper around sortable table header link and order direction indicator.
- Add option
current_link_attrs
to pagination builder. - Add options
thead_tr_attrs
,thead_th_attrs
,tbody_tr_attrs
andtbody_td_attrs
to table generator. - Add option
no_results_content
to table generator, which sets the content that is going to be displayed instead of the table if the item list is empty. A default option is applied, so make sure to set the option and/or remove your own no results messages from your templates when making the upgrade.
changed-11
Changed
- The table options
table_class
,th_wrapper_class
,symbol_class
andcontainer_class
were replaced in favour oftable_attrs
,th_wrapper_attrs
,symbol_attrs
andcontainer_attrs
for more flexibility and consistency with the pagination generator. To update, rename the options in your code and wrap the values in keyword lists with aclass
key (e.g.container_class: "table-container"
=>container_attrs: [class: "table-container"]
). - The
pagination_link_attrs
is not applied to current links anymore. Usecurrent_link_attrs
to set the attributes for the current link. - Omit
page=1
andoffset=0
when building query parameters. - Omit default values for order and limit/page size parameters when building query parameters.
- Requires Flop
~> 0.11.0
.
fixed
Fixed
- Order direction indicator was wrapped twice.
- A Flop struct with an offset was resulting in invalid pagination links.
0-6-1-2021-05-05
[0.6.1] - 2021-05-05
fixed-1
Fixed
- Pagination helper generated invalid links when using
default_limit
option.
0-6-0-2021-05-04
[0.6.0] - 2021-05-04
added-8
Added
- Add
Flop.Phoenix.table/1
for rendering sortable tables. - Add function
Flop.Phoenix.to_query/1
, which converts a Flop struct into a keyword list for query parameters. - Add function
Flop.Phoenix.build_path/3
, which applies Flop parameters to a Phoenix path helper function.
removed
Removed
- Remove
Flop.Phoenix.Live.PaginationComponent
in favor of makingFlop.Phoenix.pagination/4
work in both.eex
and.leex
templates.
0-5-1-2021-04-14
[0.5.1] - 2021-04-14
fixed-2
Fixed
- Merge pagination query parameters into existing query parameters, if present.
0-5-0-2021-03-23
[0.5.0] - 2021-03-23
changed-12
Changed
- Rename
FlopPhoenix
toFlop.Phoenix
. - Add
Flop.Phoenix.Live.PaginationComponent
for use withPhoenix.LiveView
. - Change pagination to always display links to the first and last page.
0-4-0-2020-09-04
[0.4.0] - 2020-09-04
changed-13
Changed
- Allow usage with newer versions of Flop.
0-3-0-2020-06-17
[0.3.0] - 2020-06-17
added-9
Added
- New option to hide the number of page links.
- New option to limit the number of page links.
changed-14
Changed
- Add order and filter parameters to pagination links.
0-2-0-2020-06-15
[0.2.0] - 2020-06-15
added-10
Added
- Improve documentation.
changed-15
Changed
previous_link/3
,next_link/3
andpage_links/3
are private functions now.
0-1-0-2020-06-15
[0.1.0] - 2020-06-15
Initial release