Module: DocumentationHelper

Defined in:
app/helpers/documentation_helper.rb

Instance Method Summary collapse

Instance Method Details

#document_viewer_buttons(object) ⇒ Object



43
44
45
# File 'app/helpers/documentation_helper.rb', line 43

def document_viewer_buttons(object)
  object.documentation.where('documentation.project_id = ?', sessions_current_project_id).collect{ |o| document_viewer_button(o.document)}.join(" | ")&.html_safe
end

#document_viewer_target(object) ⇒ Object



16
17
18
# File 'app/helpers/documentation_helper.rb', line 16

def document_viewer_target(object)
  viewer_documents(object).first
end

#documentation_download(documentation) ⇒ Object



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

def documentation_download(documentation)
  return nil if documentation.nil?
  link_to(
    '',
    documentation.document.document_file.url(),
    class: ['circle-button', 'btn-download'],
    download: documentation.document.document_file_file_name,
    title: documentation.document.document_file_file_name) 
end


20
21
22
23
24
25
26
27
# File 'app/helpers/documentation_helper.rb', line 20

def documentation_download_link(documentation)
  return nil if documentation.nil?
  link_to(
    document_type_label(documentation.document),
    documentation.document.document_file.url(),
    title: documentation.document.document_file_file_name,
    data: {icon: :download} ) 
end


11
12
13
14
# File 'app/helpers/documentation_helper.rb', line 11

def documentation_link(documentation)
  return nil if documentation.nil?
  link_to(documentation_tag(documentation), documentation).html_safe
end


39
40
41
# File 'app/helpers/documentation_helper.rb', line 39

def documentation_links(object)
  object.documentation.where('documentation.project_id = ?', sessions_current_project_id).collect{ |o| documentation_download_link(o)}.join(" | ")&.html_safe
end

#documentation_tag(documentation) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/documentation_helper.rb', line 3

def documentation_tag(documentation)
  return nil if documentation.nil?
  string = [
    documentation.documentation_object_type, ': ',
    object_tag(documentation.documentation_object)].join.html_safe
  string
end