Update the Book form to add remove buttons for ids and author roles.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -54,8 +54,8 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
|||||||
<table class="w-full">
|
<table class="w-full">
|
||||||
<thead class="border-b border-zinc-100">
|
<thead class="border-b border-zinc-100">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-left font-medium text-sm pb-1 px-3">Type</th>
|
<th class="text-left font-medium text-sm pb-1 px-3 w-24">Type</th>
|
||||||
<th class="text-left font-medium text-sm pb-1 px-3" colspan="2">Id</th>
|
<th class="text-left font-medium text-sm pb-1 px-3">Id</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody phx-hook="bidSort" id="bidSort" phx-target={@myself}>
|
<tbody phx-hook="bidSort" id="bidSort" phx-target={@myself}>
|
||||||
@@ -69,20 +69,31 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
|||||||
<label for={bid_form[:bid].id} class="hidden">Id</label>
|
<label for={bid_form[:bid].id} class="hidden">Id</label>
|
||||||
<.input field={bid_form[:bid]} />
|
<.input field={bid_form[:bid]} />
|
||||||
</td>
|
</td>
|
||||||
|
<td class="w-12">
|
||||||
|
<.button_link
|
||||||
|
phx-click="remove-bid"
|
||||||
|
phx-value-path={bid_form.name}
|
||||||
|
phx-target={@myself}
|
||||||
|
kind="error"
|
||||||
|
size="xs"
|
||||||
|
inverse
|
||||||
|
>
|
||||||
|
<.icon name="hero-trash" class="size-5" />
|
||||||
|
</.button_link>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</.inputs_for>
|
</.inputs_for>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<.button_link phx-click="add-bid" phx-target={@myself} kind="primary" size="sm" inverse>
|
<.button_link phx-click="add-bid" phx-target={@myself} kind="primary" size="sm" inverse>
|
||||||
Add Book Id.
|
Add Book Id
|
||||||
</.button_link>
|
</.button_link>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_event("add-bid", params, socket) do
|
def handle_event("add-bid", params, socket) do
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
update(socket, :form, fn form ->
|
update(socket, :form, fn form ->
|
||||||
AshPhoenix.Form.add_form(form, :bids)
|
AshPhoenix.Form.add_form(form, :bids)
|
||||||
@@ -118,7 +129,7 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
|||||||
<table class="w-full">
|
<table class="w-full">
|
||||||
<thead class="border-b border-zinc-100">
|
<thead class="border-b border-zinc-100">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-left font-medium text-sm pb-1 px-3">Author</th>
|
<th class="text-left font-medium text-sm pb-1 px-3 w-80">Author</th>
|
||||||
<th class="text-left font-medium text-sm pb-1 px-3">Role</th>
|
<th class="text-left font-medium text-sm pb-1 px-3">Role</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -129,11 +140,22 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
|||||||
<label for={author_roles_form[:author_id].id} class="hidden">Type</label>
|
<label for={author_roles_form[:author_id].id} class="hidden">Type</label>
|
||||||
<.input field={author_roles_form[:author_id]} />
|
<.input field={author_roles_form[:author_id]} />
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="px-3">
|
<td class="px-3">
|
||||||
<label for={author_roles_form[:role].id} class="hidden">Id</label>
|
<label for={author_roles_form[:role].id} class="hidden">Id</label>
|
||||||
<.input field={author_roles_form[:role]} />
|
<.input field={author_roles_form[:role]} />
|
||||||
</td>
|
</td>
|
||||||
|
<td class="w-12">
|
||||||
|
<.button_link
|
||||||
|
phx-click="remove-author-role"
|
||||||
|
phx-value-path={author_roles_form.name}
|
||||||
|
phx-target={@myself}
|
||||||
|
kind="error"
|
||||||
|
size="xs"
|
||||||
|
inverse
|
||||||
|
>
|
||||||
|
<.icon name="hero-trash" class="size-5" />
|
||||||
|
</.button_link>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</.inputs_for>
|
</.inputs_for>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user