add ammo type stuff
This commit is contained in:
		| @@ -63,26 +63,104 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do | ||||
|           <%= error_tag(f, :desc) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :case_material, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :case_material, class: "text-center col-span-2 input input-primary") %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :case_material) %> | ||||
|         </div> | ||||
|  | ||||
|         <a | ||||
|           href="https://en.wikipedia.org/wiki/Bullet#Abbreviations" | ||||
|           class="col-span-3 text-center link title text-md text-primary-600" | ||||
|         > | ||||
|           Example bullet type abbreviations | ||||
|         </a> | ||||
|         <%= label(f, :bullet_type, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :bullet_type, class: "text-center col-span-2 input input-primary") %> | ||||
|         <%= text_input(f, :bullet_type, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "FMJ" | ||||
|         ) %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :bullet_type) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :grain, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= number_input(f, :grain, | ||||
|           step: "any", | ||||
|         <%= label(f, :bullet_core, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :bullet_core, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           min: 0 | ||||
|           placeholder: "Steel" | ||||
|         ) %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :grain) %> | ||||
|           <%= error_tag(f, :bullet_core) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :cartridge, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :cartridge, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "5.56x46mm NATO" | ||||
|         ) %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :cartridge) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :caliber, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :caliber, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: ".223" | ||||
|         ) %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :caliber) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :case_material, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :case_material, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "Brass" | ||||
|         ) %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :case_material) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :grains, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= number_input(f, :grains, | ||||
|           step: "1", | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           min: 1 | ||||
|         ) %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :grains) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :pressure, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :pressure, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "+P" | ||||
|         ) %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :pressure) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :rimfire, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :rimfire, class: "text-center col-span-2 checkbox") %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :rimfire) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :tracer, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :tracer, class: "text-center col-span-2 checkbox") %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :tracer) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :incendiary, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :incendiary, class: "text-center col-span-2 checkbox") %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :incendiary) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :blank, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :blank, class: "text-center col-span-2 checkbox") %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :blank) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :corrosive, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :corrosive, class: "text-center col-span-2 checkbox") %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :corrosive) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :manufacturer, class: "mr-4 title text-lg text-primary-500") %> | ||||
| @@ -91,6 +169,12 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do | ||||
|           <%= error_tag(f, :manufacturer) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= label(f, :sku, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :sku, class: "text-center col-span-2 input input-primary") %> | ||||
|         <div class="col-span-3 text-center"> | ||||
|           <%= error_tag(f, :sku) %> | ||||
|         </div> | ||||
|  | ||||
|         <%= submit("Save", | ||||
|           phx_disable_with: "Saving...", | ||||
|           class: "mx-auto col-span-3 btn btn-primary" | ||||
|   | ||||
| @@ -22,21 +22,27 @@ | ||||
|       <table class="min-w-full table-auto text-center bg-white"> | ||||
|         <thead class="border-b border-primary-600"> | ||||
|           <tr> | ||||
|             <th class="p-2"> | ||||
|               Name | ||||
|             </th> | ||||
|             <th class="p-2"> | ||||
|               Case material | ||||
|             </th> | ||||
|             <th class="p-2"> | ||||
|               Bullet type | ||||
|             </th> | ||||
|             <th class="p-2"> | ||||
|               Grain | ||||
|             </th> | ||||
|             <th class="p-2"> | ||||
|               Manufacturer | ||||
|             </th> | ||||
|             <%= for field <- [ | ||||
|                   :name, | ||||
|                   :bullet_type, | ||||
|                   :bullet_core, | ||||
|                   :cartridge, | ||||
|                   :caliber, | ||||
|                   :case_material, | ||||
|                   :grains, | ||||
|                   :pressure, | ||||
|                   :rimfire, | ||||
|                   :tracer, | ||||
|                   :incendiary, | ||||
|                   :blank, | ||||
|                   :corrosive, | ||||
|                   :manufacturer, | ||||
|                   :sku | ||||
|                 ] do %> | ||||
|               <th class="p-2"> | ||||
|                 <%= field |> humanize() %> | ||||
|               </th> | ||||
|             <% end %> | ||||
|  | ||||
|             <th class="p-2"></th> | ||||
|           </tr> | ||||
| @@ -44,37 +50,59 @@ | ||||
|         <tbody> | ||||
|           <%= for ammo_type <- @ammo_types do %> | ||||
|             <tr id={"ammo_type-#{ammo_type.id}"}> | ||||
|               <td class="p-2"> | ||||
|                 <%= ammo_type.name %> | ||||
|               </td> | ||||
|               <td class="p-2"> | ||||
|                 <%= ammo_type.case_material %> | ||||
|               </td> | ||||
|               <td class="p-2"> | ||||
|                 <%= ammo_type.bullet_type %> | ||||
|               </td> | ||||
|               <td class="p-2"> | ||||
|                 <%= ammo_type.grain %> | ||||
|               </td> | ||||
|               <td class="p-2"> | ||||
|                 <%= ammo_type.manufacturer %> | ||||
|               </td> | ||||
|               <%= for field <- [ | ||||
|                     :name, | ||||
|                     :bullet_type, | ||||
|                     :bullet_core, | ||||
|                     :cartridge, | ||||
|                     :caliber, | ||||
|                     :case_material, | ||||
|                     :grains, | ||||
|                     :pressure | ||||
|                   ] do %> | ||||
|                 <td class="p-2"> | ||||
|                   <%= ammo_type |> Map.get(field) %> | ||||
|                 </td> | ||||
|               <% end %> | ||||
|  | ||||
|               <td class="p-2 w-full h-full space-x-2 flex justify-center items-center"> | ||||
|                 <%= live_redirect("View", to: Routes.ammo_type_show_path(@socket, :show, ammo_type)) %> | ||||
|               <%= for field <- [ | ||||
|                     :rimfire, | ||||
|                     :tracer, | ||||
|                     :incendiary, | ||||
|                     :blank, | ||||
|                     :corrosive | ||||
|                   ] do %> | ||||
|                 <td class="p-2"> | ||||
|                   <%= ammo_type |> Map.get(field) |> humanize() %> | ||||
|                 </td> | ||||
|               <% end %> | ||||
|  | ||||
|                 <%= live_patch to: Routes.ammo_type_index_path(@socket, :edit, ammo_type), | ||||
|                            class: "text-primary-500 link" do %> | ||||
|                   <i class="fa-fw fa-lg fas fa-edit"></i> | ||||
|                 <% end %> | ||||
|               <%= for field <- [:manufacturer, :sku] do %> | ||||
|                 <td class="p-2"> | ||||
|                   <%= ammo_type |> Map.get(field) %> | ||||
|                 </td> | ||||
|               <% end %> | ||||
|  | ||||
|                 <%= link to: "#", | ||||
|                      class: "text-primary-500 link", | ||||
|                      phx_click: "delete", | ||||
|                      phx_value_id: ammo_type.id, | ||||
|                      data: [confirm: "Are you sure you want to delete this ammo?"] do %> | ||||
|                   <i class="fa-fw fa-lg fas fa-trash"></i> | ||||
|                 <% end %> | ||||
|               <td class="p-2"> | ||||
|                 <div class="px-4 py-2 space-x-4 flex justify-center items-center"> | ||||
|                   <%= live_redirect to: Routes.ammo_type_show_path(@socket, :show, ammo_type), | ||||
|                                 class: "text-primary-500 link" do %> | ||||
|                     <i class="fa-lg fas fa-eye"></i> | ||||
|                   <% end %> | ||||
|  | ||||
|                   <%= live_patch to: Routes.ammo_type_index_path(@socket, :edit, ammo_type), | ||||
|                             class: "text-primary-500 link" do %> | ||||
|                     <i class="fa-lg fas fa-edit"></i> | ||||
|                   <% end %> | ||||
|  | ||||
|                   <%= link to: "#", | ||||
|                       class: "text-primary-500 link", | ||||
|                       phx_click: "delete", | ||||
|                       phx_value_id: ammo_type.id, | ||||
|                       data: [confirm: "Are you sure you want to delete this ammo?"] do %> | ||||
|                     <i class="fa-lg fas fa-trash"></i> | ||||
|                   <% end %> | ||||
|                 </div> | ||||
|               </td> | ||||
|             </tr> | ||||
|           <% end %> | ||||
|   | ||||
| @@ -1,39 +1,16 @@ | ||||
| <div class="mx-auto space-y-4 max-w-3xl flex flex-col justify-center items-center"> | ||||
| <div class="mx-auto px-4 sm:px-8 space-y-4 max-w-3xl | ||||
|   flex flex-col justify-center items-center"> | ||||
|   <h1 class="title text-2xl title-primary-500"> | ||||
|     <%= @ammo_type.name %> | ||||
|   </h1> | ||||
|  | ||||
|   <div class="space-y-2 flex flex-col justify-center items-center"> | ||||
|     <%= if @ammo_type.desc do %> | ||||
|       <span class="rounded-lg title text-lg"> | ||||
|         Desc: <%= @ammo_type.desc %> | ||||
|       </span> | ||||
|     <% end %> | ||||
|  | ||||
|     <%= if @ammo_type.case_material do %> | ||||
|       <span class="rounded-lg title text-lg"> | ||||
|         Case material: <%= @ammo_type.case_material %> | ||||
|       </span> | ||||
|     <% end %> | ||||
|  | ||||
|     <%= if @ammo_type.bullet_type do %> | ||||
|       <span class="rounded-lg title text-lg"> | ||||
|         Bullet type: <%= @ammo_type.bullet_type %> | ||||
|       </span> | ||||
|     <% end %> | ||||
|  | ||||
|     <%= if @ammo_type.grain do %> | ||||
|       <span class="rounded-lg title text-lg"> | ||||
|         Grain: <%= @ammo_type.grain %> | ||||
|       </span> | ||||
|     <% end %> | ||||
|  | ||||
|     <%= if @ammo_type.manufacturer do %> | ||||
|       <span class="rounded-lg title text-lg"> | ||||
|         Manufacturer: <%= @ammo_type.manufacturer %> | ||||
|       </span> | ||||
|     <% end %> | ||||
|   </div> | ||||
|   <%= if @ammo_type.desc do %> | ||||
|     <span class="max-w-2xl w-full px-8 py-4 rounded-lg | ||||
|       text-center title text-lg | ||||
|       border border-primary-600"> | ||||
|       <%= @ammo_type.desc %> | ||||
|     </span> | ||||
|   <% end %> | ||||
|  | ||||
|   <div class="flex space-x-4 justify-center items-center text-primary-500"> | ||||
|     <%= live_patch to: Routes.ammo_type_show_path(@socket, :edit, @ammo_type), | ||||
| @@ -49,9 +26,61 @@ | ||||
|     <% end %> | ||||
|   </div> | ||||
|  | ||||
|   <hr class="mb-4 w-full"> | ||||
|   <hr class="hr"> | ||||
|  | ||||
|   <div class="mb-4"> | ||||
|   <div class="grid sm:grid-cols-2 text-center justify-center items-center"> | ||||
|     <%= for field <- [ | ||||
|           :bullet_type, | ||||
|           :bullet_core, | ||||
|           :cartridge, | ||||
|           :caliber, | ||||
|           :case_material, | ||||
|           :grains, | ||||
|           :pressure | ||||
|         ] do %> | ||||
|       <%= if @ammo_type |> Map.get(field) do %> | ||||
|         <h3 class="mb-2 sm:mr-4 title text-lg"> | ||||
|           <%= field |> humanize() %> : | ||||
|         </h3> | ||||
|  | ||||
|         <span class="mb-4 sm:mb-2 text-primary-600"> | ||||
|           <%= @ammo_type |> Map.get(field) %> | ||||
|         </span> | ||||
|       <% end %> | ||||
|     <% end %> | ||||
|  | ||||
|     <%= for field <- [ | ||||
|           :rimfire, | ||||
|           :tracer, | ||||
|           :incendiary, | ||||
|           :blank, | ||||
|           :corrosive | ||||
|         ] do %> | ||||
|       <h3 class="mb-2 sm:mr-4 title text-lg"> | ||||
|         <%= field |> humanize() %> : | ||||
|       </h3> | ||||
|  | ||||
|       <span class="mb-4 sm:mb-2 text-primary-600"> | ||||
|         <%= @ammo_type |> Map.get(field) |> humanize() %> | ||||
|       </span> | ||||
|     <% end %> | ||||
|  | ||||
|     <%= for field <- [:manufacturer, :sku] do %> | ||||
|       <%= if @ammo_type |> Map.get(field) do %> | ||||
|         <h3 class="mb-2 sm:mr-4 title text-lg"> | ||||
|           <%= field |> humanize() %> : | ||||
|         </h3> | ||||
|  | ||||
|         <span class="mb-4 sm:mb-2 text-primary-600"> | ||||
|           <%= @ammo_type |> Map.get(field) %> | ||||
|         </span> | ||||
|       <% end %> | ||||
|     <% end %> | ||||
|   </div> | ||||
|  | ||||
|   <hr class="hr"> | ||||
|  | ||||
|   <div> | ||||
|     <%= if @ammo_type.ammo_groups |> Enum.empty?() do %> | ||||
|       No ammo for this type | ||||
|     <% else %> | ||||
|   | ||||
| @@ -20,15 +20,15 @@ defmodule CanneryWeb.ModalComponent do | ||||
|       phx-target={"#{@id}"} | ||||
|       phx-page-loading | ||||
|     > | ||||
|       <div class="w-full max-w-4xl relative | ||||
|         p-8 flex flex-col justify-start items-center | ||||
|       <div class="w-full max-w-3xl max-h-128 relative overflow-y-auto | ||||
|         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="w-full flex flex-col space-y-4 justify-center items-center"> | ||||
|         <div class="p-8 flex flex-col space-y-4 justify-start items-center"> | ||||
|           <%= live_component(@component, @opts) %> | ||||
|         </div> | ||||
|       </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user