From 47dab6490d911921ca22e391d1544c0a86e4000b Mon Sep 17 00:00:00 2001 From: shibao Date: Sat, 4 Feb 2023 10:28:13 -0500 Subject: [PATCH] improve templates --- CHANGELOG.md | 1 + .../add_shot_group_component.html.heex | 11 +- lib/cannery_web/components/ammo_group_card.ex | 71 ++-- lib/cannery_web/components/container_card.ex | 40 +- .../components/container_table_component.ex | 6 +- lib/cannery_web/components/invite_card.ex | 12 +- .../components/table_component.html.heex | 25 +- lib/cannery_web/components/tag_card.ex | 4 +- lib/cannery_web/components/topbar.ex | 18 +- lib/cannery_web/components/user_card.ex | 12 +- .../ammo_group_live/form_component.html.heex | 17 +- .../live/ammo_group_live/index.html.heex | 13 +- .../ammo_type_live/form_component.html.heex | 11 +- .../live/ammo_type_live/index.html.heex | 29 +- .../live/ammo_type_live/show.html.heex | 50 +-- .../edit_tags_component.html.heex | 51 ++- .../container_live/form_component.html.heex | 11 +- .../live/container_live/index.html.heex | 129 ++++--- .../live/container_live/show.html.heex | 82 ++-- lib/cannery_web/live/home_live.ex | 157 -------- lib/cannery_web/live/home_live.html.heex | 144 ++++++++ .../live/invite_live/form_component.html.heex | 13 +- .../live/invite_live/index.html.heex | 216 ++++++----- lib/cannery_web/live/live_helpers.ex | 24 +- .../live/range_live/form_component.html.heex | 11 +- .../live/range_live/index.html.heex | 91 +++-- .../live/tag_live/form_component.ex | 47 --- .../live/tag_live/form_component.html.heex | 42 +++ lib/cannery_web/live/tag_live/index.html.heex | 68 ++-- .../templates/error/error.html.heex | 2 +- .../templates/layout/app.html.heex | 16 +- .../templates/layout/live.html.heex | 33 +- .../templates/user_confirmation/new.html.heex | 27 +- .../templates/user_registration/new.html.heex | 27 +- .../user_reset_password/edit.html.heex | 39 +- .../user_reset_password/new.html.heex | 27 +- .../templates/user_session/new.html.heex | 41 +- .../templates/user_settings/edit.html.heex | 45 +-- lib/cannery_web/views/error_helpers.ex | 12 +- lib/cannery_web/views/layout_view.ex | 12 +- lib/cannery_web/views/view_helpers.ex | 50 ++- priv/gettext/actions.pot | 94 +++-- priv/gettext/de/LC_MESSAGES/actions.po | 94 +++-- priv/gettext/de/LC_MESSAGES/default.po | 349 ++++++++++-------- priv/gettext/de/LC_MESSAGES/errors.po | 12 +- priv/gettext/de/LC_MESSAGES/prompts.po | 62 ++-- priv/gettext/default.pot | 327 ++++++++-------- priv/gettext/en/LC_MESSAGES/actions.po | 94 +++-- priv/gettext/en/LC_MESSAGES/default.po | 327 ++++++++-------- priv/gettext/en/LC_MESSAGES/errors.po | 12 +- priv/gettext/en/LC_MESSAGES/prompts.po | 62 ++-- priv/gettext/errors.pot | 12 +- priv/gettext/es/LC_MESSAGES/actions.po | 94 +++-- priv/gettext/es/LC_MESSAGES/default.po | 349 ++++++++++-------- priv/gettext/es/LC_MESSAGES/errors.po | 12 +- priv/gettext/es/LC_MESSAGES/prompts.po | 62 ++-- priv/gettext/fr/LC_MESSAGES/actions.po | 94 +++-- priv/gettext/fr/LC_MESSAGES/default.po | 349 ++++++++++-------- priv/gettext/fr/LC_MESSAGES/errors.po | 12 +- priv/gettext/fr/LC_MESSAGES/prompts.po | 62 ++-- priv/gettext/ga/LC_MESSAGES/actions.po | 94 +++-- priv/gettext/ga/LC_MESSAGES/default.po | 345 +++++++++-------- priv/gettext/ga/LC_MESSAGES/errors.po | 12 +- priv/gettext/ga/LC_MESSAGES/prompts.po | 62 ++-- priv/gettext/prompts.pot | 62 ++-- 65 files changed, 2418 insertions(+), 2373 deletions(-) create mode 100644 lib/cannery_web/live/home_live.html.heex create mode 100644 lib/cannery_web/live/tag_live/form_component.html.heex diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d4a8def..c541fb9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # v0.8.2 - Fix bug with public registration +- Improve templates # v0.8.1 - Update dependencies diff --git a/lib/cannery_web/components/add_shot_group_component.html.heex b/lib/cannery_web/components/add_shot_group_component.html.heex index 7e8d1b1d..c68a2663 100644 --- a/lib/cannery_web/components/add_shot_group_component.html.heex +++ b/lib/cannery_web/components/add_shot_group_component.html.heex @@ -12,11 +12,12 @@ phx-change="validate" phx-submit="save" > - <%= if @changeset.action && not @changeset.valid? do %> -
- <%= changeset_errors(@changeset) %> -
- <% end %> +
+ <%= changeset_errors(@changeset) %> +
<%= label(f, :ammo_left, gettext("Rounds left"), class: "title text-lg text-primary-600") %> <%= number_input(f, :ammo_left, diff --git a/lib/cannery_web/components/ammo_group_card.ex b/lib/cannery_web/components/ammo_group_card.ex index 70165c51..1af9d073 100644 --- a/lib/cannery_web/components/ammo_group_card.ex +++ b/lib/cannery_web/components/ammo_group_card.ex @@ -23,9 +23,10 @@ defmodule CanneryWeb.Components.AmmoGroupCard do ~H"""
<.link navigate={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)} class="mb-2 link">

@@ -39,31 +40,28 @@ defmodule CanneryWeb.Components.AmmoGroupCard do <%= if @ammo_group.count == 0, do: gettext("Empty"), else: @ammo_group.count %> - <%= if @ammo_group |> Ammo.get_original_count() != @ammo_group.count do %> - - <%= gettext("Original Count:") %> - <%= @ammo_group |> Ammo.get_original_count() %> - - <% end %> + Ammo.get_original_count() != @ammo_group.count} + class="rounded-lg title text-lg" + > + <%= gettext("Original Count:") %> + <%= @ammo_group |> Ammo.get_original_count() %> + - <%= if @ammo_group.notes do %> - - <%= gettext("Notes:") %> - <%= @ammo_group.notes %> - - <% end %> + + <%= gettext("Notes:") %> + <%= @ammo_group.notes %> + <%= gettext("Purchased on:") %> <.date date={@ammo_group.purchased_on} /> - <%= if @ammo_group |> Ammo.get_last_used_shot_group() do %> - - <%= gettext("Last used on:") %> - <.date date={@ammo_group |> Ammo.get_last_used_shot_group() |> Map.get(:date)} /> - - <% end %> + Ammo.get_last_used_shot_group()} class="rounded-lg title text-lg"> + <%= gettext("Last used on:") %> + <.date date={@ammo_group |> Ammo.get_last_used_shot_group() |> Map.get(:date)} /> + <%= if @ammo_group.price_paid do %> @@ -81,25 +79,24 @@ defmodule CanneryWeb.Components.AmmoGroupCard do <% end %> - <%= if @show_container and @ammo_group.container do %> - - <%= gettext("Container:") %> + + <%= gettext("Container:") %> - <.link - navigate={Routes.container_show_path(Endpoint, :show, @ammo_group.container)} - class="link" - > - <%= @ammo_group.container.name %> - - - <% end %> + <.link + navigate={Routes.container_show_path(Endpoint, :show, @ammo_group.container)} + class="link" + > + <%= @ammo_group.container.name %> + +

- <%= if assigns |> Map.has_key?(:inner_block) do %> -
- <%= render_slot(@inner_block) %> -
- <% end %> +
Map.has_key?(:inner_block)} + class="mt-4 flex space-x-4 justify-center items-center" + > + <%= render_slot(@inner_block) %> +
""" end diff --git a/lib/cannery_web/components/container_card.ex b/lib/cannery_web/components/container_card.ex index c8d24905..c69637bf 100644 --- a/lib/cannery_web/components/container_card.ex +++ b/lib/cannery_web/components/container_card.ex @@ -23,7 +23,8 @@ defmodule CanneryWeb.Components.ContainerCard do ~H"""
@@ -34,24 +35,20 @@ defmodule CanneryWeb.Components.ContainerCard do - <%= if @container.desc do %> - - <%= gettext("Description:") %> - <%= @container.desc %> - - <% end %> + + <%= gettext("Description:") %> + <%= @container.desc %> + <%= gettext("Type:") %> <%= @container.type %> - <%= if @container.location do %> - - <%= gettext("Location:") %> - <%= @container.location %> - - <% end %> + + <%= gettext("Location:") %> + <%= @container.location %> + <%= unless @container.ammo_groups |> Enum.empty?() do %> @@ -66,21 +63,18 @@ defmodule CanneryWeb.Components.ContainerCard do <% end %>
- <%= unless @container.tags |> Enum.empty?() do %> - <%= for tag <- @container.tags do %> - <.simple_tag_card tag={tag} /> - <% end %> - <% end %> + <.simple_tag_card :for={tag <- @container.tags} :if={@container.tags} tag={tag} /> <%= render_slot(@tag_actions) %>
- <%= if assigns |> Map.has_key?(:inner_block) do %> -
- <%= render_slot(@inner_block) %> -
- <% end %> +
Map.has_key?(:inner_block)} + class="flex space-x-4 justify-center items-center" + > + <%= render_slot(@inner_block) %> +
""" end diff --git a/lib/cannery_web/components/container_table_component.ex b/lib/cannery_web/components/container_table_component.ex index c97c585d..e41d616a 100644 --- a/lib/cannery_web/components/container_table_component.ex +++ b/lib/cannery_web/components/container_table_component.ex @@ -135,11 +135,7 @@ defmodule CanneryWeb.Components.ContainerTableComponent do {container.tags |> Enum.map(fn %{name: name} -> name end), ~H"""
- <%= unless @container.tags |> Enum.empty?() do %> - <%= for tag <- @container.tags do %> - - <% end %> - <% end %> + <%= render_slot(@tag_actions, @container) %>
diff --git a/lib/cannery_web/components/invite_card.ex b/lib/cannery_web/components/invite_card.ex index 1c69cd77..e4cd254f 100644 --- a/lib/cannery_web/components/invite_card.ex +++ b/lib/cannery_web/components/invite_card.ex @@ -18,8 +18,8 @@ defmodule CanneryWeb.Components.InviteCard do

<%= @invite.name %> @@ -56,11 +56,9 @@ defmodule CanneryWeb.Components.InviteCard do <%= render_slot(@code_actions) %>

- <%= if @inner_block do %> -
- <%= render_slot(@inner_block) %> -
- <% end %> +
+ <%= render_slot(@inner_block) %> +
""" end diff --git a/lib/cannery_web/components/table_component.html.heex b/lib/cannery_web/components/table_component.html.heex index 97e53fce..6f568ae6 100644 --- a/lib/cannery_web/components/table_component.html.heex +++ b/lib/cannery_web/components/table_component.html.heex @@ -34,20 +34,19 @@ - <%= for {values, i} <- @rows |> Enum.with_index() do %> - Integer.is_even(), do: @row_class, else: @alternate_row_class}> - <%= for %{key: key} = value <- @columns do %> - - <%= case values |> Map.get(key) do %> - <% {_custom_sort_value, value} -> %> - <%= value %> - <% value -> %> - <%= value %> - <% end %> - + Enum.with_index()} + class={if i |> Integer.is_even(), do: @row_class, else: @alternate_row_class} + > + + <%= case values |> Map.get(key) do %> + <% {_custom_sort_value, value} -> %> + <%= value %> + <% value -> %> + <%= value %> <% end %> - - <% end %> + + diff --git a/lib/cannery_web/components/tag_card.ex b/lib/cannery_web/components/tag_card.ex index 24598615..b7dca456 100644 --- a/lib/cannery_web/components/tag_card.ex +++ b/lib/cannery_web/components/tag_card.ex @@ -14,8 +14,8 @@ defmodule CanneryWeb.Components.TagCard do
<.simple_tag_card tag={@tag} /> <%= render_slot(@inner_block) %> diff --git a/lib/cannery_web/components/topbar.ex b/lib/cannery_web/components/topbar.ex index 573446fb..ca554b9a 100644 --- a/lib/cannery_web/components/topbar.ex +++ b/lib/cannery_web/components/topbar.ex @@ -119,16 +119,14 @@ defmodule CanneryWeb.Components.Topbar do <% end %> <% else %> - <%= if Accounts.allow_registration?() do %> -
  • - <.link - navigate={Routes.user_registration_path(Endpoint, :new)} - class="text-primary-600 text-white hover:underline truncate" - > - <%= dgettext("actions", "Register") %> - -
  • - <% end %> +
  • + <.link + navigate={Routes.user_registration_path(Endpoint, :new)} + class="text-primary-600 text-white hover:underline truncate" + > + <%= dgettext("actions", "Register") %> + +
  • <.link navigate={Routes.user_session_path(Endpoint, :new)} diff --git a/lib/cannery_web/components/user_card.ex b/lib/cannery_web/components/user_card.ex index 5daba522..8cdac98e 100644 --- a/lib/cannery_web/components/user_card.ex +++ b/lib/cannery_web/components/user_card.ex @@ -14,8 +14,8 @@ defmodule CanneryWeb.Components.UserCard do

    <%= @user.email %> @@ -43,11 +43,9 @@ defmodule CanneryWeb.Components.UserCard do

    - <%= if @inner_block do %> -
    - <%= render_slot(@inner_block) %> -
    - <% end %> +
    + <%= render_slot(@inner_block) %> +
    """ end diff --git a/lib/cannery_web/live/ammo_group_live/form_component.html.heex b/lib/cannery_web/live/ammo_group_live/form_component.html.heex index 7957b2bb..d9fec97e 100644 --- a/lib/cannery_web/live/ammo_group_live/form_component.html.heex +++ b/lib/cannery_web/live/ammo_group_live/form_component.html.heex @@ -12,11 +12,12 @@ phx-submit="save" class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" > - <%= if @changeset.action && not @changeset.valid? do %> -
    - <%= changeset_errors(@changeset) %> -
    - <% end %> +
    + <%= changeset_errors(@changeset) %> +
    <%= label(f, :ammo_type_id, gettext("Ammo type"), class: "title text-lg text-primary-600") %> <%= select(f, :ammo_type_id, ammo_type_options(@ammo_types), @@ -59,8 +60,8 @@ ) %> <%= error_tag(f, :container_id, "col-span-3 text-center") %> - <%= cond do %> - <% @action in [:new, :clone] -> %> + <%= case @action do %> + <% action when action in [:new, :clone] -> %>
    <%= label(f, :multiplier, gettext("Copies"), class: "title text-lg text-primary-600") %> @@ -77,7 +78,7 @@ ) %> <%= error_tag(f, :multiplier, "col-span-3 text-center") %> - <% @action == :edit -> %> + <% :edit -> %> <%= submit(dgettext("actions", "Save"), phx_disable_with: dgettext("prompts", "Saving..."), class: "mx-auto col-span-3 btn btn-primary" 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 c64c3570..19120b40 100644 --- a/lib/cannery_web/live/ammo_group_live/index.html.heex +++ b/lib/cannery_web/live/ammo_group_live/index.html.heex @@ -3,12 +3,13 @@ <%= gettext("Ammo") %> - <%= if @ammo_groups |> Enum.empty?() and @search |> is_nil() do %> -

    - <%= gettext("No Ammo") %> - <%= display_emoji("😔") %> -

    - <% end %> +

    Enum.empty?() and @search |> is_nil()} + class="title text-xl text-primary-600" + > + <%= gettext("No Ammo") %> + <%= display_emoji("😔") %> +

    <%= cond do %> <% @containers_count == 0 -> %> diff --git a/lib/cannery_web/live/ammo_type_live/form_component.html.heex b/lib/cannery_web/live/ammo_type_live/form_component.html.heex index 342ff94a..652532fa 100644 --- a/lib/cannery_web/live/ammo_type_live/form_component.html.heex +++ b/lib/cannery_web/live/ammo_type_live/form_component.html.heex @@ -11,11 +11,12 @@ phx-submit="save" class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" > - <%= if @changeset.action && not @changeset.valid? do %> -
    - <%= changeset_errors(@changeset) %> -
    - <% end %> +
    + <%= changeset_errors(@changeset) %> +
    <%= label(f, :name, gettext("Name"), class: "title text-lg text-primary-600") %> <%= text_input(f, :name, class: "text-center col-span-2 input input-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 67a85f33..955da69c 100644 --- a/lib/cannery_web/live/ammo_type_live/index.html.heex +++ b/lib/cannery_web/live/ammo_type_live/index.html.heex @@ -104,17 +104,18 @@ <% end %>
  • -<%= if @live_action in [:new, :edit, :clone] do %> - <.modal return_to={Routes.ammo_type_index_path(Endpoint, :index)}> - <.live_component - module={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(Endpoint, :index)} - current_user={@current_user} - } - /> - -<% end %> +<.modal + :if={@live_action in [:new, :edit, :clone]} + return_to={Routes.ammo_type_index_path(Endpoint, :index)} +> + <.live_component + module={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(Endpoint, :index)} + current_user={@current_user} + } + /> + 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 3dcdc5d0..894bc19f 100644 --- a/lib/cannery_web/live/ammo_type_live/show.html.heex +++ b/lib/cannery_web/live/ammo_type_live/show.html.heex @@ -3,13 +3,14 @@ <%= @ammo_type.name %> - <%= if @ammo_type.desc do %> - - <%= @ammo_type.desc %> - - <% end %> + + <%= @ammo_type.desc %> +
    <.link @@ -185,25 +186,28 @@ <% else %>
    - <%= for ammo_group <- @ammo_groups do %> - <.ammo_group_card ammo_group={ammo_group} show_container={true} /> - <% end %> + <.ammo_group_card + :for={ammo_group <- @ammo_groups} + ammo_group={ammo_group} + show_container={true} + />
    <% end %> <% end %>
    -<%= if @live_action in [:edit] do %> - <.modal return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)}> - <.live_component - module={CanneryWeb.AmmoTypeLive.FormComponent} - id={@ammo_type.id} - title={@page_title} - action={@live_action} - ammo_type={@ammo_type} - return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)} - current_user={@current_user} - /> - -<% end %> +<.modal + :if={@live_action == :edit} + return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)} +> + <.live_component + module={CanneryWeb.AmmoTypeLive.FormComponent} + id={@ammo_type.id} + title={@page_title} + action={@live_action} + ammo_type={@ammo_type} + return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)} + current_user={@current_user} + /> + diff --git a/lib/cannery_web/live/container_live/edit_tags_component.html.heex b/lib/cannery_web/live/container_live/edit_tags_component.html.heex index 69565f68..2583aeab 100644 --- a/lib/cannery_web/live/container_live/edit_tags_component.html.heex +++ b/lib/cannery_web/live/container_live/edit_tags_component.html.heex @@ -4,34 +4,31 @@
    - <%= for tag <- @container.tags do %> - <.link - href="#" - class="mx-2 my-1 px-4 py-2 rounded-lg title text-xl" - style={"color: #{tag.text_color}; background-color: #{tag.bg_color}"} - phx-click="delete" - phx-value-tag-id={tag.id} - phx-target={@myself} - data-confirm={ - dgettext( - "prompts", - "Are you sure you want to remove the %{tag_name} tag from %{container_name}?", - tag_name: tag.name, - container_name: @container.name - ) - } - > - <%= tag.name %> - - - <% end %> + <.link + :for={tag <- @container.tags} + href="#" + class="mx-2 my-1 px-4 py-2 rounded-lg title text-xl" + style={"color: #{tag.text_color}; background-color: #{tag.bg_color}"} + phx-click="delete" + phx-value-tag-id={tag.id} + phx-target={@myself} + data-confirm={ + dgettext( + "prompts", + "Are you sure you want to remove the %{tag_name} tag from %{container_name}?", + tag_name: tag.name, + container_name: @container.name + ) + } + > + <%= tag.name %> + + - <%= if @container.tags |> Enum.empty?() do %> -

    - <%= gettext("No tags") %> - <%= display_emoji("😔") %> -

    - <% end %> +

    Enum.empty?()} class="title text-xl text-primary-600"> + <%= gettext("No tags") %> + <%= display_emoji("😔") %> +

    <%= unless tag_options(@tags, @container) |> Enum.empty?() do %> diff --git a/lib/cannery_web/live/container_live/form_component.html.heex b/lib/cannery_web/live/container_live/form_component.html.heex index 848f58dc..2d6c3405 100644 --- a/lib/cannery_web/live/container_live/form_component.html.heex +++ b/lib/cannery_web/live/container_live/form_component.html.heex @@ -11,11 +11,12 @@ phx-change="validate" phx-submit="save" > - <%= if @changeset.action && not @changeset.valid? do %> -
    - <%= changeset_errors(@changeset) %> -
    - <% end %> +
    + <%= changeset_errors(@changeset) %> +
    <%= label(f, :name, gettext("Name"), class: "title text-lg text-primary-600") %> <%= text_input(f, :name, diff --git a/lib/cannery_web/live/container_live/index.html.heex b/lib/cannery_web/live/container_live/index.html.heex index 380cf563..2de82590 100644 --- a/lib/cannery_web/live/container_live/index.html.heex +++ b/lib/cannery_web/live/container_live/index.html.heex @@ -99,78 +99,73 @@ <% else %>
    - <%= for container <- @containers do %> - <.container_card container={container}> - <:tag_actions> -
    - <.link - patch={Routes.container_index_path(Endpoint, :edit_tags, container)} - class="text-primary-600 link" - > - - -
    - - <.link - patch={Routes.container_index_path(Endpoint, :edit, container)} - class="text-primary-600 link" - data-qa={"edit-#{container.id}"} - > - - + <.container_card :for={container <- @containers} container={container}> + <:tag_actions> +
    + <.link + patch={Routes.container_index_path(Endpoint, :edit_tags, container)} + class="text-primary-600 link" + > + + +
    + + <.link + patch={Routes.container_index_path(Endpoint, :edit, container)} + class="text-primary-600 link" + data-qa={"edit-#{container.id}"} + > + + - <.link - patch={Routes.container_index_path(Endpoint, :clone, container)} - class="text-primary-600 link" - data-qa={"clone-#{container.id}"} - > - - + <.link + patch={Routes.container_index_path(Endpoint, :clone, container)} + class="text-primary-600 link" + data-qa={"clone-#{container.id}"} + > + + - <.link - href="#" - class="text-primary-600 link" - phx-click="delete" - phx-value-id={container.id} - data-confirm={ - dgettext("prompts", "Are you sure you want to delete %{name}?", - name: container.name - ) - } - data-qa={"delete-#{container.id}"} - > - - - - <% end %> + <.link + href="#" + class="text-primary-600 link" + phx-click="delete" + phx-value-id={container.id} + data-confirm={ + dgettext("prompts", "Are you sure you want to delete %{name}?", name: container.name) + } + data-qa={"delete-#{container.id}"} + > + + +
    <% end %> <% end %> -<%= if @live_action in [:new, :edit, :clone] do %> - <.modal return_to={Routes.container_index_path(Endpoint, :index)}> - <.live_component - module={CanneryWeb.ContainerLive.FormComponent} - id={@container.id || :new} - title={@page_title} - action={@live_action} - container={@container} - return_to={Routes.container_index_path(Endpoint, :index)} - current_user={@current_user} - /> - -<% end %> +<.modal + :if={@live_action in [:new, :edit, :clone]} + return_to={Routes.container_index_path(Endpoint, :index)} +> + <.live_component + module={CanneryWeb.ContainerLive.FormComponent} + id={@container.id || :new} + title={@page_title} + action={@live_action} + container={@container} + return_to={Routes.container_index_path(Endpoint, :index)} + current_user={@current_user} + /> + -<%= if @live_action == :edit_tags do %> - <.modal return_to={Routes.container_index_path(Endpoint, :index)}> - <.live_component - module={CanneryWeb.ContainerLive.EditTagsComponent} - id={@container.id} - title={@page_title} - action={@live_action} - container={@container} - current_user={@current_user} - /> - -<% end %> +<.modal :if={@live_action == :edit_tags} return_to={Routes.container_index_path(Endpoint, :index)}> + <.live_component + module={CanneryWeb.ContainerLive.EditTagsComponent} + id={@container.id} + title={@page_title} + action={@live_action} + container={@container} + current_user={@current_user} + /> + diff --git a/lib/cannery_web/live/container_live/show.html.heex b/lib/cannery_web/live/container_live/show.html.heex index 8ab92347..a892e163 100644 --- a/lib/cannery_web/live/container_live/show.html.heex +++ b/lib/cannery_web/live/container_live/show.html.heex @@ -3,24 +3,20 @@ <%= @container.name %> - <%= if @container.desc do %> - - <%= gettext("Description:") %> - <%= @container.desc %> - - <% end %> + + <%= gettext("Description:") %> + <%= @container.desc %> + <%= gettext("Type:") %> <%= @container.type %> - <%= if @container.location do %> - - <%= gettext("Location:") %> - <%= @container.location %> - - <% end %> + + <%= gettext("Location:") %> + <%= @container.location %> + <%= unless @ammo_groups |> Enum.empty?() do %> @@ -82,9 +78,7 @@ <% else %>
    - <%= for tag <- @container.tags do %> - <.simple_tag_card tag={tag} /> - <% end %> + <.simple_tag_card :for={tag <- @container.tags} tag={tag} />
    <.link @@ -134,39 +128,39 @@ <% else %>
    - <%= for ammo_group <- @ammo_groups do %> - <.ammo_group_card ammo_group={ammo_group} /> - <% end %> + <.ammo_group_card :for={ammo_group <- @ammo_groups} ammo_group={ammo_group} />
    <% end %> <% end %>
    -<%= if @live_action in [:edit] do %> - <.modal return_to={Routes.container_show_path(Endpoint, :show, @container)}> - <.live_component - module={CanneryWeb.ContainerLive.FormComponent} - id={@container.id} - title={@page_title} - action={@live_action} - container={@container} - return_to={Routes.container_show_path(Endpoint, :show, @container)} - current_user={@current_user} - /> - -<% end %> +<.modal + :if={@live_action == :edit} + return_to={Routes.container_show_path(Endpoint, :show, @container)} +> + <.live_component + module={CanneryWeb.ContainerLive.FormComponent} + id={@container.id} + title={@page_title} + action={@live_action} + container={@container} + return_to={Routes.container_show_path(Endpoint, :show, @container)} + current_user={@current_user} + /> + -<%= if @live_action == :edit_tags do %> - <.modal return_to={Routes.container_show_path(Endpoint, :show, @container)}> - <.live_component - module={CanneryWeb.ContainerLive.EditTagsComponent} - id={@container.id} - title={@page_title} - action={@live_action} - container={@container} - return_to={Routes.container_show_path(Endpoint, :show, @container)} - current_user={@current_user} - /> - -<% end %> +<.modal + :if={@live_action == :edit_tags} + return_to={Routes.container_show_path(Endpoint, :show, @container)} +> + <.live_component + module={CanneryWeb.ContainerLive.EditTagsComponent} + id={@container.id} + title={@page_title} + action={@live_action} + container={@container} + return_to={Routes.container_show_path(Endpoint, :show, @container)} + current_user={@current_user} + /> + diff --git a/lib/cannery_web/live/home_live.ex b/lib/cannery_web/live/home_live.ex index 3f8a589a..b1f8e160 100644 --- a/lib/cannery_web/live/home_live.ex +++ b/lib/cannery_web/live/home_live.ex @@ -15,161 +15,4 @@ defmodule CanneryWeb.HomeLive do socket = socket |> assign(page_title: gettext("Home"), admins: admins, version: @version) {:ok, socket} end - - @impl true - def render(assigns) do - ~H""" -
    - {gettext("Cannery:3")} - /> - -

    - <%= gettext("Welcome to %{name}", name: "Cannery") %> -

    - -

    - <%= gettext("The self-hosted firearm tracker website") %> -

    - -
    - -
      -
    • - - <%= gettext("Easy to Use:") %> - -

      - <%= gettext( - "%{name} lets you easily keep an eye on your ammo levels before and after range day", - name: "Cannery" - ) %> -

      -
    • -
    • - - <%= gettext("Secure:") %> - -

      - <%= gettext("Self-host your own instance, or use an instance from someone you trust.") %> - <%= gettext("Your data stays with you, period") %> -

      -
    • -
    • - - <%= gettext("Simple:") %> - -

      - <%= gettext("Access from any internet-capable device") %> -

      -
    • -
    - -
    - -
      -

      - <%= gettext("Instance Information") %> -

      - -
    • - - <%= gettext("Admins:") %> - -

      - <%= if @admins |> Enum.empty?() do %> - <.link - href={Routes.user_registration_path(CanneryWeb.Endpoint, :new)} - class="hover:underline" - > - <%= dgettext("prompts", "Register to setup %{name}", name: "Cannery") %> - - <% else %> -

      - <%= for admin <- @admins do %> - - <%= admin.email %> - - <% end %> -
      - <% end %> -

      -
    • - -
    • - Registration: -

      - <%= case Application.get_env(:cannery, Cannery.Accounts)[:registration] do - "public" -> gettext("Public Signups") - _ -> gettext("Invite Only") - end %> -

      -
    • - -
    • - Version: - <.link - href="https://gitea.bubbletea.dev/shibao/cannery/src/branch/stable/CHANGELOG.md" - class="flex flex-row justify-center items-center space-x-2 hover:underline" - target="_blank" - rel="noopener noreferrer" - > -

      - <%= @version %> -

      - - -
    • -
    - -
    - -
      -

      - <%= gettext("Get involved!") %> -

      - -
    • - <.link - class="flex flex-row justify-center items-center space-x-2 hover:underline" - href="https://gitea.bubbletea.dev/shibao/cannery" - target="_blank" - rel="noopener noreferrer" - > -

      <%= gettext("View the source code") %>

      - - -
    • -
    • - <.link - class="flex flex-row justify-center items-center space-x-2 hover:underline" - href="https://weblate.bubbletea.dev/engage/cannery" - target="_blank" - rel="noopener noreferrer" - > -

      <%= gettext("Help translate") %>

      - - -
    • -
    • - <.link - class="flex flex-row justify-center items-center space-x-2 hover:underline" - href="https://gitea.bubbletea.dev/shibao/cannery/issues/new" - target="_blank" - rel="noopener noreferrer" - > -

      <%= gettext("Report bugs or request features") %>

      - - -
    • -
    -
    - """ - end end diff --git a/lib/cannery_web/live/home_live.html.heex b/lib/cannery_web/live/home_live.html.heex new file mode 100644 index 00000000..0a0ea1db --- /dev/null +++ b/lib/cannery_web/live/home_live.html.heex @@ -0,0 +1,144 @@ +
    + {gettext("Cannery:3")} + /> + +

    + <%= gettext("Welcome to Cannery") %> +

    + +

    + <%= gettext("The self-hosted firearm tracker website") %> +

    + +
    + +
      +
    • + + <%= gettext("Easy to Use:") %> + +

      + <%= gettext( + "Cannery lets you easily keep an eye on your ammo levels before and after range day" + ) %> +

      +
    • +
    • + + <%= gettext("Secure:") %> + +

      + <%= gettext("Self-host your own instance, or use an instance from someone you trust.") %> + <%= gettext("Your data stays with you, period") %> +

      +
    • +
    • + + <%= gettext("Simple:") %> + +

      + <%= gettext("Access from any internet-capable device") %> +

      +
    • +
    + +
    + +
      +

      + <%= gettext("Instance Information") %> +

      + +
    • + + <%= gettext("Admins:") %> + +

      + <%= if @admins |> Enum.empty?() do %> + <.link href={Routes.user_registration_path(Endpoint, :new)} class="hover:underline"> + <%= dgettext("prompts", "Register to setup Cannery") %> + + <% else %> +

      + <% end %> +

      +
    • + +
    • + <%= gettext("Registration:") %> +

      + <%= case Application.get_env(:cannery, Cannery.Accounts)[:registration] do + "public" -> gettext("Public Signups") + _ -> gettext("Invite Only") + end %> +

      +
    • + +
    • + <%= gettext("Version:") %> + <.link + href="https://gitea.bubbletea.dev/shibao/cannery/src/branch/stable/CHANGELOG.md" + class="flex flex-row justify-center items-center space-x-2 hover:underline" + target="_blank" + rel="noopener noreferrer" + > +

      + <%= @version %> +

      + + +
    • +
    + +
    + +
      +

      + <%= gettext("Get involved!") %> +

      + +
    • + <.link + class="flex flex-row justify-center items-center space-x-2 hover:underline" + href="https://gitea.bubbletea.dev/shibao/cannery" + target="_blank" + rel="noopener noreferrer" + > +

      <%= gettext("View the source code") %>

      + + +
    • +
    • + <.link + class="flex flex-row justify-center items-center space-x-2 hover:underline" + href="https://weblate.bubbletea.dev/engage/cannery" + target="_blank" + rel="noopener noreferrer" + > +

      <%= gettext("Help translate") %>

      + + +
    • +
    • + <.link + class="flex flex-row justify-center items-center space-x-2 hover:underline" + href="https://gitea.bubbletea.dev/shibao/cannery/issues/new" + target="_blank" + rel="noopener noreferrer" + > +

      <%= gettext("Report bugs or request features") %>

      + + +
    • +
    +
    diff --git a/lib/cannery_web/live/invite_live/form_component.html.heex b/lib/cannery_web/live/invite_live/form_component.html.heex index de8e8ccb..2258827f 100644 --- a/lib/cannery_web/live/invite_live/form_component.html.heex +++ b/lib/cannery_web/live/invite_live/form_component.html.heex @@ -11,11 +11,12 @@ phx-change="validate" phx-submit="save" > - <%= if @changeset.action && not @changeset.valid? do %> -
    - <%= changeset_errors(@changeset) %> -
    - <% end %> +
    + <%= changeset_errors(@changeset) %> +
    <%= label(f, :name, gettext("Name"), class: "title text-lg text-primary-600") %> <%= text_input(f, :name, class: "input input-primary col-span-2") %> @@ -25,7 +26,7 @@ <%= number_input(f, :uses_left, min: 0, class: "input input-primary col-span-2") %> <%= error_tag(f, :uses_left, "col-span-3") %> - <%= gettext("Leave \"Uses left\" blank to make invite unlimited") %> + <%= gettext(~s/Leave "Uses left" blank to make invite unlimited/) %> <%= submit(dgettext("actions", "Save"), diff --git a/lib/cannery_web/live/invite_live/index.html.heex b/lib/cannery_web/live/invite_live/index.html.heex index 35915896..8d6e9f5a 100644 --- a/lib/cannery_web/live/invite_live/index.html.heex +++ b/lib/cannery_web/live/invite_live/index.html.heex @@ -19,69 +19,65 @@ <% end %>
    - <%= for invite <- @invites do %> - <.invite_card invite={invite}> - <:code_actions> -
    - -
    - - <.link - patch={Routes.invite_index_path(Endpoint, :edit, invite)} - class="text-primary-600 link" - data-qa={"edit-#{invite.id}"} - > - - - - <.link - href="#" - class="text-primary-600 link" - phx-click="delete_invite" - phx-value-id={invite.id} - data-confirm={ - dgettext("prompts", "Are you sure you want to delete the invite for %{name}?", - name: invite.name - ) - } - data-qa={"delete-#{invite.id}"} - > - - - - <%= if invite.disabled_at |> is_nil() do %> - - <%= dgettext("actions", "Disable") %> - - <% else %> - - <%= dgettext("actions", "Enable") %> - - <% end %> - - <%= if invite.disabled_at |> is_nil() and not (invite.uses_left |> is_nil()) do %> - + <:code_actions> +
    + +
    + + <.link + patch={Routes.invite_index_path(Endpoint, :edit, invite)} + class="text-primary-600 link" + data-qa={"edit-#{invite.id}"} + > + + + + <.link + href="#" + class="text-primary-600 link" + phx-click="delete_invite" + phx-value-id={invite.id} + data-confirm={ + dgettext("prompts", "Are you sure you want to delete the invite for %{name}?", + name: invite.name + ) + } + data-qa={"delete-#{invite.id}"} + > + + + + + <%= if invite.disabled_at, do: gettext("Enable"), else: gettext("Disable") %> + + + is_nil() and not (invite.uses_left |> is_nil())} + href="#" + class="btn btn-primary" + phx-click="set_unlimited" + phx-value-id={invite.id} + data-confirm={ + dgettext("prompts", "Are you sure you want to make %{name} unlimited?", + name: invite.name + ) + } + > + <%= dgettext("actions", "Set Unlimited") %> + +
    <%= unless @admins |> Enum.empty?() do %> @@ -92,25 +88,23 @@
    - <%= for admin <- @admins do %> - <.user_card user={admin}> - <.link - href="#" - class="text-primary-600 link" - phx-click="delete_user" - phx-value-id={admin.id} - data-confirm={ - dgettext( - "prompts", - "Are you sure you want to delete %{email}? This action is permanent!", - email: admin.email - ) - } - > - - - - <% end %> + <.user_card :for={admin <- @admins} user={admin}> + <.link + href="#" + class="text-primary-600 link" + phx-click="delete_user" + phx-value-id={admin.id} + data-confirm={ + dgettext( + "prompts", + "Are you sure you want to delete %{email}? This action is permanent!", + email: admin.email + ) + } + > + + +
    <% end %> @@ -122,39 +116,35 @@
    - <%= for user <- @users do %> - <.user_card user={user}> - <.link - href="#" - class="text-primary-600 link" - phx-click="delete_user" - phx-value-id={user.id} - data-confirm={ - dgettext( - "prompts", - "Are you sure you want to delete %{email}? This action is permanent!", - email: user.email - ) - } - > - - - - <% end %> + <.user_card :for={user <- @users} user={user}> + <.link + href="#" + class="text-primary-600 link" + phx-click="delete_user" + phx-value-id={user.id} + data-confirm={ + dgettext( + "prompts", + "Are you sure you want to delete %{email}? This action is permanent!", + email: user.email + ) + } + > + + +
    <% end %> -<%= if @live_action in [:new, :edit] do %> - <.modal return_to={Routes.invite_index_path(Endpoint, :index)}> - <.live_component - module={CanneryWeb.InviteLive.FormComponent} - id={@invite.id || :new} - title={@page_title} - action={@live_action} - invite={@invite} - return_to={Routes.invite_index_path(Endpoint, :index)} - current_user={@current_user} - /> - -<% end %> +<.modal :if={@live_action in [:new, :edit]} return_to={Routes.invite_index_path(Endpoint, :index)}> + <.live_component + module={CanneryWeb.InviteLive.FormComponent} + id={@invite.id || :new} + title={@page_title} + action={@live_action} + invite={@invite} + return_to={Routes.invite_index_path(Endpoint, :index)} + current_user={@current_user} + /> + diff --git a/lib/cannery_web/live/live_helpers.ex b/lib/cannery_web/live/live_helpers.ex index 6599bacb..76695a5b 100644 --- a/lib/cannery_web/live/live_helpers.ex +++ b/lib/cannery_web/live/live_helpers.ex @@ -31,10 +31,10 @@ defmodule CanneryWeb.LiveHelpers do patch={@return_to} id="modal-bg" class="fade-in fixed z-10 left-0 top-0 - w-full h-full overflow-hidden - p-8 flex flex-col justify-center items-center cursor-auto" + w-full h-full overflow-hidden + p-8 flex flex-col justify-center items-center cursor-auto" style="background-color: rgba(0,0,0,0.4);" - phx_remove={hide_modal()} + phx-remove={hide_modal()} > @@ -48,18 +48,18 @@ defmodule CanneryWeb.LiveHelpers do -<%= if @live_action in [:new, :edit] do %> - <.modal return_to={Routes.tag_index_path(Endpoint, :index)}> - <.live_component - module={CanneryWeb.TagLive.FormComponent} - id={@tag.id || :new} - title={@page_title} - action={@live_action} - tag={@tag} - return_to={Routes.tag_index_path(Endpoint, :index)} - current_user={@current_user} - /> - -<% end %> +<.modal :if={@live_action in [:new, :edit]} return_to={Routes.tag_index_path(Endpoint, :index)}> + <.live_component + module={CanneryWeb.TagLive.FormComponent} + id={@tag.id || :new} + title={@page_title} + action={@live_action} + tag={@tag} + return_to={Routes.tag_index_path(Endpoint, :index)} + current_user={@current_user} + /> + diff --git a/lib/cannery_web/templates/error/error.html.heex b/lib/cannery_web/templates/error/error.html.heex index dea1c8cc..11c6cefa 100644 --- a/lib/cannery_web/templates/error/error.html.heex +++ b/lib/cannery_web/templates/error/error.html.heex @@ -5,7 +5,7 @@ - <%= dgettext("errors", "Error") %>| Cannery + <%= dgettext("errors", "Error") %> | <%= gettext("Cannery") %>