Module: BootstrapConcerns::ComponentsHelper

Defined in:
lib/bootstrap_concerns/components_helper.rb

Instance Method Summary collapse

Instance Method Details

#assign_iconObject



3
4
5
# File 'lib/bootstrap_concerns/components_helper.rb', line 3

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

#boolean_false_iconObject



7
8
9
# File 'lib/bootstrap_concerns/components_helper.rb', line 7

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

#boolean_true_iconObject



11
12
13
# File 'lib/bootstrap_concerns/components_helper.rb', line 11

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

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



15
16
17
# File 'lib/bootstrap_concerns/components_helper.rb', line 15

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


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

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


38
39
40
# File 'lib/bootstrap_concerns/components_helper.rb', line 38

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

#copy_iconObject



42
43
44
# File 'lib/bootstrap_concerns/components_helper.rb', line 42

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

#delete_icon(text = "Delete") ⇒ Object



46
47
48
# File 'lib/bootstrap_concerns/components_helper.rb', line 46

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

#download_iconObject



50
51
52
# File 'lib/bootstrap_concerns/components_helper.rb', line 50

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

#edit_iconObject



54
55
56
# File 'lib/bootstrap_concerns/components_helper.rb', line 54

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

#export_icon(label = "Export") ⇒ Object



58
59
60
# File 'lib/bootstrap_concerns/components_helper.rb', line 58

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

#flash_alert_color(key) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/bootstrap_concerns/components_helper.rb', line 62

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

#icon(name, text) ⇒ Object



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

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

#import_iconObject



77
78
79
# File 'lib/bootstrap_concerns/components_helper.rb', line 77

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

#new_icon(label = "New") ⇒ Object



81
82
83
# File 'lib/bootstrap_concerns/components_helper.rb', line 81

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

#rename_iconObject



85
86
87
# File 'lib/bootstrap_concerns/components_helper.rb', line 85

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

#search_iconObject



89
90
91
# File 'lib/bootstrap_concerns/components_helper.rb', line 89

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