-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polished date picker implementation #2195
Changes from all commits
82b8744
a811840
c880070
ada7ecd
223c9d3
c99efb8
89b0b64
6a34718
f5f3d21
7312f78
fa58c4e
51f758b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,6 @@ defmodule Dotcom.TripPlan.InputForm do | |
|
||
alias OpenTripPlannerClient.PlanParams | ||
|
||
@time_types ~W(now leave_at arrive_by)a | ||
|
||
@error_messages %{ | ||
from: "Please specify an origin location.", | ||
to: "Please add a destination.", | ||
|
@@ -25,13 +23,11 @@ defmodule Dotcom.TripPlan.InputForm do | |
embeds_one(:from, __MODULE__.Location) | ||
embeds_one(:to, __MODULE__.Location) | ||
embeds_one(:modes, __MODULE__.Modes) | ||
field(:datetime_type, Ecto.Enum, values: @time_types) | ||
field(:datetime_type, :string) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📓 I changed this for now because we need to have a way to navigate between these atoms and the string we're given back by the form. We can figure this out later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the atom/string juggling was definitely my least favorite part about trying to handle mode changes too... |
||
field(:datetime, :naive_datetime) | ||
field(:wheelchair, :boolean, default: true) | ||
end | ||
|
||
def time_types, do: @time_types | ||
|
||
def initial_modes do | ||
__MODULE__.Modes.fields() | ||
|> Enum.map(&{Atom.to_string(&1), "true"}) | ||
|
@@ -49,7 +45,7 @@ defmodule Dotcom.TripPlan.InputForm do | |
%{ | ||
fromPlace: PlanParams.to_place_param(from), | ||
toPlace: PlanParams.to_place_param(to), | ||
arriveBy: datetime_type == :arrive_by, | ||
arriveBy: datetime_type == "arrive_by", | ||
date: PlanParams.to_date_param(datetime), | ||
time: PlanParams.to_time_param(datetime), | ||
transportModes: __MODULE__.Modes.selected_mode_keys(modes) |> PlanParams.to_modes_param(), | ||
|
@@ -114,7 +110,7 @@ defmodule Dotcom.TripPlan.InputForm do | |
|
||
defp validate_chosen_datetime(changeset) do | ||
case get_field(changeset, :datetime_type) do | ||
:now -> | ||
"now" -> | ||
force_change(changeset, :datetime, Util.now()) | ||
|
||
_ -> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📓 Bootstrap was setting this to grey so we need this override.