From c75816a58281fa406c8b2b5fc8df2705cff8bbb4 Mon Sep 17 00:00:00 2001 From: shibao Date: Tue, 1 Feb 2022 01:08:18 -0500 Subject: [PATCH] reenable heex_formatter --- .formatter.exs | 4 +- lib/cannery_web/component/topbar.ex | 6 +- .../live/ammo_group_live/index.html.heex | 56 +++++++++++---- .../live/ammo_type_live/form_component.ex | 9 ++- .../live/ammo_type_live/index.html.heex | 72 ++++++++++++++----- .../live/ammo_type_live/show.html.heex | 9 +-- .../live/container_live/index.html.heex | 13 ++-- lib/cannery_web/live/modal_component.ex | 3 +- lib/cannery_web/live/tag_live/index.html.heex | 11 ++- .../templates/layout/live.html.heex | 3 +- mix.exs | 2 +- mix.lock | 4 +- 12 files changed, 127 insertions(+), 65 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index c2573048..f7db5228 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,6 +1,6 @@ [ import_deps: [:ecto, :phoenix], inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"], - subdirectories: ["priv/*/migrations"] - # plugins: [HeexFormatter] + subdirectories: ["priv/*/migrations"], + plugins: [HeexFormatter] ] diff --git a/lib/cannery_web/component/topbar.ex b/lib/cannery_web/component/topbar.ex index eb8a4ad1..853c062c 100644 --- a/lib/cannery_web/component/topbar.ex +++ b/lib/cannery_web/component/topbar.ex @@ -73,15 +73,13 @@ defmodule CanneryWeb.Component.Topbar do <%= link to: Routes.user_session_path(CanneryWeb.Endpoint, :delete), method: :delete, data: [confirm: "Are you sure you want to log out?"] do %> - - + <% end %> <%= if @current_user.role == :admin and function_exported?(Routes, :live_dashboard_path, 2) do %>
  • <%= link to: Routes.live_dashboard_path(CanneryWeb.Endpoint, :home) do %> - - + <% end %>
  • <% end %> 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 a589392d..16c5e1b4 100644 --- a/lib/cannery_web/live/ammo_group_live/index.html.heex +++ b/lib/cannery_web/live/ammo_group_live/index.html.heex @@ -8,21 +8,29 @@ No Ammo 😔 - <%= live_patch "Add your first box!", + <%= live_patch("Add your first box!", to: Routes.ammo_group_index_path(@socket, :new), - class: "btn btn-primary" %> + class: "btn btn-primary" + ) %> <% else %> - <%= live_patch "New Ammo group", + <%= live_patch("New Ammo group", to: Routes.ammo_group_index_path(@socket, :new), - class: "btn btn-primary" %> + class: "btn btn-primary" + ) %>
    - - - + + + @@ -30,14 +38,31 @@ <%= for ammo_group <- @ammo_groups do %> - - - + + + <% end %> @@ -48,10 +73,11 @@ <%= if @live_action in [:new, :edit] do %> - <%= live_modal CanneryWeb.AmmoGroupLive.FormComponent, + <%= live_modal(CanneryWeb.AmmoGroupLive.FormComponent, id: @ammo_group.id || :new, title: @page_title, action: @live_action, ammo_group: @ammo_group, - return_to: Routes.ammo_group_index_path(@socket, :index) %> + return_to: Routes.ammo_group_index_path(@socket, :index) + ) %> <% 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 70ff7fab..0f0fde65 100644 --- a/lib/cannery_web/live/ammo_type_live/form_component.ex +++ b/lib/cannery_web/live/ammo_type_live/form_component.ex @@ -57,7 +57,8 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do <%= 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") %> + phx_hook: "MaintainAttrs" + ) %>
    <%= error_tag(f, :desc) %>
    @@ -78,7 +79,8 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do <%= number_input(f, :grain, step: "any", class: "text-center col-span-2 input input-primary", - min: 0) %> + min: 0 + ) %>
    <%= error_tag(f, :grain) %>
    @@ -91,7 +93,8 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do <%= submit("Save", phx_disable_with: "Saving...", - class: "mx-auto col-span-3 btn btn-primary") %> + 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 index d894d71d..ba5fd8a5 100644 --- a/lib/cannery_web/live/ammo_type_live/index.html.heex +++ b/lib/cannery_web/live/ammo_type_live/index.html.heex @@ -8,23 +8,35 @@ No Ammo Types 😔 - <%= live_patch "Add your first type!", + <%= live_patch("Add your first type!", to: Routes.ammo_type_index_path(@socket, :new), - class: "btn btn-primary" %> + class: "btn btn-primary" + ) %> <% else %> - <%= live_patch "New Ammo type", + <%= live_patch("New Ammo type", to: Routes.ammo_type_index_path(@socket, :new), - class: "btn btn-primary" %> + class: "btn btn-primary" + ) %>
    CountPrice paidNotes + Count + + Price paid + + Notes +
    <%= ammo_group.count %><%= ammo_group.price_paid %><%= ammo_group.notes %> + <%= ammo_group.count %> + + <%= ammo_group.price_paid %> + + <%= ammo_group.notes %> + - <%= live_redirect "Show", to: Routes.ammo_group_show_path(@socket, :show, ammo_group) %> - <%= live_patch "Edit", to: Routes.ammo_group_index_path(@socket, :edit, ammo_group) %> - <%= link "Delete", to: "#", phx_click: "delete", phx_value_id: ammo_group.id, data: [confirm: "Are you sure?"] %> + + <%= live_redirect("Show", to: Routes.ammo_group_show_path(@socket, :show, ammo_group)) %> + + + <%= live_patch("Edit", to: Routes.ammo_group_index_path(@socket, :edit, ammo_group)) %> + + + <%= link("Delete", + to: "#", + phx_click: "delete", + phx_value_id: ammo_group.id, + data: [confirm: "Are you sure?"] + ) %> +
    - - - - - + + + + + @@ -32,16 +44,37 @@ <%= for ammo_type <- @ammo_types do %> - - - - - + + + + + <% end %> @@ -52,10 +85,11 @@ <%= if @live_action in [:new, :edit] do %> - <%= live_modal CanneryWeb.AmmoTypeLive.FormComponent, + <%= 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) %> + return_to: Routes.ammo_type_index_path(@socket, :index) + ) %> <% end %> 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 f7166cc1..5ff88763 100644 --- a/lib/cannery_web/live/ammo_type_live/show.html.heex +++ b/lib/cannery_web/live/ammo_type_live/show.html.heex @@ -4,8 +4,8 @@
    - <%= live_redirect "Back", to: Routes.ammo_type_index_path(@socket, :index), class: "link" %> - <%= live_patch "Edit", to: Routes.ammo_type_show_path(@socket, :edit, @ammo_type), class: "button" %> + <%= live_redirect("Back", to: Routes.ammo_type_index_path(@socket, :index), class: "link") %> + <%= live_patch("Edit", to: Routes.ammo_type_show_path(@socket, :edit, @ammo_type), class: "button") %> <%= link("Delete", to: "#", class: "link", @@ -45,10 +45,11 @@
    <%= if @live_action in [:edit] do %> - <%= live_modal CanneryWeb.AmmoTypeLive.FormComponent, + <%= live_modal(CanneryWeb.AmmoTypeLive.FormComponent, id: @ammo_type.id, title: @page_title, action: @live_action, ammo_type: @ammo_type, - return_to: Routes.ammo_type_show_path(@socket, :show, @ammo_type) %> + return_to: Routes.ammo_type_show_path(@socket, :show, @ammo_type) + ) %> <% end %> diff --git a/lib/cannery_web/live/container_live/index.html.heex b/lib/cannery_web/live/container_live/index.html.heex index d176e4cf..df63902d 100644 --- a/lib/cannery_web/live/container_live/index.html.heex +++ b/lib/cannery_web/live/container_live/index.html.heex @@ -8,21 +8,24 @@ No containers 😔 - <%= live_patch "Add your first container!", + <%= live_patch("Add your first container!", to: Routes.container_index_path(@socket, :new), - class: "btn btn-primary" %> + class: "btn btn-primary" + ) %> <% else %> <%= live_patch to: Routes.container_index_path(@socket, :new), - class: "btn btn-primary" do %> + class: "btn btn-primary" do %> New Container <% end %> <% end %>
    <%= for container <- @containers do %> -
    + border border-gray-400 rounded-lg shadow-lg hover:shadow-md" + >

    <%= container.name %> diff --git a/lib/cannery_web/live/modal_component.ex b/lib/cannery_web/live/modal_component.ex index 007b9dcc..5a0be9bc 100644 --- a/lib/cannery_web/live/modal_component.ex +++ b/lib/cannery_web/live/modal_component.ex @@ -26,8 +26,7 @@ defmodule CanneryWeb.ModalComponent do <%= 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 %> - - + <% end %>
    <%= live_component(@component, @opts) %> diff --git a/lib/cannery_web/live/tag_live/index.html.heex b/lib/cannery_web/live/tag_live/index.html.heex index 68d2db80..05356a54 100644 --- a/lib/cannery_web/live/tag_live/index.html.heex +++ b/lib/cannery_web/live/tag_live/index.html.heex @@ -10,9 +10,10 @@ No tags 😔

    - <%= live_patch "Make your first tag!", + <%= live_patch("Make your first tag!", to: Routes.tag_index_path(@socket, :new), - class: "btn btn-primary" %> + class: "btn btn-primary" + ) %> <% else %> <%= live_patch("New Tag", to: Routes.tag_index_path(@socket, :new), @@ -34,16 +35,14 @@ <%= live_patch to: Routes.tag_index_path(@socket, :edit, tag), class: "text-primary-500 link" do %> - - + <% end %> <%= link to: "#", class: "text-primary-500 link", phx_click: "delete", phx_value_id: tag.id, data: [confirm: "Are you sure you want to delete #{tag.name}?"] do %> - - + <% end %>
    <% end %> diff --git a/lib/cannery_web/templates/layout/live.html.heex b/lib/cannery_web/templates/layout/live.html.heex index 77890279..256f7f94 100644 --- a/lib/cannery_web/templates/layout/live.html.heex +++ b/lib/cannery_web/templates/layout/live.html.heex @@ -1,7 +1,6 @@
    - - +
    <%= if @flash && @flash |> Map.has_key?(:info) do %>
    NameCase materialBullet typeGrainManufacturer + Name + + Case material + + Bullet type + + Grain + + Manufacturer +
    <%= ammo_type.name %><%= ammo_type.case_material %><%= ammo_type.bullet_type %><%= ammo_type.grain %><%= ammo_type.manufacturer %> + <%= 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?"] %> + + <%= 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?"] + ) %> +