Module: DocumentsHelper

Defined in:
app/helpers/documents_helper.rb

Instance Method Summary collapse

Instance Method Details

#document_download(document) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'app/helpers/documents_helper.rb', line 22

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


8
9
10
11
# File 'app/helpers/documents_helper.rb', line 8

def document_link(document)
  return nil if document.nil?
  link_to(document_tag(document).html_safe, document)
end

#document_tag(document) ⇒ Object



3
4
5
6
# File 'app/helpers/documents_helper.rb', line 3

def document_tag(document)
  return nil if document.nil?
  document.document_file_file_name
end

#document_type_label(document) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/documents_helper.rb', line 36

def document_type_label(document)
  case document.document_file_content_type
  when 'application/pdf'
    'pdf'
  when 'application/octet-stream'
    'binary (Word or other)'
  when 'text/plain'
    'text'
  when 'text/xml'
    'xml'
  end
end

#document_viewer_button(document) ⇒ Object



13
14
15
16
17
18
19
20
# File 'app/helpers/documents_helper.rb', line 13

def document_viewer_button (document)
  return nil if document.nil?
  (:a,
    '',
    class: ['button-circle', 'pdf-button', 'button-default'],
    title: document.document_file_file_name,
    data: { pdfviewer: document.document_file.url() })
end

#documents_search_formObject



32
33
34
# File 'app/helpers/documents_helper.rb', line 32

def documents_search_form
  render('/documents/quick_search_form')
end