Basic turbo todo list implementation

Based on:

https://webcrunch.com/posts/digging-into-turbo-with-ruby-on-rails-7
This commit is contained in:
2024-07-28 23:53:35 +02:00
parent 84e6e43812
commit ea5d597fc7
8 changed files with 72 additions and 66 deletions

View File

@@ -1,12 +1,13 @@
<div id="<%= dom_id todo %>">
<p class="my-5">
<strong class="block font-medium mb-1">Title:</strong>
<%= todo.title %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Status:</strong>
<%= todo.status %>
</p>
</div>
<li id="<%= "#{dom_id(todo)}" %>" class="py-3">
<%= turbo_frame_tag dom_id(todo) do %>
<div class="flex items-center justify-center">
<%= link_to todo.title, edit_todo_path(todo), class: "flex-1 #{"line-through opacity-50" if todo.complete?}" %>
<% if todo.complete? %>
<%= button_to "Mark incomplete", todo_path(todo, todo: { status: 'incomplete'}), method: :patch, class: "bg-gray-50 px-3 py-2 rounded inline-flex items-center justify-center text-gray-600" %>
<% else %>
<%= button_to "Mark complete", todo_path(todo, todo: { status: 'complete'}), method: :patch, class: "bg-green-50 px-3 py-2 rounded inline-flex items-center justify-center text-green-600" %>
<% end %>
<%= button_to "Delete", todo_path(todo), method: :delete, class: "bg-red-50 px-3 py-2 rounded inline-flex items-center justify-center text-red-600" %>
</div>
<% end %>
</li>