neiam
/apollos_crib
It's Apollo's Crib
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions failure · Badges · Packages
⭐
Log in to mark this repository.
More form fixes. and the re-public-ing
9be8a61 · gmorell · 2023-06-20 01:49
Files changed
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_ankyra/form_component.ex
+9
−3
@@ -40,7 +40,7 @@ defmodule RoomSanctumWeb.AnkyraLive.FormComponent do
| 40 | 40 | end |
| 41 | 41 | |
| 42 | 42 | @impl true |
| 43 | − def handle_event("validate", %{"ankyra" => ankyra_params}, socket) do | |
| 43 | + def handle_event("validate", %{"rabbit_user" => ankyra_params}, socket) do | |
| 44 | 44 | ankyra_params = inj_uid(ankyra_params, socket) |
| 45 | 45 | |
| 46 | 46 | changeset = |
@@ -60,21 +60,27 @@ defmodule RoomSanctumWeb.AnkyraLive.FormComponent do
| 60 | 60 | |> Map.get(:place) |
| 61 | 61 | ) |
| 62 | 62 | |
| 63 | + ankyra_params = case ankyra_params |> Map.get("username") do | |
| 64 | + nil -> ankyra_params |> Map.put("username", Ecto.UUID.generate) | |
| 65 | + _otherwise -> ankyra_params | |
| 66 | + end | |
| 67 | + | |
| 63 | 68 | save_ankyra(socket, socket.assigns.action, ankyra_params) |
| 64 | 69 | end |
| 65 | 70 | |
| 66 | 71 | def handle_event("save", %{}, socket) do |
| 67 | 72 | params = socket.assigns.changeset |> Ecto.Changeset.change(user_id: socket.assigns.current_user.id) |
| 73 | + | |
| 68 | 74 | save_ankyra(socket, socket.assigns.action, params.changes) |
| 69 | 75 | end |
| 70 | 76 | |
| 71 | 77 | def handle_event("generate-new-password", _params, socket) do |
| 72 | − changeset = socket.assigns.changeset |> Ecto.Changeset.change(password: gen_pw()) | |
| 78 | + changeset = socket.assigns.rabbit_user |> Ecto.Changeset.change(password: gen_pw()) |> Map.put(:action, :validate) | |
| 73 | 79 | {:noreply, assign_form(socket, changeset)} |
| 74 | 80 | end |
| 75 | 81 | |
| 76 | 82 | def handle_event("generate-new-topic", _params, socket) do |
| 77 | − changeset = socket.assigns.changeset |> Ecto.Changeset.change(topic: gen_topic()) | |
| 83 | + changeset = socket.assigns.rabbit_user |> Ecto.Changeset.change(topic: gen_topic()) |> Map.put(:action, :validate) | |
| 78 | 84 | {:noreply, assign_form(socket, changeset)} |
| 79 | 85 | end |
| 80 | 86 |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_foci_live/form_component.ex
+2
−1
@@ -59,13 +59,14 @@ defmodule RoomSanctumWeb.FociLive.FormComponent do
| 59 | 59 | |
| 60 | 60 | def handle_event("map-update", %{"latlng" => latlng}, socket) do |
| 61 | 61 | lat_lng_pt = %Geo.Point{coordinates: {latlng["lat"] |> normalize_ll, latlng["lng"] |> normalize_ll}, srid: 4326} |
| 62 | − cs = socket.assigns.changeset |> Ecto.Changeset.change(place: lat_lng_pt) | |
| 62 | + cs = socket.assigns.foci |> Ecto.Changeset.change(place: lat_lng_pt) | |
| 63 | 63 | # |> Map.put(:action, :validate) |
| 64 | 64 | # cs = socket.assigns.foci |> Configuration.change_foci(%{place: lat_lng_pt}) |> Map.put(:action, :validate) |
| 65 | 65 | { |
| 66 | 66 | :noreply, |
| 67 | 67 | socket |
| 68 | 68 | |> assign(:changeset, cs) |
| 69 | + |> assign_form(cs) | |
| 69 | 70 | |> assign(:place, lat_lng_pt) |
| 70 | 71 | } |
| 71 | 72 | end |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_foci_live/form_component.html.heex
+1
−1
@@ -26,7 +26,7 @@
| 26 | 26 | <div> |
| 27 | 27 | <div class="w-full"> |
| 28 | 28 | <div class="form-control"> |
| 29 | − <label for={@form[:place]} class="block text-sm font-semibold leading-6 text-zinc-800"> | |
| 29 | + <label class="block text-sm font-semibold leading-6 text-zinc-800"> | |
| 30 | 30 | <div id="structural-shim" phx-update="ignore"> |
| 31 | 31 | <div id="map" style="height: 400px; width: 600px" phx-hook="mkMap" data-latlng={@foci |>getlatlng} class="rounded-sm"></div> |
| 32 | 32 | </div> |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_pythiae_live/public.html.heex
+2
−2
@@ -4,7 +4,7 @@
| 4 | 4 | <div class="card bg-base-300 shadow-xl w-full mb-1"> |
| 5 | 5 | <div class="card-body"> |
| 6 | 6 | <div class="flex gap-1"> |
| 7 | − <i class={"fas fa-fw fa-md #{icon(k |> elem(1))}"}></i> | |
| 7 | + <i class={"fas fa-fw fa-md #{get_icon(k |> elem(1))}"}></i> | |
| 8 | 8 | <span class="text-secondary font-bold"><%= get_query_data(k |> elem(0), @queries, 64) %></span> |
| 9 | 9 | </div> |
| 10 | 10 | <%= case k do %> |
@@ -21,4 +21,4 @@
| 21 | 21 | </div> |
| 22 | 22 | <% end %> |
| 23 | 23 | <% end %> |
| 24 | − </div> | |
| 24 | + </div> |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_pythiae_live/show.html.heex
+2
−2
@@ -117,7 +117,7 @@
| 117 | 117 | <%= for {k, p} <- @preview do %> |
| 118 | 118 | <div class="flex"> |
| 119 | 119 | <div class="w-16"> |
| 120 | − <i class={"fas fa-fw fa-2xl #{icon(k |> elem(1))}"}></i> | |
| 120 | + <i class={"fas fa-fw fa-2xl #{get_icon(k |> elem(1))}"}></i> | |
| 121 | 121 | </div> |
| 122 | 122 | <div class="w-7/8"> |
| 123 | 123 | <span class="text-secondary font-bold"><%= get_query_data(k |> elem(0), @queries, 64) %></span> |
@@ -130,4 +130,4 @@
| 130 | 130 | </div> |
| 131 | 131 | </div> |
| 132 | 132 | </div> |
| 133 | −</div> | |
| 133 | +</div> |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_scribus_live/form_component.ex
+1
−1
@@ -20,7 +20,7 @@ defmodule RoomSanctumWeb.ScribusLive.FormComponent do
| 20 | 20 | phx-submit="save" |
| 21 | 21 | > |
| 22 | 22 | <.input field={@form[:name]} type="text" label="Name" /> |
| 23 | − <.input field={@form[:resolution]} type="text" label="Resolution" /> | |
| 23 | + <.input field={@form[:resolution]} type="select" label="Resolution" options={["850x480"]} /> | |
| 24 | 24 | <.input |
| 25 | 25 | field={@form[:configuration]} |
| 26 | 26 | type="select" |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_scribus_live/index.html.heex
+6
−6
@@ -1,7 +1,7 @@
| 1 | 1 | <.header> |
| 2 | 2 | Listing Cfg scribus |
| 3 | 3 | <:actions> |
| 4 | − <.link patch={~p"/cfg_scribus/new"}> | |
| 4 | + <.link patch={~p"/cfg/scribus/new"}> | |
| 5 | 5 | <.button>New Scribus</.button> |
| 6 | 6 | </.link> |
| 7 | 7 | </:actions> |
@@ -10,16 +10,16 @@
| 10 | 10 | <.table |
| 11 | 11 | id="cfg_scribus" |
| 12 | 12 | rows={@streams.cfg_scribus} |
| 13 | − row_click={fn {_id, scribus} -> JS.navigate(~p"/cfg_scribus/#{scribus}") end} | |
| 13 | + row_click={fn {_id, scribus} -> JS.navigate(~p"/cfg/scribus/#{scribus}") end} | |
| 14 | 14 | > |
| 15 | 15 | <:col :let={{_id, scribus}} label="Name"><%= scribus.name %></:col> |
| 16 | 16 | <:col :let={{_id, scribus}} label="Resolution"><%= scribus.resolution %></:col> |
| 17 | 17 | <:col :let={{_id, scribus}} label="Configuration"><%= scribus.configuration %></:col> |
| 18 | 18 | <:action :let={{_id, scribus}}> |
| 19 | 19 | <div class="sr-only"> |
| 20 | − <.link navigate={~p"/cfg_scribus/#{scribus}"}>Show</.link> | |
| 20 | + <.link navigate={~p"/cfg/scribus/#{scribus}"}>Show</.link> | |
| 21 | 21 | </div> |
| 22 | − <.link patch={~p"/cfg_scribus/#{scribus}/edit"}>Edit</.link> | |
| 22 | + <.link patch={~p"/cfg/scribus/#{scribus}/edit"}>Edit</.link> | |
| 23 | 23 | </:action> |
| 24 | 24 | <:action :let={{id, scribus}}> |
| 25 | 25 | <.link |
@@ -31,13 +31,13 @@
| 31 | 31 | </:action> |
| 32 | 32 | </.table> |
| 33 | 33 | |
| 34 | −<.modal :if={@live_action in [:new, :edit]} id="scribus-modal" show on_cancel={JS.patch(~p"/cfg_scribus")}> | |
| 34 | +<.modal :if={@live_action in [:new, :edit]} id="scribus-modal" show on_cancel={JS.patch(~p"/cfg/scribus")}> | |
| 35 | 35 | <.live_component |
| 36 | 36 | module={RoomSanctumWeb.ScribusLive.FormComponent} |
| 37 | 37 | id={@scribus.id || :new} |
| 38 | 38 | title={@page_title} |
| 39 | 39 | action={@live_action} |
| 40 | 40 | scribus={@scribus} |
| 41 | − patch={~p"/cfg_scribus"} | |
| 41 | + patch={~p"/cfg/scribus"} | |
| 42 | 42 | /> |
| 43 | 43 | </.modal> |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_vision_live/form_component.ex
+20
−9
@@ -7,14 +7,15 @@ defmodule RoomSanctumWeb.VisionLive.FormComponent do
| 7 | 7 | params |
| 8 | 8 | # |> IO.inspect |
| 9 | 9 | |> Map.put("user_id", socket.assigns.current_user.id) |
| 10 | − |> Map.put("query_ids", params["queries"] |> Enum.map(fn {k,v} -> v["data"]["query"] end )) | |
| 10 | + |> Map.put("query_ids", params |> Map.get("queries", %{}) |> Enum.map(fn {k,v} -> v["data"]["query"] end )) | |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | defp inj_types(params) do |
| 14 | 14 | params |
| 15 | 15 | |> Map.put( |
| 16 | 16 | "queries", |
| 17 | − params["queries"] | |
| 17 | + params | |
| 18 | + |> Map.get("queries", %{}) | |
| 18 | 19 | |> Enum.map(fn {k, v} -> {k, v |> Kernel.put_in(["data", "__type__"], v["type"])} end) |
| 19 | 20 | |> Enum.into(%{}) |
| 20 | 21 | ) |
@@ -64,21 +65,31 @@ defmodule RoomSanctumWeb.VisionLive.FormComponent do
| 64 | 65 | f = socket.assigns.form |
| 65 | 66 | |
| 66 | 67 | existing_as_simple = case f.params do |
| 67 | − map when map == %{} -> f.data.queries |> Enum.map(fn x -> x |> Poison.encode!() |> Poison.decode!() end) | |
| 68 | − otherwise -> f.params |> Map.get("queries") |> Enum.map(fn {k,v} -> v end) | |
| 68 | + map when map == %{} -> f.data.queries |> Poison.encode!() |> Poison.decode!() |> Enum.with_index |> Enum.map(fn {k,v} -> {"#{v}",k} end) |> Map.new | |
| 69 | + otherwise -> f.params |> Map.get("queries") #|> Enum.map(fn {k,v} -> v end) | |
| 69 | 70 | end |
| 70 | 71 | |
| 71 | − IO.inspect(existing_as_simple) | |
| 72 | − combined = | |
| 73 | − existing_as_simple ++ | |
| 74 | − [ | |
| 72 | +# IO.inspect(existing_as_simple) | |
| 73 | + combined = case existing_as_simple do | |
| 74 | + list when list == [] -> %{"0" => %{ | |
| 75 | + "data" => %{"__type__" => "pinned", "query" => 0}, | |
| 76 | + "id" => nil, | |
| 77 | + "type" => "pinned", | |
| 78 | + "order" => 0 | |
| 79 | + } | |
| 80 | + } | |
| 81 | + _otherwise -> existing_as_simple |> Map.merge( | |
| 82 | + %{ "#{existing_as_simple |> Map.keys |> length }" => | |
| 75 | 83 | %{ |
| 76 | 84 | "data" => %{"__type__" => "pinned", "query" => 0}, |
| 77 | 85 | "id" => nil, |
| 78 | 86 | "type" => "pinned", |
| 79 | 87 | "order" => 0 |
| 80 | 88 | } |
| 81 | − ] | |
| 89 | + } | |
| 90 | + ) | |
| 91 | + end | |
| 92 | + | |
| 82 | 93 | |
| 83 | 94 | changeset = |
| 84 | 95 | socket.assigns.vision |
modified
apps/room_sanctum/lib/room_sanctum_web/router.ex
+1
−1
@@ -23,7 +23,7 @@ defmodule RoomSanctumWeb.Router do
| 23 | 23 | scope "/", RoomSanctumWeb do |
| 24 | 24 | pipe_through [:browser] |
| 25 | 25 | live "/", LandingLive.Index, :index |
| 26 | − live_session :public, root_layout: {RoomSanctumWeb.LayoutView, :root_public} do | |
| 26 | + live_session :public, root_layout: {RoomSanctumWeb.Layouts, :root_public} do | |
| 27 | 27 | live "/p/p/:name", PythiaeLive.Public, :show |
| 28 | 28 | end |
| 29 | 29 | end |
Parents: 0dd45ab