Class: Admin::BaseController
Instance Attribute Summary collapse
Instance Method Summary
collapse
#fv
Instance Attribute Details
Returns the value of attribute settings.
6
7
8
|
# File 'app/controllers/admin/base_controller.rb', line 6
def settings
@settings
end
|
Instance Method Details
93
94
95
96
97
98
|
# File 'app/controllers/admin/base_controller.rb', line 93
def batch
batch_action = batch_actions.detect{|a| a.name == params[:batch_action].to_sym }
count = collection.inject(0) { |c, item| apply_batch_action(item, batch_action, *params[:batch_params].presence) ? c + 1 : c }
flash[:success] = I18n.t('admin.batch_actions.status', count: count, action: batch_action.title)
redirect_to_back_or_root
end
|
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/admin/base_controller.rb', line 42
def create
create! do |success, failure|
success.html { redirect_to redirect_to_on_success }
success.js { render layout: false }
failure.js { render :new, layout: false }
unless respond_to_format?(:json)
success.json { head :no_content }
failure.json { render json: {errors: resource.errors}, status: :unprocessable_entity }
end
end
end
|
68
69
70
71
72
73
|
# File 'app/controllers/admin/base_controller.rb', line 68
def destroy
destroy! do
track_action! if @settings[:history]
redirect_to_on_success
end
end
|
81
82
83
84
85
|
# File 'app/controllers/admin/base_controller.rb', line 81
def edit
edit! do |format|
format.js { render layout: false }
end
end
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/admin/base_controller.rb', line 22
def index
super do |format|
format.js { render layout: false }
if settings[:export]
format.csv do
authorize! :export, resource_class
doc = AbAdmin::Utils::CsvDocument.new(collection, export_options)
send_data(doc.render(self, locale: params[:locale]), filename: doc.filename, type: Mime[:csv], disposition: 'attachment')
end
if Mime[:xlsx]
format.xlsx do
authorize! :export, resource_class
doc = AbAdmin::Utils::XlsDocument.new(collection, export_options)
send_data(doc.render(self, locale: params[:locale]), filename: doc.filename, type: Mime[:xlsx], disposition: 'attachment')
end
end
end
end
end
|
87
88
89
90
91
|
# File 'app/controllers/admin/base_controller.rb', line 87
def new
new! do |format|
format.js { render layout: false }
end
end
|
75
76
77
78
79
|
# File 'app/controllers/admin/base_controller.rb', line 75
def show
show! do |format|
format.js { render layout: false }
end
end
|
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/admin/base_controller.rb', line 54
def update
resource.last_updated_timestamp = params[:last_updated_timestamp].to_i if settings[:safe_save] && !params[:_force_save] && params[:last_updated_timestamp]
update! do |success, failure|
success.html { redirect_to redirect_to_on_success }
failure.html { render :edit }
success.js { render layout: false }
failure.js { render :edit, layout: false }
unless respond_to_format?(:json)
success.json { head :no_content }
failure.json { render json: {errors: resource.errors}, status: :unprocessable_entity }
end
end
end
|