2 Commits

  1. 9
      CHANGELOG.md
  2. 12
      lib/mirage_web/live/link_live/index.ex
  3. 11
      lib/mirage_web/live/link_live/show.ex
  4. 12
      lib/mirage_web/live/note_live/show.ex
  5. 3
      lib/mirage_web/live/note_live/show.html.leex
  6. 2
      mix.exs

9
CHANGELOG.md

@ -5,6 +5,15 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.66.1](https://git.inhji.de/inhji/mirage/compare/v0.66.0...v0.66.1) (2021-03-09)
### Bug Fixes:
* deleting links
## [v0.66.0](https://git.inhji.de/inhji/mirage/compare/v0.65.0...v0.66.0) (2021-03-09)

12
lib/mirage_web/live/link_live/index.ex

@ -31,16 +31,4 @@ defmodule MirageWeb.LinkLive.Index do
|> assign(:page_title, "Listing Notes links")
|> assign(:link, nil)
end
@impl true
def handle_event("delete", %{"id" => id}, socket) do
link = Links.get_link!(id)
{:ok, _} = Links.delete_link(link)
{:noreply, assign(socket, :notes_links, list_links())}
end
defp list_links do
Links.list_links()
end
end

11
lib/mirage_web/live/link_live/show.ex

@ -23,4 +23,15 @@ defmodule MirageWeb.LinkLive.Show do
|> assign(:page_title, page_title(socket.assigns.live_action))
|> assign(:link, link)}
end
@impl true
def handle_event("delete", %{"id" => id}, socket) do
link = Links.get_link!(id)
{:ok, _} = Links.delete_link(link)
{:noreply, push_redirect(socket, to: "/links")}
end
defp list_links do
Links.list_links()
end
end

12
lib/mirage_web/live/note_live/show.ex

@ -35,18 +35,6 @@ defmodule MirageWeb.NoteLive.Show do
{:noreply, push_redirect(socket, to: Routes.note_index_path(socket, :index))}
end
def handle_event("delete_link", %{"link-id" => link_id}, socket) do
link = Links.get_link!(link_id)
{:ok, _} = Links.delete_link(link)
note =
socket.assigns.note.id
|> Notes.get_note!()
|> Notes.preload_note()
{:noreply, socket |> assign(%{note: note})}
end
@impl true
def handle_event("save_link", %{"link" => link}, socket) do
note_id = socket.assigns.note.id

3
lib/mirage_web/live/note_live/show.html.leex

@ -59,9 +59,6 @@
<span class="flex"><%= link.title || link.url %></span>
<span class="flex"><%= link.domain %></span>
<% end %>
<%= if @current_user do %>
<%= link "🗑️ DELETE", to: "#", phx_click: "delete_link", phx_value_link_id: link.id, data: [confirm: "Are you sure?"] %>
<% end %>
</div>
<% end %>
</section>

2
mix.exs

@ -1,7 +1,7 @@
defmodule Mirage.MixProject do
use Mix.Project
@version "0.66.0"
@version "0.66.1"
def project do
[

Loading…
Cancel
Save