add search to tag index
This commit is contained in:
parent
d743336868
commit
3ea4b77b67
@ -1,6 +1,6 @@
|
||||
# v0.8.0
|
||||
- Add search to catalog, ammo and container index
|
||||
- Tweak urls for catalog, ammo and containers
|
||||
- Add search to catalog, ammo, container and tag index
|
||||
- Tweak urls for catalog, ammo, containers and tags
|
||||
|
||||
# v0.7.2
|
||||
- Code improvements
|
||||
|
@ -15,11 +15,38 @@ defmodule Cannery.Tags do
|
||||
iex> list_tags(%User{id: 123})
|
||||
[%Tag{}, ...]
|
||||
|
||||
iex> list_tags("cool", %User{id: 123})
|
||||
[%Tag{name: "my cool tag"}, ...]
|
||||
|
||||
"""
|
||||
@spec list_tags(User.t()) :: [Tag.t()]
|
||||
def list_tags(%{id: user_id}),
|
||||
@spec list_tags(search :: nil | String.t(), User.t()) :: [Tag.t()]
|
||||
def list_tags(search \\ nil, user)
|
||||
|
||||
def list_tags(search, %{id: user_id}) when search |> is_nil() or search == "",
|
||||
do: Repo.all(from t in Tag, where: t.user_id == ^user_id, order_by: t.name)
|
||||
|
||||
def list_tags(search, %{id: user_id}) when search |> is_binary() do
|
||||
trimmed_search = String.trim(search)
|
||||
|
||||
Repo.all(
|
||||
from t in Tag,
|
||||
where: t.user_id == ^user_id,
|
||||
where:
|
||||
fragment(
|
||||
"search @@ websearch_to_tsquery('english', ?)",
|
||||
^trimmed_search
|
||||
),
|
||||
order_by: {
|
||||
:desc,
|
||||
fragment(
|
||||
"ts_rank_cd(search, websearch_to_tsquery('english', ?), 4)",
|
||||
^trimmed_search
|
||||
)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a single tag.
|
||||
|
||||
|
@ -9,27 +9,53 @@ defmodule CanneryWeb.TagLive.Index do
|
||||
alias CanneryWeb.{Endpoint, ViewHelpers}
|
||||
|
||||
@impl true
|
||||
def mount(_params, _session, socket), do: {:ok, socket |> display_tags()}
|
||||
def mount(%{"search" => search}, _session, socket) do
|
||||
{:ok, socket |> assign(:search, search) |> display_tags()}
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket |> assign(:search, nil) |> display_tags()}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_params(params, _url, %{assigns: %{live_action: live_action}} = socket) do
|
||||
{:noreply, apply_action(socket, live_action, params) |> display_tags}
|
||||
{:noreply, apply_action(socket, live_action, params)}
|
||||
end
|
||||
|
||||
defp apply_action(%{assigns: %{current_user: current_user}} = socket, :edit, %{"id" => id}) do
|
||||
socket
|
||||
|> assign(:page_title, gettext("Edit Tag"))
|
||||
|> assign(:tag, Tags.get_tag!(id, current_user))
|
||||
|> assign(
|
||||
page_title: gettext("Edit Tag"),
|
||||
tag: Tags.get_tag!(id, current_user)
|
||||
)
|
||||
end
|
||||
|
||||
defp apply_action(socket, :new, _params) do
|
||||
socket
|
||||
|> assign(:page_title, gettext("New Tag"))
|
||||
|> assign(:tag, %Tag{bg_color: ViewHelpers.random_color(), text_color: "#ffffff"})
|
||||
|> assign(
|
||||
page_title: gettext("New Tag"),
|
||||
tag: %Tag{bg_color: ViewHelpers.random_color(), text_color: "#ffffff"}
|
||||
)
|
||||
end
|
||||
|
||||
defp apply_action(socket, :index, _params) do
|
||||
socket |> assign(:page_title, gettext("Tags")) |> assign(:tag, nil)
|
||||
socket
|
||||
|> assign(
|
||||
page_title: gettext("Tags"),
|
||||
search: nil,
|
||||
tag: nil
|
||||
)
|
||||
|> display_tags()
|
||||
end
|
||||
|
||||
defp apply_action(socket, :search, %{"search" => search}) do
|
||||
socket
|
||||
|> assign(
|
||||
page_title: gettext("Tags"),
|
||||
search: search,
|
||||
tag: nil
|
||||
)
|
||||
|> display_tags()
|
||||
end
|
||||
|
||||
@impl true
|
||||
@ -39,7 +65,16 @@ defmodule CanneryWeb.TagLive.Index do
|
||||
{:noreply, socket |> put_flash(:info, prompt) |> display_tags()}
|
||||
end
|
||||
|
||||
defp display_tags(%{assigns: %{current_user: current_user}} = socket) do
|
||||
socket |> assign(tags: Tags.list_tags(current_user))
|
||||
@impl true
|
||||
def handle_event("search", %{"search" => %{"search_term" => ""}}, socket) do
|
||||
{:noreply, socket |> push_patch(to: Routes.tag_index_path(Endpoint, :index))}
|
||||
end
|
||||
|
||||
def handle_event("search", %{"search" => %{"search_term" => search_term}}, socket) do
|
||||
{:noreply, socket |> push_patch(to: Routes.tag_index_path(Endpoint, :search, search_term))}
|
||||
end
|
||||
|
||||
defp display_tags(%{assigns: %{search: search, current_user: current_user}} = socket) do
|
||||
socket |> assign(tags: Tags.list_tags(search, current_user))
|
||||
end
|
||||
end
|
||||
|
@ -5,7 +5,7 @@
|
||||
<p class="title text-md text-primary-600">
|
||||
<%= gettext("Tags can be added to your containers to help you organize") %>
|
||||
</p>
|
||||
<%= if @tags |> Enum.empty?() do %>
|
||||
<%= if @tags |> Enum.empty?() and @search |> is_nil() do %>
|
||||
<h2 class="title text-xl text-primary-600">
|
||||
<%= gettext("No tags") %>
|
||||
<%= display_emoji("😔") %>
|
||||
@ -19,7 +19,33 @@
|
||||
<%= dgettext("actions", "New Tag") %>
|
||||
</.link>
|
||||
<% end %>
|
||||
|
||||
<div class="w-full flex flex-col sm:flex-row justify-center items-center space-y-4 sm:space-y-0 sm:space-x-4 max-w-xl">
|
||||
<.form
|
||||
:let={f}
|
||||
for={:search}
|
||||
phx-change="search"
|
||||
phx-submit="search"
|
||||
class="grow self-stretch flex flex-col items-stretch"
|
||||
data-qa="tag_search"
|
||||
>
|
||||
<%= text_input(f, :search_term,
|
||||
class: "input input-primary",
|
||||
value: @search,
|
||||
phx_debounce: 300,
|
||||
placeholder: gettext("Search tags")
|
||||
) %>
|
||||
</.form>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row flex-wrap justify-center items-center">
|
||||
<%= if @tags |> Enum.empty?() do %>
|
||||
<h2 class="title text-xl text-primary-600">
|
||||
<%= gettext("No tags") %>
|
||||
<%= display_emoji("😔") %>
|
||||
</h2>
|
||||
<% end %>
|
||||
|
||||
<%= for tag <- @tags do %>
|
||||
<.tag_card tag={tag}>
|
||||
<.link
|
||||
|
@ -64,7 +64,8 @@ defmodule CanneryWeb.Router do
|
||||
|
||||
live "/tags", TagLive.Index, :index
|
||||
live "/tags/new", TagLive.Index, :new
|
||||
live "/tags/:id/edit", TagLive.Index, :edit
|
||||
live "/tags/edit/:id", TagLive.Index, :edit
|
||||
live "/tags/search/:search", TagLive.Index, :search
|
||||
|
||||
live "/catalog", AmmoTypeLive.Index, :index
|
||||
live "/catalog/new", AmmoTypeLive.Index, :new
|
||||
|
@ -162,7 +162,7 @@ msgstr "Einfache Anwendung:"
|
||||
msgid "Edit Invite"
|
||||
msgstr "Einladung bearbeiten"
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:21
|
||||
#: lib/cannery_web/live/tag_live/index.ex:28
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit Tag"
|
||||
msgstr "Tag bearbeiten"
|
||||
@ -277,7 +277,7 @@ msgstr "Neuer Behälter"
|
||||
msgid "New Invite"
|
||||
msgstr "Neue Einladung"
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:27
|
||||
#: lib/cannery_web/live/tag_live/index.ex:36
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "New Tag"
|
||||
msgstr "Neuer Tag"
|
||||
@ -306,6 +306,7 @@ msgstr "Keine Einladung"
|
||||
|
||||
#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:31
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:10
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:44
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No tags"
|
||||
msgstr "Keine Tags"
|
||||
@ -394,7 +395,8 @@ msgstr "Gelagert in"
|
||||
|
||||
#: lib/cannery_web/components/container_table_component.ex:52
|
||||
#: lib/cannery_web/components/topbar.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:32
|
||||
#: lib/cannery_web/live/tag_live/index.ex:44
|
||||
#: lib/cannery_web/live/tag_live/index.ex:54
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:3
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tags"
|
||||
@ -1132,3 +1134,8 @@ msgstr ""
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Search containers"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:36
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Search tags"
|
||||
msgstr ""
|
||||
|
@ -141,7 +141,7 @@ msgstr "ist nicht gültig"
|
||||
msgid "must have the @ sign and no spaces"
|
||||
msgstr "Muss ein @ Zeichen und keine Leerzeichen haben"
|
||||
|
||||
#: lib/cannery/tags.ex:39
|
||||
#: lib/cannery/tags.ex:66
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tag not found"
|
||||
msgstr "Tag nicht gefunden"
|
||||
|
@ -35,7 +35,7 @@ msgstr "%{name} erfolgreich erstellt"
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:55
|
||||
#: lib/cannery_web/live/invite_live/index.ex:53
|
||||
#: lib/cannery_web/live/invite_live/index.ex:133
|
||||
#: lib/cannery_web/live/tag_live/index.ex:38
|
||||
#: lib/cannery_web/live/tag_live/index.ex:64
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
msgstr "%{name} erfolgreich gelöscht"
|
||||
@ -85,7 +85,7 @@ msgstr ""
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:93
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:138
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:59
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:39
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Are you sure you want to delete %{name}?"
|
||||
msgstr "Sind Sie sicher, dass sie %{name} löschen möchten?"
|
||||
|
@ -147,7 +147,7 @@ msgstr ""
|
||||
msgid "Edit Invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:21
|
||||
#: lib/cannery_web/live/tag_live/index.ex:28
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit Tag"
|
||||
msgstr ""
|
||||
@ -262,7 +262,7 @@ msgstr ""
|
||||
msgid "New Invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:27
|
||||
#: lib/cannery_web/live/tag_live/index.ex:36
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "New Tag"
|
||||
msgstr ""
|
||||
@ -291,6 +291,7 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:31
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:10
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:44
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No tags"
|
||||
msgstr ""
|
||||
@ -377,7 +378,8 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/container_table_component.ex:52
|
||||
#: lib/cannery_web/components/topbar.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:32
|
||||
#: lib/cannery_web/live/tag_live/index.ex:44
|
||||
#: lib/cannery_web/live/tag_live/index.ex:54
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:3
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tags"
|
||||
@ -1115,3 +1117,8 @@ msgstr ""
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Search containers"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:36
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Search tags"
|
||||
msgstr ""
|
||||
|
@ -148,7 +148,7 @@ msgstr ""
|
||||
msgid "Edit Invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:21
|
||||
#: lib/cannery_web/live/tag_live/index.ex:28
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit Tag"
|
||||
msgstr ""
|
||||
@ -263,7 +263,7 @@ msgstr ""
|
||||
msgid "New Invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:27
|
||||
#: lib/cannery_web/live/tag_live/index.ex:36
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "New Tag"
|
||||
msgstr ""
|
||||
@ -292,6 +292,7 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:31
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:10
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:44
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No tags"
|
||||
msgstr ""
|
||||
@ -378,7 +379,8 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/container_table_component.ex:52
|
||||
#: lib/cannery_web/components/topbar.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:32
|
||||
#: lib/cannery_web/live/tag_live/index.ex:44
|
||||
#: lib/cannery_web/live/tag_live/index.ex:54
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:3
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tags"
|
||||
@ -1116,3 +1118,8 @@ msgstr ""
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Search containers"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:36
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Search tags"
|
||||
msgstr ""
|
||||
|
@ -128,7 +128,7 @@ msgstr ""
|
||||
msgid "must have the @ sign and no spaces"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery/tags.ex:39
|
||||
#: lib/cannery/tags.ex:66
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tag not found"
|
||||
msgstr ""
|
||||
|
@ -23,7 +23,7 @@ msgstr ""
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:55
|
||||
#: lib/cannery_web/live/invite_live/index.ex:53
|
||||
#: lib/cannery_web/live/invite_live/index.ex:133
|
||||
#: lib/cannery_web/live/tag_live/index.ex:38
|
||||
#: lib/cannery_web/live/tag_live/index.ex:64
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
msgstr ""
|
||||
@ -71,7 +71,7 @@ msgstr ""
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:93
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:138
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:59
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:39
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Are you sure you want to delete %{name}?"
|
||||
msgstr ""
|
||||
|
@ -127,7 +127,7 @@ msgstr ""
|
||||
msgid "must have the @ sign and no spaces"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery/tags.ex:39
|
||||
#: lib/cannery/tags.ex:66
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tag not found"
|
||||
msgstr ""
|
||||
|
@ -162,7 +162,7 @@ msgstr ""
|
||||
msgid "Edit Invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:21
|
||||
#: lib/cannery_web/live/tag_live/index.ex:28
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit Tag"
|
||||
msgstr ""
|
||||
@ -277,7 +277,7 @@ msgstr ""
|
||||
msgid "New Invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:27
|
||||
#: lib/cannery_web/live/tag_live/index.ex:36
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "New Tag"
|
||||
msgstr ""
|
||||
@ -306,6 +306,7 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:31
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:10
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:44
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No tags"
|
||||
msgstr ""
|
||||
@ -392,7 +393,8 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/container_table_component.ex:52
|
||||
#: lib/cannery_web/components/topbar.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:32
|
||||
#: lib/cannery_web/live/tag_live/index.ex:44
|
||||
#: lib/cannery_web/live/tag_live/index.ex:54
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:3
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tags"
|
||||
@ -1130,3 +1132,8 @@ msgstr ""
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Search containers"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:36
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Search tags"
|
||||
msgstr ""
|
||||
|
@ -143,7 +143,7 @@ msgstr "no es válido"
|
||||
msgid "must have the @ sign and no spaces"
|
||||
msgstr "debe tener el signo @ y no contener espacios"
|
||||
|
||||
#: lib/cannery/tags.ex:39
|
||||
#: lib/cannery/tags.ex:66
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tag not found"
|
||||
msgstr "Etiqueta no encontrada"
|
||||
|
@ -35,7 +35,7 @@ msgstr "%{name} creado exitosamente"
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:55
|
||||
#: lib/cannery_web/live/invite_live/index.ex:53
|
||||
#: lib/cannery_web/live/invite_live/index.ex:133
|
||||
#: lib/cannery_web/live/tag_live/index.ex:38
|
||||
#: lib/cannery_web/live/tag_live/index.ex:64
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
msgstr "%{name} borrado exitosamente"
|
||||
@ -85,7 +85,7 @@ msgstr "Está seguro que desea eliminar %{email}? Esta acción es permanente!"
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:93
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:138
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:59
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:39
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Are you sure you want to delete %{name}?"
|
||||
msgstr "Está seguro que desea eliminar %{name}?"
|
||||
|
@ -162,7 +162,7 @@ msgstr "Simple à utiliser :"
|
||||
msgid "Edit Invite"
|
||||
msgstr "Modifier l’invitation"
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:21
|
||||
#: lib/cannery_web/live/tag_live/index.ex:28
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit Tag"
|
||||
msgstr "Modifier le tag"
|
||||
@ -277,7 +277,7 @@ msgstr "Nouveau conteneur"
|
||||
msgid "New Invite"
|
||||
msgstr "Nouvelle invitation"
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:27
|
||||
#: lib/cannery_web/live/tag_live/index.ex:36
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "New Tag"
|
||||
msgstr "Nouveau tag"
|
||||
@ -306,6 +306,7 @@ msgstr "Aucune invitation"
|
||||
|
||||
#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:31
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:10
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:44
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No tags"
|
||||
msgstr "Aucun tag"
|
||||
@ -394,7 +395,8 @@ msgstr "Est stocké dans"
|
||||
|
||||
#: lib/cannery_web/components/container_table_component.ex:52
|
||||
#: lib/cannery_web/components/topbar.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:32
|
||||
#: lib/cannery_web/live/tag_live/index.ex:44
|
||||
#: lib/cannery_web/live/tag_live/index.ex:54
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:3
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tags"
|
||||
@ -1135,3 +1137,8 @@ msgstr ""
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Search containers"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:36
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Search tags"
|
||||
msgstr ""
|
||||
|
@ -142,7 +142,7 @@ msgstr "n’est pas valide"
|
||||
msgid "must have the @ sign and no spaces"
|
||||
msgstr "doit contenir le symbole @ et aucune espace"
|
||||
|
||||
#: lib/cannery/tags.ex:39
|
||||
#: lib/cannery/tags.ex:66
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tag not found"
|
||||
msgstr "Tag pas trouvé"
|
||||
|
@ -35,7 +35,7 @@ msgstr "%{name} créé· avec succès"
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:55
|
||||
#: lib/cannery_web/live/invite_live/index.ex:53
|
||||
#: lib/cannery_web/live/invite_live/index.ex:133
|
||||
#: lib/cannery_web/live/tag_live/index.ex:38
|
||||
#: lib/cannery_web/live/tag_live/index.ex:64
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
msgstr "%{name} supprimé· avec succès"
|
||||
@ -86,7 +86,7 @@ msgstr ""
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:93
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:138
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:59
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:39
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Are you sure you want to delete %{name}?"
|
||||
msgstr "Êtes-vous certain·e de supprimer %{name} ?"
|
||||
|
@ -158,7 +158,7 @@ msgstr ""
|
||||
msgid "Edit Invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:21
|
||||
#: lib/cannery_web/live/tag_live/index.ex:28
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit Tag"
|
||||
msgstr ""
|
||||
@ -273,7 +273,7 @@ msgstr ""
|
||||
msgid "New Invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.ex:27
|
||||
#: lib/cannery_web/live/tag_live/index.ex:36
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "New Tag"
|
||||
msgstr ""
|
||||
@ -302,6 +302,7 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/container_live/edit_tags_component.html.heex:31
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:10
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:44
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No tags"
|
||||
msgstr ""
|
||||
@ -388,7 +389,8 @@ msgstr ""
|
||||
|
||||
#: lib/cannery_web/components/container_table_component.ex:52
|
||||
#: lib/cannery_web/components/topbar.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:32
|
||||
#: lib/cannery_web/live/tag_live/index.ex:44
|
||||
#: lib/cannery_web/live/tag_live/index.ex:54
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:3
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tags"
|
||||
@ -1126,3 +1128,8 @@ msgstr ""
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Search containers"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:36
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Search tags"
|
||||
msgstr ""
|
||||
|
@ -143,7 +143,7 @@ msgstr ""
|
||||
msgid "must have the @ sign and no spaces"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery/tags.ex:39
|
||||
#: lib/cannery/tags.ex:66
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Tag not found"
|
||||
msgstr ""
|
||||
|
@ -33,7 +33,7 @@ msgstr ""
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:55
|
||||
#: lib/cannery_web/live/invite_live/index.ex:53
|
||||
#: lib/cannery_web/live/invite_live/index.ex:133
|
||||
#: lib/cannery_web/live/tag_live/index.ex:38
|
||||
#: lib/cannery_web/live/tag_live/index.ex:64
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
msgstr ""
|
||||
@ -81,7 +81,7 @@ msgstr ""
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:93
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:138
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:59
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:39
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Are you sure you want to delete %{name}?"
|
||||
msgstr ""
|
||||
|
@ -22,7 +22,7 @@ msgstr ""
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:55
|
||||
#: lib/cannery_web/live/invite_live/index.ex:53
|
||||
#: lib/cannery_web/live/invite_live/index.ex:133
|
||||
#: lib/cannery_web/live/tag_live/index.ex:38
|
||||
#: lib/cannery_web/live/tag_live/index.ex:64
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
msgstr ""
|
||||
@ -70,7 +70,7 @@ msgstr ""
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:93
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:138
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:59
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:39
|
||||
#: lib/cannery_web/live/tag_live/index.html.heex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Are you sure you want to delete %{name}?"
|
||||
msgstr ""
|
||||
|
@ -31,10 +31,28 @@ defmodule Cannery.TagsTest do
|
||||
[tag: tag_fixture(current_user), current_user: current_user]
|
||||
end
|
||||
|
||||
test "list_tags/0 returns all tags", %{tag: tag, current_user: current_user} do
|
||||
test "list_tags/1 returns all tags", %{tag: tag, current_user: current_user} do
|
||||
assert Tags.list_tags(current_user) == [tag]
|
||||
end
|
||||
|
||||
test "list_tags/2 returns relevant tags for a user", %{current_user: current_user} do
|
||||
tag_a = tag_fixture(%{"name" => "bullets"}, current_user)
|
||||
tag_b = tag_fixture(%{"name" => "hollows"}, current_user)
|
||||
|
||||
_shouldnt_return =
|
||||
%{
|
||||
"name" => "bullet",
|
||||
"desc" => "pews brass shell"
|
||||
}
|
||||
|> tag_fixture(user_fixture())
|
||||
|
||||
# name
|
||||
assert Tags.list_tags("bullet", current_user) == [tag_a]
|
||||
assert Tags.list_tags("bullets", current_user) == [tag_a]
|
||||
assert Tags.list_tags("hollow", current_user) == [tag_b]
|
||||
assert Tags.list_tags("hollows", current_user) == [tag_b]
|
||||
end
|
||||
|
||||
test "get_tag!/1 returns the tag with given id", %{tag: tag, current_user: current_user} do
|
||||
assert Tags.get_tag!(tag.id, current_user) == tag
|
||||
end
|
||||
|
@ -41,6 +41,32 @@ defmodule CanneryWeb.TagLiveTest do
|
||||
assert html =~ tag.bg_color
|
||||
end
|
||||
|
||||
test "can search for tag", %{conn: conn, tag: tag} do
|
||||
{:ok, index_live, html} = live(conn, Routes.tag_index_path(conn, :index))
|
||||
|
||||
assert html =~ tag.name
|
||||
|
||||
assert index_live
|
||||
|> form("[data-qa=\"tag_search\"]",
|
||||
search: %{search_term: tag.name}
|
||||
)
|
||||
|> render_change() =~ tag.name
|
||||
|
||||
assert_patch(index_live, Routes.tag_index_path(conn, :search, tag.name))
|
||||
|
||||
refute index_live
|
||||
|> form("[data-qa=\"tag_search\"]", search: %{search_term: "something_else"})
|
||||
|> render_change() =~ tag.name
|
||||
|
||||
assert_patch(index_live, Routes.tag_index_path(conn, :search, "something_else"))
|
||||
|
||||
assert index_live
|
||||
|> form("[data-qa=\"tag_search\"]", search: %{search_term: ""})
|
||||
|> render_change() =~ tag.name
|
||||
|
||||
assert_patch(index_live, Routes.tag_index_path(conn, :index))
|
||||
end
|
||||
|
||||
test "saves new tag", %{conn: conn} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.tag_index_path(conn, :index))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user