From 11d768a5715ee86af9cd0db6f773a38efb8ce114 Mon Sep 17 00:00:00 2001 From: Andrew Njoo Date: Thu, 24 Oct 2024 06:07:14 -0600 Subject: [PATCH] helper --- app/helpers/notes_helper.rb | 4 +++ app/views/notes/_note.html.erb | 46 +++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 8078f73..00521be 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -1,2 +1,6 @@ +# app/helpers/notes_helper.rb module NotesHelper + def format_with_newlines(text) + raw(text.gsub(/\n/, "
")) + end end diff --git a/app/views/notes/_note.html.erb b/app/views/notes/_note.html.erb index 20e0e0c..50d41c7 100644 --- a/app/views/notes/_note.html.erb +++ b/app/views/notes/_note.html.erb @@ -1,51 +1,57 @@ -
  • +
  • - + <%= note.title %> -

    - <%= note.content %> +

    + <%= format_with_newlines(note.content) %>

    + + + <% if note.deadline.present? %> +

    + Deadline: <%= note.deadline.strftime("%B %d, %Y") %> +

    + <% end %> -
    +
    <%= form_with url: toggle_completion_note_path(note), method: :patch, local: true do |f| %> - <%= f.check_box :completed, checked: note.completed, onchange: 'this.form.submit();' %> - + <%= f.check_box :completed, checked: note.completed, class: "mr-2", onchange: 'this.form.submit();' %> + <% end %> - - - <%= link_to 'Delete', archive_note_path(note), class: 'text-red-600 underline hover:text-red-800', data: { turbo_method: :patch, turbo_confirm: 'Are you sure?' } %> + + <%= link_to 'Delete', archive_note_path(note), class: 'text-red-700 underline hover:text-red-900 uppercase', data: { turbo_method: :patch, turbo_confirm: 'Are you sure?' } %>