Module: ApplicationHelper

Includes:
WithStudentPathNavigation
Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Methods included from WithStudentPathNavigation

#close_modal_button, #next_button, #next_exercise_button, #next_lesson_button

Instance Method Details

#avatar_image(avatar_url, **options) ⇒ Object



14
15
16
17
# File 'app/helpers/application_helper.rb', line 14

def avatar_image(avatar_url, **options)
  options.merge!(class: "rounded-circle #{options[:class]}")
  image_tag(image_url(avatar_url), options)
end

#btn_toggle(hidden_text, active_text, active, **options) ⇒ Object



43
44
45
46
47
48
# File 'app/helpers/application_helper.rb', line 43

def btn_toggle(hidden_text, active_text, active, **options)
  %Q{
    <button class="btn btn-complementary #{'d-none' if active} #{options[:class]}" onclick="#{options[:onclick]}">#{hidden_text}</button>
    <button class="btn btn-secondary #{'d-none' unless active} #{options[:class]}" onclick="#{options[:onclick]}">#{active_text}</button>
  }.html_safe
end

#chapter_finished(chapter) ⇒ Object



39
40
41
# File 'app/helpers/application_helper.rb', line 39

def chapter_finished(chapter)
  t :chapter_finished_html, chapter: link_to_path_element(chapter) if chapter
end

#corollary_box(with_corollary, trailing_boxes = false) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'app/helpers/application_helper.rb', line 29

def corollary_box(with_corollary, trailing_boxes = false)
  if with_corollary.corollary.present?
    %Q{
      <div class="#{last_box_class trailing_boxes}">
        <p>#{with_corollary.corollary_html}</p>
      </div>
    }.html_safe
  end
end

#current_time_zone_htmlObject



54
55
56
# File 'app/helpers/application_helper.rb', line 54

def current_time_zone_html
  %Q{(<span class="select-date-timezone">#{Organization.current.time_zone}</span>)}.html_safe
end

#html_rescape(html) ⇒ Object

html-escapes an string even if it is html-safe



5
6
7
# File 'app/helpers/application_helper.rb', line 5

def html_rescape(html)
  html_escape html.to_str
end

#last_box_class(trailing_boxes) ⇒ Object



25
26
27
# File 'app/helpers/application_helper.rb', line 25

def last_box_class(trailing_boxes)
  trailing_boxes ? '' : 'mu-last-box'
end

#notification_preview_for(notification) ⇒ Object



50
51
52
# File 'app/helpers/application_helper.rb', line 50

def notification_preview_for(notification)
  render "notifications/previews/#{notification.subject}", { notification: notification }
end

#paginate(object, options = {}) ⇒ Object



19
20
21
22
23
# File 'app/helpers/application_helper.rb', line 19

def paginate(object, options = {})
  unless limited_query?
    super(object, {theme: 'bootstrap-5', pagination_class: 'flex-wrap justify-content-center'}.merge(options))
  end
end

#profile_picture_for(user, **options) ⇒ Object



9
10
11
12
# File 'app/helpers/application_helper.rb', line 9

def profile_picture_for(user, **options)
  default_options = { height: 40, onError: "this.onerror = null; this.src = '#{image_url(user.placeholder_image_url)}'" }
  avatar_image(user.profile_picture, default_options.merge(options))
end