Module: BootstrapConcerns::ComponentsHelper

Defined in:
lib/bootstrap_concerns/components_helper.rb

Constant Summary collapse

SEARCH_COL_MARGIN =
"mb-3".freeze

Instance Method Summary collapse

Instance Method Details

#assign_iconObject



5
6
7
# File 'lib/bootstrap_concerns/components_helper.rb', line 5

def assign_icon
  icon("box-arrow-in-left", "Assign")
end

#boolean_false_iconObject



9
10
11
# File 'lib/bootstrap_concerns/components_helper.rb', line 9

def boolean_false_icon
  (:i, "", class: "bi bi-x-circle-fill")
end

#boolean_true_iconObject



13
14
15
# File 'lib/bootstrap_concerns/components_helper.rb', line 13

def boolean_true_icon
  (:i, "", class: "bi bi-check-circle-fill")
end

#bs_button_to(name = nil, options = nil, html_options = nil) ⇒ Object



17
18
19
# File 'lib/bootstrap_concerns/components_helper.rb', line 17

def bs_button_to(name = nil, options = nil, html_options = nil, &)
  bs_link_or_button_to(:button_to, name, options, html_options, &)
end


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bootstrap_concerns/components_helper.rb', line 21

def bs_link_or_button_to(method_name, name, options, html_options, &)
  normalized_html_options =
    if block_given?
      options ||= {}
    else
      html_options ||= {}
    end

  normalized_html_options.merge!(Option.options_with_button_class(normalized_html_options))

  public_send(
    method_name,
    name,
    options,
    html_options,
    &
  )
end


40
41
42
# File 'lib/bootstrap_concerns/components_helper.rb', line 40

def bs_link_to(name = nil, options = nil, html_options = nil, &)
  bs_link_or_button_to(:link_to, name, options, html_options, &)
end

#bs_search_colObject



44
45
46
# File 'lib/bootstrap_concerns/components_helper.rb', line 44

def bs_search_col(&)
  (:div, class: "col-12 col-sm #{SEARCH_COL_MARGIN}", &)
end

#bs_search_submit_colObject



48
49
50
51
52
53
54
# File 'lib/bootstrap_concerns/components_helper.rb', line 48

def bs_search_submit_col
  (:div, class: "col-auto #{SEARCH_COL_MARGIN}") do
    (:button, BootstrapConcerns::Option.options_with_button_class) do
      search_icon
    end
  end
end

#bs_tableObject



103
104
105
106
107
# File 'lib/bootstrap_concerns/components_helper.rb', line 103

def bs_table(&)
   :div, class: "table-responsive" do
    (:table, class: "table table-striped table-sm", &)
  end
end

#copy_iconObject



56
57
58
# File 'lib/bootstrap_concerns/components_helper.rb', line 56

def copy_icon
  icon("files", "Copy")
end

#delete_icon(text = "Delete") ⇒ Object



60
61
62
# File 'lib/bootstrap_concerns/components_helper.rb', line 60

def delete_icon(text = "Delete")
  icon("trash", text)
end

#download_iconObject



64
65
66
# File 'lib/bootstrap_concerns/components_helper.rb', line 64

def download_icon
  icon("download", "Download")
end

#edit_iconObject



68
69
70
# File 'lib/bootstrap_concerns/components_helper.rb', line 68

def edit_icon
  icon("pencil-square", "Edit")
end

#export_icon(label = "Export") ⇒ Object



72
73
74
# File 'lib/bootstrap_concerns/components_helper.rb', line 72

def export_icon(label = "Export")
  icon("filetype-xlsx", label)
end

#flash_alert_color(key) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/bootstrap_concerns/components_helper.rb', line 76

def flash_alert_color(key)
  case key.to_s
  when "notice"
    "success"
  when "alert"
    "danger"
  else
    key
  end
end

#icon(name, text) ⇒ Object



87
88
89
# File 'lib/bootstrap_concerns/components_helper.rb', line 87

def icon(name, text)
  ("i", "", class: "bi bi-#{name}") + (:span, text, class: "ms-1 d-none d-sm-inline")
end

#import_iconObject



91
92
93
# File 'lib/bootstrap_concerns/components_helper.rb', line 91

def import_icon
  icon("box-arrow-in-down", "Import")
end

#new_icon(label = "New") ⇒ Object



95
96
97
# File 'lib/bootstrap_concerns/components_helper.rb', line 95

def new_icon(label = "New")
  icon("file-earmark-plus", label)
end

#rename_iconObject



99
100
101
# File 'lib/bootstrap_concerns/components_helper.rb', line 99

def rename_icon
  icon("input-cursor-text", "Rename")
end

#search_iconObject



109
110
111
# File 'lib/bootstrap_concerns/components_helper.rb', line 109

def search_icon
  icon("search", "Search")
end