Module: Renalware::ApplicationHelper

Defined in:
app/helpers/renalware/application_helper.rb

Instance Method Summary collapse

Instance Method Details



48
49
50
51
52
53
54
55
# File 'app/helpers/renalware/application_helper.rb', line 48

def back_link_to(text, path)
  capture do
    link_to(path) do
      concat "<i class='fa fa-arrow-left'></i>&nbsp;".html_safe
      concat text
    end
  end
end

#blank_separatorObject



91
92
93
# File 'app/helpers/renalware/application_helper.rb', line 91

def blank_separator
  "&nbsp;".html_safe
end


31
32
33
# File 'app/helpers/renalware/application_helper.rb', line 31

def breadcrumb_for(title, url)
  Breadcrumb.new(title: title, anchor: link_to(title, url))
end

#default_for_associated(assoc, method, msg) ⇒ Object



71
72
73
# File 'app/helpers/renalware/application_helper.rb', line 71

def default_for_associated(assoc, method, msg)
  assoc.present? ? assoc.public_send(method) : msg
end

#default_for_blank(val, msg) ⇒ Object



75
76
77
# File 'app/helpers/renalware/application_helper.rb', line 75

def default_for_blank(val, msg)
  val.presence || msg
end

#default_for_blank_date(date, msg) ⇒ Object



79
80
81
# File 'app/helpers/renalware/application_helper.rb', line 79

def default_for_blank_date(date, msg)
  date.blank? ? msg : l(date)
end

#default_for_blank_units(val, unit, msg) ⇒ Object



83
84
85
# File 'app/helpers/renalware/application_helper.rb', line 83

def default_for_blank_units(val, unit, msg)
  val.blank? ? msg : "#{val} #{unit}"
end


11
12
13
# File 'app/helpers/renalware/application_helper.rb', line 11

def default_patient_link(patient)
  link_to(patient.to_s(:default), patient_clinical_summary_path(patient))
end


15
16
17
# File 'app/helpers/renalware/application_helper.rb', line 15

def default_patient_link_with_nhs_number(patient)
  link_to(patient&.to_s(:long), patient_clinical_summary_path(patient))
end

#errors_css_class(model, attr) ⇒ Object



57
58
59
# File 'app/helpers/renalware/application_helper.rb', line 57

def errors_css_class(model, attr)
  " field_with_errors" if model.errors.key?(attr)
end

#flash_messagesObject



35
36
37
# File 'app/helpers/renalware/application_helper.rb', line 35

def flash_messages
  flash.to_hash.reject{ |key| key.to_sym == :timedout }
end

#inline_image(file_path) ⇒ Object



100
101
102
# File 'app/helpers/renalware/application_helper.rb', line 100

def inline_image(file_path)
  InlineImage.new(asset_path(file_path))
end

#inline_image_tag(file_path, options = {}) ⇒ Object



95
96
97
98
# File 'app/helpers/renalware/application_helper.rb', line 95

def inline_image_tag(file_path, options = {})
  image = inline_image(file_path)
  image_tag(image.src, options)
end

#modality_description_for(modality) ⇒ Object



104
105
106
107
108
109
110
# File 'app/helpers/renalware/application_helper.rb', line 104

def modality_description_for(modality)
  if modality.blank? || modality.new_record?
    I18n.t("renalware.modalities.none")
  else
    modality.description.name
  end
end

#page_heading(title) ⇒ Object

For use in pages



40
41
42
# File 'app/helpers/renalware/application_helper.rb', line 40

def page_heading(title)
  content_for(:page_title){ title.html_safe }
end

#page_title(separator = Renalware.config.page_title_spearator) ⇒ Object

For use in layouts



24
25
26
27
28
29
# File 'app/helpers/renalware/application_helper.rb', line 24

def page_title(separator = Renalware.config.page_title_spearator)
  [
    content_for(:page_title),
    Renalware.config.site_name
  ].compact.join(separator)
end

#patient_searchObject



19
20
21
# File 'app/helpers/renalware/application_helper.rb', line 19

def patient_search
  ::Renalware::Patients::PatientSearch.call(params)
end

#pipe_separatorObject



87
88
89
# File 'app/helpers/renalware/application_helper.rb', line 87

def pipe_separator
  "&nbsp;|&nbsp;".html_safe
end

#semantic_app_versionObject



112
113
114
# File 'app/helpers/renalware/application_helper.rb', line 112

def semantic_app_version
  "#{VERSION}+sha.#{GitCommitSha.current}"
end

#t?(key) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/helpers/renalware/application_helper.rb', line 44

def t?(key)
  t(key, cascade: false, raise: false, default: "").present?
end

#yes_no(bool) ⇒ Object



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

def yes_no(bool)
  bool ? "Yes" : "No"
end

#yes_no_if_set(bool) ⇒ Object



65
66
67
68
69
# File 'app/helpers/renalware/application_helper.rb', line 65

def yes_no_if_set(bool)
  return if bool.nil?

  yes_no(bool)
end