Class: Binda::StructuresController
Instance Method Summary
collapse
#after_sign_in_path_for, #after_sign_out_path_for, #set_locale
Instance Method Details
#add_field_group ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'app/controllers/binda/structures_controller.rb', line 66
def add_field_group
@field_group = FieldGroup.new(
name: "#{I18n.t('binda.field_group.new')}",
structure_id: @structure.id
)
@field_group.save!
render 'binda/structures/_form_new_field_group_item', layout: false
end
|
#create ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/binda/structures_controller.rb', line 22
def create
@structure = Structure.new(structure_params)
if @structure.save
redirect_to structure_path( @structure.slug ), notice: "#{ @structure.name.capitalize } structure was successfully created."
else
render :new
end
end
|
#destroy ⇒ Object
41
42
43
44
|
# File 'app/controllers/binda/structures_controller.rb', line 41
def destroy
@structure.destroy
redirect_to structures_url, notice: "#{ @structure.name.capitalize } structure was successfully destroyed."
end
|
#edit ⇒ Object
19
20
|
# File 'app/controllers/binda/structures_controller.rb', line 19
def edit
end
|
#fields_update ⇒ Object
46
47
48
|
# File 'app/controllers/binda/structures_controller.rb', line 46
def fields_update
redirect_to :back, notice: "#{ @structure.name.capitalize } structure was successfully updated."
end
|
#index ⇒ Object
7
8
9
|
# File 'app/controllers/binda/structures_controller.rb', line 7
def index
@structures = Structure.order('position').all.page params[:page]
end
|
#new ⇒ Object
15
16
17
|
# File 'app/controllers/binda/structures_controller.rb', line 15
def new
@structure = Structure.new
end
|
#show ⇒ Object
11
12
13
|
# File 'app/controllers/binda/structures_controller.rb', line 11
def show
redirect_to action: :edit
end
|
#sort ⇒ Object
50
51
52
53
54
55
|
# File 'app/controllers/binda/structures_controller.rb', line 50
def sort
params[:structure].each_with_index do |id, i|
Structure.find( id ).update({ position: i })
end
render js: "$('##{params[:id]}').sortable('option', 'disabled', false); $('.popup-warning').addClass('popup-warning--hidden'); $('.sortable').removeClass('sortable--disabled')"
end
|
#sort_field_groups ⇒ Object
61
62
63
64
|
# File 'app/controllers/binda/structures_controller.rb', line 61
def sort_field_groups
sort_field_group_by(params["form--list-item"])
render json: { id: "##{params[:id]}" }, status: 200
end
|
#sort_index ⇒ Object
57
58
59
|
# File 'app/controllers/binda/structures_controller.rb', line 57
def sort_index
@structures = Structure.order('position').all.page params[:page]
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'app/controllers/binda/structures_controller.rb', line 32
def update
if @structure.update(structure_params)
redirect_to structure_path( @structure.slug ), notice: "#{ @structure.name.capitalize } structure was successfully updated."
else
render :edit
end
end
|