mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
set default sources for image view page if none are available
This commit is contained in:
parent
880d27ac1e
commit
adc77429f6
2 changed files with 6 additions and 3 deletions
|
@ -81,6 +81,7 @@ defmodule PhilomenaWeb.ImageController do
|
|||
|
||||
image_changeset =
|
||||
image
|
||||
|> update_in([:sources], &sources_for_edit/1)
|
||||
|> Images.change_image()
|
||||
|
||||
watching = Images.subscribed?(image, conn.assigns.current_user)
|
||||
|
@ -109,7 +110,7 @@ defmodule PhilomenaWeb.ImageController do
|
|||
|
||||
def new(conn, _params) do
|
||||
changeset =
|
||||
%Image{sources: [%Source{}]}
|
||||
%Image{sources: sources_for_edit()}
|
||||
|> Images.change_image()
|
||||
|
||||
render(conn, "new.html", title: "New Image", changeset: changeset)
|
||||
|
@ -218,4 +219,8 @@ defmodule PhilomenaWeb.ImageController do
|
|||
|> assign(:source_change_count, source_changes)
|
||||
end
|
||||
end
|
||||
|
||||
defp sources_for_edit(), do: [%Source{}]
|
||||
defp sources_for_edit([]), do: sources_for_edit()
|
||||
defp source_for_edit(sources), do: sources
|
||||
end
|
||||
|
|
|
@ -43,8 +43,6 @@
|
|||
span.js-max-source-count> 10
|
||||
' source URLs. Leave any sources you don't want to use blank.
|
||||
|
||||
= inputs_for f, :sources, [as: "image[old_sources]"], fn fs ->
|
||||
= hidden_input fs, :source
|
||||
= inputs_for f, :sources, fn fs ->
|
||||
.field.js-image-source.field--inline.flex--no-wrap.flex--centered
|
||||
= text_input fs, :source, class: "input flex__grow js-source-url", placeholder: "Source URL"
|
||||
|
|
Loading…
Reference in a new issue