defmodule TasksComponent do
use PlannerWeb, :live_component
alias Planner.Tasks
alias Planner.Tasks.Task
def update(%{:changeset => changeset, :id => _id}, socket) do
{:ok, assign(socket, :changeset, changeset)}
end
def update(assigns, socket) do
socket =
socket
|> assign(assigns)
|> assign(:changeset, Tasks.change_task(%Task{}))
{:ok, socket}
end
def render(assigns) do
~L"""
<%= f = form_for(@changeset, "#", [phx_submit: "new-task"]) %>
"""
end
end
defmodule TaskDetailsComponent do
use PlannerWeb, :live_component
def render(assigns) do
~L"""
<%= live_patch("",
to: @route_index_tasks.(@socket),
class: "delete is-pulled-right"
) %>
<%= if(not is_nil(@task.due_at) or not is_nil(@task.finished_at) or length(@task.plans) == 0) do %>
<%= if(not is_nil(@task.due_at)) do %>
due: <%= @task.due_at %>
<% end %>
<%= if(not is_nil(@task.finished_at)) do %>
completed
<% end %>
<%= if(length(@task.plans) == 0) do %>
unfiled
<% end %>
"""
end
end
defmodule TaskEditComponent do
use PlannerWeb, :live_component
alias Planner.Tasks
def update(%{:changeset => changeset, :id => _id}, socket) do
{:ok, assign(socket, :changeset, changeset)}
end
def update(assigns, socket) do
socket =
socket
|> assign(assigns)
|> assign(:changeset, Tasks.change_task(assigns.task))
{:ok, socket}
end
def render(assigns) do
~L"""