update liveview

This commit is contained in:
2022-11-16 21:11:02 -05:00
parent 2ce94fd6d1
commit 1f438d0fe5
32 changed files with 362 additions and 273 deletions

View File

@ -33,7 +33,7 @@ defmodule MemexWeb.NoteLive.FormComponent do
{:noreply,
socket
|> put_flash(:info, "Note updated successfully")
|> push_redirect(to: socket.assigns.return_to)}
|> push_navigate(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, :changeset, changeset)}
@ -46,7 +46,7 @@ defmodule MemexWeb.NoteLive.FormComponent do
{:noreply,
socket
|> put_flash(:info, "Note created successfully")
|> push_redirect(to: socket.assigns.return_to)}
|> push_navigate(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, changeset: changeset)}

View File

@ -2,7 +2,7 @@
<h2><%= @title %></h2>
<.form
let={f}
:let={f}
for={@changeset}
id="note-form"
phx-target={@myself}

View File

@ -34,16 +34,24 @@
<td>
<span>
<%= live_redirect("Show", to: Routes.note_show_path(@socket, :show, note)) %>
<.link navigate={Routes.note_show_path(@socket, :show, note)}>
<%= dgettext("actions", "Show") %>
</.link>
</span>
<span><%= live_patch("Edit", to: Routes.note_index_path(@socket, :edit, note)) %></span>
<span>
<%= link("Delete",
to: "#",
phx_click: "delete",
phx_value_id: note.id,
data: [confirm: "Are you sure?"]
) %>
<.link patch={Routes.note_index_path(@socket, :edit, note)}>
<%= dgettext("actions", "Edit") %>
</.link>
</span>
<span>
<.link
href="#"
phx-click="delete"
phx-value-id={note.id}
data-confirm={dgettext("prompts", "Are you sure?")}
>
<%= dgettext("actions", "Delete") %>
</.link>
</span>
</td>
</tr>
@ -51,4 +59,8 @@
</tbody>
</table>
<span><%= live_patch("New Note", to: Routes.note_index_path(@socket, :new)) %></span>
<span>
<.link patch={Routes.note_index_path(@socket, :new)}>
<%= dgettext("actions", "New Note") %>
</.link>
</span>

View File

@ -36,6 +36,13 @@
</ul>
<span>
<%= live_patch("Edit", to: Routes.note_show_path(@socket, :edit, @note), class: "button") %>
<.link patch={Routes.note_show_path(@socket, :edit, @note)} class="button">
<%= dgettext("actions", "Edit") %>
</.link>
</span>
|
<span>
<.link patch={Routes.note_index_path(@socket, :index)}>
<%= dgettext("actions", "Back") %>
</.link>
</span>
| <span><%= live_redirect("Back", to: Routes.note_index_path(@socket, :index)) %></span>