forked from shibao/cannery
		
	fix some values not being sorted in tables properly
This commit is contained in:
		| @@ -3,6 +3,7 @@ | |||||||
| - Show ammo groups under a type in a table by default | - Show ammo groups under a type in a table by default | ||||||
| - Only show historical ammo type information when displaying "Show used" in table | - Only show historical ammo type information when displaying "Show used" in table | ||||||
| - Only show historical ammo group information when displaying "Show used" in table | - Only show historical ammo group information when displaying "Show used" in table | ||||||
|  | - Fix some values not being sorted in tables properly | ||||||
|  |  | ||||||
| # v0.8.5 | # v0.8.5 | ||||||
| - Add link in readme to github mirror | - Add link in readme to github mirror | ||||||
|   | |||||||
| @@ -167,10 +167,10 @@ defmodule CanneryWeb.Components.AmmoGroupTableComponent do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_value_for_key(:price_paid, %{price_paid: nil}, _additional_data), |   defp get_value_for_key(:price_paid, %{price_paid: nil}, _additional_data), | ||||||
|     do: {nil, gettext("No cost information")} |     do: {0, gettext("No cost information")} | ||||||
|  |  | ||||||
|   defp get_value_for_key(:price_paid, %{price_paid: price_paid}, _additional_data), |   defp get_value_for_key(:price_paid, %{price_paid: price_paid}, _additional_data), | ||||||
|     do: gettext("$%{amount}", amount: display_currency(price_paid)) |     do: {price_paid, gettext("$%{amount}", amount: display_currency(price_paid))} | ||||||
|  |  | ||||||
|   defp get_value_for_key(:purchased_on, %{purchased_on: purchased_on} = assigns, _additional_data) do |   defp get_value_for_key(:purchased_on, %{purchased_on: purchased_on} = assigns, _additional_data) do | ||||||
|     {purchased_on, |     {purchased_on, | ||||||
| @@ -203,9 +203,8 @@ defmodule CanneryWeb.Components.AmmoGroupTableComponent do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_value_for_key(:remaining, ammo_group, %{current_user: current_user}) do |   defp get_value_for_key(:remaining, ammo_group, %{current_user: current_user}) do | ||||||
|     gettext("%{percentage}%", |     percentage = ammo_group |> Ammo.get_percentage_remaining(current_user) | ||||||
|       percentage: ammo_group |> Ammo.get_percentage_remaining(current_user) |     {percentage, gettext("%{percentage}%", percentage: percentage)} | ||||||
|     ) |  | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_value_for_key(:actions, ammo_group, %{actions: actions}) do |   defp get_value_for_key(:actions, ammo_group, %{actions: actions}) do | ||||||
| @@ -245,13 +244,15 @@ defmodule CanneryWeb.Components.AmmoGroupTableComponent do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_value_for_key(:cpr, %{price_paid: nil}, _additional_data), |   defp get_value_for_key(:cpr, %{price_paid: nil}, _additional_data), | ||||||
|     do: {nil, gettext("No cost information")} |     do: {0, gettext("No cost information")} | ||||||
|  |  | ||||||
|   defp get_value_for_key(:cpr, %{id: ammo_group_id}, %{cprs: cprs}), |   defp get_value_for_key(:cpr, %{id: ammo_group_id}, %{cprs: cprs}) do | ||||||
|     do: gettext("$%{amount}", amount: display_currency(Map.fetch!(cprs, ammo_group_id))) |     amount = Map.fetch!(cprs, ammo_group_id) | ||||||
|  |     {amount, gettext("$%{amount}", amount: display_currency(amount))} | ||||||
|  |   end | ||||||
|  |  | ||||||
|   defp get_value_for_key(:count, %{count: count}, _additional_data), |   defp get_value_for_key(:count, %{count: count}, _additional_data), | ||||||
|     do: if(count == 0, do: gettext("Empty"), else: count) |     do: if(count == 0, do: {0, gettext("Empty")}, else: count) | ||||||
|  |  | ||||||
|   defp get_value_for_key(key, ammo_group, _additional_data), do: ammo_group |> Map.get(key) |   defp get_value_for_key(key, ammo_group, _additional_data), do: ammo_group |> Map.get(key) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -183,7 +183,7 @@ defmodule CanneryWeb.Components.AmmoTypeTableComponent do | |||||||
|     do: ammo_type |> Map.get(key) |> humanize() |     do: ammo_type |> Map.get(key) |> humanize() | ||||||
|  |  | ||||||
|   defp get_ammo_type_value(:round_count, _key, %{id: ammo_type_id}, %{round_counts: round_counts}), |   defp get_ammo_type_value(:round_count, _key, %{id: ammo_type_id}, %{round_counts: round_counts}), | ||||||
|     do: Map.get(round_counts, ammo_type_id) |     do: Map.get(round_counts, ammo_type_id, 0) | ||||||
|  |  | ||||||
|   defp get_ammo_type_value( |   defp get_ammo_type_value( | ||||||
|          :historical_round_count, |          :historical_round_count, | ||||||
| @@ -191,7 +191,7 @@ defmodule CanneryWeb.Components.AmmoTypeTableComponent do | |||||||
|          %{id: ammo_type_id}, |          %{id: ammo_type_id}, | ||||||
|          %{historical_round_counts: historical_round_counts} |          %{historical_round_counts: historical_round_counts} | ||||||
|        ) do |        ) do | ||||||
|     Map.get(historical_round_counts, ammo_type_id) |     Map.get(historical_round_counts, ammo_type_id, 0) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_ammo_type_value( |   defp get_ammo_type_value( | ||||||
| @@ -200,7 +200,7 @@ defmodule CanneryWeb.Components.AmmoTypeTableComponent do | |||||||
|          %{id: ammo_type_id}, |          %{id: ammo_type_id}, | ||||||
|          %{used_counts: used_counts} |          %{used_counts: used_counts} | ||||||
|        ) do |        ) do | ||||||
|     Map.get(used_counts, ammo_type_id) |     Map.get(used_counts, ammo_type_id, 0) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_ammo_type_value( |   defp get_ammo_type_value( | ||||||
| @@ -209,7 +209,7 @@ defmodule CanneryWeb.Components.AmmoTypeTableComponent do | |||||||
|          %{id: ammo_type_id}, |          %{id: ammo_type_id}, | ||||||
|          %{historical_pack_counts: historical_pack_counts} |          %{historical_pack_counts: historical_pack_counts} | ||||||
|        ) do |        ) do | ||||||
|     Map.get(historical_pack_counts, ammo_type_id) |     Map.get(historical_pack_counts, ammo_type_id, 0) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_ammo_type_value( |   defp get_ammo_type_value( | ||||||
| @@ -231,19 +231,20 @@ defmodule CanneryWeb.Components.AmmoTypeTableComponent do | |||||||
|          %{average_costs: average_costs} |          %{average_costs: average_costs} | ||||||
|        ) do |        ) do | ||||||
|     case Map.get(average_costs, ammo_type_id) do |     case Map.get(average_costs, ammo_type_id) do | ||||||
|       nil -> gettext("No cost information") |       nil -> {0, gettext("No cost information")} | ||||||
|       count -> gettext("$%{amount}", amount: display_currency(count)) |       count -> {count, gettext("$%{amount}", amount: display_currency(count))} | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_ammo_type_value(:name, _key, ammo_type, _other_data) do |   defp get_ammo_type_value(:name, _key, %{name: ammo_type_name} = ammo_type, _other_data) do | ||||||
|     assigns = %{ammo_type: ammo_type} |     assigns = %{ammo_type: ammo_type} | ||||||
|  |  | ||||||
|     ~H""" |     {ammo_type_name, | ||||||
|     <.link navigate={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)} class="link"> |      ~H""" | ||||||
|       <%= @ammo_type.name %> |      <.link navigate={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)} class="link"> | ||||||
|     </.link> |        <%= @ammo_type.name %> | ||||||
|     """ |      </.link> | ||||||
|  |      """} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_ammo_type_value(:actions, _key, ammo_type, %{actions: actions}) do |   defp get_ammo_type_value(:actions, _key, ammo_type, %{actions: actions}) do | ||||||
|   | |||||||
| @@ -621,7 +621,7 @@ msgid "Rounds:" | |||||||
| msgstr "Patronen:" | msgstr "Patronen:" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:170 | #: lib/cannery_web/components/ammo_group_table_component.ex:170 | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:248 | #: lib/cannery_web/components/ammo_group_table_component.ex:247 | ||||||
| #: lib/cannery_web/components/ammo_type_table_component.ex:234 | #: lib/cannery_web/components/ammo_type_table_component.ex:234 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -809,7 +809,7 @@ msgstr "Behälter" | |||||||
| msgid "Show used" | msgid "Show used" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:206 | #: lib/cannery_web/components/ammo_group_table_component.ex:207 | ||||||
| #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "%{percentage}%" | msgid "%{percentage}%" | ||||||
| @@ -996,7 +996,7 @@ msgstr "" | |||||||
| msgid "Edit %{ammo_type_name}" | msgid "Edit %{ammo_type_name}" | ||||||
| msgstr "%{name} bearbeiten" | msgstr "%{name} bearbeiten" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:254 | #: lib/cannery_web/components/ammo_group_table_component.ex:255 | ||||||
| #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Empty" | msgid "Empty" | ||||||
|   | |||||||
| @@ -615,7 +615,7 @@ msgid "Rounds:" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:170 | #: lib/cannery_web/components/ammo_group_table_component.ex:170 | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:248 | #: lib/cannery_web/components/ammo_group_table_component.ex:247 | ||||||
| #: lib/cannery_web/components/ammo_type_table_component.ex:234 | #: lib/cannery_web/components/ammo_type_table_component.ex:234 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -803,7 +803,7 @@ msgstr "" | |||||||
| msgid "Show used" | msgid "Show used" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:206 | #: lib/cannery_web/components/ammo_group_table_component.ex:207 | ||||||
| #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "%{percentage}%" | msgid "%{percentage}%" | ||||||
| @@ -990,7 +990,7 @@ msgstr "" | |||||||
| msgid "Edit %{ammo_type_name}" | msgid "Edit %{ammo_type_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:254 | #: lib/cannery_web/components/ammo_group_table_component.ex:255 | ||||||
| #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Empty" | msgid "Empty" | ||||||
|   | |||||||
| @@ -615,7 +615,7 @@ msgid "Rounds:" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:170 | #: lib/cannery_web/components/ammo_group_table_component.ex:170 | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:248 | #: lib/cannery_web/components/ammo_group_table_component.ex:247 | ||||||
| #: lib/cannery_web/components/ammo_type_table_component.ex:234 | #: lib/cannery_web/components/ammo_type_table_component.ex:234 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -803,7 +803,7 @@ msgstr "" | |||||||
| msgid "Show used" | msgid "Show used" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:206 | #: lib/cannery_web/components/ammo_group_table_component.ex:207 | ||||||
| #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "%{percentage}%" | msgid "%{percentage}%" | ||||||
| @@ -990,7 +990,7 @@ msgstr "" | |||||||
| msgid "Edit %{ammo_type_name}" | msgid "Edit %{ammo_type_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:254 | #: lib/cannery_web/components/ammo_group_table_component.ex:255 | ||||||
| #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Empty" | msgid "Empty" | ||||||
|   | |||||||
| @@ -622,7 +622,7 @@ msgid "Rounds:" | |||||||
| msgstr "Balas:" | msgstr "Balas:" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:170 | #: lib/cannery_web/components/ammo_group_table_component.ex:170 | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:248 | #: lib/cannery_web/components/ammo_group_table_component.ex:247 | ||||||
| #: lib/cannery_web/components/ammo_type_table_component.ex:234 | #: lib/cannery_web/components/ammo_type_table_component.ex:234 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -811,7 +811,7 @@ msgstr "Contenedor:" | |||||||
| msgid "Show used" | msgid "Show used" | ||||||
| msgstr "Mostrar usadas" | msgstr "Mostrar usadas" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:206 | #: lib/cannery_web/components/ammo_group_table_component.ex:207 | ||||||
| #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "%{percentage}%" | msgid "%{percentage}%" | ||||||
| @@ -998,7 +998,7 @@ msgstr "" | |||||||
| msgid "Edit %{ammo_type_name}" | msgid "Edit %{ammo_type_name}" | ||||||
| msgstr "Editar %{ammo_type_name}" | msgstr "Editar %{ammo_type_name}" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:254 | #: lib/cannery_web/components/ammo_group_table_component.ex:255 | ||||||
| #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Empty" | msgid "Empty" | ||||||
|   | |||||||
| @@ -623,7 +623,7 @@ msgid "Rounds:" | |||||||
| msgstr "Cartouches :" | msgstr "Cartouches :" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:170 | #: lib/cannery_web/components/ammo_group_table_component.ex:170 | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:248 | #: lib/cannery_web/components/ammo_group_table_component.ex:247 | ||||||
| #: lib/cannery_web/components/ammo_type_table_component.ex:234 | #: lib/cannery_web/components/ammo_type_table_component.ex:234 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -812,7 +812,7 @@ msgstr "Conteneur" | |||||||
| msgid "Show used" | msgid "Show used" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:206 | #: lib/cannery_web/components/ammo_group_table_component.ex:207 | ||||||
| #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "%{percentage}%" | msgid "%{percentage}%" | ||||||
| @@ -999,7 +999,7 @@ msgstr "" | |||||||
| msgid "Edit %{ammo_type_name}" | msgid "Edit %{ammo_type_name}" | ||||||
| msgstr "Éditer %{name}" | msgstr "Éditer %{name}" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:254 | #: lib/cannery_web/components/ammo_group_table_component.ex:255 | ||||||
| #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Empty" | msgid "Empty" | ||||||
|   | |||||||
| @@ -617,7 +617,7 @@ msgid "Rounds:" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:170 | #: lib/cannery_web/components/ammo_group_table_component.ex:170 | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:248 | #: lib/cannery_web/components/ammo_group_table_component.ex:247 | ||||||
| #: lib/cannery_web/components/ammo_type_table_component.ex:234 | #: lib/cannery_web/components/ammo_type_table_component.ex:234 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:139 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -805,7 +805,7 @@ msgstr "" | |||||||
| msgid "Show used" | msgid "Show used" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:206 | #: lib/cannery_web/components/ammo_group_table_component.ex:207 | ||||||
| #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_group_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "%{percentage}%" | msgid "%{percentage}%" | ||||||
| @@ -992,7 +992,7 @@ msgstr "" | |||||||
| msgid "Edit %{ammo_type_name}" | msgid "Edit %{ammo_type_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/ammo_group_table_component.ex:254 | #: lib/cannery_web/components/ammo_group_table_component.ex:255 | ||||||
| #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | #: lib/cannery_web/components/core_components/ammo_group_card.html.heex:17 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Empty" | msgid "Empty" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user