diff --git a/app/models/task.rb b/app/models/task.rb index c22525029..e399fc72c 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -23,4 +23,6 @@ class Task < ApplicationRecord validates :name, presence: true validates :description, presence: true + + default_scope { order(created_at: :asc) } end diff --git a/app/views/organizations/pets/tasks/_tasks.html.erb b/app/views/organizations/pets/tasks/_tasks.html.erb index 21679f82c..aac2df8db 100644 --- a/app/views/organizations/pets/tasks/_tasks.html.erb +++ b/app/views/organizations/pets/tasks/_tasks.html.erb @@ -14,15 +14,18 @@
  • -
    - <%= task.name %> -

    <%= task.description %>

    + +
    + <%= render '/organizations/pets/tasks/tasks_toggle', task: task %> +
    + <%= task.name %> +

    <%= task.description %>

    +
    - <%= task.completed %> <%= link_to 'Edit', edit_pet_task_path(@pet, task), class: 'btn btn-warning m-2' %> <%= link_to 'Delete', pet_task_path(@pet, task), class: 'btn btn-danger m-2', data: { turbo_method: "delete", turbo_confirm: 'Are you sure?' } %>
    diff --git a/app/views/organizations/pets/tasks/_tasks_toggle.html.erb b/app/views/organizations/pets/tasks/_tasks_toggle.html.erb new file mode 100644 index 000000000..8c007c6c4 --- /dev/null +++ b/app/views/organizations/pets/tasks/_tasks_toggle.html.erb @@ -0,0 +1,11 @@ +
    > + <%= form_for [@pet, task] do |form| %> +
    +
    + <%= form.check_box :completed, + { class: "form-check-input", + onclick: "this.form.requestSubmit()"} %> +
    +
    + <% end %> +
    \ No newline at end of file