diff --git a/lib/cannery/ammo/ammo_type.ex b/lib/cannery/ammo/ammo_type.ex index fcd4194..dbad5d2 100644 --- a/lib/cannery/ammo/ammo_type.ex +++ b/lib/cannery/ammo/ammo_type.ex @@ -24,6 +24,7 @@ defmodule Cannery.Ammo.AmmoType do field :case_material, :string field :grains, :integer field :pressure, :string + field :primer_type, :string field :rimfire, :boolean, null: false, default: false field :tracer, :boolean, null: false, default: false field :incendiary, :boolean, null: false, default: false @@ -41,21 +42,22 @@ defmodule Cannery.Ammo.AmmoType do @type t :: %AmmoType{ id: id(), name: String.t(), - desc: String.t(), - bullet_type: String.t(), - bullet_core: String.t(), - cartridge: String.t(), - caliber: String.t(), - case_material: String.t(), - grains: integer(), - pressure: String.t(), + desc: String.t() | nil, + bullet_type: String.t() | nil, + bullet_core: String.t() | nil, + cartridge: String.t() | nil, + caliber: String.t() | nil, + case_material: String.t() | nil, + grains: integer() | nil, + pressure: String.t() | nil, + primer_type: String.t() | nil, rimfire: boolean(), tracer: boolean(), incendiary: boolean(), blank: boolean(), corrosive: boolean(), - manufacturer: String.t(), - sku: String.t(), + manufacturer: String.t() | nil, + sku: String.t() | nil, ammo_groups: [AmmoGroup.t()] | nil, inserted_at: NaiveDateTime.t(), updated_at: NaiveDateTime.t() @@ -77,6 +79,7 @@ defmodule Cannery.Ammo.AmmoType do :case_material, :grains, :pressure, + :primer_type, :rimfire, :tracer, :incendiary, diff --git a/lib/cannery_web/live/ammo_group_live/index.html.heex b/lib/cannery_web/live/ammo_group_live/index.html.heex index b32e68a..6169113 100644 --- a/lib/cannery_web/live/ammo_group_live/index.html.heex +++ b/lib/cannery_web/live/ammo_group_live/index.html.heex @@ -43,7 +43,9 @@ - $ <%= ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %> + <%= if ammo_group.price_paid do %> + $ <%= ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %> + <% end %> diff --git a/lib/cannery_web/live/ammo_type_live/ammo_type_card.ex b/lib/cannery_web/live/ammo_type_live/ammo_type_card.ex deleted file mode 100644 index a985d1a..0000000 --- a/lib/cannery_web/live/ammo_type_live/ammo_type_card.ex +++ /dev/null @@ -1,46 +0,0 @@ -defmodule CanneryWeb.AmmoTypeLive.AmmoTypeCard do - @moduledoc """ - Display card for an ammo type - """ - - use CanneryWeb, :component - alias Cannery.Repo - alias CanneryWeb.Endpoint - - def ammo_group_card(assigns) do - assigns = assigns |> assign(:ammo_group, assigns.ammo_group |> Repo.preload(:ammo_type)) - - ~H""" -
- <%= live_redirect to: Routes.ammo_group_show_path(Endpoint, :show, @ammo_group), - class: "mb-2 link" do %> -

- <%= @ammo_group.ammo_type.name %> -

- <% end %> - -
- - Count: <%= @ammo_group.count %> - - - <%= if @ammo_group.notes do %> - - Notes: <%= @ammo_group.notes %> - - <% end %> - - <%= if @ammo_group.price_paid do %> - - Price paid: $ <%= @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %> - - <% end %> -
-
- """ - end -end diff --git a/lib/cannery_web/live/ammo_type_live/form_component.ex b/lib/cannery_web/live/ammo_type_live/form_component.ex index 57aecec..45d72cc 100644 --- a/lib/cannery_web/live/ammo_type_live/form_component.ex +++ b/lib/cannery_web/live/ammo_type_live/form_component.ex @@ -117,6 +117,13 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do ) %> <%= error_tag(f, :pressure, "col-span-3 text-center") %> + <%= label(f, :primer_type, class: "mr-4 title text-lg text-primary-500") %> + <%= text_input(f, :primer_type, + class: "text-center col-span-2 input input-primary", + placeholder: "Boxer" + ) %> + <%= error_tag(f, :primer_type, "col-span-3 text-center") %> + <%= label(f, :rimfire, class: "mr-4 title text-lg text-primary-500") %> <%= checkbox(f, :rimfire, class: "text-center col-span-2 checkbox") %> <%= error_tag(f, :rimfire, "col-span-3 text-center") %> diff --git a/lib/cannery_web/live/ammo_type_live/index.html.heex b/lib/cannery_web/live/ammo_type_live/index.html.heex index 7641ac5..53feaf1 100644 --- a/lib/cannery_web/live/ammo_type_live/index.html.heex +++ b/lib/cannery_web/live/ammo_type_live/index.html.heex @@ -31,6 +31,7 @@ :case_material, :grains, :pressure, + :primer_type, :rimfire, :tracer, :incendiary, @@ -58,7 +59,8 @@ :caliber, :case_material, :grains, - :pressure + :pressure, + :primer_type ] do %> <%= ammo_type |> Map.get(field) %> 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 353aa55..a62e26d 100644 --- a/lib/cannery_web/live/ammo_type_live/show.html.heex +++ b/lib/cannery_web/live/ammo_type_live/show.html.heex @@ -36,11 +36,12 @@ :caliber, :case_material, :grains, - :pressure + :pressure, + :primer_type ] do %> <%= if @ammo_type |> Map.get(field) do %>

- <%= field |> humanize() %>: + <%= field |> humanize() %> :

@@ -57,7 +58,7 @@ :corrosive ] do %>

- <%= field |> humanize() %>: + <%= field |> humanize() %> :

@@ -68,7 +69,7 @@ <%= for field <- [:manufacturer, :sku] do %> <%= if @ammo_type |> Map.get(field) do %>

- <%= field |> humanize() %>: + <%= field |> humanize() %> :

diff --git a/lib/cannery_web/live/modal_component.ex b/lib/cannery_web/live/modal_component.ex index 640d96f..0c70ae7 100644 --- a/lib/cannery_web/live/modal_component.ex +++ b/lib/cannery_web/live/modal_component.ex @@ -24,8 +24,8 @@ defmodule CanneryWeb.ModalComponent do flex flex-col justify-start items-center bg-white border-2 rounded-lg"> <%= live_patch to: @return_to, - class: "absolute top-8 right-10 text-gray-500 hover:text-gray-800 - transition-all duration-500 ease-in-out" do %> + class: + "absolute top-8 right-10 text-gray-500 hover:text-gray-800 transition-all duration-500 ease-in-out" do %> <% end %>
diff --git a/lib/cannery_web/templates/layout/live.html.heex b/lib/cannery_web/templates/layout/live.html.heex index 93c044f..5690388 100644 --- a/lib/cannery_web/templates/layout/live.html.heex +++ b/lib/cannery_web/templates/layout/live.html.heex @@ -1,4 +1,4 @@ -
+
diff --git a/priv/repo/migrations/20210903015537_create_ammo_types.exs b/priv/repo/migrations/20210903015537_create_ammo_types.exs index 628e715..5f919c9 100644 --- a/priv/repo/migrations/20210903015537_create_ammo_types.exs +++ b/priv/repo/migrations/20210903015537_create_ammo_types.exs @@ -15,6 +15,7 @@ defmodule Cannery.Repo.Migrations.CreateAmmoTypes do add :case_material, :string add :grains, :integer add :pressure, :string + add :primer_type, :string add :rimfire, :boolean, null: false, default: false add :tracer, :boolean, null: false, default: false add :incendiary, :boolean, null: false, default: false