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 rubocop:disable Rails/OutputSafety.
-
#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
rubocop:enable Rails/OutputSafety.
- #yes_no(bool) ⇒ Object
- #yes_no_if_set(bool) ⇒ Object
Instance Method Details
#back_link_to(text, path) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'app/helpers/renalware/application_helper.rb', line 50 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
93 94 95 |
# File 'app/helpers/renalware/application_helper.rb', line 93 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
73 74 75 |
# File 'app/helpers/renalware/application_helper.rb', line 73 def default_for_associated(assoc, method, msg) assoc.present? ? assoc.public_send(method) : msg end |
#default_for_blank(val, msg) ⇒ Object
77 78 79 |
# File 'app/helpers/renalware/application_helper.rb', line 77 def default_for_blank(val, msg) val.presence || msg end |
#default_for_blank_date(date, msg) ⇒ Object
81 82 83 |
# File 'app/helpers/renalware/application_helper.rb', line 81 def default_for_blank_date(date, msg) date.blank? ? msg : l(date) end |
#default_for_blank_units(val, unit, msg) ⇒ Object
85 86 87 |
# File 'app/helpers/renalware/application_helper.rb', line 85 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
59 60 61 |
# File 'app/helpers/renalware/application_helper.rb', line 59 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
102 103 104 |
# File 'app/helpers/renalware/application_helper.rb', line 102 def inline_image(file_path) InlineImage.new(asset_path(file_path)) end |
#inline_image_tag(file_path, options = {}) ⇒ Object
97 98 99 100 |
# File 'app/helpers/renalware/application_helper.rb', line 97 def inline_image_tag(file_path, = {}) image = inline_image(file_path) image_tag(image.src, ) end |
#modality_description_for(modality) ⇒ Object
106 107 108 109 110 111 112 |
# File 'app/helpers/renalware/application_helper.rb', line 106 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 rubocop:disable Rails/OutputSafety
41 42 43 |
# File 'app/helpers/renalware/application_helper.rb', line 41 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
89 90 91 |
# File 'app/helpers/renalware/application_helper.rb', line 89 def pipe_separator " | ".html_safe end |
#semantic_app_version ⇒ Object
114 115 116 |
# File 'app/helpers/renalware/application_helper.rb', line 114 def semantic_app_version "#{Renalware::VERSION}+sha.#{GitCommitSha.current}" end |
#t?(key) ⇒ Boolean
rubocop:enable Rails/OutputSafety
46 47 48 |
# File 'app/helpers/renalware/application_helper.rb', line 46 def t?(key) t(key, cascade: false, raise: false, default: "").present? end |
#yes_no(bool) ⇒ Object
63 64 65 |
# File 'app/helpers/renalware/application_helper.rb', line 63 def yes_no(bool) bool ? "Yes" : "No" end |
#yes_no_if_set(bool) ⇒ Object
67 68 69 70 71 |
# File 'app/helpers/renalware/application_helper.rb', line 67 def yes_no_if_set(bool) return if bool.nil? yes_no(bool) end |