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.
fix the vision form, fix the form buttons on the right side and left side, overall make things nicerer. Soon to the scribus
ed894c6 · gmorell · 2023-06-16 03:46
Files changed
modified
apps/room_sanctum/lib/room_sanctum_web/components/core_components.ex
+5
−5
@@ -184,7 +184,7 @@ defmodule RoomSanctumWeb.CoreComponents do
| 184 | 184 | def simple_form(assigns) do |
| 185 | 185 | ~H""" |
| 186 | 186 | <.form :let={f} for={@for} as={@as} {@rest}> |
| 187 | − <div class="mt-10 space-y-8 bg-primary"> | |
| 187 | + <div class="mt-10 space-y-6 bg-primary"> | |
| 188 | 188 | <%= render_slot(@inner_block, f) %> |
| 189 | 189 | <div :for={action <- @actions} class="mt-2 flex items-center justify-between gap-6"> |
| 190 | 190 | <%= render_slot(action, f) %> |
@@ -384,22 +384,22 @@ defmodule RoomSanctumWeb.CoreComponents do
| 384 | 384 | ~H""" |
| 385 | 385 | <div phx-feedback-for={@name}> |
| 386 | 386 | <.label for={@id}><%= @label %></.label> |
| 387 | − <div class="input-group"> | |
| 387 | + <div class="input-group input-group-md"> | |
| 388 | 388 | <input |
| 389 | 389 | type={@type} |
| 390 | 390 | name={@name} |
| 391 | 391 | id={@id} |
| 392 | 392 | value={Phoenix.HTML.Form.normalize_value(@type, @value)} |
| 393 | 393 | class={[ |
| 394 | − "mt-2 block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6", | |
| 394 | + "block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6", | |
| 395 | 395 | "phx-no-feedback:border-zinc-300 phx-no-feedback:focus:border-zinc-400", |
| 396 | 396 | @errors == [] && "border-zinc-300 focus:border-zinc-400", |
| 397 | 397 | @errors != [] && "border-rose-400 focus:border-rose-400" |
| 398 | 398 | ]} |
| 399 | 399 | {@rest} |
| 400 | 400 | /> |
| 401 | − <btn class="btn btn-accent" phx-click={action} phx-target={tgt}> | |
| 402 | − <i class="fa-solid #{icon}"></i> | |
| 401 | + <btn class="btn btn-accent btn-square" phx-click={action} phx-target={tgt}> | |
| 402 | + <i class={"fa-solid #{icon}"}></i> | |
| 403 | 403 | </btn> |
| 404 | 404 | </div> |
| 405 | 405 | <.error :for={msg <- @errors}><%= msg %></.error> |
modified
apps/room_sanctum/lib/room_sanctum_web/components/layouts/root.html.heex
+0
−41
@@ -12,47 +12,6 @@
| 12 | 12 | "/assets/app.js")}></script> |
| 13 | 13 | </head> |
| 14 | 14 | <body> |
| 15 | − <ul class="relative z-10 flex items-center gap-4 px-4 sm:px-6 lg:px-8 justify-end"> | |
| 16 | − <%= if @current_user do %> | |
| 17 | − <li class="text-[0.8125rem] leading-6 text-zinc-900"> | |
| 18 | − <%= @current_user.email %> | |
| 19 | − </li> | |
| 20 | − <li> | |
| 21 | − <.link | |
| 22 | − href={~p"/users/settings"} | |
| 23 | − class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700" | |
| 24 | − > | |
| 25 | − Settings | |
| 26 | − </.link> | |
| 27 | − </li> | |
| 28 | − <li> | |
| 29 | − <.link | |
| 30 | − href={~p"/users/log_out"} | |
| 31 | − method="delete" | |
| 32 | − class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700" | |
| 33 | − > | |
| 34 | − Log out | |
| 35 | − </.link> | |
| 36 | − </li> | |
| 37 | − <% else %> | |
| 38 | − <li> | |
| 39 | − <.link | |
| 40 | − href={~p"/users/register"} | |
| 41 | − class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700" | |
| 42 | − > | |
| 43 | − Register | |
| 44 | − </.link> | |
| 45 | − </li> | |
| 46 | − <li> | |
| 47 | − <.link | |
| 48 | − href={~p"/users/log_in"} | |
| 49 | − class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700" | |
| 50 | − > | |
| 51 | − Log in | |
| 52 | − </.link> | |
| 53 | − </li> | |
| 54 | − <% end %> | |
| 55 | − </ul> | |
| 56 | 15 | <div class="p-2"> |
| 57 | 16 | <div class="navbar bg-neutral text-accent sm:rounded-lg shadow-xl"> |
| 58 | 17 | <div class="navbar-start"> |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_ankyra/form_component.html.heex
+2
−2
@@ -20,11 +20,11 @@
| 20 | 20 | <div class="w-full"> |
| 21 | 21 | <%= if @rabbit_user.id == nil do %> |
| 22 | 22 | <div class="form-control"> |
| 23 | − <.input field={@form[:topic]} type="text" label="Topic" rb_a="generate-new-topic" rb_i="fa-arrows-rotate" /> | |
| 23 | + <.input field={@form[:topic]} type="text" label="Topic" rb_a="generate-new-topic" rb_i="fa-arrows-rotate" rb_tgt="#ankyra-form" /> | |
| 24 | 24 | </div> |
| 25 | 25 | <% end %> |
| 26 | 26 | <div class="form-control"> |
| 27 | − <.input field={@form[:password]} type="text" label="Password" rb_a="generate-new-password" rb_i="fa-arrows-rotate" /> | |
| 27 | + <.input field={@form[:password]} type="text" label="Password" rb_a="generate-new-password" rb_i="fa-arrows-rotate" rb_tgt="#ankyra-form" /> | |
| 28 | 28 | </div> |
| 29 | 29 | </div> |
| 30 | 30 | </div> |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_pythiae_live/form_component.html.heex
+1
−1
@@ -11,7 +11,7 @@
| 11 | 11 | <div class="flex"> |
| 12 | 12 | <div class="w-full"> |
| 13 | 13 | <div class="form-control"> |
| 14 | − <.input field={@form[:name]} type="text" label="Topic" lb_a="generate-new-name" lb_i="fa-arrows-rotate" /> | |
| 14 | + <.input field={@form[:name]} type="text" label="Topic" lb_a="generate-new-name" lb_i="fa-arrows-rotate" lb_tgt="#pythiae-form" /> | |
| 15 | 15 | </div> |
| 16 | 16 | <div class="form-control"> |
| 17 | 17 | <.input field={@form[:visions]} type="select" multiple="true" label="Visions" options={@cfg_visions_sel}/> |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_vision_live/form_component.ex
+14
−13
@@ -5,7 +5,7 @@ defmodule RoomSanctumWeb.VisionLive.FormComponent do
| 5 | 5 | |
| 6 | 6 | defp inj_uid(params, socket) do |
| 7 | 7 | params |
| 8 | − |> IO.inspect | |
| 8 | +# |> IO.inspect | |
| 9 | 9 | |> Map.put("user_id", socket.assigns.current_user.id) |
| 10 | 10 | |> Map.put("query_ids", params["queries"] |> Enum.map(fn {k,v} -> v["data"]["query"] end )) |
| 11 | 11 | end |
@@ -60,18 +60,22 @@ defmodule RoomSanctumWeb.VisionLive.FormComponent do
| 60 | 60 | end |
| 61 | 61 | |
| 62 | 62 | def handle_event("add-entry", _data, socket) do |
| 63 | − # TODO: Make this behave the ankyra key generators do | |
| 64 | − existing_as_simple = | |
| 65 | − socket.assigns.vision.queries | |
| 66 | − |> Enum.map(fn x -> x |> Poison.encode!() |> Poison.decode!() end) | |
| 63 | +# IO.inspect(socket.assigns.form) | |
| 64 | + f = socket.assigns.form | |
| 67 | 65 | |
| 66 | + 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) | |
| 69 | + end | |
| 70 | + | |
| 71 | + IO.inspect(existing_as_simple) | |
| 68 | 72 | combined = |
| 69 | 73 | existing_as_simple ++ |
| 70 | 74 | [ |
| 71 | 75 | %{ |
| 72 | − "data" => %{"__type__" => "alerts", "query" => 0}, | |
| 76 | + "data" => %{"__type__" => "pinned", "query" => 0}, | |
| 73 | 77 | "id" => nil, |
| 74 | − "type" => "alerts", | |
| 78 | + "type" => "pinned", | |
| 75 | 79 | "order" => 0 |
| 76 | 80 | } |
| 77 | 81 | ] |
@@ -85,7 +89,7 @@ defmodule RoomSanctumWeb.VisionLive.FormComponent do
| 85 | 89 | { |
| 86 | 90 | :noreply, |
| 87 | 91 | socket |
| 88 | − |> assign(:changeset, changeset) | |
| 92 | + |> assign_form(changeset) | |
| 89 | 93 | } |
| 90 | 94 | end |
| 91 | 95 |
@@ -173,8 +177,7 @@ defmodule RoomSanctumWeb.VisionLive.FormComponent do
| 173 | 177 | # |> Map.get(:type) |
| 174 | 178 | # ) |
| 175 | 179 | |
| 176 | −# IO.inspect(form) | |
| 177 | − q = | |
| 180 | + q = form.params |> Map.get("queries", %{}) |> Map.get("#{ctr}", %{}) |> Map.get("type") || | |
| 178 | 181 | form.data |
| 179 | 182 | |> Map.get(:queries, []) |
| 180 | 183 | |> Enum.at(ctr, %{}) |
@@ -188,8 +191,6 @@ defmodule RoomSanctumWeb.VisionLive.FormComponent do
| 188 | 191 | |> Map.get(:data, %{}) |
| 189 | 192 | |> Map.get(:type) |
| 190 | 193 | |
| 191 | −# IO.puts("xxxxx") | |
| 192 | −# IO.inspect(q) | |
| 193 | − q | |
| 194 | + q # |> IO.inspect | |
| 194 | 195 | end |
| 195 | 196 | end |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_vision_live/form_component.html.heex
+31
−26
@@ -15,12 +15,10 @@
| 15 | 15 | </div> |
| 16 | 16 | </div> |
| 17 | 17 | </div> |
| 18 | − | |
| 19 | − | |
| 20 | 18 | <%= for {fq, ctr} <- Enum.with_index(inputs_for(@form, :queries)) do %> |
| 19 | + <%= hidden_inputs_for(fq) %> | |
| 21 | 20 | <div class="flex"> |
| 22 | − <div class="flex-none w-16 font-bold text-7xl"> | |
| 23 | − <%= hidden_inputs_for(fq) %> | |
| 21 | + <div class="flex-none w-16 font-bold text-7xl py-6"> | |
| 24 | 22 | <%= ctr %> |
| 25 | 23 | </div> |
| 26 | 24 | <div class="flex-none w-32 p-1"> |
@@ -31,33 +29,40 @@
| 31 | 29 | |
| 32 | 30 | <%= for fd <- polymorphic_embed_inputs_for fq, :data do %> |
| 33 | 31 | <%= hidden_inputs_for(fd) %> |
| 34 | − <div class="flex-none w-24 p-1"> | |
| 35 | − <div class="form-control"> | |
| 36 | − <.input field={fd[:order]} type="number" label="Order" /> | |
| 37 | − </div> | |
| 38 | − </div> | |
| 39 | − <div class="flex-1 w-64 p-1"> | |
| 40 | − <div class="form-control"> | |
| 41 | − <.input field={fd[:query]} type="select" label="Type" options={@cfg_queries_sel}/> | |
| 42 | − </div> | |
| 43 | − </div> | |
| 44 | − <div class="flex-1 w-64 p-1"> | |
| 45 | − <%= case gfv(@form, fq, ctr) do %> | |
| 46 | − <% :time -> %> | |
| 32 | + <div class="flex flex-col"> | |
| 33 | + <div class="flex"> | |
| 34 | + <div class="flex-none w-24 p-1"> | |
| 47 | 35 | <div class="form-control"> |
| 48 | − <label>Weekdays</label> | |
| 49 | − <.input field={fd[:weekdays]} type="select" multiple="true" label="Visions" options={Enum.map(Ecto.Enum.values(RoomSanctum.Configuration.Vision.Schema1Time, :weekdays), fn c -> etuple(c) end)}/> | |
| 50 | − </div> | |
| 51 | − <div class="card card-compact rounded-md bg-base-100 shadow-xl p-2 my-1"> | |
| 52 | − <div class="time-inputs"> | |
| 53 | − <.input field={fd[:time_start]} type="time" label={raw("<i class=\"fa-solid fa-forward-step\"></i>")} /> | |
| 36 | + <.input field={fd[:order]} type="number" label="Order" /> | |
| 54 | 37 | </div> |
| 55 | − <div class="time-inputs"> | |
| 56 | − <.input field={fd[:time_end]} type="time" label={raw("<i class=\"fa-solid fa-backward-step\"></i>")} /> | |
| 38 | + </div> | |
| 39 | + <div class="flex-1 w-full p-1"> | |
| 40 | + <div class="form-control"> | |
| 41 | + <.input field={fd[:query]} type="select" label="Type" options={@cfg_queries_sel}/> | |
| 57 | 42 | </div> |
| 43 | + </div> | |
| 44 | + </div> | |
| 45 | + <div class="flex-1 w-full p-1"> | |
| 46 | + <%= case gfv(@form, fq, ctr) do %> | |
| 47 | + <% val when val in [:time, "time"] -> %> | |
| 48 | + <div class="flex"> | |
| 49 | + <div class="form-control"> | |
| 50 | + <.input field={fd[:weekdays]} type="select" multiple="true" label="Weekday" options={Enum.map(Ecto.Enum.values(RoomSanctum.Configuration.Vision.Schema1Time, :weekdays), fn c -> etuple(c) end)}/> | |
| 51 | + </div> | |
| 52 | + <div class="px-4 | |
| 53 | +"> | |
| 54 | + <label class="block text-md font-bold leading-6 pt-4 text-primary-content">Times</label> | |
| 55 | + <div class="time-inputs"> | |
| 56 | + <.input field={fd[:time_start]} type="time" label="Start")} /> | |
| 57 | + </div> | |
| 58 | + <div class="time-inputs"> | |
| 59 | + <.input field={fd[:time_end]} type="time" label="End")} /> | |
| 60 | + </div> | |
| 61 | + </div> | |
| 58 | 62 | </div> |
| 59 | − <% _ -> %> | |
| 63 | + <% _ -> %> | |
| 60 | 64 | <% end %> |
| 65 | + </div> | |
| 61 | 66 | </div> |
| 62 | 67 | <% end %> |
| 63 | 68 | </div> |
Parents: fe1bf9b