- add primer_type to ammo type
- fix ammo type typespec - remove unused ammo type card - mix format
This commit is contained in:
parent
94b88f9f9e
commit
22c148e93b
@ -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,
|
||||
|
@ -43,7 +43,9 @@
|
||||
</td>
|
||||
|
||||
<td class="p-2">
|
||||
<%= if ammo_group.price_paid do %>
|
||||
$ <%= ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %>
|
||||
<% end %>
|
||||
</td>
|
||||
|
||||
<td class="p-2">
|
||||
|
@ -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"""
|
||||
<div
|
||||
id={"ammo_group-#{@ammo_group.id}"}
|
||||
class="px-8 py-4 flex flex-col justify-center items-center
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md"
|
||||
>
|
||||
<%= live_redirect to: Routes.ammo_group_show_path(Endpoint, :show, @ammo_group),
|
||||
class: "mb-2 link" do %>
|
||||
<h1 class="title text-xl title-primary-500">
|
||||
<%= @ammo_group.ammo_type.name %>
|
||||
</h1>
|
||||
<% end %>
|
||||
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<span class="rounded-lg title text-lg">
|
||||
Count: <%= @ammo_group.count %>
|
||||
</span>
|
||||
|
||||
<%= if @ammo_group.notes do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
Notes: <%= @ammo_group.notes %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<%= if @ammo_group.price_paid do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
Price paid: $ <%= @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
end
|
@ -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") %>
|
||||
|
@ -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 %>
|
||||
<td class="p-2">
|
||||
<%= ammo_type |> Map.get(field) %>
|
||||
|
@ -36,7 +36,8 @@
|
||||
:caliber,
|
||||
:case_material,
|
||||
:grains,
|
||||
:pressure
|
||||
:pressure,
|
||||
:primer_type
|
||||
] do %>
|
||||
<%= if @ammo_type |> Map.get(field) do %>
|
||||
<h3 class="mb-2 sm:mr-4 title text-lg">
|
||||
|
@ -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 %>
|
||||
<i class="fa-fw fa-lg fas fa-times"></i>
|
||||
<% end %>
|
||||
<div class="p-8 flex flex-col space-y-4 justify-start items-center">
|
||||
|
@ -1,4 +1,4 @@
|
||||
<main class="container min-w-full">
|
||||
<main class="mb-8 container min-w-full">
|
||||
<header>
|
||||
<CanneryWeb.Component.Topbar.topbar current_user={assigns[:current_user]}></CanneryWeb.Component.Topbar.topbar>
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user