Skip to content

Commit

Permalink
Fix forms UX
Browse files Browse the repository at this point in the history
  • Loading branch information
alxlion committed Oct 19, 2024
1 parent d6c48a3 commit 6f8a2fd
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 4 deletions.
13 changes: 10 additions & 3 deletions lib/claper_web/live/event_live/event_form_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,19 @@ defmodule ClaperWeb.EventLive.EventFormComponent do
end)

changeset =
socket.assigns.changeset
|> Ecto.Changeset.put_assoc(:leaders, leaders)

# Preserve other event fields and changes
updated_changeset =
case leaders do
[] -> Events.change_event(socket.assigns.event, %{leaders: leaders})
_ -> socket.assigns.changeset |> Ecto.Changeset.put_assoc(:leaders, leaders)
[] ->
Events.change_event(socket.assigns.event, Map.put(socket.assigns.changeset.changes, :leaders, []))
_ ->
changeset
end

{:noreply, assign(socket, changeset: changeset)}
{:noreply, assign(socket, changeset: updated_changeset)}
end

defp get_temp_id, do: :crypto.strong_rand_bytes(5) |> Base.url_encode64() |> binary_part(0, 5)
Expand Down
2 changes: 1 addition & 1 deletion lib/claper_web/live/event_live/manage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ defmodule ClaperWeb.EventLive.Manage do
socket
|> assign(:create, "poll")
|> assign(:poll, %Polls.Poll{
poll_opts: [%Polls.PollOpt{id: 0}, %Polls.PollOpt{id: 1}]
poll_opts: [%Polls.PollOpt{content: gettext("Yes")}, %Polls.PollOpt{content: gettext("No")}]
})
end

Expand Down
10 changes: 10 additions & 0 deletions priv/gettext/de/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -1602,3 +1602,13 @@ msgstr "Beenden"
#, elixir-autogen, elixir-format
msgid "More options"
msgstr "Weitere Optionen"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "No"
msgstr "Nein"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "Yes"
msgstr "Ja"
10 changes: 10 additions & 0 deletions priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1604,3 +1604,13 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "More options"
msgstr ""

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "No"
msgstr ""

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "Yes"
msgstr ""
10 changes: 10 additions & 0 deletions priv/gettext/en/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -1602,3 +1602,13 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "More options"
msgstr ""

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "No"
msgstr ""

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "Yes"
msgstr ""
10 changes: 10 additions & 0 deletions priv/gettext/es/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -1602,3 +1602,13 @@ msgstr "Finalizar"
#, elixir-autogen, elixir-format
msgid "More options"
msgstr "Más opciones"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "No"
msgstr "No"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "Yes"
msgstr "Sí"
10 changes: 10 additions & 0 deletions priv/gettext/fr/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -1607,3 +1607,13 @@ msgstr "Terminer"
#, elixir-autogen, elixir-format
msgid "More options"
msgstr "Plus d'options"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "No"
msgstr "Non"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "Yes"
msgstr "Oui"
10 changes: 10 additions & 0 deletions priv/gettext/it/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -1603,3 +1603,13 @@ msgstr "Fine"
#, elixir-autogen, elixir-format
msgid "More options"
msgstr "Altre opzioni"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "No"
msgstr "No"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "Yes"
msgstr "Sì"
10 changes: 10 additions & 0 deletions priv/gettext/nl/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -1602,3 +1602,13 @@ msgstr "Beëindigen"
#, elixir-autogen, elixir-format
msgid "More options"
msgstr "Meer opties"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "No"
msgstr "Nee"

#: lib/claper_web/live/event_live/manage.ex:687
#, elixir-autogen, elixir-format
msgid "Yes"
msgstr "Ja"

0 comments on commit 6f8a2fd

Please sign in to comment.