mirror of
https://github.com/ClaperCo/Claper.git
synced 2026-08-29 10:09:08 +02:00
Fix file upload
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="wrapper" class={if @container == :drawer, do: "flex h-full flex-col", else: ""}>
|
||||
<% 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")}
|
||||
</label>
|
||||
<.live_file_input upload={@uploads.presentation_file} class="sr-only" />
|
||||
<p class="mt-3 text-xs text-base-content/50">
|
||||
{gettext("PDF, PPT, or PPTX up to %{size} MB", size: @max_file_size)}
|
||||
</p>
|
||||
</div>
|
||||
<% 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 %>
|
||||
<div class="alert alert-error mt-3 py-2 text-sm" role="alert">
|
||||
|
||||
Reference in New Issue
Block a user