Module: NotesHelper

Defined in:
app/helpers/notes_helper.rb

Instance Method Summary collapse

Instance Method Details



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


61
62
63
# File 'app/helpers/notes_helper.rb', line 61

def destroy_note_link(note)
  destroy_object_link(note)
end


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


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


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


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 = [
    (:span, mark_tag(note.text, term), class: [:subtitle_type]),
    (:div, object_tag(note.note_object), class: [:feedback, 'feedback-secondary', 'feedback-thin'] ),
    (:span, note.note_object_type, class: [:feedback, 'feedback-info', 'feedback-thin'] ),
  ].compact.join(' ').html_safe
end


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, metamorphosize_if(note.note_object)  )
end

#note_list_tag(object) ⇒ String

Returns with html.

Returns:

  • (String)

    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?
  (:h3, 'Notes') +
    (:ul, class: 'annotations__note_list') do
      object.notes.collect{|a| (: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).
  (:div, MARKDOWN_HTML.render(note.text).html_safe, class: [:annotation__note])
end

#notes_recent_objects_partialTrue

Returns indicates a custom partial should be used, see list_helper.rb.

Returns:

  • (True)

    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_formObject



70
71
72
# File 'app/helpers/notes_helper.rb', line 70

def notes_search_form
  render('/notes/quick_search_form')
end