Sha256: 37abc5e34fe5ee8562e5087cb3f9faac7d410fc0cd2524c6a21fd6e2651e88e6
Contents?: true
Size: 1.46 KB
Versions: 25
Compression:
Stored size: 1.46 KB
Contents
module Effective module EffectiveDatatable module Dsl module BulkActions def bulk_action(*args) datatable._bulk_actions.push(content_tag(:li, link_to_bulk_action(*args))) end def bulk_download(*args) datatable._bulk_actions.push(content_tag(:li, link_to_bulk_action(*args), 'data-authenticity-token' => form_authenticity_token)) end def bulk_action_divider datatable._bulk_actions.push(content_tag(:li, '', class: 'divider', role: 'separator')) end def bulk_action_content(&block) datatable._bulk_actions.push(block.call) end private # We can't let any data-method be applied to the link, or jquery_ujs does the wrong thing with it def link_to_bulk_action(*args) args.map! do |arg| if arg.kind_of?(Hash) data_method = ( arg.delete(:'data-method') || arg.delete('data-method') || (arg[:data] || {}).delete('method') || (arg[:data] || {}).delete(:method) ) # But if the data-method was :get, we add bulk-actions-get-link = true if data_method.to_s == 'get' arg[:data].present? ? arg[:data]['bulk-actions-get'] = true : arg['data-bulk-actions-get'] = true end end arg end link_to(*args) end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems