Module: NotesHelper

Defined in:
app/helpers/notes_helper.rb

Instance Method Summary (collapse)

Instance Method Details



38
39
40
41
42
43
# File 'app/helpers/notes_helper.rb', line 38

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


50
51
52
# File 'app/helpers/notes_helper.rb', line 50

def destroy_note_link(note)
  destroy_object_link(note)
end


45
46
47
48
# File 'app/helpers/notes_helper.rb', line 45

def edit_note_link(note)
  edit_object_link(note)
  # link_to('Edit', edit_note_path(note))
end


28
29
30
31
32
33
34
35
36
# File 'app/helpers/notes_helper.rb', line 28

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


20
21
22
# File 'app/helpers/notes_helper.rb', line 20

def link_to_destroy_note(link_text, note)
  link_to(link_text, '', class: 'note-destroy', note_id: note.id)
end


24
25
26
# File 'app/helpers/notes_helper.rb', line 24

def link_to_edit_note(link_text, note)
  link_to(link_text, '', class: 'note-edit', note_id: note.id)
end


55
56
57
58
# File 'app/helpers/notes_helper.rb', line 55

def note_link(note)
  return nil if note.nil?
  link_to(note_tag(note).html_safe, metamorphosize_if(note.note_object)  )
end

- (Object) note_list_tag(object)



12
13
14
15
16
17
18
# File 'app/helpers/notes_helper.rb', line 12

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

- (Object) note_tag(note) 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

- (Object) notes_recent_objects_partial

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



66
67
68
# File 'app/helpers/notes_helper.rb', line 66

def notes_recent_objects_partial
  true 
end

- (Object) notes_search_form



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

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