add actions as render block in tag card
This commit is contained in:
parent
332f92a02f
commit
11ddba79e3
@ -4,7 +4,6 @@ defmodule CanneryWeb.Components.TagCard do
|
||||
"""
|
||||
|
||||
use CanneryWeb, :component
|
||||
alias CanneryWeb.Endpoint
|
||||
|
||||
def tag_card(assigns) do
|
||||
~H"""
|
||||
@ -20,20 +19,7 @@ defmodule CanneryWeb.Components.TagCard do
|
||||
<%= @tag.name %>
|
||||
</h1>
|
||||
|
||||
<%= live_patch to: Routes.tag_index_path(Endpoint, :edit, @tag),
|
||||
class: "text-primary-500 link" do %>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-500 link",
|
||||
phx_click: "delete",
|
||||
phx_value_id: @tag.id,
|
||||
data: [
|
||||
confirm: dgettext("prompts", "Are you sure you want to delete %{name}?", name: @tag.name)
|
||||
] do %>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
@ -5,8 +5,8 @@ defmodule CanneryWeb.TagLive.Index do
|
||||
|
||||
use CanneryWeb, :live_view
|
||||
import CanneryWeb.Components.TagCard
|
||||
alias Cannery.Tags
|
||||
alias Cannery.Tags.Tag
|
||||
alias Cannery.{Tags, Tags.Tag}
|
||||
alias CanneryWeb.Endpoint
|
||||
|
||||
@impl true
|
||||
def mount(_params, session, socket) do
|
||||
|
@ -22,7 +22,22 @@
|
||||
<% end %>
|
||||
<div class="flex flex-row flex-wrap">
|
||||
<%= for tag <- @tags do %>
|
||||
<.tag_card tag={tag} />
|
||||
<.tag_card tag={tag}>
|
||||
<%= live_patch to: Routes.tag_index_path(Endpoint, :edit, tag),
|
||||
class: "text-primary-500 link" do %>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-500 link",
|
||||
phx_click: "delete",
|
||||
phx_value_id: tag.id,
|
||||
data: [
|
||||
confirm: dgettext("prompts", "Are you sure you want to delete %{name}?", name: tag.name)
|
||||
] do %>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.tag_card>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user