Module: NotesHelper
- Defined in:
- app/helpers/notes_helper.rb
Instance Method Summary collapse
- #add_note_link(object: nil, attribute: nil) ⇒ Object
- #destroy_note_link(note) ⇒ Object
- #edit_note_link(note) ⇒ Object
- #link_to_add_note(link_text, f) ⇒ Object
- #link_to_destroy_note(link_text, note) ⇒ Object
- #link_to_edit_note(link_text, note) ⇒ Object
- #note_autocomplete_tag(note, term) ⇒ Object
- #note_link(note) ⇒ Object
-
#note_list_tag(object) ⇒ String
With html.
- #note_tag(note) ⇒ Object (also: #note_annotation_tag)
-
#notes_recent_objects_partial ⇒ True
Indicates a custom partial should be used, see list_helper.rb.
- #notes_search_form ⇒ Object
Instance Method Details
#add_note_link(object: nil, attribute: nil) ⇒ Object
49 50 51 52 53 54 |
# File 'app/helpers/notes_helper.rb', line 49 def add_note_link(object: nil, attribute: nil) link_to('Add note', new_note_path(note: { note_object_type: object.class.base_class.name, note_object_id: object.id, note_object_attribute: attribute})) if object.has_notes? end |
#destroy_note_link(note) ⇒ Object
61 62 63 |
# File 'app/helpers/notes_helper.rb', line 61 def destroy_note_link(note) destroy_object_link(note) end |
#edit_note_link(note) ⇒ Object
56 57 58 59 |
# File 'app/helpers/notes_helper.rb', line 56 def edit_note_link(note) edit_object_link(note) # link_to('Edit', edit_note_path(note)) end |
#link_to_add_note(link_text, f) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/notes_helper.rb', line 38 def link_to_add_note(link_text, f) new_object = f.object.class.reflect_on_association(:notes).klass.new( {note_object_type: f.object.class.base_class.name, note_object_id: f.object.id, note_object_attribute: 'name'}) fields = f.fields_for(:notes, new_object, child_index: 'new_notes') do |builder| render('notes/note_fields', avf: builder) end link_to(link_text, '', class: 'note-add', association: 'notes', content: "#{fields}") end |
#link_to_destroy_note(link_text, note) ⇒ Object
30 31 32 |
# File 'app/helpers/notes_helper.rb', line 30 def link_to_destroy_note(link_text, note) link_to(link_text, '', class: 'note-destroy', note_id: note.id) end |
#link_to_edit_note(link_text, note) ⇒ Object
34 35 36 |
# File 'app/helpers/notes_helper.rb', line 34 def link_to_edit_note(link_text, note) link_to(link_text, '', class: 'note-edit', note_id: note.id) end |
#note_autocomplete_tag(note, term) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/helpers/notes_helper.rb', line 21 def note_autocomplete_tag(note, term) return nil if note.nil? a = [ content_tag(:span, mark_tag(note.text, term), class: [:subtitle_type]), content_tag(:div, object_tag(note.note_object), class: [:feedback, 'feedback-secondary', 'feedback-thin'] ), content_tag(:span, note.note_object_type, class: [:feedback, 'feedback-info', 'feedback-thin'] ), ].compact.join(' ').html_safe end |
#note_link(note) ⇒ Object
65 66 67 68 |
# File 'app/helpers/notes_helper.rb', line 65 def note_link(note) return nil if note.nil? link_to(note_tag(note).html_safe, (note.note_object) ) end |
#note_list_tag(object) ⇒ String
Returns with html.
13 14 15 16 17 18 19 |
# File 'app/helpers/notes_helper.rb', line 13 def note_list_tag(object) return nil unless object.has_notes? && object.notes.any? content_tag(:h3, 'Notes') + content_tag(:ul, class: 'annotations__note_list') do object.notes.collect{|a| content_tag(:li, note_annotation_tag(a)) }.join.html_safe end end |
#note_tag(note) ⇒ Object Also known as: note_annotation_tag
3 4 5 6 7 8 9 |
# File 'app/helpers/notes_helper.rb', line 3 def note_tag(note) return nil if note.nil? # Note that markdown standard includes a p. It is upto the style class # to remove/hide this class, do NOT replace it here or post-process it (for the time being). content_tag(:div, MARKDOWN_HTML.render(note.text).html_safe, class: [:annotation__note]) end |
#notes_recent_objects_partial ⇒ True
Returns indicates a custom partial should be used, see list_helper.rb.
76 77 78 |
# File 'app/helpers/notes_helper.rb', line 76 def notes_recent_objects_partial true end |
#notes_search_form ⇒ Object
70 71 72 |
# File 'app/helpers/notes_helper.rb', line 70 def notes_search_form render('/notes/quick_search_form') end |