Class: Binda::FieldSettingsController
Instance Method Summary
collapse
#after_sign_in_path_for, #after_sign_out_path_for, #set_locale
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/binda/field_settings_controller.rb', line 24
def create
@field_setting = @field_group.field_settings.build(field_setting_params)
if @field_setting.save
redirect_to structure_field_group_field_setting_path( @structure, @field_group, @field_setting ), notice: 'Field setting was successfully created.'
else
redirect_to new_structure_field_group_field_setting_path( @structure, @field_group ), flash: { alert: @field_setting.errors }
end
end
|
#destroy ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/binda/field_settings_controller.rb', line 42
def destroy
@field_setting.destroy!
FieldSetting.reset_field_settings_array
if params[:isAjax]
render json: { target_id: params[:target_id] }, status: 200
else
redirect_to structure_field_group_path( @structure, @field_group ), notice: 'Field setting and all dependent content were successfully destroyed.'
end
end
|
#edit ⇒ Object
21
22
|
# File 'app/controllers/binda/field_settings_controller.rb', line 21
def edit
end
|
#index ⇒ Object
9
10
11
|
# File 'app/controllers/binda/field_settings_controller.rb', line 9
def index
@field_settings = @field_group.field_settings.order('position').all
end
|
#new ⇒ Object
17
18
19
|
# File 'app/controllers/binda/field_settings_controller.rb', line 17
def new
@field_setting = @field_group.field_settings.build()
end
|
#show ⇒ Object
13
14
15
|
# File 'app/controllers/binda/field_settings_controller.rb', line 13
def show
redirect_to action: :edit
end
|
#sort ⇒ Object
52
53
54
55
56
57
|
# File 'app/controllers/binda/field_settings_controller.rb', line 52
def sort
params[:field_setting].each_with_index do |id, i|
FieldSetting.find( id ).update_column('position', i+1) end
render json: { id: "##{params[:id]}" }, status: 200
end
|
#update ⇒ Object
34
35
36
37
38
39
40
|
# File 'app/controllers/binda/field_settings_controller.rb', line 34
def update
if @field_setting.update(field_setting_params)
redirect_to structure_field_group_field_setting_path( @structure, @field_group, @field_setting ), notice: 'Field setting was successfully updated.'
else
redirect_to edit_structure_field_group_field_setting_path( @structure, @field_group, @field_setting ), flash: { alert: @field_setting.errors }
end
end
|