This commit is contained in:
@@ -21,30 +21,20 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
||||
<%= if @form.source.type == :create do %>
|
||||
<.input field={@form[:name]} type="text" label="Name" />
|
||||
<.input field={@form[:avatar_url]} type="text" label="Cover image url" />
|
||||
<.input
|
||||
field={@form[:description]}
|
||||
type="textarea"
|
||||
label="Description"
|
||||
/>
|
||||
<.input
|
||||
field={@form[:author_alias_registry_id]}
|
||||
type="text"
|
||||
label="Author alias registry"
|
||||
/>
|
||||
<.input field={@form[:description]} type="textarea" label="Description" />
|
||||
<div>
|
||||
<.input field={@form[:author_alias_registry_id]} type="hidden" label="Author alias registry" />
|
||||
<.selected_author_alias author_alias_registry_form={@form[:author_alias_registry_id]} notify_component={@myself} />
|
||||
</div>
|
||||
<% end %>
|
||||
<%= if @form.source.type == :update do %>
|
||||
<.input field={@form[:name]} type="text" label="Name" />
|
||||
<.input field={@form[:avatar_url]} type="text" label="Cover image url" />
|
||||
<.input
|
||||
field={@form[:description]}
|
||||
type="textarea"
|
||||
label="Description"
|
||||
/>
|
||||
<.input
|
||||
field={@form[:author_alias_registry_id]}
|
||||
type="text"
|
||||
label="Author alias registry"
|
||||
/>
|
||||
<.input field={@form[:description]} type="textarea" label="Description" />
|
||||
<div>
|
||||
<.input field={@form[:author_alias_registry_id]} type="hidden" label="Author alias registry" />
|
||||
<.selected_author_alias author_alias_registry_form={@form[:author_alias_registry_id]} notify_component={@myself} />
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<:actions>
|
||||
@@ -56,6 +46,20 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
||||
</.cancel_button>
|
||||
</:actions>
|
||||
</.simple_form>
|
||||
|
||||
<.modal
|
||||
:if={@select_author_alias_open? == true}
|
||||
id="select-author-alias-modal"
|
||||
show
|
||||
on_cancel={JS.push("close-select-author-alias", target: @myself)}
|
||||
>
|
||||
<.live_component
|
||||
id="select-author-alias"
|
||||
module={SelectAuthorAlias}
|
||||
current_user={@current_user}
|
||||
notify_component={@myself}
|
||||
/>
|
||||
</.modal>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
@@ -65,6 +69,7 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(assigns)
|
||||
|> assign(:select_author_alias_open?, false)
|
||||
|> assign_form()}
|
||||
end
|
||||
|
||||
@@ -151,4 +156,35 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
||||
_ -> ~p"/authors"
|
||||
end
|
||||
end
|
||||
|
||||
def handle_event("select-author-alias", %{"author-alias" => author_alias_id}, socket) do
|
||||
IO.inspect("book_editions_registry_id")
|
||||
IO.inspect(author_alias_id)
|
||||
|
||||
socket =
|
||||
socket
|
||||
|> update(:form, fn form ->
|
||||
form
|
||||
|> AshPhoenix.Form.update_params(&Map.put(&1, "author_alias_registry_id", author_alias_id))
|
||||
end)
|
||||
|> assign(:select_author_alias_open?, false)
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
def handle_event("open-select-author-alias", _params, socket) do
|
||||
socket =
|
||||
socket
|
||||
|> assign(:select_author_alias_open?, true)
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
def handle_event("close-select-author-alias", _params, socket) do
|
||||
socket =
|
||||
socket
|
||||
|> assign(:select_author_alias_open?, false)
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user