fixed errors found by tests; fixed tests

This commit is contained in:
Adam Piontek 2021-03-04 23:15:20 -05:00
parent 42c7a49e88
commit 6c5d6ce046
5 changed files with 93 additions and 37 deletions
lib/bones73k_web/live/property_live

View file

@ -1,4 +1,5 @@
<%= form_for @changeset, "#", [
id: "property-form",
phx_target: @myself,
phx_change: "validate",
phx_submit: "save"

View file

@ -17,18 +17,29 @@ defmodule Bones73kWeb.PropertyLive.Show do
property = Properties.get_property!(id)
if Roles.can?(current_user, property, live_action) do
{:noreply,
socket
|> assign(:property, property)
|> assign(:page_title, page_title(live_action))}
socket
|> assign(:property, property)
|> assign(:page_title, page_title(live_action))
|> assign(:modal_return_to, Routes.property_show_path(socket, :show, property))
|> live_noreply()
else
{:noreply,
socket
|> put_flash(:error, "Unauthorised")
|> redirect(to: "/")}
socket
|> put_flash(:error, "Unauthorised")
|> redirect(to: "/")
|> live_noreply()
end
end
@impl true
def handle_info({:close_modal, _}, %{assigns: %{modal_return_to: to}} = socket) do
socket |> copy_flash() |> push_patch(to: to) |> live_noreply()
end
@impl true
def handle_info({:put_flash_message, {flash_type, msg}}, socket) do
socket |> put_flash(flash_type, msg) |> live_noreply()
end
defp page_title(:show), do: "Show Property"
defp page_title(:edit), do: "Edit Property"
end

View file

@ -5,8 +5,7 @@
id: @property.id,
title: @page_title,
action: @live_action,
property: @property,
return_to: Routes.property_show_path(@socket, :show, @property) %>
property: @property %>
<% end %>
<table class="table table-nonfluid">