Sha256: 1534c78e6a665021c9bb2690ccd644df77c4b780764f33124853e31ab1a89ff7
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
module Olivander class Datatable < Effective::Datatable def link_col(field, path, path_args) dsl_tool.col(field) do |r| args = [].tap do |arr| if path_args.is_a? Array path_args.each do |arg| arr << r.send(arg) end else arr << r.send(path_args) end end link_to r.send(field), send(path, args) end end def self.auto_datatable(klazz, link_path: nil, only: []) collection do klazz.all end datatable do bulk_actions_col klazz.new.attributes.each do |att| key = att[0] next if only.size.positive? && !only.include?(key) sym = key.gsub('_id', '').to_sym visible = !['created', 'updated', 'created_at', 'updated_at', 'deleted_at', 'current_user', 'current_action'].include?(key) if link_path.present? && sym == :id link_col sym, link_path, :id elsif link_path.present? && sym == :name link_col sym, link_path, [:id, :name] else col sym, visible: visible end end actions_col end end end end
Version data entries
3 entries across 3 versions & 1 rubygems