From b75c0f7b1b543d2ff91ffc2bd85c9c6c829d5d3a Mon Sep 17 00:00:00 2001 From: shibao Date: Mon, 31 Jan 2022 23:03:13 -0500 Subject: [PATCH] style ammo type index --- .../live/ammo_type_live/form_component.ex | 66 +++++++++++++------ .../live/ammo_type_live/index.html.heex | 51 ++++++++++++++ .../live/ammo_type_live/index.html.leex | 45 ------------- 3 files changed, 97 insertions(+), 65 deletions(-) create mode 100644 lib/cannery_web/live/ammo_type_live/index.html.heex delete mode 100644 lib/cannery_web/live/ammo_type_live/index.html.leex 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 66201b9..9b85f36 100644 --- a/lib/cannery_web/live/ammo_type_live/form_component.ex +++ b/lib/cannery_web/live/ammo_type_live/form_component.ex @@ -35,7 +35,7 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do def render(assigns) do ~H"""
-

+

<%= @title %>

<.form @@ -45,26 +45,52 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do phx-target={@myself} phx-change="validate" phx-submit="save" + class="grid grid-cols-3 justify-center items-center space-y-4" > - <%= label(f, :name, class: "title text-lg text-primary-500") %> - <%= text_input(f, :name, class: "input input-primary") %> - <%= error_tag(f, :name) %> - <%= label(f, :desc, class: "title text-lg text-primary-500") %> - <%= text_input(f, :desc, class: "input input-primary") %> - <%= error_tag(f, :desc) %> - <%= label(f, :case_material, class: "title text-lg text-primary-500") %> - <%= text_input(f, :case_material, class: "input input-primary") %> - <%= error_tag(f, :case_material) %> - <%= label(f, :bullet_type, class: "title text-lg text-primary-500") %> - <%= text_input(f, :bullet_type, class: "input input-primary") %> - <%= error_tag(f, :bullet_type) %> - <%= label(f, :weight, class: "title text-lg text-primary-500") %> - <%= number_input(f, :weight, step: "any") %> - <%= error_tag(f, :weight) %> - <%= label(f, :manufacturer, class: "title text-lg text-primary-500") %> - <%= text_input(f, :manufacturer, class: "input input-primary") %> - <%= error_tag(f, :manufacturer) %> - <%= submit("Save", phx_disable_with: "Saving...") %> + <%= label(f, :name, class: "mr-4 title text-lg text-primary-500") %> + <%= text_input(f, :name, class: "text-center col-span-2 input input-primary") %> +
+ <%= error_tag(f, :name) %> +
+ + <%= label(f, :desc, class: "mr-4 title text-lg text-primary-500") %> + <%= textarea(f, :desc, + class: "text-center col-span-2 input input-primary", + phx_hook: "MaintainAttrs") %> +
+ <%= error_tag(f, :desc) %> +
+ + <%= 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") %> +
+ <%= error_tag(f, :case_material) %> +
+ + <%= 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") %> +
+ <%= error_tag(f, :bullet_type) %> +
+ + <%= label(f, :grain, class: "mr-4 title text-lg text-primary-500") %> + <%= number_input(f, :grain, + step: "any", + class: "text-center col-span-2 input input-primary", + min: 0) %> +
+ <%= error_tag(f, :grain) %> +
+ + <%= label(f, :manufacturer, class: "mr-4 title text-lg text-primary-500") %> + <%= text_input(f, :manufacturer, class: "text-center col-span-2 input input-primary") %> +
+ <%= error_tag(f, :manufacturer) %> +
+ + <%= submit("Save", + phx_disable_with: "Saving...", + class: "mx-auto col-span-3 btn btn-primary") %>
""" diff --git a/lib/cannery_web/live/ammo_type_live/index.html.heex b/lib/cannery_web/live/ammo_type_live/index.html.heex new file mode 100644 index 0000000..f70ca9e --- /dev/null +++ b/lib/cannery_web/live/ammo_type_live/index.html.heex @@ -0,0 +1,51 @@ +
+

+ Listing Ammo Types +

+ + <%= live_patch "New Ammo type", + to: Routes.ammo_type_index_path(@socket, :new), + class: "btn btn-primary" %> + +
+ + + + + + + + + + + + + + <%= for ammo_type <- @ammo_types do %> + + + + + + + + + + <% end %> + +
NameCase materialBullet typeGrainManufacturer
<%= ammo_type.name %><%= ammo_type.case_material %><%= ammo_type.bullet_type %><%= ammo_type.grain %><%= ammo_type.manufacturer %> + <%= live_redirect "Show", to: Routes.ammo_type_show_path(@socket, :show, ammo_type) %> + <%= live_patch "Edit", to: Routes.ammo_type_index_path(@socket, :edit, ammo_type) %> + <%= link "Delete", to: "#", phx_click: "delete", phx_value_id: ammo_type.id, data: [confirm: "Are you sure?"] %> +
+
+
+ +<%= if @live_action in [:new, :edit] do %> + <%= live_modal CanneryWeb.AmmoTypeLive.FormComponent, + id: @ammo_type.id || :new, + title: @page_title, + action: @live_action, + ammo_type: @ammo_type, + return_to: Routes.ammo_type_index_path(@socket, :index) %> +<% end %> diff --git a/lib/cannery_web/live/ammo_type_live/index.html.leex b/lib/cannery_web/live/ammo_type_live/index.html.leex deleted file mode 100644 index 9abe40e..0000000 --- a/lib/cannery_web/live/ammo_type_live/index.html.leex +++ /dev/null @@ -1,45 +0,0 @@ -

Listing Ammo types

- -<%= if @live_action in [:new, :edit] do %> - <%= live_modal CanneryWeb.AmmoTypeLive.FormComponent, - id: @ammo_type.id || :new, - title: @page_title, - action: @live_action, - ammo_type: @ammo_type, - return_to: Routes.ammo_type_index_path(@socket, :index) %> -<% end %> - - - - - - - - - - - - - - - - <%= for ammo_type <- @ammo_types do %> - - - - - - - - - - - <% end %> - -
NameDescCase materialBullet typeWeightManufacturer
<%= ammo_type.name %><%= ammo_type.desc %><%= ammo_type.case_material %><%= ammo_type.bullet_type %><%= ammo_type.weight %><%= ammo_type.manufacturer %> - <%= live_redirect "Show", to: Routes.ammo_type_show_path(@socket, :show, ammo_type) %> - <%= live_patch "Edit", to: Routes.ammo_type_index_path(@socket, :edit, ammo_type) %> - <%= link "Delete", to: "#", phx_click: "delete", phx_value_id: ammo_type.id, data: [confirm: "Are you sure?"] %> -
- -<%= live_patch "New Ammo type", to: Routes.ammo_type_index_path(@socket, :new) %>