diff --git a/CHANGELOG.md b/CHANGELOG.md index c7627c81..56e3eba5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Show tags on containers - Add "Cannery" to page titles - Don't show true/false column for ammo types if all values are false +- Fix ammo type firing type display # 0.1.0 diff --git a/lib/cannery_web/live/ammo_type_live/index.ex b/lib/cannery_web/live/ammo_type_live/index.ex index 52b3a868..f932f823 100644 --- a/lib/cannery_web/live/ammo_type_live/index.ex +++ b/lib/cannery_web/live/ammo_type_live/index.ex @@ -61,7 +61,7 @@ defmodule CanneryWeb.AmmoTypeLive.Index do {gettext("Grains"), :grains, :string}, {gettext("Pressure"), :pressure, :string}, {gettext("Primer type"), :primer_type, :string}, - {gettext("Rimfire"), :rimfire, :boolean}, + {gettext("Firing type"), :firing_type, :string}, {gettext("Tracer"), :tracer, :boolean}, {gettext("Incendiary"), :incendiary, :boolean}, {gettext("Blank"), :blank, :boolean}, @@ -69,17 +69,12 @@ defmodule CanneryWeb.AmmoTypeLive.Index do {gettext("Manufacturer"), :manufacturer, :string}, {gettext("UPC"), :upc, :string} ] - # filter columns to only used ones - |> Enum.filter(fn {_label, field, _type} -> - ammo_types |> Enum.any?(fn ammo_type -> not (ammo_type |> Map.get(field) |> is_nil()) end) - end) - # if boolean, remove if all values are false |> Enum.filter(fn {_label, field, type} -> - if type == :boolean do - ammo_types |> Enum.any?(fn ammo_type -> not (ammo_type |> Map.get(field) == false) end) - else - true - end + # remove columns if all values match defaults + default_value = if type == :boolean, do: false, else: nil + + ammo_types + |> Enum.any?(fn ammo_type -> not (ammo_type |> Map.get(field) == default_value) end) end) socket |> assign(ammo_types: ammo_types, columns_to_display: columns_to_display) diff --git a/lib/cannery_web/live/ammo_type_live/show.html.heex b/lib/cannery_web/live/ammo_type_live/show.html.heex index b4b2934c..61f6e12e 100644 --- a/lib/cannery_web/live/ammo_type_live/show.html.heex +++ b/lib/cannery_web/live/ammo_type_live/show.html.heex @@ -35,70 +35,59 @@
-
- <%= for {field_name, field} <- [ - {gettext("Bullet type"), :bullet_type}, - {gettext("Bullet core"), :bullet_core}, - {gettext("Cartridge"), :cartridge}, - {gettext("Caliber"), :caliber}, - {gettext("Case material"), :case_material}, - {gettext("Jacket type"), :jacket_type}, - {gettext("Muzzle velocity"), :muzzle_velocity}, - {gettext("Powder type"), :powder_type}, - {gettext("Powder grains per charge"), :powder_grains_per_charge}, - {gettext("Grains"), :grains}, - {gettext("Pressure"), :pressure}, - {gettext("Primer type"), :primer_type} +
+ <%= for {field_name, field, type} <- [ + {gettext("Bullet type"), :bullet_type, :string}, + {gettext("Bullet core"), :bullet_core, :string}, + {gettext("Cartridge"), :cartridge, :string}, + {gettext("Caliber"), :caliber, :string}, + {gettext("Case material"), :case_material, :string}, + {gettext("Jacket type"), :jacket_type, :string}, + {gettext("Muzzle velocity"), :muzzle_velocity, :string}, + {gettext("Powder type"), :powder_type, :string}, + {gettext("Powder grains per charge"), :powder_grains_per_charge, :string}, + {gettext("Grains"), :grains, :string}, + {gettext("Pressure"), :pressure, :string}, + {gettext("Primer type"), :primer_type, :string}, + {gettext("Firing type"), :firing_type, :string}, + {gettext("Tracer"), :tracer, :boolean}, + {gettext("Incendiary"), :incendiary, :boolean}, + {gettext("Blank"), :blank, :boolean}, + {gettext("Corrosive"), :corrosive, :boolean}, + {gettext("Manufacturer"), :manufacturer, :string}, + {gettext("UPC"), :upc, :string} ] do %> <%= if @ammo_type |> Map.get(field) do %> -

+

<%= field_name %>:

- - <%= @ammo_type |> Map.get(field) %> - - <% end %> - <% end %> - - <%= for {field_name, field} <- [ - {"Rimfire", :rimfire}, - {"Tracer", :tracer}, - {"Incendiary", :incendiary}, - {"Blank", :blank}, - {"Corrosive", :corrosive} - ] do %> -

- <%= field_name %>: -

- - - <%= @ammo_type |> Map.get(field) |> humanize() %> - - <% end %> - - <%= for {field_name, field} <- [{"Manufacturer", :manufacturer}, {"UPC", :upc}] do %> - <%= if @ammo_type |> Map.get(field) do %> -

- <%= field_name %>: -

- - - <%= @ammo_type |> Map.get(field) %> + + <%= case type do %> + <% :boolean -> %> + <%= @ammo_type |> Map.get(field) |> humanize() %> + <% _ -> %> + <%= @ammo_type |> Map.get(field) %> + <% end %> <% end %> <% end %> <%= if @avg_cost_per_round do %> -

+

<%= gettext("Average Price paid") %>:

- + <%= gettext("$%{amount}", amount: @avg_cost_per_round |> :erlang.float_to_binary(decimals: 2) ) %> + <% else %> +

+ <%= gettext("No cost information") %> + <%= display_emoji("😔") %> +

<% end %>
@@ -107,6 +96,7 @@
<%= if @ammo_groups |> Enum.empty?() do %> <%= gettext("No ammo for this type") %> + <%= display_emoji("😔") %> <% else %>
<%= for ammo_group <- @ammo_groups do %> diff --git a/lib/cannery_web/live/container_live/edit_tags_component.html.heex b/lib/cannery_web/live/container_live/edit_tags_component.html.heex index a287d29f..b42c5393 100644 --- a/lib/cannery_web/live/container_live/edit_tags_component.html.heex +++ b/lib/cannery_web/live/container_live/edit_tags_component.html.heex @@ -20,8 +20,8 @@ container_name: @container.name ) ] do %> - <%= tag.name %> - + <%= tag.name %> + <% end %> <% end %> @@ -34,7 +34,7 @@
<%= unless tag_options(@tags, @container) |> Enum.empty?() do %> -
+
<.form let={f} @@ -44,7 +44,9 @@ phx-target={@myself} phx-submit="save" > - <%= select(f, :tag_id, tag_options(@tags, @container), class: "text-center col-span-2 input input-primary") %> + <%= select(f, :tag_id, tag_options(@tags, @container), + class: "text-center col-span-2 input input-primary" + ) %> <%= error_tag(f, :tag_id, "col-span-3 text-center") %> <%= submit(dgettext("actions", "Add"), diff --git a/lib/cannery_web/live/container_live/index.html.heex b/lib/cannery_web/live/container_live/index.html.heex index e9835ba2..6cfe1f64 100644 --- a/lib/cannery_web/live/container_live/index.html.heex +++ b/lib/cannery_web/live/container_live/index.html.heex @@ -31,7 +31,6 @@ <% end %>
- <%= live_patch to: Routes.container_index_path(Endpoint, :edit, container), class: "text-primary-600 link", data: [qa: "edit-#{container.id}"] do %> diff --git a/lib/cannery_web/live/container_live/show.ex b/lib/cannery_web/live/container_live/show.ex index 4e0393dd..36ae5856 100644 --- a/lib/cannery_web/live/container_live/show.ex +++ b/lib/cannery_web/live/container_live/show.ex @@ -86,7 +86,8 @@ defmodule CanneryWeb.ContainerLive.Show do @spec render_container(Socket.t(), Container.id(), User.t()) :: Socket.t() defp render_container(%{assigns: %{live_action: live_action}} = socket, id, current_user) do - %{name: container_name} = container = + %{name: container_name} = + container = Containers.get_container!(id, current_user) |> Repo.preload([:ammo_groups, :tags], force: true) diff --git a/priv/gettext/actions.pot b/priv/gettext/actions.pot index c850da3f..fb98e755 100644 --- a/priv/gettext/actions.pot +++ b/priv/gettext/actions.pot @@ -145,7 +145,7 @@ msgid "Why not add one?" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/add_tag_component.html.heex:17 +#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:52 msgid "Add" msgstr "" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index a5b4ab7f..61885faa 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -44,7 +44,7 @@ msgid "Ammo type" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/ammo_type_live/show.html.heex:94 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:78 msgid "Average Price paid" msgstr "" @@ -56,6 +56,7 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:154 #: lib/cannery_web/live/ammo_type_live/index.ex:67 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:55 msgid "Blank" msgstr "" @@ -115,6 +116,7 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:158 #: lib/cannery_web/live/ammo_type_live/index.ex:68 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:56 msgid "Corrosive" msgstr "" @@ -137,7 +139,7 @@ msgid "Description" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/components/container_card.ex:27 +#: lib/cannery_web/components/container_card.ex:31 #: lib/cannery_web/live/container_live/show.html.heex:8 msgid "Description:" msgstr "" @@ -164,12 +166,6 @@ msgstr "" msgid "Edit Ammo type" msgstr "" -#, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/index.ex:24 -#: lib/cannery_web/live/container_live/show.ex:89 -msgid "Edit Container" -msgstr "" - #, elixir-autogen, elixir-format #: lib/cannery_web/live/invite_live/index.ex:35 msgid "Edit Invite" @@ -205,6 +201,7 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:150 #: lib/cannery_web/live/ammo_type_live/index.ex:66 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:54 msgid "Incendiary" msgstr "" @@ -240,7 +237,7 @@ msgid "Listing Ammo types" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/index.ex:33 +#: lib/cannery_web/live/container_live/index.ex:38 msgid "Listing Containers" msgstr "" @@ -261,7 +258,7 @@ msgid "Location" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/components/container_card.ex:39 +#: lib/cannery_web/components/container_card.ex:43 #: lib/cannery_web/live/container_live/show.html.heex:20 msgid "Location:" msgstr "" @@ -279,6 +276,7 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:162 #: lib/cannery_web/live/ammo_type_live/index.ex:69 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:57 msgid "Manufacturer" msgstr "" @@ -307,7 +305,7 @@ msgid "New Ammo type" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/index.ex:29 +#: lib/cannery_web/live/container_live/index.ex:33 msgid "New Container" msgstr "" @@ -332,12 +330,12 @@ msgid "No Ammo Types" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/ammo_type_live/show.html.heex:109 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:98 msgid "No ammo for this type" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/show.html.heex:88 +#: lib/cannery_web/live/container_live/show.html.heex:77 msgid "No ammo groups in this container" msgstr "" @@ -352,6 +350,7 @@ msgid "No invites" msgstr "" #, elixir-autogen, elixir-format +#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:30 #: lib/cannery_web/live/tag_live/index.html.heex:10 msgid "No tags" msgstr "" @@ -407,11 +406,6 @@ msgstr "" msgid "Public Signups" msgstr "" -#, elixir-autogen, elixir-format -#: lib/cannery_web/live/ammo_type_live/index.ex:64 -msgid "Rimfire" -msgstr "" - #, elixir-autogen, elixir-format #: lib/cannery_web/live/home_live.ex:66 msgid "Secure:" @@ -442,11 +436,6 @@ msgstr "" msgid "Show Ammo type" msgstr "" -#, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/show.ex:88 -msgid "Show Container" -msgstr "" - #, elixir-autogen, elixir-format #: lib/cannery_web/live/home_live.ex:76 msgid "Simple:" @@ -464,7 +453,6 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/components/topbar.ex:40 -#: lib/cannery_web/live/container_live/show.html.heex:60 #: lib/cannery_web/live/tag_live/index.html.heex:3 msgid "Tags" msgstr "" @@ -492,6 +480,7 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:146 #: lib/cannery_web/live/ammo_type_live/index.ex:65 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:53 msgid "Tracer" msgstr "" @@ -502,7 +491,7 @@ msgid "Type" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/components/container_card.ex:33 +#: lib/cannery_web/components/container_card.ex:37 #: lib/cannery_web/live/container_live/show.html.heex:14 msgid "Type:" msgstr "" @@ -532,11 +521,6 @@ msgstr "" msgid "Your data stays with you, period" msgstr "" -#, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/show.ex:90 -msgid "Add Tag to Container" -msgstr "" - #, elixir-autogen, elixir-format #: lib/cannery_web/live/container_live/show.html.heex:49 msgid "No tags for this container" @@ -663,7 +647,7 @@ msgstr "" #: lib/cannery_web/components/ammo_group_card.ex:43 #: lib/cannery_web/live/ammo_group_live/index.html.heex:64 #: lib/cannery_web/live/ammo_group_live/show.html.heex:22 -#: lib/cannery_web/live/ammo_type_live/show.html.heex:98 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:82 msgid "$%{amount}" msgstr "" @@ -703,6 +687,7 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:168 #: lib/cannery_web/live/ammo_type_live/index.ex:70 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:58 msgid "UPC" msgstr "" @@ -734,6 +719,8 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:137 +#: lib/cannery_web/live/ammo_type_live/index.ex:64 +#: lib/cannery_web/live/ammo_type_live/show.html.heex:52 msgid "Firing type" msgstr "" @@ -746,3 +733,30 @@ msgstr "" #: lib/cannery_web/templates/layout/live.html.heex:37 msgid "Loading..." msgstr "" + +#, elixir-autogen, elixir-format +#: lib/cannery_web/live/container_live/index.ex:29 +#: lib/cannery_web/live/container_live/show.ex:97 +msgid "Edit %{name}" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/cannery_web/live/container_live/index.ex:48 +#: lib/cannery_web/live/container_live/show.ex:98 +msgid "Edit %{name} tags" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/cannery_web/components/container_card.ex:50 +msgid "Rounds:" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/cannery_web/live/container_live/show.ex:96 +msgid "Show %{name}" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/cannery_web/live/ammo_type_live/show.html.heex:88 +msgid "No cost information" +msgstr "" diff --git a/priv/gettext/errors.pot b/priv/gettext/errors.pot index 31c1c5d3..57ec4143 100644 --- a/priv/gettext/errors.pot +++ b/priv/gettext/errors.pot @@ -11,18 +11,18 @@ msgid "" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery/containers.ex:105 +#: lib/cannery/containers.ex:122 msgid "Container must be empty before deleting" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/index.ex:55 -#: lib/cannery_web/live/container_live/show.ex:74 +#: lib/cannery_web/live/container_live/index.ex:71 +#: lib/cannery_web/live/container_live/show.ex:73 msgid "Could not delete %{name}: %{error}" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/index.ex:43 +#: lib/cannery_web/live/container_live/index.ex:59 msgid "Could not find that container" msgstr "" @@ -132,7 +132,7 @@ msgid "Tag not found" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/add_tag_component.ex:35 +#: lib/cannery_web/live/container_live/edit_tags_component.ex:30 msgid "Tag could not be added" msgstr "" @@ -152,3 +152,8 @@ msgstr "" #: lib/cannery_web/controllers/user_auth.ex:161 msgid "You must confirm your account and log in to access this page." msgstr "" + +#, elixir-autogen, elixir-format +#: lib/cannery_web/live/container_live/edit_tags_component.ex:52 +msgid "Tag could not be removed" +msgstr "" diff --git a/priv/gettext/prompts.pot b/priv/gettext/prompts.pot index f97bfd65..4713a48a 100644 --- a/priv/gettext/prompts.pot +++ b/priv/gettext/prompts.pot @@ -38,8 +38,8 @@ msgid "%{name} enabled succesfully" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/index.ex:48 -#: lib/cannery_web/live/container_live/show.ex:64 +#: lib/cannery_web/live/container_live/index.ex:64 +#: lib/cannery_web/live/container_live/show.ex:63 msgid "%{name} has been deleted" msgstr "" @@ -85,7 +85,7 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_type_live/show.html.heex:29 -#: lib/cannery_web/live/container_live/index.html.heex:38 +#: lib/cannery_web/live/container_live/index.html.heex:46 #: lib/cannery_web/live/container_live/show.html.heex:37 #: lib/cannery_web/live/tag_live/index.html.heex:38 msgid "Are you sure you want to delete %{name}?" @@ -175,22 +175,22 @@ msgid "Your account has been deleted" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/show.html.heex:71 +#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:16 msgid "Are you sure you want to remove the %{tag_name} tag from %{container_name}?" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/add_tag_component.ex:40 +#: lib/cannery_web/live/container_live/edit_tags_component.ex:36 msgid "%{name} added successfully" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/show.ex:40 +#: lib/cannery_web/live/container_live/show.ex:39 msgid "%{tag_name} has been removed from %{container_name}" msgstr "" #, elixir-autogen, elixir-format -#: lib/cannery_web/live/container_live/add_tag_component.html.heex:19 +#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:54 msgid "Adding..." msgstr "" @@ -238,3 +238,8 @@ msgstr "" #: lib/cannery_web/live/invite_live/index.ex:123 msgid "Copied to clipboard" msgstr "" + +#, elixir-autogen, elixir-format +#: lib/cannery_web/live/container_live/edit_tags_component.ex:58 +msgid "%{name} removed successfully" +msgstr ""