Skip to content

Commit

Permalink
Last few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
doughsay committed Apr 24, 2024
1 parent 73e595e commit 9ca4387
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ config :ambry, Ambry.Mailer, adapter: Swoosh.Adapters.Local

# Configure esbuild (the version is required)
config :esbuild,
version: "0.18.6",
version: "0.20.2",
default: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
Expand All @@ -43,7 +43,7 @@ config :esbuild,

# Configure tailwind (the version is required)
config :tailwind,
version: "3.3.2",
version: "3.4.3",
default: [
args: ~w(
--config=tailwind.config.js
Expand Down
4 changes: 2 additions & 2 deletions lib/ambry_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ defmodule AmbryWeb.CoreComponents do
end

attr :upload, :any, required: true
attr :on_cancel, :string, required: true
attr :label, :string, default: nil
attr :class, :string, default: nil, doc: "class overrides"
attr :errors, :list, default: []
Expand Down Expand Up @@ -499,8 +500,7 @@ defmodule AmbryWeb.CoreComponents do
<span
class="cursor-pointer text-2xl transition-colors hover:text-red-600 dark:hover:text-red-500"
phx-click="cancel-upload"
phx-value-ref={entry.ref}
phx-click={JS.push(@on_cancel, value: %{ref: entry.ref})}
>
&times;
</span>
Expand Down
1 change: 1 addition & 0 deletions lib/ambry_web/live/admin/book_live/form.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<.file_input
:if={@form[:image_type].value == "upload"}
upload={@uploads.image}
on_cancel="cancel-upload"
label="Upload image"
image_preview_class="h-48 w-48 rounded-sm"
/>
Expand Down
3 changes: 1 addition & 2 deletions lib/ambry_web/live/admin/book_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ defmodule AmbryWeb.Admin.BookLive.Index do
socket
|> assign(
page_title: "Books",
show_header_search: true,
header_new_path: ~p"/admin/books/new"
show_header_search: true
)
|> maybe_update_books(params, true)}
end
Expand Down
25 changes: 14 additions & 11 deletions lib/ambry_web/live/admin/media_live/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ defmodule AmbryWeb.Admin.MediaLive.Form do
{:noreply, cancel_upload(socket, :audio, ref)}
end

def handle_event("cancel-supplemental-upload", %{"ref" => ref}, socket) do
{:noreply, cancel_upload(socket, :supplemental, ref)}
end

@impl Phoenix.LiveView
def handle_info({:import, %{"media" => media_params}}, socket) do
# narrators could have been created, reload the data-lists
Expand All @@ -132,7 +136,10 @@ defmodule AmbryWeb.Admin.MediaLive.Form do
end

def handle_info({:files_selected, files}, socket) do
{:noreply, assign(socket, select_files: false, selected_files: files)}
{:noreply,
socket
|> assign(selected_files: files)
|> push_patch(to: media_path(socket.assigns.media), replace: true)}
end

defp handle_supplemental_files_upload(socket, media_params, name) do
Expand Down Expand Up @@ -338,15 +345,11 @@ defmodule AmbryWeb.Admin.MediaLive.Form do
bytes |> FileSize.from_bytes() |> FileSize.scale() |> FileSize.format()
end

defp open_import_form(%Media.Media{id: nil}, type),
do: JS.patch(~p"/admin/media/new?import=#{type}")

defp open_import_form(media, type), do: JS.patch(~p"/admin/media/#{media}/edit?import=#{type}")

defp close_modal(%Media.Media{id: nil}), do: JS.patch(~p"/admin/media/new", replace: true)
defp close_modal(media), do: JS.patch(~p"/admin/media/#{media}/edit", replace: true)

defp open_file_browser(%Media.Media{id: nil}), do: JS.patch(~p"/admin/media/new?browse")
defp media_path(media, params \\ %{})
defp media_path(%Media.Media{id: nil}, params), do: ~p"/admin/media/new?#{params}"
defp media_path(media, params), do: ~p"/admin/media/#{media}/edit?#{params}"

defp open_file_browser(media), do: JS.patch(~p"/admin/media/#{media}/edit?browse")
defp open_import_form(media, type), do: JS.patch(media_path(media, %{import: type}))
defp open_file_browser(media), do: JS.patch(media_path(media, %{browse: :files}))
defp close_modal(media), do: JS.patch(media_path(media), replace: true)
end
9 changes: 7 additions & 2 deletions lib/ambry_web/live/admin/media_live/form.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
mp3, mp4, m4a, m4b, opus
</.note>

<.file_input upload={@uploads.audio} />
<.file_input upload={@uploads.audio} on_cancel="cancel-upload" />
<.field_errors field={@form[:source_path]} />
</div>

Expand Down Expand Up @@ -248,7 +248,12 @@
</div>
</div>

<.file_input upload={@uploads.supplemental} label="Upload supplemental files" image_preview_class="h-48" />
<.file_input
upload={@uploads.supplemental}
on_cancel="cancel-supplemental-upload"
label="Upload supplemental files"
image_preview_class="h-48"
/>

<div :if={@live_action == :edit && @form[:supplemental_files].value != []} class="space-y-2">
<.label>Supplemental files</.label>
Expand Down
1 change: 0 additions & 1 deletion lib/ambry_web/live/admin/media_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ defmodule AmbryWeb.Admin.MediaLive.Index do
|> assign(
page_title: "Media",
show_header_search: true,
header_new_path: ~p"/admin/media/new",
processing_media_progress_map: %{}
)
|> maybe_update_media(params, true)}
Expand Down
1 change: 1 addition & 0 deletions lib/ambry_web/live/admin/person_live/form.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<.file_input
:if={@form[:image_type].value == "upload"}
upload={@uploads.image}
on_cancel="cancel-upload"
label="Upload image"
image_preview_class="h-40 w-40 rounded-full object-cover object-top"
/>
Expand Down
3 changes: 1 addition & 2 deletions lib/ambry_web/live/admin/person_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ defmodule AmbryWeb.Admin.PersonLive.Index do
socket
|> assign(
page_title: "Authors & Narrators",
show_header_search: true,
header_new_path: ~p"/admin/people/new"
show_header_search: true
)
|> maybe_update_people(params, true)}
end
Expand Down
3 changes: 1 addition & 2 deletions lib/ambry_web/live/admin/series_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ defmodule AmbryWeb.Admin.SeriesLive.Index do
socket
|> assign(
page_title: "Series",
show_header_search: true,
header_new_path: ~p"/admin/series/new"
show_header_search: true
)
|> maybe_update_series(params, true)}
end
Expand Down

0 comments on commit 9ca4387

Please sign in to comment.