Module: Renalware::ApplicationHelper
- Defined in:
- app/helpers/renalware/application_helper.rb
Instance Method Summary collapse
- #back_link_to(text, path) ⇒ Object
- #blank_separator ⇒ Object
- #breadcrumb_for(title, url) ⇒ Object
- #default_for_associated(assoc, method, msg) ⇒ Object
- #default_for_blank(val, msg) ⇒ Object
- #default_for_blank_date(date, msg) ⇒ Object
- #default_for_blank_units(val, unit, msg) ⇒ Object
- #default_patient_link(patient) ⇒ Object
- #default_patient_link_with_nhs_number(patient) ⇒ Object
- #errors_css_class(model, attr) ⇒ Object
- #flash_messages ⇒ Object
- #inline_image(file_path) ⇒ Object
- #inline_image_tag(file_path, options = {}) ⇒ Object
- #modality_description_for(modality) ⇒ Object
-
#page_heading(title) ⇒ Object
For use in pages.
-
#page_title(separator = Renalware.config.page_title_spearator) ⇒ Object
For use in layouts.
- #patient_search ⇒ Object
- #pipe_separator ⇒ Object
- #semantic_app_version ⇒ Object
- #t?(key) ⇒ Boolean
- #yes_no(bool) ⇒ Object
- #yes_no_if_set(bool) ⇒ Object
Instance Method Details
#back_link_to(text, path) ⇒ Object
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> ".html_safe concat text end end end |
#blank_separator ⇒ Object
91 92 93 |
# File 'app/helpers/renalware/application_helper.rb', line 91 def blank_separator " ".html_safe end |
#breadcrumb_for(title, url) ⇒ Object
31 32 33 |
# File 'app/helpers/renalware/application_helper.rb', line 31 def (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 |
#default_patient_link(patient) ⇒ Object
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 |
#default_patient_link_with_nhs_number(patient) ⇒ Object
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_messages ⇒ Object
35 36 37 |
# File 'app/helpers/renalware/application_helper.rb', line 35 def 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, = {}) image = inline_image(file_path) image_tag(image.src, ) 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_search ⇒ Object
19 20 21 |
# File 'app/helpers/renalware/application_helper.rb', line 19 def patient_search ::Renalware::Patients::PatientSearch.call(params) end |
#pipe_separator ⇒ Object
87 88 89 |
# File 'app/helpers/renalware/application_helper.rb', line 87 def pipe_separator " | ".html_safe end |
#semantic_app_version ⇒ Object
112 113 114 |
# File 'app/helpers/renalware/application_helper.rb', line 112 def semantic_app_version "#{VERSION}+sha.#{GitCommitSha.current}" end |
#t?(key) ⇒ 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 |