diff --git a/lib/claper_web/live/event_live/event_form_component.ex b/lib/claper_web/live/event_live/event_form_component.ex index 1cf2909..2d0e44f 100644 --- a/lib/claper_web/live/event_live/event_form_component.ex +++ b/lib/claper_web/live/event_live/event_form_component.ex @@ -47,7 +47,10 @@ defmodule ClaperWeb.EventLive.EventFormComponent do @impl true def handle_event("save", %{"event" => event_params}, socket) do - save_event(socket, socket.assigns.action, event_params) + case uploaded_entries(socket, :presentation_file) do + {_, []} -> save_event(socket, socket.assigns.action, event_params) + _ -> {:noreply, socket} + end end @impl true diff --git a/lib/claper_web/live/event_live/event_form_component.html.heex b/lib/claper_web/live/event_live/event_form_component.html.heex index 5b01249..27e32c3 100644 --- a/lib/claper_web/live/event_live/event_form_component.html.heex +++ b/lib/claper_web/live/event_live/event_form_component.html.heex @@ -1,7 +1,7 @@
<% upload_entry = Enum.at(@uploads.presentation_file.entries, 0) %> <% upload_progress = if upload_entry, do: upload_entry.progress, else: 0 %> - <% can_submit = upload_progress in [0, 100] && @changeset.valid? %> + <% can_submit = (is_nil(upload_entry) || upload_progress == 100) && @changeset.valid? %> <% presentation_file = Map.get(@event, :presentation_file) %> <% presentation_attached = not is_nil(presentation_file) && Map.get(presentation_file, :length, 0) > 0 && @@ -192,13 +192,14 @@ > {gettext("Choose file")} - <.live_file_input upload={@uploads.presentation_file} class="sr-only" />

{gettext("PDF, PPT, or PPTX up to %{size} MB", size: @max_file_size)}

<% end %> + <.live_file_input upload={@uploads.presentation_file} class="sr-only" /> + <%= if upload_entry do %> <%= for err <- upload_errors(@uploads.presentation_file, upload_entry) do %>