diff --git a/lib/shift73k/shifts/templates/shift_template.ex b/lib/shift73k/shifts/templates/shift_template.ex index 56ae8ac5..37c4949d 100644 --- a/lib/shift73k/shifts/templates/shift_template.ex +++ b/lib/shift73k/shifts/templates/shift_template.ex @@ -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 diff --git a/lib/shift73k_web/live/shift_assign_live/delete_component.html.heex b/lib/shift73k_web/live/shift_assign_live/delete_component.html.heex new file mode 100644 index 00000000..0f3a91d7 --- /dev/null +++ b/lib/shift73k_web/live/shift_assign_live/delete_component.html.heex @@ -0,0 +1,35 @@ +
Are you sure you want to delete all assigned shifts from the selected days?
+ + <%= for {y, data} <- @date_map do %> +Are you sure you want to delete all assigned shifts from the selected days?
- - <%= for {y, data} <- @date_map do %> -