Module: RailsExecution::RenderingHelper

Defined in:
app/helpers/rails_execution/rendering_helper.rb

Instance Method Summary collapse

Instance Method Details

#re_attachment_file_acceptable_typesObject



65
66
67
# File 'app/helpers/rails_execution/rendering_helper.rb', line 65

def re_attachment_file_acceptable_types
  ::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)
   :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)
   :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
     :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 render_notification_message(mode, message)
  case mode
  when 'alert'
     :div, class: 'alert alert-warning align-items-center' do
      concat (:i, nil, class: 'bi bi-x-octagon mr-2')
      concat (:span, message, class: 'ms-2')
    end
  when 'notice'
     :div, class: 'alert alert-success align-items-center' do
      concat (:i, nil, class: 'bi bi-check-circle mr-2')
      concat (:span, message, 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?

   :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 (user, avatar_size: '40x40')
   :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