Module: RailsExecution::RenderingHelper
- Defined in:
- app/helpers/rails_execution/rendering_helper.rb
Instance Method Summary collapse
- #re_attachment_file_acceptable_types ⇒ Object
- #re_badge_color(status) ⇒ Object
- #re_card_content(id: nil, &block) ⇒ Object
- #re_get_file_name(url) ⇒ Object
- #re_page_actions(&block) ⇒ Object
- #re_render_paging(relation) ⇒ Object
- #render_notification_message(mode, message) ⇒ Object
- #render_owner_avatar(owner, size: '32x32') ⇒ Object
- #render_owner_name(owner) ⇒ Object
- #render_user_info(user, avatar_size: '40x40') ⇒ Object
- #task_reviewed_status(task) ⇒ Object
Instance Method Details
#re_attachment_file_acceptable_types ⇒ Object
65 66 67 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 65 def ::RailsExecution.configuration.acceptable_file_types.keys.join(',') end |
#re_badge_color(status) ⇒ Object
73 74 75 76 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 73 def re_badge_color(status) color = status_to_color(status.to_s.downcase.to_sym) content_tag :small, status.to_s.titleize, class: "fw-light badge rounded-pill text-bg-#{color}" end |
#re_card_content(id: nil, &block) ⇒ Object
55 56 57 58 59 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 55 def re_card_content(id: nil, &block) content_tag :div, id: id, class: 'my-3 p-3 bg-body rounded shadow-sm' do capture(&block) end end |
#re_get_file_name(url) ⇒ Object
69 70 71 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 69 def re_get_file_name(url) URI(url).path.split('/').last end |
#re_page_actions(&block) ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 47 def re_page_actions(&block) content_for :page_actions do content_tag :span, class: 'ms-2' do capture(&block) end end end |
#re_render_paging(relation) ⇒ Object
61 62 63 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 61 def re_render_paging(relation) render partial: 'rails_execution/shared/paging', locals: { page: relation.re_current_page, total_pages: relation.re_total_pages } end |
#render_notification_message(mode, message) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 27 def (mode, ) case mode when 'alert' content_tag :div, class: 'alert alert-warning align-items-center' do concat content_tag(:i, nil, class: 'bi bi-x-octagon mr-2') concat content_tag(:span, , class: 'ms-2') end when 'notice' content_tag :div, class: 'alert alert-success align-items-center' do concat content_tag(:i, nil, class: 'bi bi-check-circle mr-2') concat content_tag(:span, , class: 'ms-2') end end end |
#render_owner_avatar(owner, size: '32x32') ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 11 def render_owner_avatar(owner, size: '32x32') return nil if owner.blank? avatar_url = RailsExecution.configuration.owner_avatar.call(owner) return nil if avatar_url.blank? image_tag avatar_url, size: size, class: 'bd-placeholder-img flex-shrink-0 me-2 rounded' end |
#render_owner_name(owner) ⇒ Object
20 21 22 23 24 25 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 20 def render_owner_name(owner) return nil if owner.blank? return nil if RailsExecution.configuration.owner_name_method.blank? content_tag :span, owner.public_send(RailsExecution.configuration.owner_name_method) end |
#render_user_info(user, avatar_size: '40x40') ⇒ Object
4 5 6 7 8 9 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 4 def render_user_info(user, avatar_size: '40x40') content_tag :div, class: 'user-info' do concat render_owner_avatar(user, size: avatar_size) concat render_owner_name(user) end end |
#task_reviewed_status(task) ⇒ Object
42 43 44 45 |
# File 'app/helpers/rails_execution/rendering_helper.rb', line 42 def task_reviewed_status(task) @task_reviewed_status ||= {} @task_reviewed_status[task] ||= task.task_reviews.find_by(owner_id: current_owner&.id)&.status&.inquiry end |