-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
export.rb
41 lines (35 loc) · 1.12 KB
/
export.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true
module RailsAdmin
module Config
module Actions
class Export < RailsAdmin::Config::Actions::Base
RailsAdmin::Config::Actions.register(self)
register_instance_option :collection do
true
end
register_instance_option :http_methods do
%i[get post]
end
register_instance_option :controller do
proc do
format = params[:json] && :json || params[:csv] && :csv || params[:xml] && :xml
if format
request.format = format
@schema = HashHelper.symbolize(params[:schema].slice(:except, :include, :methods, :only).permit!.to_h) if params[:schema] # to_json and to_xml expect symbols for keys AND values.
@objects = list_entries(@model_config, :export)
index
else
render @action.template_name
end
end
end
register_instance_option :bulkable? do
true
end
register_instance_option :link_icon do
'fas fa-file-export'
end
end
end
end
end