style: formatter seems to work now
This commit is contained in:
parent
70aeb019a5
commit
f34936b176
11 changed files with 117 additions and 116 deletions
|
|
@ -6,7 +6,7 @@ defmodule PutzplanWeb.TaskLive.FormComponent do
|
|||
~H"""
|
||||
<div>
|
||||
<.header>
|
||||
<%= @title %>
|
||||
{@title}
|
||||
<:subtitle>Use this form to manage task records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
|
|
@ -17,10 +17,12 @@ defmodule PutzplanWeb.TaskLive.FormComponent do
|
|||
phx-change="validate"
|
||||
phx-submit="save"
|
||||
>
|
||||
|
||||
<.input field={@form[:description]} type="text" label="Description" /><.input field={@form[:repetition_days]} type="number" label="Repetition days" />
|
||||
|
||||
|
||||
<.input field={@form[:description]} type="text" label="Description" /><.input
|
||||
field={@form[:repetition_days]}
|
||||
type="number"
|
||||
label="Repetition days"
|
||||
/>
|
||||
|
||||
<:actions>
|
||||
<.button phx-disable-with="Saving...">Save Task</.button>
|
||||
</:actions>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule PutzplanWeb.TaskLive.Index do
|
|||
Listing Tasks
|
||||
<:actions>
|
||||
<.link patch={~p"/tasks/new"}>
|
||||
<.button>New Task</.button>
|
||||
<.button>New Task</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
|
@ -18,21 +18,21 @@ defmodule PutzplanWeb.TaskLive.Index do
|
|||
rows={@streams.tasks}
|
||||
row_click={fn {_id, task} -> JS.navigate(~p"/tasks/#{task}") end}
|
||||
>
|
||||
<:col :let={{_id, task}} label="Description">{task.description}</:col>
|
||||
|
||||
<:col :let={{_id, task}} label="Description"><%= task.description %></:col>
|
||||
|
||||
<:col :let={{_id, task}} label="Due"><%= task.due %></:col>
|
||||
<:col :let={{_id, task}} label="Due">{task.due}</:col>
|
||||
|
||||
<:action :let={{_id, task}}>
|
||||
<div class="sr-only">
|
||||
<.link navigate={~p"/tasks/#{task}"}>Show</.link>
|
||||
</div>
|
||||
|
||||
<.link patch={~p"/tasks/#{task}/edit"}>Edit</.link>
|
||||
<.link phx-click={JS.push("complete", value: %{id: task.id})}>Complete</.link>
|
||||
|
||||
</:action>
|
||||
|
||||
<:action :let={{_id, task}}>
|
||||
<.link patch={~p"/tasks/#{task}/edit"}>Edit</.link>
|
||||
</:action>
|
||||
<:action :let={{_id, task}}>
|
||||
<.link phx-click={JS.push("complete", value: %{id: task.id})}>Complete</.link>
|
||||
</:action>
|
||||
<:action :let={{id, task}}>
|
||||
<.link
|
||||
phx-click={JS.push("delete", value: %{id: task.id}) |> hide("##{id}")}
|
||||
|
|
@ -41,19 +41,19 @@ defmodule PutzplanWeb.TaskLive.Index do
|
|||
Delete
|
||||
</.link>
|
||||
</:action>
|
||||
|
||||
</.table>
|
||||
<.modal :if={@live_action in [:new, :edit]} id="task-modal" show on_cancel={JS.patch(~p"/tasks")}>
|
||||
<.live_component
|
||||
module={PutzplanWeb.TaskLive.FormComponent}
|
||||
id={(@task && @task.id) || :new}
|
||||
title={@page_title}
|
||||
current_user={@current_user}
|
||||
action={@live_action}
|
||||
task={@task}
|
||||
patch={~p"/"}
|
||||
/>
|
||||
</.modal>
|
||||
|
||||
<.modal :if={@live_action in [:new, :edit]} id="task-modal" show on_cancel={JS.patch(~p"/tasks")}>
|
||||
<.live_component
|
||||
module={PutzplanWeb.TaskLive.FormComponent}
|
||||
id={(@task && @task.id) || :new}
|
||||
title={@page_title}
|
||||
current_user={@current_user}
|
||||
action={@live_action}
|
||||
task={@task}
|
||||
patch={~p"/"}
|
||||
/>
|
||||
</.modal>
|
||||
"""
|
||||
end
|
||||
|
||||
|
|
@ -76,7 +76,10 @@ defmodule PutzplanWeb.TaskLive.Index do
|
|||
defp apply_action(socket, :edit, %{"id" => id}) do
|
||||
socket
|
||||
|> assign(:page_title, "Edit Task")
|
||||
|> assign(:task, Ash.get!(Putzplan.Tasks.Task, id, actor: socket.assigns.current_user))
|
||||
|> assign(
|
||||
:task,
|
||||
Ash.get!(Putzplan.Tasks.Task, id, load: [:due], actor: socket.assigns.current_user)
|
||||
)
|
||||
end
|
||||
|
||||
defp apply_action(socket, :new, _params) do
|
||||
|
|
@ -109,7 +112,7 @@ defmodule PutzplanWeb.TaskLive.Index do
|
|||
Putzplan.Tasks.CompletedTask
|
||||
|> Ash.Changeset.for_create(:create, %{task: id, user: socket.assigns.current_user.id})
|
||||
|> Ash.create!(actor: socket.assigns.current_user)
|
||||
|
||||
|
||||
{:noreply, stream_insert(socket, :tasks, Ash.get!(Putzplan.Tasks.Task, id, load: [:due]))}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,26 +6,22 @@ defmodule PutzplanWeb.TaskLive.Show do
|
|||
def render(assigns) do
|
||||
~H"""
|
||||
<.header>
|
||||
Task <%= @task.description %>
|
||||
<:actions>
|
||||
<.link patch={~p"/tasks/#{@task}/show/edit"} phx-click={JS.push_focus()}>
|
||||
<.button>Edit task</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
|
||||
Task {@task.description}
|
||||
<:actions>
|
||||
<.link patch={~p"/tasks/#{@task}/show/edit"} phx-click={JS.push_focus()}>
|
||||
<.button>Edit task</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.table
|
||||
id="completed_tasks"
|
||||
rows={@streams.completed_tasks}
|
||||
>
|
||||
<:col :let={{_id, completed_task}} label="Completed by"><%= completed_task.users.name %></:col>
|
||||
<:col :let={{_id, completed_task}} label="Date"><%= completed_task.completion %></:col>
|
||||
<:action :let={{id, completed_task}}>
|
||||
<.link phx-click={JS.push("delete", value: %{id: completed_task.id}) |> hide("##{id}")}>
|
||||
Delete
|
||||
</.link>
|
||||
</:action>
|
||||
<.table id="completed_tasks" rows={@streams.completed_tasks}>
|
||||
<:col :let={{_id, completed_task}} label="Completed by">{completed_task.users.name}</:col>
|
||||
<:col :let={{_id, completed_task}} label="Date">{completed_task.completion}</:col>
|
||||
<:action :let={{id, completed_task}}>
|
||||
<.link phx-click={JS.push("delete", value: %{id: completed_task.id}) |> hide("##{id}")}>
|
||||
Delete
|
||||
</.link>
|
||||
</:action>
|
||||
</.table>
|
||||
|
||||
<.back navigate={~p"/"}>Back to tasks</.back>
|
||||
|
|
@ -58,7 +54,9 @@ defmodule PutzplanWeb.TaskLive.Show do
|
|||
|
||||
@impl true
|
||||
def handle_event("delete", %{"id" => id}, socket) do
|
||||
completed_task = Ash.get!(Putzplan.Tasks.CompletedTask, id, actor: socket.assigns.current_user)
|
||||
completed_task =
|
||||
Ash.get!(Putzplan.Tasks.CompletedTask, id, actor: socket.assigns.current_user)
|
||||
|
||||
Ash.destroy!(completed_task, actor: socket.assigns.current_user)
|
||||
|
||||
{:noreply, stream_delete(socket, :completed_tasks, completed_task)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue