Module: Renalware::ApplicationHelper
- Includes:
- Pagy::Frontend
- 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
yes_no(bool) end.
- #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.
Instance Method Details
#back_link_to(text, path) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'app/helpers/renalware/application_helper.rb', line 52 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
95 96 97 |
# File 'app/helpers/renalware/application_helper.rb', line 95 def blank_separator " ".html_safe end |
#breadcrumb_for(title, url) ⇒ Object
33 34 35 |
# File 'app/helpers/renalware/application_helper.rb', line 33 def (title, url) Breadcrumb.new(title: title, anchor: link_to(title, url)) end |
#default_for_associated(assoc, method, msg) ⇒ Object
yes_no(bool) end
75 76 77 |
# File 'app/helpers/renalware/application_helper.rb', line 75 def default_for_associated(assoc, method, msg) assoc.present? ? assoc.public_send(method) : msg end |
#default_for_blank(val, msg) ⇒ Object
79 80 81 |
# File 'app/helpers/renalware/application_helper.rb', line 79 def default_for_blank(val, msg) val.presence || msg end |
#default_for_blank_date(date, msg) ⇒ Object
83 84 85 |
# File 'app/helpers/renalware/application_helper.rb', line 83 def default_for_blank_date(date, msg) date.blank? ? msg : l(date) end |
#default_for_blank_units(val, unit, msg) ⇒ Object
87 88 89 |
# File 'app/helpers/renalware/application_helper.rb', line 87 def default_for_blank_units(val, unit, msg) val.blank? ? msg : "#{val} #{unit}" end |
#default_patient_link(patient) ⇒ Object
13 14 15 |
# File 'app/helpers/renalware/application_helper.rb', line 13 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
17 18 19 |
# File 'app/helpers/renalware/application_helper.rb', line 17 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
61 62 63 |
# File 'app/helpers/renalware/application_helper.rb', line 61 def errors_css_class(model, attr) " field_with_errors" if model.errors.key?(attr) end |
#flash_messages ⇒ Object
37 38 39 |
# File 'app/helpers/renalware/application_helper.rb', line 37 def flash.to_hash.reject { |key| key.to_sym == :timedout } end |
#inline_image(file_path) ⇒ Object
104 105 106 |
# File 'app/helpers/renalware/application_helper.rb', line 104 def inline_image(file_path) InlineImage.new(asset_path(file_path)) end |
#inline_image_tag(file_path, options = {}) ⇒ Object
99 100 101 102 |
# File 'app/helpers/renalware/application_helper.rb', line 99 def inline_image_tag(file_path, = {}) image = inline_image(file_path) image_tag(image.src, ) end |
#modality_description_for(modality) ⇒ Object
108 109 110 111 112 113 114 |
# File 'app/helpers/renalware/application_helper.rb', line 108 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
43 44 45 |
# File 'app/helpers/renalware/application_helper.rb', line 43 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
26 27 28 29 30 31 |
# File 'app/helpers/renalware/application_helper.rb', line 26 def page_title(separator = Renalware.config.page_title_spearator) [ content_for(:page_title), Renalware.config.site_name ].compact.join(separator) end |
#patient_search ⇒ Object
21 22 23 |
# File 'app/helpers/renalware/application_helper.rb', line 21 def patient_search ::Renalware::Patients::PatientSearch.call(params) end |
#pipe_separator ⇒ Object
91 92 93 |
# File 'app/helpers/renalware/application_helper.rb', line 91 def pipe_separator " | ".html_safe end |
#semantic_app_version ⇒ Object
116 117 118 |
# File 'app/helpers/renalware/application_helper.rb', line 116 def semantic_app_version "#{Renalware::VersionNumber::VERSION}+sha.#{GitCommitSha.current}" end |
#t?(key) ⇒ Boolean
rubocop:enable Rails/OutputSafety
48 49 50 |
# File 'app/helpers/renalware/application_helper.rb', line 48 def t?(key) t(key, cascade: false, raise: false, default: "").present? end |