forked from shibao/cannery
improve code in table components
This commit is contained in:
parent
58b32817ba
commit
0894293620
@ -89,19 +89,20 @@ defmodule CanneryWeb.Components.AmmoGroupTableComponent do
|
||||
[%{label: gettext("Ammo type"), key: :ammo_type} | columns]
|
||||
end
|
||||
|
||||
extra_data = %{
|
||||
current_user: current_user,
|
||||
ammo_type: ammo_type,
|
||||
columns: columns,
|
||||
container: container,
|
||||
actions: actions,
|
||||
range: range
|
||||
}
|
||||
|
||||
rows =
|
||||
ammo_groups
|
||||
|> Repo.preload([:ammo_type, :container])
|
||||
|> Enum.map(fn ammo_group ->
|
||||
ammo_group
|
||||
|> get_row_data_for_ammo_group(%{
|
||||
current_user: current_user,
|
||||
ammo_type: ammo_type,
|
||||
columns: columns,
|
||||
container: container,
|
||||
actions: actions,
|
||||
range: range
|
||||
})
|
||||
ammo_group |> get_row_data_for_ammo_group(extra_data)
|
||||
end)
|
||||
|
||||
socket |> assign(columns: columns, rows: rows)
|
||||
|
@ -121,11 +121,12 @@ defmodule CanneryWeb.Components.AmmoTypeTableComponent do
|
||||
%{label: nil, key: "actions", type: :actions, sortable: false}
|
||||
])
|
||||
|
||||
extra_data = %{actions: actions, current_user: current_user}
|
||||
|
||||
rows =
|
||||
ammo_types
|
||||
|> Enum.map(fn ammo_type ->
|
||||
ammo_type
|
||||
|> get_ammo_type_values(columns, %{actions: actions, current_user: current_user})
|
||||
ammo_type |> get_ammo_type_values(columns, extra_data)
|
||||
end)
|
||||
|
||||
socket |> assign(columns: columns, rows: rows)
|
||||
|
@ -66,15 +66,16 @@ defmodule CanneryWeb.Components.ContainerTableComponent do
|
||||
end)
|
||||
end)
|
||||
|
||||
extra_data = %{
|
||||
current_user: current_user,
|
||||
tag_actions: tag_actions,
|
||||
actions: actions
|
||||
}
|
||||
|
||||
rows =
|
||||
containers
|
||||
|> Enum.map(fn container ->
|
||||
container
|
||||
|> get_row_data_for_container(columns, %{
|
||||
current_user: current_user,
|
||||
tag_actions: tag_actions,
|
||||
actions: actions
|
||||
})
|
||||
container |> get_row_data_for_container(columns, extra_data)
|
||||
end)
|
||||
|
||||
socket
|
||||
|
@ -555,9 +555,9 @@ msgstr "Schießkladde"
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:71
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:78
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:152
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:224
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:153
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:225
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:180
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:136
|
||||
@ -661,8 +661,8 @@ msgstr "Editiere %{name} Tags"
|
||||
msgid "Rounds:"
|
||||
msgstr "Patronen:"
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:221
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:178
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:222
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:142
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No cost information"
|
||||
@ -856,7 +856,7 @@ msgstr "Behälter"
|
||||
msgid "Show used"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:192
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:193
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{percentage}%"
|
||||
@ -1044,7 +1044,7 @@ msgid "Edit %{ammo_type_name}"
|
||||
msgstr "%{name} bearbeiten"
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:39
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:230
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:231
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Empty"
|
||||
msgstr ""
|
||||
@ -1094,7 +1094,7 @@ msgstr ""
|
||||
msgid "Last used on:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:177
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:178
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Never used"
|
||||
msgstr ""
|
||||
|
@ -538,9 +538,9 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:71
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:78
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:152
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:224
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:153
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:225
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:180
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:136
|
||||
@ -644,8 +644,8 @@ msgstr ""
|
||||
msgid "Rounds:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:221
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:178
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:222
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:142
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No cost information"
|
||||
@ -839,7 +839,7 @@ msgstr ""
|
||||
msgid "Show used"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:192
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:193
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{percentage}%"
|
||||
@ -1027,7 +1027,7 @@ msgid "Edit %{ammo_type_name}"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:39
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:230
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:231
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Empty"
|
||||
msgstr ""
|
||||
@ -1077,7 +1077,7 @@ msgstr ""
|
||||
msgid "Last used on:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:177
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:178
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Never used"
|
||||
msgstr ""
|
||||
|
@ -539,9 +539,9 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:71
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:78
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:152
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:224
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:153
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:225
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:180
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:136
|
||||
@ -645,8 +645,8 @@ msgstr ""
|
||||
msgid "Rounds:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:221
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:178
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:222
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:142
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No cost information"
|
||||
@ -840,7 +840,7 @@ msgstr ""
|
||||
msgid "Show used"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:192
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:193
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{percentage}%"
|
||||
@ -1028,7 +1028,7 @@ msgid "Edit %{ammo_type_name}"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:39
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:230
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:231
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Empty"
|
||||
msgstr ""
|
||||
@ -1078,7 +1078,7 @@ msgstr ""
|
||||
msgid "Last used on:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:177
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:178
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Never used"
|
||||
msgstr ""
|
||||
|
@ -553,9 +553,9 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:71
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:78
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:152
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:224
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:153
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:225
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:180
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:136
|
||||
@ -659,8 +659,8 @@ msgstr ""
|
||||
msgid "Rounds:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:221
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:178
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:222
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:142
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No cost information"
|
||||
@ -854,7 +854,7 @@ msgstr ""
|
||||
msgid "Show used"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:192
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:193
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{percentage}%"
|
||||
@ -1042,7 +1042,7 @@ msgid "Edit %{ammo_type_name}"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:39
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:230
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:231
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Empty"
|
||||
msgstr ""
|
||||
@ -1092,7 +1092,7 @@ msgstr ""
|
||||
msgid "Last used on:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:177
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:178
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Never used"
|
||||
msgstr ""
|
||||
|
@ -557,9 +557,9 @@ msgstr "Évènements de tir"
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:71
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:78
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:152
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:224
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:153
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:225
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:180
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:136
|
||||
@ -663,8 +663,8 @@ msgstr "Éditer les tags de %{name}"
|
||||
msgid "Rounds:"
|
||||
msgstr "Cartouches :"
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:221
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:178
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:222
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:142
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No cost information"
|
||||
@ -859,7 +859,7 @@ msgstr "Conteneur"
|
||||
msgid "Show used"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:192
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:193
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{percentage}%"
|
||||
@ -1047,7 +1047,7 @@ msgid "Edit %{ammo_type_name}"
|
||||
msgstr "Éditer %{name}"
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:39
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:230
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:231
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Empty"
|
||||
msgstr ""
|
||||
@ -1097,7 +1097,7 @@ msgstr ""
|
||||
msgid "Last used on:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:177
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:178
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Never used"
|
||||
msgstr ""
|
||||
|
@ -549,9 +549,9 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:71
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:78
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:152
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:224
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:153
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:225
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:180
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:136
|
||||
@ -655,8 +655,8 @@ msgstr ""
|
||||
msgid "Rounds:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:221
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:178
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:222
|
||||
#: lib/cannery_web/components/ammo_type_table_component.ex:179
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:142
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No cost information"
|
||||
@ -850,7 +850,7 @@ msgstr ""
|
||||
msgid "Show used"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:192
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:193
|
||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{percentage}%"
|
||||
@ -1038,7 +1038,7 @@ msgid "Edit %{ammo_type_name}"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_card.ex:39
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:230
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:231
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Empty"
|
||||
msgstr ""
|
||||
@ -1088,7 +1088,7 @@ msgstr ""
|
||||
msgid "Last used on:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:177
|
||||
#: lib/cannery_web/components/ammo_group_table_component.ex:178
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Never used"
|
||||
msgstr ""
|
||||
|
Loading…
Reference in New Issue
Block a user