update to liveview 0.18
This commit is contained in:
@ -2,7 +2,7 @@ defmodule LokalWeb.InitAssigns do
|
||||
@moduledoc """
|
||||
Ensures common `assigns` are applied to all LiveViews attaching this hook.
|
||||
"""
|
||||
import Phoenix.LiveView
|
||||
import Phoenix.Component
|
||||
alias Lokal.Accounts
|
||||
|
||||
def on_mount(:default, _params, %{"locale" => locale, "user_token" => user_token}, socket) do
|
||||
|
@ -3,7 +3,7 @@
|
||||
<%= @title %>
|
||||
</h2>
|
||||
<.form
|
||||
let={f}
|
||||
:let={f}
|
||||
for={@changeset}
|
||||
id="invite-form"
|
||||
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
|
||||
|
@ -8,15 +8,13 @@
|
||||
<%= gettext("No invites 😔") %>
|
||||
</h1>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Invite someone new!"),
|
||||
to: Routes.invite_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Invite someone new!") %>
|
||||
</.link>
|
||||
<% else %>
|
||||
<%= live_patch(dgettext("actions", "Create Invite"),
|
||||
to: Routes.invite_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Create Invite") %>
|
||||
</.link>
|
||||
<% end %>
|
||||
|
||||
<div class="w-full flex flex-row flex-wrap justify-center items-center">
|
||||
@ -33,25 +31,28 @@
|
||||
</button>
|
||||
</form>
|
||||
</:code_actions>
|
||||
<%= live_patch to: Routes.invite_index_path(Endpoint, :edit, invite),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit-#{invite.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.invite_index_path(Endpoint, :edit, invite)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"edit-#{invite.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete_invite",
|
||||
phx_value_id: invite.id,
|
||||
data: [
|
||||
confirm:
|
||||
dgettext("prompts", "Are you sure you want to delete the invite for %{invite_name}?",
|
||||
invite_name: invite.name
|
||||
),
|
||||
qa: "delete-#{invite.id}"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete_invite"
|
||||
phx-value-id={invite.id}
|
||||
data-confirm={
|
||||
dgettext("prompts", "Are you sure you want to delete the invite for %{invite_name}?",
|
||||
invite_name: invite.name
|
||||
)
|
||||
}
|
||||
data-qa={"delete-#{invite.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= if invite.disabled_at |> is_nil() do %>
|
||||
<a href="#" class="btn btn-primary" phx-click="disable_invite" phx-value-id={invite.id}>
|
||||
@ -92,20 +93,21 @@
|
||||
<div class="w-full flex flex-row flex-wrap justify-center items-center">
|
||||
<%= for admin <- @admins do %>
|
||||
<.user_card user={admin}>
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete_user",
|
||||
phx_value_id: admin.id,
|
||||
data: [
|
||||
confirm:
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{email}? This action is permanent!",
|
||||
email: admin.email
|
||||
)
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete_user"
|
||||
phx-value-id={admin.id}
|
||||
data-confirm={
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{email}? This action is permanent!",
|
||||
email: admin.email
|
||||
)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</.user_card>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -121,20 +123,21 @@
|
||||
<div class="w-full flex flex-row flex-wrap justify-center items-center">
|
||||
<%= for user <- @users do %>
|
||||
<.user_card user={user}>
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete_user",
|
||||
phx_value_id: user.id,
|
||||
data: [
|
||||
confirm:
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{email}? This action is permanent!",
|
||||
email: user.email
|
||||
)
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete_user"
|
||||
phx-value-id={user.id}
|
||||
data-confirm={
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{email}? This action is permanent!",
|
||||
email: user.email
|
||||
)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</.user_card>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -3,7 +3,7 @@ defmodule LokalWeb.LiveHelpers do
|
||||
Contains resuable methods for all liveviews
|
||||
"""
|
||||
|
||||
import Phoenix.LiveView.Helpers
|
||||
import Phoenix.Component
|
||||
alias Phoenix.LiveView.JS
|
||||
|
||||
@doc """
|
||||
@ -27,17 +27,17 @@ defmodule LokalWeb.LiveHelpers do
|
||||
"""
|
||||
def modal(assigns) do
|
||||
~H"""
|
||||
<%= live_patch to: @return_to,
|
||||
id: "modal-bg",
|
||||
class:
|
||||
"fade-in fixed z-10 left-0 top-0
|
||||
<.link
|
||||
id="modal-bg"
|
||||
patch={@return_to}
|
||||
class="fade-in fixed z-10 left-0 top-0
|
||||
w-full h-full overflow-hidden
|
||||
p-8 flex flex-col justify-center items-center cursor-auto",
|
||||
style: "background-color: rgba(0,0,0,0.4);",
|
||||
phx_remove: hide_modal()
|
||||
do %>
|
||||
p-8 flex flex-col justify-center items-center cursor-auto"
|
||||
style="background-color: rgba(0,0,0,0.4);"
|
||||
phx_remove={hide_modal()}
|
||||
>
|
||||
<span class="hidden"></span>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<div
|
||||
id="modal"
|
||||
@ -53,15 +53,16 @@ defmodule LokalWeb.LiveHelpers do
|
||||
flex flex-col justify-start items-center
|
||||
bg-white border-2 rounded-lg"
|
||||
>
|
||||
<%= live_patch to: @return_to,
|
||||
id: "close",
|
||||
class:
|
||||
"absolute top-8 right-10
|
||||
<.link
|
||||
id="close"
|
||||
href={@return_to}
|
||||
class="absolute top-8 right-10
|
||||
text-gray-500 hover:text-gray-800
|
||||
transition-all duration-500 ease-in-out",
|
||||
phx_remove: hide_modal() do %>
|
||||
transition-all duration-500 ease-in-out"
|
||||
phx_remove={hide_modal()}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-times"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<div class="overflow-x-hidden overflow-y-auto w-full p-8 flex flex-col space-y-4 justify-start items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
|
Reference in New Issue
Block a user