forked from shibao/cannery
make bullet type rifle/pistol type-only field
This commit is contained in:
@ -55,8 +55,6 @@ defmodule Cannery.Ammo.Type do
|
||||
field :class, Ecto.Enum, values: [:rifle, :shotgun, :pistol]
|
||||
|
||||
# common fields
|
||||
# https://shootersreference.com/reloadingdata/bullet_abbreviations/
|
||||
field :bullet_type, :string
|
||||
field :bullet_core, :string
|
||||
# also gauge for shotguns
|
||||
field :caliber, :string
|
||||
@ -75,6 +73,8 @@ defmodule Cannery.Ammo.Type do
|
||||
field :corrosive, :boolean, default: false
|
||||
|
||||
# rifle/pistol fields
|
||||
# https://shootersreference.com/reloadingdata/bullet_abbreviations/
|
||||
field :bullet_type, :string
|
||||
field :cartridge, :string
|
||||
field :jacket_type, :string
|
||||
field :powder_grains_per_charge, :integer
|
||||
|
@ -117,24 +117,28 @@
|
||||
) %>
|
||||
<%= error_tag(f, :grains, "col-span-3 text-center") %>
|
||||
|
||||
<%= label f, :bullet_type, class: "flex title text-lg text-primary-600 space-x-2" do %>
|
||||
<p><%= gettext("Bullet type") %></p>
|
||||
<%= if Changeset.get_field(@changeset, :class) in [:rifle, :pistol] do %>
|
||||
<%= label f, :bullet_type, class: "flex title text-lg text-primary-600 space-x-2" do %>
|
||||
<p><%= gettext("Bullet type") %></p>
|
||||
|
||||
<.link
|
||||
href="https://shootersreference.com/reloadingdata/bullet_abbreviations/"
|
||||
class="link"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<i class="fas fa-md fa-external-link-alt"></i>
|
||||
</.link>
|
||||
<.link
|
||||
href="https://shootersreference.com/reloadingdata/bullet_abbreviations/"
|
||||
class="link"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<i class="fas fa-md fa-external-link-alt"></i>
|
||||
</.link>
|
||||
<% end %>
|
||||
<%= text_input(f, :bullet_type,
|
||||
class: "text-center col-span-2 input input-primary",
|
||||
maxlength: 255,
|
||||
placeholder: gettext("FMJ")
|
||||
) %>
|
||||
<%= error_tag(f, :bullet_type, "col-span-3 text-center") %>
|
||||
<% else %>
|
||||
<%= hidden_input(f, :bullet_type, value: nil) %>
|
||||
<% end %>
|
||||
<%= text_input(f, :bullet_type,
|
||||
class: "text-center col-span-2 input input-primary",
|
||||
maxlength: 255,
|
||||
placeholder: gettext("FMJ")
|
||||
) %>
|
||||
<%= error_tag(f, :bullet_type, "col-span-3 text-center") %>
|
||||
|
||||
<%= label(
|
||||
f,
|
||||
|
Reference in New Issue
Block a user