From c3ceb877b2dd4ef10a74e16c1d3ba8849f7cd38f Mon Sep 17 00:00:00 2001 From: shibao Date: Thu, 15 Dec 2022 22:33:10 -0500 Subject: [PATCH] search tags when on click --- changelog.md | 1 + .../components/contexts_table_component.ex | 12 +++++++++- .../components/notes_table_component.ex | 12 +++++++++- .../components/pipelines_table_component.ex | 12 +++++++++- .../live/context_live/show.html.heex | 8 ++++++- lib/memex_web/live/note_live/show.html.heex | 8 ++++++- .../live/pipeline_live/show.html.heex | 8 ++++++- lib/memex_web/templates/error/error.html.heex | 2 +- mix.exs | 2 +- priv/gettext/actions.pot | 24 +++++++++---------- priv/gettext/de/LC_MESSAGES/actions.po | 24 +++++++++---------- priv/gettext/de/LC_MESSAGES/default.po | 12 +++++----- priv/gettext/de/LC_MESSAGES/prompts.po | 8 +++---- priv/gettext/default.pot | 12 +++++----- priv/gettext/prompts.pot | 8 +++---- test/memex_web/live/context_live_test.exs | 16 +++++++++++++ test/memex_web/live/note_live_test.exs | 16 +++++++++++++ test/memex_web/live/pipeline_live_test.exs | 16 +++++++++++++ test/support/fixtures/contexts_fixtures.ex | 2 +- test/support/fixtures/notes_fixtures.ex | 2 +- test/support/fixtures/pipelines_fixtures.ex | 2 +- 21 files changed, 152 insertions(+), 55 deletions(-) diff --git a/changelog.md b/changelog.md index def4f2d..c809d91 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # v0.1.3 - backlink to other notes in notes +- search tags on click # v0.1.2 - fix more typos diff --git a/lib/memex_web/components/contexts_table_component.ex b/lib/memex_web/components/contexts_table_component.ex index cc2456c..4006db3 100644 --- a/lib/memex_web/components/contexts_table_component.ex +++ b/lib/memex_web/components/contexts_table_component.ex @@ -105,7 +105,17 @@ defmodule MemexWeb.Components.ContextsTableComponent do end defp get_value_for_key(:tags, %{tags: tags}, _additional_data) do - tags |> Enum.join(", ") + assigns = %{tags: tags} + + ~H""" +
+ <%= for tag <- @tags do %> + <.link patch={Routes.context_index_path(Endpoint, :search, tag)} class="link"> + <%= tag %> + + <% end %> +
+ """ end defp get_value_for_key(:actions, context, %{actions: actions}) do diff --git a/lib/memex_web/components/notes_table_component.ex b/lib/memex_web/components/notes_table_component.ex index 94f8b7c..527faf7 100644 --- a/lib/memex_web/components/notes_table_component.ex +++ b/lib/memex_web/components/notes_table_component.ex @@ -105,7 +105,17 @@ defmodule MemexWeb.Components.NotesTableComponent do end defp get_value_for_key(:tags, %{tags: tags}, _additional_data) do - tags |> Enum.join(", ") + assigns = %{tags: tags} + + ~H""" +
+ <%= for tag <- @tags do %> + <.link patch={Routes.note_index_path(Endpoint, :search, tag)} class="link"> + <%= tag %> + + <% end %> +
+ """ end defp get_value_for_key(:actions, note, %{actions: actions}) do diff --git a/lib/memex_web/components/pipelines_table_component.ex b/lib/memex_web/components/pipelines_table_component.ex index 542d5c5..a2c5be7 100644 --- a/lib/memex_web/components/pipelines_table_component.ex +++ b/lib/memex_web/components/pipelines_table_component.ex @@ -118,7 +118,17 @@ defmodule MemexWeb.Components.PipelinesTableComponent do end defp get_value_for_key(:tags, %{tags: tags}, _additional_data) do - tags |> Enum.join(", ") + assigns = %{tags: tags} + + ~H""" +
+ <%= for tag <- @tags do %> + <.link patch={Routes.pipeline_index_path(Endpoint, :search, tag)} class="link"> + <%= tag %> + + <% end %> +
+ """ end defp get_value_for_key(:actions, pipeline, %{actions: actions}) do diff --git a/lib/memex_web/live/context_live/show.html.heex b/lib/memex_web/live/context_live/show.html.heex index 0b88abf..1d5be4d 100644 --- a/lib/memex_web/live/context_live/show.html.heex +++ b/lib/memex_web/live/context_live/show.html.heex @@ -3,7 +3,13 @@ <%= @context.slug %> -

<%= if @context.tags, do: @context.tags |> Enum.join(", ") %>

+
+ <%= for tag <- @context.tags do %> + <.link navigate={Routes.context_index_path(Endpoint, :search, tag)} class="link"> + <%= tag %> + + <% end %> +
<.context_content context={@context} /> diff --git a/lib/memex_web/live/note_live/show.html.heex b/lib/memex_web/live/note_live/show.html.heex index 690d329..f02b6ea 100644 --- a/lib/memex_web/live/note_live/show.html.heex +++ b/lib/memex_web/live/note_live/show.html.heex @@ -3,7 +3,13 @@ <%= @note.slug %> -

<%= if @note.tags, do: @note.tags |> Enum.join(", ") %>

+
+ <%= for tag <- @note.tags do %> + <.link navigate={Routes.note_index_path(Endpoint, :search, tag)} class="link"> + <%= tag %> + + <% end %> +
<.note_content note={@note} /> diff --git a/lib/memex_web/live/pipeline_live/show.html.heex b/lib/memex_web/live/pipeline_live/show.html.heex index 4072ba6..45b5aa4 100644 --- a/lib/memex_web/live/pipeline_live/show.html.heex +++ b/lib/memex_web/live/pipeline_live/show.html.heex @@ -3,7 +3,13 @@ <%= @pipeline.slug %> -

<%= if @pipeline.tags, do: @pipeline.tags |> Enum.join(", ") %>

+
+ <%= for tag <- @pipeline.tags do %> + <.link navigate={Routes.pipeline_index_path(Endpoint, :search, tag)} class="link"> + <%= tag %> + + <% end %> +
<%= if @pipeline.description do %>