Module: Utilities::PageHelper

Included in:
BaseEditingHelper, SearchHelper
Defined in:
app/helpers/utilities/page_helper.rb

Instance Method Summary collapse

Instance Method Details

#boolean_to_icon(valore) ⇒ Object

Parameters:

  • valore (TrueClass, FalseClass)


28
29
30
31
32
33
34
# File 'app/helpers/utilities/page_helper.rb', line 28

def boolean_to_icon(valore)
  if valore
    icon("check-lg", class: "text-success")
  else
    icon("x-lg", class: "text-danger")
  end
end

#error_messages_for(obj, field) ⇒ Object

Parameters:

  • obj (BaseModel)

    instance

  • field (Symbol)


45
46
47
48
49
50
# File 'app/helpers/utilities/page_helper.rb', line 45

def error_messages_for(obj, field)
  if obj.errors.include?(field)
    msg = obj.errors.full_messages_for(field).join(",")
    (:div, icon("x-circle-fill", msg), class: "invalid-feedback")
  end
end

#new_button(path, options = {}) ⇒ Object

Parameters:

  • path (String)
  • options (Hash) (defaults to: {})


38
39
40
41
# File 'app/helpers/utilities/page_helper.rb', line 38

def new_button(path, options = {})
  options.merge!({class: 'btn btn-success btn-sm'})
  link_to icon("plus-lg", I18n.t(:new)), path, options
end

#title_mod_g(base_class) ⇒ Object

Parameters:

  • base_class (BaseModel)


3
4
5
# File 'app/helpers/utilities/page_helper.rb', line 3

def title_mod_g(base_class)
  "#{t("edit")} #{base_class.model_name.human}"
end

#title_new_g(base_class) ⇒ Object

Parameters:

  • base_class (BaseModel)


8
9
10
# File 'app/helpers/utilities/page_helper.rb', line 8

def title_new_g(base_class)
  "#{t("new")} #{base_class.model_name.human}"
end