shittily filter sources on tint application/removal

7893138 · gmorell · 2024-08-20 03:09

8 files +10 -3

Files changed

modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_source_live/index.ex
+9 −2
@@ -75,8 +75,8 @@ defmodule RoomSanctumWeb.SourceLive.Index do
75 75 def handle_event("set-tint", %{"tint"=> tint}, socket) do
76 76 IO.inspect({"set-tint", tint, socket.assigns.tint})
77 77 case socket.assigns.tint == tint do
78 − true -> {:noreply, socket |> assign(:tint, nil)}
79 − false -> {:noreply, socket |> assign(:tint, tint)}
78 + true -> {:noreply, socket |> assign(:tint, nil) |> stream(:cfg_sources, list_cfg_sources(socket.assigns.current_user.id), reset: true)}
79 + false -> {:noreply, socket |> assign(:tint, tint) |> stream(:cfg_sources, list_cfg_sources(socket.assigns.current_user.id, tint), reset: true)}
80 80 end
81 81
82 82 end
@@ -85,6 +85,10 @@ defmodule RoomSanctumWeb.SourceLive.Index do
85 85 Configuration.list_cfg_sources({:user, uid})
86 86 end
87 87
88 + defp list_cfg_sources(uid, tint) do
89 + Configuration.list_cfg_sources({:user, uid}) |> Enum.filter(fn s -> s.meta.tint == tint end)
90 + end
91 +
88 92 defp get_icon(source_type) do
89 93 case source_type do
90 94 :calendar ->
@@ -119,6 +123,9 @@ defmodule RoomSanctumWeb.SourceLive.Index do
119 123
120 124 :gitlab ->
121 125 "fa-code-branch"
126 +
127 + :packages ->
128 + "fa-envelopes-bulk"
122 129 end
123 130 end
124 131 end
modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_source_live/index.html.heex
+1 −1
@@ -64,7 +64,7 @@
64 64 <i class={"fa fa-circle text-#{source.meta.tint}-500"} phx-click="set-tint" phx-value-tint={source.meta.tint} ></i>
65 65 <% end %>
66 66 </td>
67 − <td>
67 + <td class={"bg-#{@tint}-500"}>
68 68 <span>
69 69
70 70 <.ib icon="fa-eye" to={Routes.source_show_path(@socket, :show, source)} function={:live_redirect}></.ib>

Parents: 8deb00d