diff --git a/assets/js/app.js b/assets/js/app.js index 17e51287..bf4af30f 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -123,6 +123,10 @@ Hooks.SetIdeaLabelColor = { const color = this.el.getAttribute("data-color"); this.el.style.color = color; }, + updated() { + const color = this.el.getAttribute("data-color"); + this.el.style.color = color; + } }; Hooks.SetIdeaLabelBackgroundColor = { diff --git a/lib/mindwendel/idea_labels.ex b/lib/mindwendel/idea_labels.ex index 2707d7cb..5e85f546 100644 --- a/lib/mindwendel/idea_labels.ex +++ b/lib/mindwendel/idea_labels.ex @@ -46,13 +46,15 @@ defmodule Mindwendel.IdeaLabels do end def remove_idea_label_from_idea(%Idea{} = idea, %IdeaLabel{} = idea_label) do - from(idea_idea_label in IdeaIdeaLabel, - where: - idea_idea_label.idea_id == ^idea.id and - idea_idea_label.idea_label_id == ^idea_label.id - ) - |> Repo.delete_all() + result = + from(idea_idea_label in IdeaIdeaLabel, + where: + idea_idea_label.idea_id == ^idea.id and + idea_idea_label.idea_label_id == ^idea_label.id + ) + |> Repo.delete_all() Lanes.broadcast_lanes_update(idea.brainstorming_id) + result end end diff --git a/lib/mindwendel/likes.ex b/lib/mindwendel/likes.ex index caeb78b7..f1f8a515 100644 --- a/lib/mindwendel/likes.ex +++ b/lib/mindwendel/likes.ex @@ -6,22 +6,23 @@ defmodule Mindwendel.Likes do import Ecto.Query, warn: false alias Mindwendel.Repo alias Mindwendel.Ideas - alias Mindwendel.Lanes + alias Mindwendel.Brainstormings alias Mindwendel.Brainstormings.Like require Logger @doc """ - Returns a Boolean if a like for the given idea and user exists. + Returns a boolean if like with a given user id exists in the given likes. + This method is primarily used with preloaded data from an idea, therefore it is not needed to reload data from the repo. ## Examples - iex> exists_like_for_idea?(1, 2) + iex> exists_user_in_likes?([...], 2) true """ - def exists_like_for_idea?(idea_id, user_id) do - Repo.exists?(from like in Like, where: like.user_id == ^user_id and like.idea_id == ^idea_id) + def exists_user_in_likes?(likes, user_id) do + likes |> Enum.map(fn like -> like.user_id end) |> Enum.member?(user_id) end @doc """ @@ -41,7 +42,7 @@ defmodule Mindwendel.Likes do case status do :ok -> - {:ok, Lanes.broadcast_lanes_update(Ideas.get_idea!(idea_id).brainstorming_id)} + {:ok, Brainstormings.broadcast({:ok, Ideas.get_idea!(idea_id)}, :idea_updated)} :error -> {:error, result} @@ -63,7 +64,7 @@ defmodule Mindwendel.Likes do from like in Like, where: like.user_id == ^user_id and like.idea_id == ^idea_id ) - Lanes.broadcast_lanes_update(Ideas.get_idea!(idea_id).brainstorming_id) + Brainstormings.broadcast({:ok, Ideas.get_idea!(idea_id)}, :idea_updated) end @doc """ diff --git a/lib/mindwendel_web/live/brainstorming_live/show.ex b/lib/mindwendel_web/live/brainstorming_live/show.ex index 34cee437..778b133d 100644 --- a/lib/mindwendel_web/live/brainstorming_live/show.ex +++ b/lib/mindwendel_web/live/brainstorming_live/show.ex @@ -76,15 +76,15 @@ defmodule MindwendelWeb.BrainstormingLive.Show do {:noreply, assign(socket, :lanes, new_lanes)} end - # idea updated - only relevant if the show modal of the idea is opened def handle_info({:idea_updated, idea}, socket) do + # first, update the specific card of the idea + send_update(MindwendelWeb.IdeaLive.CardComponent, id: idea.id, idea: idea) + # if the idea show modal is opened, also update the idea within the modal if socket.assigns.live_action == :show_idea and socket.assigns.idea.id == idea.id do - # update the idea modal with new content send_update(MindwendelWeb.IdeaLive.ShowComponent, id: :show, idea: idea) - {:noreply, socket} - else - {:noreply, socket} end + + {:noreply, socket} end def handle_info({:brainstorming_filter_updated, brainstorming, lanes}, socket) do diff --git a/lib/mindwendel_web/live/idea_live/card_component.ex b/lib/mindwendel_web/live/idea_live/card_component.ex new file mode 100644 index 00000000..19fc768b --- /dev/null +++ b/lib/mindwendel_web/live/idea_live/card_component.ex @@ -0,0 +1,67 @@ +defmodule MindwendelWeb.IdeaLive.CardComponent do + use MindwendelWeb, :live_component + alias Mindwendel.Ideas + alias Mindwendel.IdeaLabels + alias Mindwendel.Likes + + @impl true + def handle_event("delete_idea", %{"id" => id}, socket) do + idea = Ideas.get_idea!(id) + + %{current_user: current_user, brainstorming: brainstorming} = socket.assigns + + if current_user.id in [idea.user_id | brainstorming.moderating_users |> Enum.map(& &1.id)] do + {:ok, _} = Ideas.delete_idea(idea) + end + + # broadcast will take care of the removal from the list + {:noreply, socket} + end + + def handle_event("like", %{"id" => id}, socket) do + Likes.add_like(id, socket.assigns.current_user.id) + + {:noreply, socket} + end + + def handle_event("unlike", %{"id" => id}, socket) do + Likes.delete_like(id, socket.assigns.current_user.id) + + {:noreply, socket} + end + + def handle_event( + "add_idea_label_to_idea", + %{ + "idea-id" => idea_id, + "idea-label-id" => idea_label_id + }, + socket + ) do + idea = Ideas.get_idea!(idea_id) + idea_label = IdeaLabels.get_idea_label(idea_label_id) + + case(IdeaLabels.add_idea_label_to_idea(idea, idea_label)) do + {:ok, _idea} -> + {:noreply, socket} + + {:error, _changeset} -> + {:noreply, socket} + end + end + + def handle_event( + "remove_idea_label_from_idea", + %{ + "idea-id" => idea_id, + "idea-label-id" => idea_label_id + }, + socket + ) do + idea = Ideas.get_idea!(idea_id) + idea_label = IdeaLabels.get_idea_label(idea_label_id) + + IdeaLabels.remove_idea_label_from_idea(idea, idea_label) + {:noreply, socket} + end +end diff --git a/lib/mindwendel_web/live/idea_live/card_component.html.heex b/lib/mindwendel_web/live/idea_live/card_component.html.heex new file mode 100644 index 00000000..206e6b31 --- /dev/null +++ b/lib/mindwendel_web/live/idea_live/card_component.html.heex @@ -0,0 +1,152 @@ +
+
+ <%= if has_moderating_or_ownership_permission(@brainstorming, @idea, @current_user) do %> + <.link + class="float-end ms-3 mb-3" + phx-click="delete_idea" + phx-target={@myself} + phx-value-id={@idea.id} + title={gettext("Delete idea")} + data-confirm={gettext("Are you sure you want to delete this idea?")} + > + + + <.link + patch={~p"/brainstormings/#{@brainstorming.id}/ideas/#{@idea.id}/edit"} + class="float-end ms-3 mb-3" + title={gettext("Edit idea")} + > + + + <% end %> + <.link + patch={~p"/brainstormings/#{@brainstorming.id}/ideas/#{@idea.id}"} + class="float-end ms-3 mb-3" + title={gettext("Show idea")} + > + + + + <%= for idea_label <- Enum.sort_by(@idea.idea_labels, &(&1.position_order)) do %> + + <%= idea_label.name %> + + <% end %> + + <%= unless @idea.link do %> +

<%= raw(@idea.body) %>

+ <% end %> + + <%= if @idea.link do %> + <.link href={@idea.link.url}> + <%= raw(@idea.body) %> + +
+
+
+ +
+
+

<%= @idea.link.title %>

+

<%= @idea.link.description %>

+
+
+ <% end %> + + <%= if length(@idea.files) > 0 do %> + <%= for attachment <- @idea.files do %> + +

+ <.link href={~p"/files/#{attachment.id}"} download={attachment.name}> + <%= attachment.name || gettext("No filename") %> + +

+ <% end %> + <% end %> +
+ + +
diff --git a/lib/mindwendel_web/live/lane_live/index_component.ex b/lib/mindwendel_web/live/lane_live/index_component.ex index b8602112..47dd7be7 100644 --- a/lib/mindwendel_web/live/lane_live/index_component.ex +++ b/lib/mindwendel_web/live/lane_live/index_component.ex @@ -3,25 +3,10 @@ defmodule MindwendelWeb.LaneLive.IndexComponent do use MindwendelWeb, :live_component alias Mindwendel.Ideas - alias Mindwendel.IdeaLabels - alias Mindwendel.Likes alias Mindwendel.Lanes alias Mindwendel.Brainstormings @impl true - def handle_event("delete_idea", %{"id" => id}, socket) do - idea = Ideas.get_idea!(id) - - %{current_user: current_user, brainstorming: brainstorming} = socket.assigns - - if current_user.id in [idea.user_id | brainstorming.moderating_users |> Enum.map(& &1.id)] do - {:ok, _} = Ideas.delete_idea(idea) - end - - # broadcast will take care of the removal from the list - {:noreply, socket} - end - def handle_event("delete_lane", %{"id" => id}, socket) do lane = Lanes.get_lane!(id) @@ -35,18 +20,6 @@ defmodule MindwendelWeb.LaneLive.IndexComponent do {:noreply, socket} end - def handle_event("like", %{"id" => id}, socket) do - Likes.add_like(id, socket.assigns.current_user.id) - - {:noreply, socket} - end - - def handle_event("unlike", %{"id" => id}, socket) do - Likes.delete_like(id, socket.assigns.current_user.id) - - {:noreply, socket} - end - def handle_event( "change_position", %{ @@ -88,46 +61,6 @@ defmodule MindwendelWeb.LaneLive.IndexComponent do {:noreply, socket} end - def handle_event( - "add_idea_label_to_idea", - %{ - "idea-id" => idea_id, - "idea-label-id" => idea_label_id - }, - socket - ) do - idea = Ideas.get_idea!(idea_id) - idea_label = IdeaLabels.get_idea_label(idea_label_id) - - case(IdeaLabels.add_idea_label_to_idea(idea, idea_label)) do - {:ok, _idea} -> - {:noreply, socket} - - {:error, _changeset} -> - {:noreply, socket} - end - end - - def handle_event( - "remove_idea_label_from_idea", - %{ - "idea-id" => idea_id, - "idea-label-id" => idea_label_id - }, - socket - ) do - idea = Ideas.get_idea!(idea_id) - idea_label = IdeaLabels.get_idea_label(idea_label_id) - - case(IdeaLabels.remove_idea_label_from_idea(idea, idea_label)) do - {:ok, _idea} -> - {:noreply, socket} - - {:error, _changeset} -> - {:noreply, socket} - end - end - def handle_event("sort_by_likes", %{"id" => id, "lane-id" => lane_id}, socket) do brainstorming = Brainstormings.get_brainstorming!(id) diff --git a/lib/mindwendel_web/live/lane_live/index_component.html.heex b/lib/mindwendel_web/live/lane_live/index_component.html.heex index 7c3b4231..ebd4c4f0 100644 --- a/lib/mindwendel_web/live/lane_live/index_component.html.heex +++ b/lib/mindwendel_web/live/lane_live/index_component.html.heex @@ -93,168 +93,14 @@ "card-mindwendel--full-width" end %> <%= for idea <- lane.ideas do %> -
-
- <%= if has_moderating_or_ownership_permission(@brainstorming, idea, @current_user) do %> - <.link - class="float-end ms-3 mb-3" - phx-click="delete_idea" - phx-target={@myself} - phx-value-id={idea.id} - title={gettext("Delete idea")} - data-confirm={gettext("Are you sure you want to delete this idea?")} - > - - - <.link - patch={~p"/brainstormings/#{@brainstorming.id}/ideas/#{idea.id}/edit"} - class="float-end ms-3 mb-3" - title={gettext("Edit idea")} - > - - - <% end %> - <.link - patch={~p"/brainstormings/#{@brainstorming.id}/ideas/#{idea.id}"} - class="float-end ms-3 mb-3" - title={gettext("Show idea")} - > - - - - <%= for idea_label <- Enum.sort_by(idea.idea_labels, &(&1.position_order)) do %> - - <%= idea_label.name %> - - <% end %> - - <%= unless idea.link do %> -

<%= raw(idea.body) %>

- <% end %> - - <%= if idea.link do %> - <.link href={idea.link.url}> - <%= raw(idea.body) %> - -
-
-
- -
-
-

<%= idea.link.title %>

-

<%= idea.link.description %>

-
-
- <% end %> - - <%= if length(idea.files) > 0 do %> - <%= for attachment <- idea.files do %> - -

- <.link href={~p"/files/#{attachment.id}"} download={attachment.name}> - <%= attachment.name || gettext("No filename") %> - -

- <% end %> - <% end %> -
- - -
+ <.live_component + module={MindwendelWeb.IdeaLive.CardComponent} + brainstorming={@brainstorming} + id={idea.id} + current_user={@current_user} + width_class={width_class} + idea={idea} + /> <% end %> <%= if Enum.empty?(lane.ideas) do %> diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index b53418b5..f493ee5f 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -37,7 +37,7 @@ msgid "%{name} - New Idea" msgstr "%{name} - Neue Idee" #: lib/mindwendel_web/live/comment_live/show_component.html.heex:22 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:113 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:18 #, elixir-autogen, elixir-format msgid "Are you sure you want to delete this idea?" msgstr "Möchtest du die Idee löschen?" @@ -113,7 +113,7 @@ msgstr "Neues Brainstorming" msgid "New idea" msgstr "Neue Idee" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:263 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:109 #, elixir-autogen, elixir-format msgid "No ideas brainstormed" msgstr "Bisher keine Ideen vorhanden" @@ -202,7 +202,7 @@ msgstr "Nutzername" #: lib/mindwendel_web/controllers/admin/brainstorming_html/export.html.heex:3 #: lib/mindwendel_web/live/comment_live/show_component.html.heex:40 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:180 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:85 #, elixir-autogen, elixir-format msgid "By" msgstr "Von" @@ -421,7 +421,7 @@ msgstr "Name" #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:26 #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:28 #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:114 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:284 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:130 #, elixir-autogen, elixir-format msgid "New lane" msgstr "Neue Spalte" @@ -455,7 +455,7 @@ msgstr "Spalte aktualisiert" #: lib/mindwendel_web/live/lane_live/index_component.html.heex:10 #: lib/mindwendel_web/live/lane_live/index_component.html.heex:13 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:268 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:114 #, elixir-autogen, elixir-format, fuzzy msgid "Add idea" msgstr "Neue Idee" @@ -465,18 +465,18 @@ msgstr "Neue Idee" msgid "Default lane" msgstr "Eine Spalte" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:279 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:125 #, elixir-autogen, elixir-format msgid "No lanes available" msgstr "Keine Spalten vorhanden" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:120 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:25 #, elixir-autogen, elixir-format, fuzzy msgid "Edit idea" msgstr "Idee bearbeiten" #: lib/mindwendel_web/live/comment_live/show_component.html.heex:30 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:112 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:17 #, elixir-autogen, elixir-format, fuzzy msgid "Delete idea" msgstr "Löschen" @@ -491,9 +491,9 @@ msgstr "Idee aktualisiert" msgid "Additional Attachment" msgstr "Zusätzlicher Anhang" +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:75 #: lib/mindwendel_web/live/idea_live/form_component.html.heex:43 #: lib/mindwendel_web/live/idea_live/show_component.html.heex:27 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:170 #, elixir-autogen, elixir-format msgid "No filename" msgstr "Kein Dateiname" @@ -549,7 +549,7 @@ msgid "No comments available" msgstr "Keine Kommentare vorhanden" #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:97 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:128 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:33 #, elixir-autogen, elixir-format, fuzzy msgid "Show idea" msgstr "Zeige Idee" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index f4e4845c..932f373f 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -36,7 +36,7 @@ msgid "%{name} - New Idea" msgstr "" #: lib/mindwendel_web/live/comment_live/show_component.html.heex:22 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:113 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:18 #, elixir-autogen, elixir-format msgid "Are you sure you want to delete this idea?" msgstr "" @@ -112,7 +112,7 @@ msgstr "" msgid "New idea" msgstr "" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:263 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:109 #, elixir-autogen, elixir-format msgid "No ideas brainstormed" msgstr "" @@ -201,7 +201,7 @@ msgstr "" #: lib/mindwendel_web/controllers/admin/brainstorming_html/export.html.heex:3 #: lib/mindwendel_web/live/comment_live/show_component.html.heex:40 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:180 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:85 #, elixir-autogen, elixir-format msgid "By" msgstr "" @@ -420,7 +420,7 @@ msgstr "" #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:26 #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:28 #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:114 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:284 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:130 #, elixir-autogen, elixir-format msgid "New lane" msgstr "" @@ -454,7 +454,7 @@ msgstr "" #: lib/mindwendel_web/live/lane_live/index_component.html.heex:10 #: lib/mindwendel_web/live/lane_live/index_component.html.heex:13 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:268 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:114 #, elixir-autogen, elixir-format msgid "Add idea" msgstr "" @@ -464,18 +464,18 @@ msgstr "" msgid "Default lane" msgstr "" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:279 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:125 #, elixir-autogen, elixir-format msgid "No lanes available" msgstr "" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:120 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:25 #, elixir-autogen, elixir-format msgid "Edit idea" msgstr "" #: lib/mindwendel_web/live/comment_live/show_component.html.heex:30 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:112 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:17 #, elixir-autogen, elixir-format msgid "Delete idea" msgstr "" @@ -490,9 +490,9 @@ msgstr "" msgid "Additional Attachment" msgstr "" +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:75 #: lib/mindwendel_web/live/idea_live/form_component.html.heex:43 #: lib/mindwendel_web/live/idea_live/show_component.html.heex:27 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:170 #, elixir-autogen, elixir-format msgid "No filename" msgstr "" @@ -548,7 +548,7 @@ msgid "No comments available" msgstr "" #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:97 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:128 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:33 #, elixir-autogen, elixir-format msgid "Show idea" msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index 0f75428e..3dff1709 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -37,7 +37,7 @@ msgid "%{name} - New Idea" msgstr "" #: lib/mindwendel_web/live/comment_live/show_component.html.heex:22 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:113 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:18 #, elixir-autogen, elixir-format msgid "Are you sure you want to delete this idea?" msgstr "" @@ -113,7 +113,7 @@ msgstr "" msgid "New idea" msgstr "" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:263 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:109 #, elixir-autogen, elixir-format msgid "No ideas brainstormed" msgstr "" @@ -202,7 +202,7 @@ msgstr "" #: lib/mindwendel_web/controllers/admin/brainstorming_html/export.html.heex:3 #: lib/mindwendel_web/live/comment_live/show_component.html.heex:40 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:180 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:85 #, elixir-autogen, elixir-format msgid "By" msgstr "" @@ -421,7 +421,7 @@ msgstr "" #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:26 #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:28 #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:114 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:284 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:130 #, elixir-autogen, elixir-format msgid "New lane" msgstr "" @@ -455,7 +455,7 @@ msgstr "" #: lib/mindwendel_web/live/lane_live/index_component.html.heex:10 #: lib/mindwendel_web/live/lane_live/index_component.html.heex:13 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:268 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:114 #, elixir-autogen, elixir-format, fuzzy msgid "Add idea" msgstr "" @@ -465,18 +465,18 @@ msgstr "" msgid "Default lane" msgstr "" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:279 +#: lib/mindwendel_web/live/lane_live/index_component.html.heex:125 #, elixir-autogen, elixir-format msgid "No lanes available" msgstr "" -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:120 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:25 #, elixir-autogen, elixir-format, fuzzy msgid "Edit idea" msgstr "" #: lib/mindwendel_web/live/comment_live/show_component.html.heex:30 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:112 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:17 #, elixir-autogen, elixir-format, fuzzy msgid "Delete idea" msgstr "" @@ -491,9 +491,9 @@ msgstr "" msgid "Additional Attachment" msgstr "" +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:75 #: lib/mindwendel_web/live/idea_live/form_component.html.heex:43 #: lib/mindwendel_web/live/idea_live/show_component.html.heex:27 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:170 #, elixir-autogen, elixir-format msgid "No filename" msgstr "" @@ -549,7 +549,7 @@ msgid "No comments available" msgstr "" #: lib/mindwendel_web/live/brainstorming_live/show.html.heex:97 -#: lib/mindwendel_web/live/lane_live/index_component.html.heex:128 +#: lib/mindwendel_web/live/idea_live/card_component.html.heex:33 #, elixir-autogen, elixir-format, fuzzy msgid "Show idea" msgstr "" diff --git a/test/mindwendel/likes_test.exs b/test/mindwendel/likes_test.exs index 883ececb..be39a907 100644 --- a/test/mindwendel/likes_test.exs +++ b/test/mindwendel/likes_test.exs @@ -2,6 +2,7 @@ defmodule Mindwendel.LikesTest do use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Likes + alias Mindwendel.Brainstormings.Like setup do user = Factory.insert!(:user) @@ -16,14 +17,16 @@ defmodule Mindwendel.LikesTest do } end - describe "exists_like_for_idea?" do + describe "exists_user_in_likes?" do test "returns true if like is given", %{idea: idea, user: user} do Factory.insert!(:like, %{idea_id: idea.id, user_id: user.id}) - assert Likes.exists_like_for_idea?(idea.id, user.id) == true + likes = Repo.all(from like in Like, where: like.idea_id == ^idea.id) + assert Likes.exists_user_in_likes?(likes, user.id) == true end test "returns false if like is not given", %{idea: idea, user: user} do - assert Likes.exists_like_for_idea?(idea.id, user.id) == false + likes = Repo.all(from like in Like, where: like.idea_id == ^idea.id) + assert Likes.exists_user_in_likes?(likes, user.id) == false end end