fix credo
This commit is contained in:
@ -106,33 +106,30 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do
|
||||
defp get_rows_for_containers(containers, assigns, columns) do
|
||||
containers
|
||||
|> Enum.map(fn container ->
|
||||
assigns = assigns |> Map.put(:container, container)
|
||||
|
||||
columns
|
||||
|> Enum.into(%{}, fn %{key: key} ->
|
||||
value =
|
||||
case key do
|
||||
"actions" ->
|
||||
~H"""
|
||||
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
phx-click="move"
|
||||
phx-target={@myself}
|
||||
phx-value-container_id={container.id}
|
||||
>
|
||||
<%= dgettext("actions", "Select") %>
|
||||
</button>
|
||||
</div>
|
||||
"""
|
||||
|
||||
key ->
|
||||
container |> Map.get(key |> String.to_existing_atom())
|
||||
end
|
||||
|
||||
{key, value}
|
||||
end)
|
||||
|> Enum.into(%{}, fn %{key: key} -> {key, get_row_value_by_key(key, container, assigns)} end)
|
||||
end)
|
||||
end
|
||||
|
||||
@spec get_row_value_by_key(String.t(), Container.t(), map()) :: any()
|
||||
defp get_row_value_by_key("actions", container, assigns) do
|
||||
assigns = assigns |> Map.put(:container, container)
|
||||
|
||||
~H"""
|
||||
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
phx-click="move"
|
||||
phx-target={@myself}
|
||||
phx-value-container_id={container.id}
|
||||
>
|
||||
<%= dgettext("actions", "Select") %>
|
||||
</button>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
defp get_row_value_by_key(key, container, _assigns),
|
||||
do: container |> Map.get(key |> String.to_existing_atom())
|
||||
end
|
||||
|
@ -5,15 +5,19 @@
|
||||
<%= for %{key: key, label: label} = column <- @columns do %>
|
||||
<%= if column |> Map.get(:sortable, true) do %>
|
||||
<th class={"p-2 #{column[:class]}"}>
|
||||
<span class="cursor-pointer"
|
||||
<span
|
||||
class="cursor-pointer"
|
||||
phx-click="sort_by"
|
||||
phx-value-sort-key={key}
|
||||
phx-target={@myself}>
|
||||
phx-target={@myself}
|
||||
>
|
||||
<span class="underline"><%= label %></span>
|
||||
<%= if @last_sort_key == key do %>
|
||||
<%= case @sort_mode do %>
|
||||
<% :asc -> %> <i class="fas fa-sm fa-chevron-down"></i>
|
||||
<% :desc -> %> <i class="fas fa-sm fa-chevron-up"></i>
|
||||
<% :asc -> %>
|
||||
<i class="fas fa-sm fa-chevron-down"></i>
|
||||
<% :desc -> %>
|
||||
<i class="fas fa-sm fa-chevron-up"></i>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<i class="fas fa-sm fa-chevron-up opacity-0"></i>
|
||||
@ -34,8 +38,10 @@
|
||||
<%= for %{key: key} = value <- @columns do %>
|
||||
<td class={"p-2 #{value[:class]}"}>
|
||||
<%= case values |> Map.get(key) do %>
|
||||
<%= {_custom_sort_value, value} -> %> <%= value %>
|
||||
<% value -> %> <%= value %>
|
||||
<% {_custom_sort_value, value} -> %>
|
||||
<%= value %>
|
||||
<% value -> %>
|
||||
<%= value %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
|
Reference in New Issue
Block a user