IMP: better route funcs (#34)
This commit is contained in:
parent
3d70659861
commit
2cd2f38356
2 changed files with 11 additions and 9 deletions
|
@ -41,8 +41,9 @@ defmodule TasksComponent do
|
||||||
task: task,
|
task: task,
|
||||||
live_action: @live_action,
|
live_action: @live_action,
|
||||||
is_active: @active_task == task.id,
|
is_active: @active_task == task.id,
|
||||||
route_func_2: @route_func_2,
|
route_show_task: @route_show_task,
|
||||||
route_func_3: @route_func_3
|
route_edit_task: @route_edit_task,
|
||||||
|
route_index_tasks: @route_index_tasks
|
||||||
)%>
|
)%>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -77,8 +78,8 @@ defmodule TaskComponent do
|
||||||
TaskDetailsComponent,
|
TaskDetailsComponent,
|
||||||
id: "task_details:#{@task.id}",
|
id: "task_details:#{@task.id}",
|
||||||
task: @task,
|
task: @task,
|
||||||
route_func_2: @route_func_2,
|
route_index_tasks: @route_index_tasks,
|
||||||
route_func_3: @route_func_3
|
route_edit_task: @route_edit_task
|
||||||
)%>
|
)%>
|
||||||
<% :edit -> %>
|
<% :edit -> %>
|
||||||
<%= live_component(@socket,
|
<%= live_component(@socket,
|
||||||
|
@ -88,7 +89,7 @@ defmodule TaskComponent do
|
||||||
)%>
|
)%>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= live_patch(to: @route_func_3.(@socket, :show, @task.id),
|
<%= live_patch(to: @route_show_task.(@socket, @task.id),
|
||||||
style: "display: block;"
|
style: "display: block;"
|
||||||
) do %>
|
) do %>
|
||||||
<div class="value ">
|
<div class="value ">
|
||||||
|
@ -117,7 +118,7 @@ defmodule TaskDetailsComponent do
|
||||||
~L"""
|
~L"""
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<%= live_patch("",
|
<%= live_patch("",
|
||||||
to: @route_func_2.(@socket, :index),
|
to: @route_index_tasks.(@socket),
|
||||||
class: "delete is-pulled-right"
|
class: "delete is-pulled-right"
|
||||||
) %>
|
) %>
|
||||||
<%= if(not is_nil(@task.due_at) or is_nil(@task.filed_at)) do %>
|
<%= if(not is_nil(@task.due_at) or is_nil(@task.filed_at)) do %>
|
||||||
|
@ -145,7 +146,7 @@ defmodule TaskDetailsComponent do
|
||||||
|
|
||||||
<div class="buttons has-addons">
|
<div class="buttons has-addons">
|
||||||
<%= live_patch("edit",
|
<%= live_patch("edit",
|
||||||
to: @route_func_3.(@socket, :edit, @task.id),
|
to: @route_edit_task.(@socket, @task.id),
|
||||||
class: "button is-dark is-small"
|
class: "button is-dark is-small"
|
||||||
) %>
|
) %>
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -32,8 +32,9 @@ defmodule PlannerWeb.TasksLive do
|
||||||
live_action: @live_action,
|
live_action: @live_action,
|
||||||
tasks: @tasks,
|
tasks: @tasks,
|
||||||
active_task: @active_task,
|
active_task: @active_task,
|
||||||
route_func_2: &Routes.tasks_path/2,
|
route_show_task: &(Routes.tasks_path(&1, :show, &2)),
|
||||||
route_func_3: &Routes.tasks_path/3
|
route_edit_task: &(Routes.tasks_path(&1, :edit, &2)),
|
||||||
|
route_index_tasks: &(Routes.tasks_path(&1, :index))
|
||||||
)%>
|
)%>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue