Skip to content
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

Close #204 #236

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
### Breaking Changes
* Require minimum Gettext v0.26 to use the new backend module

### Fixes
- Close #204 - skip `PageBuilder.Table.handle_params/3` when the requested page has no pagination data

### Enhancements
- [Visual Editor] Improve DnD highlight states and simplify logic significantly ([#219](https://github.com/BeaconCMS/beacon_live_admin/pull/219))
- [Visual Editor] Better detect overlapping when dragging elements to reorder ([#216](https://github.com/BeaconCMS/beacon_live_admin/pull/216))
Expand Down
6 changes: 4 additions & 2 deletions lib/beacon/live_admin/page_builder/table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ defmodule Beacon.LiveAdmin.PageBuilder.Table do
updating params for a Table.
"""
@spec handle_params(Socket.t(), map(), (Page.t() -> integer())) :: Socket.t()
def handle_params(socket, params, count_fn) do
%{per_page: per_page, sort_by: sort_by} = socket.assigns.beacon_page.table
def handle_params(socket, params, count_fn)

def handle_params(%{assigns: %{beacon_page: %{table: %{per_page: per_page, sort_by: sort_by}}}} = socket, params, count_fn) do
current_page = params |> Map.get("page", "1") |> String.to_integer()
page_count = ceil(count_fn.(socket.assigns.beacon_page) / per_page)
sort_by = params |> Map.get("sort_by", sort_by) |> safe_to_atom()
Expand All @@ -141,6 +141,8 @@ defmodule Beacon.LiveAdmin.PageBuilder.Table do
)
end

def handle_params(socket, _params, _count_fn), do: socket

defp safe_to_atom(value) when is_atom(value), do: value
defp safe_to_atom(value) when is_binary(value), do: String.to_existing_atom(value)

Expand Down