Module: Lintity::ApplicationHelper

Defined in:
app/helpers/lintity/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#filters_select_optionsObject



10
11
12
13
14
15
# File 'app/helpers/lintity/application_helper.rb', line 10

def filters_select_options
  options_from_collection_for_select(
    [OpenStruct.new(id: 'eq', name: '='), OpenStruct.new(id: 'less', name: '<='),
     OpenStruct.new(id: 'more', name: '>=')], 'id', 'name'
  )
end

#numeric_filter_tag(filter_field, field_info) ⇒ Object



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

def numeric_filter_tag(filter_field, field_info)
  button_tag "#{field_info[:name]}<i class=\"bi bi-funnel-fill #{'text-success' if filter_field == field_info[:field]}\"></i>".html_safe,
             class: 'btn btn-link', data: { 'entity-list-field-param' => field_info[:field], 'action' => 'click->entity-list#numberic_filter' }
end

#render_entity_list_header(caption, button_path) ⇒ Object

Renders a header with a caption and an optional “New” button. caption - String displayed as the header title. button_path - URL for the button; if nil or blank, the button is omitted.



20
21
22
23
24
25
# File 'app/helpers/lintity/application_helper.rb', line 20

def render_entity_list_header(caption, button_path)
  (:div, class: 'entity-list-header d-flex justify-content-between align-items-center mb-3') do
    concat (:h2, caption, class: 'mb-0')
    concat link_to('New', button_path, class: 'btn btn-primary') if button_path.present?
  end
end

#render_entity_report_header(caption, button_path) ⇒ Object



27
28
29
30
31
32
# File 'app/helpers/lintity/application_helper.rb', line 27

def render_entity_report_header(caption, button_path)
  (:div, class: 'entity-list-header d-flex justify-content-between align-items-center mb-3') do
    concat (:h2, caption, class: 'mb-0')
    concat link_to('PDF', button_path, class: 'btn btn-primary') if button_path.present?
  end
end