From ca1c9c05d2dcfc37727e61fa487d3aeaae092acb Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sun, 27 Apr 2025 15:42:22 +0300 Subject: [PATCH] Update the add_button to add_button_link and remove the extra links. --- .../components/my_components.ex | 2 +- .../components/my_components/buttons.ex | 20 ++++++++++++++++--- .../live/author_live/show.ex | 8 +++----- .../live/book_live/form_component.ex | 9 ++++----- .../live/book_live/show.ex | 8 +++----- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lib/decentralised_book_index_web/components/my_components.ex b/lib/decentralised_book_index_web/components/my_components.ex index 8c71ffb..daafdb9 100644 --- a/lib/decentralised_book_index_web/components/my_components.ex +++ b/lib/decentralised_book_index_web/components/my_components.ex @@ -17,7 +17,7 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents do only: [ success_button: 1, primary_button: 1, - add_button: 1, + add_button_link: 1, save_button: 1, edit_button: 1, cancel_button: 1 diff --git a/lib/decentralised_book_index_web/components/my_components/buttons.ex b/lib/decentralised_book_index_web/components/my_components/buttons.ex index 4bd62f5..39aef08 100644 --- a/lib/decentralised_book_index_web/components/my_components/buttons.ex +++ b/lib/decentralised_book_index_web/components/my_components/buttons.ex @@ -69,7 +69,7 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.Buttons do slot :inner_block, required: true - def add_button(assigns) do + def add_button_link(assigns) do ~H""" <.link class={[ @@ -80,8 +80,22 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.Buttons do ]} {@rest} > -
- <.link patch={~p"/authors/#{@author}/new"}> - <.add_button> - Alias - - + <.add_button_link patch={~p"/authors/#{@author}/new"}> + Alias + <.link patch={~p"/authors/#{@author}/edit"}> <.edit_button> Edit diff --git a/lib/decentralised_book_index_web/live/book_live/form_component.ex b/lib/decentralised_book_index_web/live/book_live/form_component.ex index aa43722..4b81e3d 100644 --- a/lib/decentralised_book_index_web/live/book_live/form_component.ex +++ b/lib/decentralised_book_index_web/live/book_live/form_component.ex @@ -169,10 +169,9 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do - <.add_button phx-click="add-bid" phx-target={@myself} class="w-44"> + <.add_button_link phx-click="add-bid" phx-target={@myself} class="w-44"> Add Book Id - - + """ end @@ -260,9 +259,9 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do - <.add_button phx-click="add-author-role" phx-target={@myself} class="w-40"> + <.add_button_link phx-click="add-author-role" phx-target={@myself} class="w-40"> Add Author - + """ end diff --git a/lib/decentralised_book_index_web/live/book_live/show.ex b/lib/decentralised_book_index_web/live/book_live/show.ex index d618722..7e7fc27 100644 --- a/lib/decentralised_book_index_web/live/book_live/show.ex +++ b/lib/decentralised_book_index_web/live/book_live/show.ex @@ -16,11 +16,9 @@ defmodule DecentralisedBookIndexWeb.BookLive.Show do <:actions> <%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
- <.link patch={~p"/books/#{@book}/new"}> - <.add_button> - Edition - - + <.add_button_link patch={~p"/books/#{@book}/new"}> + Edition + <.link patch={~p"/books/#{@book}/edit"}> <.edit_button> Edit