diff --git a/lib/mindwendel_web/live/brainstorming_live/show.html.heex b/lib/mindwendel_web/live/brainstorming_live/show.html.heex index 474c603b..4dabb261 100644 --- a/lib/mindwendel_web/live/brainstorming_live/show.html.heex +++ b/lib/mindwendel_web/live/brainstorming_live/show.html.heex @@ -105,6 +105,10 @@ ) %> <% end %> + <%= live_component(MindwendelWeb.LabelLive.CaptionsComponent, + brainstorming: @brainstorming + ) %> + <%= live_component(MindwendelWeb.IdeaLive.IndexComponent, ideas: @ideas, brainstorming: @brainstorming, diff --git a/lib/mindwendel_web/live/label_live/captions_component.ex b/lib/mindwendel_web/live/label_live/captions_component.ex new file mode 100644 index 00000000..9a8ccc9a --- /dev/null +++ b/lib/mindwendel_web/live/label_live/captions_component.ex @@ -0,0 +1,3 @@ +defmodule MindwendelWeb.LabelLive.CaptionsComponent do + use MindwendelWeb, :live_component +end diff --git a/lib/mindwendel_web/live/label_live/captions_component.html.heex b/lib/mindwendel_web/live/label_live/captions_component.html.heex new file mode 100644 index 00000000..d1e29b76 --- /dev/null +++ b/lib/mindwendel_web/live/label_live/captions_component.html.heex @@ -0,0 +1,14 @@ +
+ <%= for brainstorming_idea_label <- @brainstorming.labels do %> +
+ + <%= brainstorming_idea_label.name %> + +
+ <% end %> +
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 4cd12c16..2aeb2f6e 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -97,7 +97,7 @@ msgid "Idea created successfully" msgstr "" #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:25 -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:117 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:121 #, elixir-autogen, elixir-format msgid "New Idea" msgstr "" @@ -122,7 +122,7 @@ msgstr "" msgid "No ideas brainstormed" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:120 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:124 #, elixir-autogen, elixir-format msgid "Open new idea page (Hotkey: i)" msgstr "" diff --git a/test/mindwendel_web/live/label_live/captions_test.exs b/test/mindwendel_web/live/label_live/captions_test.exs new file mode 100644 index 00000000..43231eb6 --- /dev/null +++ b/test/mindwendel_web/live/label_live/captions_test.exs @@ -0,0 +1,24 @@ +defmodule MindwendelWeb.LabelLive.CaptionsTest do + alias MindwendelWeb.LabelLive.CaptionsComponent + use MindwendelWeb.ConnCase + import Phoenix.LiveViewTest + + alias Mindwendel.Factory + + setup do + %{brainstorming: Factory.insert!(:brainstorming)} + end + + test "captions contain all labels", %{ + brainstorming: brainstorming + } do + captions_component = render_component(CaptionsComponent, brainstorming: brainstorming) + + # make sure that there is at least one label in the list: + assert Enum.count(brainstorming.labels) > 0 + + Enum.each(brainstorming.labels, fn label -> + assert captions_component =~ label.name + end) + end +end