mirror of
https://github.com/ClaperCo/Claper.git
synced 2026-09-01 19:49:11 +02:00
Use user's locale for native date picker
This commit is contained in:
@@ -264,6 +264,7 @@
|
||||
form={f}
|
||||
key={:started_at}
|
||||
name={gettext("Start date and time")}
|
||||
locale={@current_user.locale}
|
||||
required="true"
|
||||
/>
|
||||
<p class="text-xs text-base-content/60">{gettext("Shown in your local time.")}</p>
|
||||
|
||||
@@ -272,6 +272,7 @@ defmodule ClaperWeb.Component.Input do
|
||||
|> assign_new(:autofocus, fn -> false end)
|
||||
|> assign_new(:placeholder, fn -> false end)
|
||||
|> assign_new(:readonly, fn -> false end)
|
||||
|> assign_new(:locale, fn -> Gettext.get_locale(ClaperWeb.Gettext) end)
|
||||
|> assign_new(:labelClass, fn -> "text-gray-700" end)
|
||||
|> assign_new(:fieldClass, fn -> "bg-white" end)
|
||||
|
||||
@@ -286,6 +287,7 @@ defmodule ClaperWeb.Component.Input do
|
||||
readonly: @readonly,
|
||||
autofocus: @autofocus,
|
||||
autocomplete: "off",
|
||||
lang: @locale,
|
||||
step: 300,
|
||||
class:
|
||||
"input h-12 w-full bg-white px-4 read-only:opacity-50 #{if Keyword.has_key?(@form.errors, @key), do: "input-error", else: ""}"
|
||||
|
||||
@@ -65,6 +65,16 @@ defmodule ClaperWeb.EventLiveTest do
|
||||
assert has_element?(new_live, ~s(button[form="event-form"]), "Create event")
|
||||
end
|
||||
|
||||
test "uses the user's locale for the native date picker", %{user: user} do
|
||||
{:ok, %{locale: "fr"} = user} =
|
||||
Claper.Accounts.update_user_preferences(user, %{locale: "fr"})
|
||||
|
||||
conn = build_conn() |> log_in_user(user)
|
||||
{:ok, new_live, _html} = live(conn, ~p"/events/new")
|
||||
|
||||
assert has_element?(new_live, ~s(#date-picker input[type="datetime-local"][lang="fr"]))
|
||||
end
|
||||
|
||||
test "adds and removes an unsaved facilitator", %{
|
||||
conn: conn,
|
||||
presentation_file: presentation_file
|
||||
|
||||
Reference in New Issue
Block a user