main shift assign UI updated, with custom shift field fixes & shift template form field fix for time_zone
This commit is contained in:
parent
8cd984adc5
commit
24642d7c67
7 changed files with 89 additions and 71 deletions
lib/shift73k/shifts/templates
|
@ -57,6 +57,7 @@ defmodule Shift73k.Shifts.Templates.ShiftTemplate do
|
|||
[]
|
||||
end
|
||||
end)
|
||||
|> validate_not_nil([:time_zone])
|
||||
|> validate_inclusion(:time_zone, Tzdata.zone_list(),
|
||||
message: "must be a valid IANA tz database time zone"
|
||||
)
|
||||
|
@ -72,4 +73,14 @@ defmodule Shift73k.Shifts.Templates.ShiftTemplate do
|
|||
|> Map.from_struct()
|
||||
|> Map.drop([:__meta__, :id, :inserted_at, :updated_at, :user, :is_fave_of_user])
|
||||
end
|
||||
|
||||
def validate_not_nil(changeset, fields) do
|
||||
Enum.reduce(fields, changeset, fn field, changeset ->
|
||||
if get_field(changeset, field) == nil do
|
||||
add_error(changeset, field, "nil")
|
||||
else
|
||||
changeset
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue