Module: Adminterface::Extensions::Views::TableActions

Defined in:
lib/adminterface/extensions/views/index_as_table.rb

Instance Method Summary collapse

Instance Method Details

#confirm?(options) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/adminterface/extensions/views/index_as_table.rb', line 39

def confirm?(options)
  options.dig(:data, :confirm).present?
end

#confirm_dialog_configObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/adminterface/extensions/views/index_as_table.rb', line 43

def confirm_dialog_config
  {
    buttons: {
      confirm: {
        text: I18n.t(:confirm, scope: "active_admin.confirm_dialog"),
        class: confirm_dialog_css_classes[:confirm]
      },
      cancel: {
        text: I18n.t(:cancel, scope: "active_admin.confirm_dialog"),
        class: confirm_dialog_css_classes[:cancel]
      }
    }
  }
end

#default_class_nameObject



28
29
30
# File 'lib/adminterface/extensions/views/index_as_table.rb', line 28

def default_class_name
  "#{super} #{index_as_table_css_classes.dig(:actions, :buttons, :group)}".squish
end

#item(*args) ⇒ Object



32
33
34
35
36
37
# File 'lib/adminterface/extensions/views/index_as_table.rb', line 32

def item(*args)
  options = args.extract_options!
  options[:class] = "#{options[:class]} #{index_as_table_css_classes.dig(:actions, :buttons, :item)}".squish
  options["data-aa-confirm-dialog"] = confirm_dialog_config.to_json if confirm?(options)
  text_node link_to(*args, options)
end