diff --git a/lib/cannery_web/component/topbar.ex b/lib/cannery_web/component/topbar.ex
new file mode 100644
index 0000000..b32c4ee
--- /dev/null
+++ b/lib/cannery_web/component/topbar.ex
@@ -0,0 +1,121 @@
+defmodule CanneryWeb.Component.Topbar do
+ use CanneryWeb, :component
+
+ alias Cannery.{Accounts}
+ alias CanneryWeb.{HomeLive}
+
+ def topbar(assigns) do
+ assigns =
+ %{results: [], title_content: nil, flash: nil, current_user: nil} |> Map.merge(assigns)
+
+ ~H"""
+
+
+
+ <%= if @flash && @flash |> Map.has_key?(:info) do %>
+
+ <%= live_flash(@flash, :info) %>
+
+ <% end %>
+
+ <%= if @flash && @flash |> Map.has_key?(:error) do %>
+
+ <%= live_flash(@flash, :error) %>
+
+ <% end %>
+
+ """
+ end
+end
diff --git a/lib/cannery_web/live/ammo_group_live/form_component.ex b/lib/cannery_web/live/ammo_group_live/form_component.ex
index b01aa0f..02b585a 100644
--- a/lib/cannery_web/live/ammo_group_live/form_component.ex
+++ b/lib/cannery_web/live/ammo_group_live/form_component.ex
@@ -27,6 +27,36 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do
save_ammo_group(socket, socket.assigns.action, ammo_group_params)
end
+ @impl true
+ def render(assigns) do
+ ~H"""
+
+
<%= @title %>
+
+ <.form let={f} for={@changeset},
+ id="ammo_group-form"
+ phx-target={@myself}
+ phx-change="validate"
+ phx-submit="save">
+
+ <%= label f, :count, class: "title text-lg text-primary-500" %>
+ <%= number_input f, :count %>
+ <%= error_tag f, :count %>
+
+ <%= label f, :price_paid, class: "title text-lg text-primary-500" %>
+ <%= number_input f, :price_paid, step: "any" %>
+ <%= error_tag f, :price_paid %>
+
+ <%= label f, :notes, class: "title text-lg text-primary-500" %>
+ <%= textarea f, :notes, class: "input" %>
+ <%= error_tag f, :notes %>
+
+ <%= submit "Save", phx_disable_with: "Saving..." %>
+
+
+ """
+ end
+
defp save_ammo_group(socket, :edit, ammo_group_params) do
case Ammo.update_ammo_group(socket.assigns.ammo_group, ammo_group_params) do
{:ok, _ammo_group} ->
diff --git a/lib/cannery_web/live/ammo_group_live/form_component.html.leex b/lib/cannery_web/live/ammo_group_live/form_component.html.leex
deleted file mode 100644
index 47b1603..0000000
--- a/lib/cannery_web/live/ammo_group_live/form_component.html.leex
+++ /dev/null
@@ -1,22 +0,0 @@
-<%= @title %>
-
-<%= f = form_for @changeset, "#",
- id: "ammo_group-form",
- phx_target: @myself,
- phx_change: "validate",
- phx_submit: "save" %>
-
- <%= label f, :count, class: "title text-lg text-primary-500" %>
- <%= number_input f, :count %>
- <%= error_tag f, :count %>
-
- <%= label f, :price_paid, class: "title text-lg text-primary-500" %>
- <%= number_input f, :price_paid, step: "any" %>
- <%= error_tag f, :price_paid %>
-
- <%= label f, :notes, class: "title text-lg text-primary-500" %>
- <%= textarea f, :notes, class: "input" %>
- <%= error_tag f, :notes %>
-
- <%= submit "Save", phx_disable_with: "Saving..." %>
-
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 3095b42..e4dad09 100644
--- a/lib/cannery_web/live/ammo_type_live/form_component.ex
+++ b/lib/cannery_web/live/ammo_type_live/form_component.ex
@@ -27,6 +27,48 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do
save_ammo_type(socket, socket.assigns.action, ammo_type_params)
end
+ @impl true
+ def render(assigns) do
+ ~H"""
+
+
<%= @title %>
+
+ <.form let={f} for={@changeset}
+ id="ammo_type-form"
+ phx-target={@myself}
+ phx-change="validate"
+ phx-submit="save">
+
+ <%= 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..." %>
+
+
+ """
+ end
+
defp save_ammo_type(socket, :edit, ammo_type_params) do
case Ammo.update_ammo_type(socket.assigns.ammo_type, ammo_type_params) do
{:ok, _ammo_type} ->
diff --git a/lib/cannery_web/live/ammo_type_live/form_component.html.leex b/lib/cannery_web/live/ammo_type_live/form_component.html.leex
deleted file mode 100644
index abd99c2..0000000
--- a/lib/cannery_web/live/ammo_type_live/form_component.html.leex
+++ /dev/null
@@ -1,34 +0,0 @@
-<%= @title %>
-
-<%= f = form_for @changeset, "#",
- id: "ammo_type-form",
- phx_target: @myself,
- phx_change: "validate",
- phx_submit: "save" %>
-
- <%= 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..." %>
-
diff --git a/lib/cannery_web/live/component/topbar.ex b/lib/cannery_web/live/component/topbar.ex
deleted file mode 100644
index d982382..0000000
--- a/lib/cannery_web/live/component/topbar.ex
+++ /dev/null
@@ -1,13 +0,0 @@
-defmodule CanneryWeb.Live.Component.Topbar do
- use CanneryWeb, :live_component
-
- alias Cannery.{Accounts}
-
- def mount(socket) do
- {:ok, socket |> assign(results: [], title_content: nil)}
- end
-
- def update(assigns, socket) do
- {:ok, socket |> assign(assigns)}
- end
-end
diff --git a/lib/cannery_web/live/component/topbar.html.leex b/lib/cannery_web/live/component/topbar.html.leex
deleted file mode 100644
index 57fad13..0000000
--- a/lib/cannery_web/live/component/topbar.html.leex
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
-
- <%= if live_flash(@flash, :info) do %>
-
- <%= live_flash(@flash, :info) %>
-
- <% end %>
-
- <%= if live_flash(@flash, :error) do %>
-
- <%= live_flash(@flash, :error) %>
-
- <% end %>
-
diff --git a/lib/cannery_web/live/container_live/form_component.ex b/lib/cannery_web/live/container_live/form_component.ex
index 063b12e..83215e5 100644
--- a/lib/cannery_web/live/container_live/form_component.ex
+++ b/lib/cannery_web/live/container_live/form_component.ex
@@ -27,6 +27,40 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
save_container(socket, socket.assigns.action, container_params)
end
+ @impl true
+ def render(assigns) do
+ ~H"""
+
+
<%= @title %>
+
+ <.form let={f} for={@changeset}
+ id="container-form"
+ phx-target={@myself}
+ phx-change="validate"
+ phx-submit="save">
+
+ <%= 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, :type, class: "title text-lg text-primary-500" %>
+ <%= text_input f, :type, class: "input input-primary" %>
+ <%= error_tag f, :type %>
+
+ <%= label f, :location, class: "title text-lg text-primary-500" %>
+ <%= text_input f, :location, class: "input input-primary" %>
+ <%= error_tag f, :location %>
+
+ <%= submit "Save", phx_disable_with: "Saving..." %>
+
+
+ """
+ end
+
defp save_container(socket, :edit, container_params) do
case Containers.update_container(socket.assigns.container, container_params) do
{:ok, _container} ->
diff --git a/lib/cannery_web/live/container_live/form_component.html.leex b/lib/cannery_web/live/container_live/form_component.html.leex
deleted file mode 100644
index 7a66b6e..0000000
--- a/lib/cannery_web/live/container_live/form_component.html.leex
+++ /dev/null
@@ -1,26 +0,0 @@
-<%= @title %>
-
-<%= f = form_for @changeset, "#",
- id: "container-form",
- phx_target: @myself,
- phx_change: "validate",
- phx_submit: "save" %>
-
- <%= 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, :type, class: "title text-lg text-primary-500" %>
- <%= text_input f, :type, class: "input input-primary" %>
- <%= error_tag f, :type %>
-
- <%= label f, :location, class: "title text-lg text-primary-500" %>
- <%= text_input f, :location, class: "input input-primary" %>
- <%= error_tag f, :location %>
-
- <%= submit "Save", phx_disable_with: "Saving..." %>
-
diff --git a/lib/cannery_web/live/invite_live/form_component.ex b/lib/cannery_web/live/invite_live/form_component.ex
index 402b1f5..685f515 100644
--- a/lib/cannery_web/live/invite_live/form_component.ex
+++ b/lib/cannery_web/live/invite_live/form_component.ex
@@ -27,6 +27,40 @@ defmodule CanneryWeb.InviteLive.FormComponent do
save_invite(socket, socket.assigns.action, invite_params)
end
+ @impl true
+ def render(assigns) do
+ ~H"""
+
+
+ <%= @title %>
+
+
+ <.form let={f} for={@changeset}
+ id="invite-form"
+ class="grid grid-cols-3 justify-center items-center space-y-4"
+ phx-target={@myself}
+ phx-change="validate"
+ phx-submit="save">
+
+ <%= label f, :name, class: "title text-lg text-primary-500" %>
+ <%= text_input f, :name, class: "input input-primary col-span-2" %>
+
+ <%= error_tag f, :name %>
+
+
+ <%= label f, :uses_left, class: "title text-lg text-primary-500" %>
+ <%= number_input f, :uses_left, min: 0, class: "input input-primary col-span-2" %>
+
+ <%= error_tag f, :uses_left %>
+
+
+ <%= submit "Save", class: "mx-auto btn btn-primary col-span-3",
+ phx_disable_with: "Saving..." %>
+
+
+ """
+ end
+
defp save_invite(socket, :edit, invite_params) do
case Invites.update_invite(socket.assigns.invite, invite_params) do
{:ok, _invite} ->
diff --git a/lib/cannery_web/live/invite_live/form_component.html.leex b/lib/cannery_web/live/invite_live/form_component.html.leex
deleted file mode 100644
index d605b48..0000000
--- a/lib/cannery_web/live/invite_live/form_component.html.leex
+++ /dev/null
@@ -1,26 +0,0 @@
-
- <%= @title %>
-
-
-<%= f = form_for @changeset, "#",
- id: "invite-form",
- class: "grid grid-cols-3 justify-center items-center space-y-4",
- phx_target: @myself,
- phx_change: "validate",
- phx_submit: "save" %>
-
- <%= label f, :name, class: "title text-lg text-primary-500" %>
- <%= text_input f, :name, class: "input input-primary col-span-2" %>
-
- <%= error_tag f, :name %>
-
-
- <%= label f, :uses_left, class: "title text-lg text-primary-500" %>
- <%= number_input f, :uses_left, min: 0, class: "input input-primary col-span-2" %>
-
- <%= error_tag f, :uses_left %>
-
-
- <%= submit "Save", class: "mx-auto btn btn-primary col-span-3",
- phx_disable_with: "Saving..." %>
-
diff --git a/lib/cannery_web/live/modal_component.ex b/lib/cannery_web/live/modal_component.ex
index 870e4bd..7fbe058 100644
--- a/lib/cannery_web/live/modal_component.ex
+++ b/lib/cannery_web/live/modal_component.ex
@@ -3,15 +3,15 @@ defmodule CanneryWeb.ModalComponent do
@impl true
def render(assigns) do
- ~L"""
-
+
+ <%= @title %>
+
+
+ <.form let={f} for={@changeset}
+ id="tag-form"
+ class="grid grid-cols-3 justify-center items-center space-y-4"
+ phx-target={@myself}
+ phx-change="validate"
+ phx-submit="save">
+
+ <%= label f, :name, class: "title text-lg text-primary-500" %>
+ <%= text_input f, :name, class: "input input-primary col-span-2" %>
+
+ <%= error_tag f, :name %>
+
+
+ <%= label f, :bg_color, class: "title text-lg text-primary-500" %>
+
+ <%= color_input f, :bg_color, value: random_color() %>
+
+
+ <%= error_tag f, :bg_color %>
+
+
+ <%= label f, :text_color, class: "title text-lg text-primary-500" %>
+
+ <%= color_input f, :text_color, value: "#ffffff" %>
+
+
+ <%= error_tag f, :text_color %>
+
+
+ <%= submit "Save", class: "mx-auto btn btn-primary col-span-3",
+ phx_disable_with: "Saving..." %>
+
+
+ """
+ end
+
defp save_tag(socket, :edit, tag_params) do
case Tags.update_tag(socket.assigns.tag, tag_params) do
{:ok, _tag} ->
@@ -54,8 +98,7 @@ defmodule CanneryWeb.TagLive.FormComponent do
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, socket |> assign(changeset: changeset)}
end
- end
-
+ end-
@doc """
Returns a random tag color in `#ffffff` hex format
"""
diff --git a/lib/cannery_web/live/tag_live/form_component.html.leex b/lib/cannery_web/live/tag_live/form_component.html.leex
deleted file mode 100644
index acd4f0e..0000000
--- a/lib/cannery_web/live/tag_live/form_component.html.leex
+++ /dev/null
@@ -1,36 +0,0 @@
-
- <%= @title %>
-
-
-<%= f = form_for @changeset, "#",
- id: "tag-form",
- class: "grid grid-cols-3 justify-center items-center space-y-4",
- phx_target: @myself,
- phx_change: "validate",
- phx_submit: "save" %>
-
- <%= label f, :name, class: "title text-lg text-primary-500" %>
- <%= text_input f, :name, class: "input input-primary col-span-2" %>
-
- <%= error_tag f, :name %>
-
-
- <%= label f, :bg_color, class: "title text-lg text-primary-500" %>
-
- <%= color_input f, :bg_color, value: random_color() %>
-
-
- <%= error_tag f, :bg_color %>
-
-
- <%= label f, :text_color, class: "title text-lg text-primary-500" %>
-
- <%= color_input f, :text_color, value: "#ffffff" %>
-
-
- <%= error_tag f, :text_color %>
-
-
- <%= submit "Save", class: "mx-auto btn btn-primary col-span-3",
- phx_disable_with: "Saving..." %>
-
diff --git a/lib/cannery_web/templates/layout/live.html.heex b/lib/cannery_web/templates/layout/live.html.heex
index 1beb8a8..29b6870 100644
--- a/lib/cannery_web/templates/layout/live.html.heex
+++ b/lib/cannery_web/templates/layout/live.html.heex
@@ -1,10 +1,12 @@