binda 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -29
- data/Rakefile +16 -10
- data/app/assets/javascripts/binda/components/form_item.js +12 -1
- data/app/assets/javascripts/binda/components/form_item_asset.js +1 -0
- data/app/assets/javascripts/binda/components/form_item_choice.js +58 -0
- data/app/assets/javascripts/binda/components/form_item_editor.js +39 -0
- data/app/assets/javascripts/binda/components/form_item_repeater.js +7 -0
- data/app/assets/javascripts/binda/components/sortable.js +0 -1
- data/app/assets/javascripts/binda/dist/binda.bundle.js +175 -8
- data/app/assets/javascripts/binda/index.js +4 -0
- data/app/assets/stylesheets/binda/components/form_item.scss +64 -2
- data/app/controllers/binda/application_controller.rb +2 -10
- data/app/controllers/binda/choices_controller.rb +19 -0
- data/app/controllers/binda/components_controller.rb +38 -134
- data/app/controllers/binda/field_groups_controller.rb +18 -30
- data/app/controllers/binda/structures_controller.rb +6 -6
- data/app/controllers/concerns/binda/component_controller_helper.rb +16 -0
- data/app/models/binda/checkbox.rb +7 -0
- data/app/models/binda/choice.rb +11 -0
- data/app/models/binda/component.rb +12 -136
- data/app/models/binda/field_group.rb +1 -1
- data/app/models/binda/field_setting.rb +40 -8
- data/app/models/binda/radio.rb +5 -0
- data/app/models/binda/repeater.rb +11 -79
- data/app/models/binda/select.rb +7 -0
- data/app/models/binda/structure.rb +13 -13
- data/app/models/concerns/binda/component_model_helper.rb +170 -0
- data/app/views/binda/components/_form_item_new_repeater.html.erb +3 -5
- data/app/views/binda/components/_form_item_selectable.html.erb +72 -0
- data/app/views/binda/components/_form_section.html.erb +7 -2
- data/app/views/binda/components/_form_section_repeater.html.erb +10 -0
- data/app/views/binda/field_groups/_form_item.html.erb +54 -26
- data/app/views/binda/field_groups/_form_item_choice.erb +96 -0
- data/app/views/binda/field_groups/_form_section.html.erb +2 -2
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +2 -2
- data/config/locales/en.yml +7 -0
- data/config/routes.rb +2 -1
- data/db/migrate/1_create_binda_tables.rb +17 -0
- data/lib/binda/engine.rb +6 -0
- data/lib/binda/version.rb +1 -1
- data/lib/generators/binda/install/install_generator.rb +6 -8
- data/lib/generators/binda/setup/setup_generator.rb +8 -4
- metadata +66 -42
- data/app/controllers/binda/dates_controller.rb +0 -62
- data/app/controllers/binda/texts_controller.rb +0 -62
- data/app/views/binda/dates/_form.html.erb +0 -22
- data/app/views/binda/dates/edit.html.erb +0 -6
- data/app/views/binda/dates/index.html.erb +0 -27
- data/app/views/binda/dates/new.html.erb +0 -5
- data/app/views/binda/dates/show.html.erb +0 -9
- data/app/views/binda/repeaters/_form.html.erb +0 -27
- data/app/views/binda/repeaters/edit.html.erb +0 -6
- data/app/views/binda/repeaters/index.html.erb +0 -29
- data/app/views/binda/repeaters/new.html.erb +0 -5
- data/app/views/binda/repeaters/show.html.erb +0 -14
- data/app/views/binda/structures/add_child.html.erb +0 -0
- data/app/views/binda/texts/_form.html.erb +0 -22
- data/app/views/binda/texts/edit.html.erb +0 -6
- data/app/views/binda/texts/index.html.erb +0 -27
- data/app/views/binda/texts/new.html.erb +0 -5
- data/app/views/binda/texts/show.html.erb +0 -9
@@ -5,6 +5,8 @@
|
|
5
5
|
import { _FormItem } from './components/form_item'
|
6
6
|
import { _FormItemRepeater } from './components/form_item_repeater'
|
7
7
|
import { _FormItemAsset } from './components/form_item_asset'
|
8
|
+
import { _FormItemChoice } from './components/form_item_choice'
|
9
|
+
import { _FormItemEditor } from './components/form_item_editor'
|
8
10
|
import setupSortable from './components/sortable'
|
9
11
|
|
10
12
|
$(document).ready( function()
|
@@ -12,5 +14,7 @@ $(document).ready( function()
|
|
12
14
|
if ( _FormItem.isSet() ) { _FormItem.setEvents() }
|
13
15
|
if ( _FormItemRepeater.isSet() ) { _FormItemRepeater.setEvents() }
|
14
16
|
if ( _FormItemAsset.isSet() ) { _FormItemAsset.setEvents() }
|
17
|
+
if ( _FormItemChoice.isSet() ) { _FormItemChoice.setEvents() }
|
18
|
+
if ( _FormItemEditor.isSet() ) { _FormItemEditor.setEvents() }
|
15
19
|
setupSortable()
|
16
20
|
})
|
@@ -31,6 +31,27 @@
|
|
31
31
|
}
|
32
32
|
}
|
33
33
|
|
34
|
+
.form-item--half-size {
|
35
|
+
position: relative;
|
36
|
+
width: 46%;
|
37
|
+
margin-right: 4%;
|
38
|
+
float: left;
|
39
|
+
|
40
|
+
h5 {
|
41
|
+
width: 100%;
|
42
|
+
}
|
43
|
+
|
44
|
+
.form-item--select-input {
|
45
|
+
margin-left: 0;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
.form-item--full-size {
|
50
|
+
position: relative;
|
51
|
+
width: 96%;
|
52
|
+
clear: both;
|
53
|
+
}
|
54
|
+
|
34
55
|
.form-item--new {
|
35
56
|
position: absolute;
|
36
57
|
top: 101%;
|
@@ -81,13 +102,13 @@
|
|
81
102
|
}
|
82
103
|
|
83
104
|
.form-item--editor {
|
84
|
-
max-height:
|
105
|
+
// max-height: is set via javascript in app/assets/javscripts/components/form_item_editor.js;
|
85
106
|
overflow-y: hidden;
|
86
107
|
transition: max-height 0.6s ease-out;
|
87
108
|
}
|
88
109
|
|
89
110
|
.form-item--editor-close {
|
90
|
-
max-height: 0;
|
111
|
+
max-height: 0 !important;
|
91
112
|
}
|
92
113
|
|
93
114
|
.form-item--label-on-top .form-group {
|
@@ -166,4 +187,45 @@
|
|
166
187
|
.form-group {
|
167
188
|
margin-bottom: $font-size-base;
|
168
189
|
}
|
190
|
+
}
|
191
|
+
|
192
|
+
.form-item--choices {
|
193
|
+
position: relative;
|
194
|
+
}
|
195
|
+
|
196
|
+
.form-item--editor .form-item--choice {
|
197
|
+
position: relative;
|
198
|
+
clear: left;
|
199
|
+
|
200
|
+
&:last-child {
|
201
|
+
padding-bottom: $font-size-base/2;
|
202
|
+
border-bottom: 1px solid $gray-lighter;
|
203
|
+
margin-bottom: $font-size-base;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
.form-item--new-choice {
|
208
|
+
display: none;
|
209
|
+
}
|
210
|
+
|
211
|
+
.form-item--choice-label,
|
212
|
+
.form-item--choice-content {
|
213
|
+
@extend .form-item--half-size;
|
214
|
+
}
|
215
|
+
|
216
|
+
.form-item--delete-choice,
|
217
|
+
.form-item--js-delete-choice {
|
218
|
+
position: absolute;
|
219
|
+
top: 32px;
|
220
|
+
right: 0;
|
221
|
+
}
|
222
|
+
|
223
|
+
.form-item--add-choice {
|
224
|
+
position: absolute;
|
225
|
+
top: 0;
|
226
|
+
right: 0;
|
227
|
+
}
|
228
|
+
|
229
|
+
.form-item--new-choice .form-item--delete-choice {
|
230
|
+
display: none;
|
169
231
|
}
|
@@ -5,6 +5,8 @@ module Binda
|
|
5
5
|
|
6
6
|
before_action :authenticate_user!
|
7
7
|
|
8
|
+
include ComponentControllerHelper
|
9
|
+
|
8
10
|
# _ indicates that we are not using the argument in the method
|
9
11
|
def after_sign_in_path_for(_)
|
10
12
|
binda.dashboard_path
|
@@ -15,15 +17,5 @@ module Binda
|
|
15
17
|
root_path
|
16
18
|
end
|
17
19
|
|
18
|
-
def get_components( slug, ask_for_published = true, custom_order = '' )
|
19
|
-
if ask_for_published && custom_order.blank?
|
20
|
-
Binda::Structure.friendly.find( slug ).components.published.order('position')
|
21
|
-
elsif custom_order.blank?
|
22
|
-
Binda::Structure.friendly.find( slug ).components.order('position')
|
23
|
-
else
|
24
|
-
Binda::Structure.friendly.find( slug ).components.order( custom_order )
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
20
|
end
|
29
21
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_dependency "binda/application_controller"
|
2
|
+
|
3
|
+
module Binda
|
4
|
+
class ChoicesController < ApplicationController
|
5
|
+
|
6
|
+
before_action :set_choice
|
7
|
+
|
8
|
+
def destroy
|
9
|
+
@choice.destroy
|
10
|
+
head :ok
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def set_choice
|
16
|
+
@choice = Choice.find( params[:id] )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -25,7 +25,7 @@ module Binda
|
|
25
25
|
@component = @structure.components.build(component_params)
|
26
26
|
@component.position = @position
|
27
27
|
if @component.save
|
28
|
-
redirect_to structure_component_path( @structure.slug, @component.slug ), notice:
|
28
|
+
redirect_to structure_component_path( @structure.slug, @component.slug ), notice: "A #{ @component.name } was successfully created."
|
29
29
|
else
|
30
30
|
redirect_to new_structure_component_path( @structure.slug ), flash: { alert: @component.errors }
|
31
31
|
end
|
@@ -33,7 +33,7 @@ module Binda
|
|
33
33
|
|
34
34
|
def update
|
35
35
|
if @component.update(component_params)
|
36
|
-
redirect_to structure_component_path( @structure.slug, @component.slug ), notice:
|
36
|
+
redirect_to structure_component_path( @structure.slug, @component.slug ), notice: "A #{ @component.name } was successfully updated."
|
37
37
|
else
|
38
38
|
redirect_to edit_structure_component_path( @structure.slug, @component.slug ), flash: { alert: @component.errors }
|
39
39
|
end
|
@@ -41,25 +41,26 @@ module Binda
|
|
41
41
|
|
42
42
|
def destroy
|
43
43
|
@component.destroy
|
44
|
-
redirect_to structure_components_url( @structure.slug ), notice:
|
44
|
+
redirect_to structure_components_url( @structure.slug ), notice: "A #{ @component.name } was successfully destroyed."
|
45
45
|
end
|
46
46
|
|
47
47
|
def new_repeater
|
48
|
-
|
49
|
-
|
48
|
+
@repeater_setting = FieldSetting.find( params[:repeater_setting_id] )
|
49
|
+
position = @component.repeaters.find_all{|r| r.field_setting_id=@repeater_setting.id }.length + 1
|
50
|
+
@repeater = @component.repeaters.create( field_setting: @repeater_setting, position: position )
|
50
51
|
render 'binda/components/_form_item_new_repeater', layout: false
|
51
52
|
end
|
52
53
|
|
53
54
|
def sort_repeaters
|
54
55
|
params[:repeater].each_with_index do |id, i|
|
55
|
-
|
56
|
+
Repeater.find( id ).update({ position: i + 1 })
|
56
57
|
end
|
57
58
|
head :ok
|
58
59
|
end
|
59
60
|
|
60
61
|
def sort
|
61
62
|
params[:component].each_with_index do |id, i|
|
62
|
-
|
63
|
+
Component.find( id ).update({ position: i + 1 })
|
63
64
|
end
|
64
65
|
head :ok
|
65
66
|
end
|
@@ -81,137 +82,40 @@ module Binda
|
|
81
82
|
# Only allow a trusted parameter "white list" through.
|
82
83
|
def component_params
|
83
84
|
params.require(:component).permit(
|
84
|
-
:name,
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
:
|
96
|
-
],
|
97
|
-
|
98
|
-
:id,
|
99
|
-
:field_setting_id,
|
100
|
-
:fieldable_type,
|
101
|
-
:fieldable_id,
|
102
|
-
:
|
103
|
-
|
104
|
-
assets_attributes: [
|
105
|
-
:id,
|
106
|
-
:field_setting_id,
|
107
|
-
:fieldable_type,
|
108
|
-
:fieldable_id,
|
109
|
-
:image
|
110
|
-
],
|
111
|
-
dates_attributes: [
|
112
|
-
:id,
|
113
|
-
:field_setting_id,
|
114
|
-
:fieldable_type,
|
115
|
-
:fieldable_id,
|
116
|
-
:date
|
117
|
-
],
|
118
|
-
galleries_attributes: [
|
119
|
-
:id,
|
120
|
-
:field_setting_id,
|
121
|
-
:fieldable_type,
|
122
|
-
:fieldable_id
|
123
|
-
],
|
124
|
-
repeaters_attributes: [
|
125
|
-
:id,
|
126
|
-
:field_setting_id,
|
127
|
-
:field_group_id,
|
128
|
-
:fieldable_type,
|
129
|
-
:fieldable_id,
|
130
|
-
texts_attributes: [
|
131
|
-
:id,
|
132
|
-
:repeater_id,
|
133
|
-
:field_setting_id,
|
134
|
-
:fieldable_type,
|
135
|
-
:fieldable_id,
|
136
|
-
:content
|
137
|
-
],
|
138
|
-
assets_attributes: [
|
139
|
-
:id,
|
140
|
-
:repeater_id,
|
141
|
-
:field_setting_id,
|
142
|
-
:fieldable_type,
|
143
|
-
:fieldable_id,
|
144
|
-
:image
|
145
|
-
],
|
146
|
-
dates_attributes: [
|
147
|
-
:id,
|
148
|
-
:repeater_id,
|
149
|
-
:field_setting_id,
|
150
|
-
:fieldable_type,
|
151
|
-
:fieldable_id,
|
152
|
-
:date
|
153
|
-
],
|
154
|
-
galleries_attributes: [
|
155
|
-
:id,
|
156
|
-
:repeater_id,
|
157
|
-
:field_setting_id,
|
158
|
-
:fieldable_type,
|
159
|
-
:fieldable_id
|
160
|
-
],
|
161
|
-
repeaters_attributes: [
|
162
|
-
:id,
|
163
|
-
:repeater_id,
|
164
|
-
:field_setting_id,
|
165
|
-
:field_group_id,
|
166
|
-
:fieldable_type,
|
167
|
-
:fieldable_id
|
168
|
-
]
|
169
|
-
])
|
85
|
+
:name, :slug, :position, :publish_state, :structure_id, :category_ids,
|
86
|
+
structure_attributes: [ :id ],
|
87
|
+
categories_attributes: [ :id, :category_id ],
|
88
|
+
texts_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :content ],
|
89
|
+
assets_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :image ],
|
90
|
+
dates_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :date ],
|
91
|
+
galleries_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id ],
|
92
|
+
radios_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :choice_ids ],
|
93
|
+
selects_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
94
|
+
checkboxes_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
95
|
+
repeaters_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :field_group_id,
|
96
|
+
texts_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
97
|
+
assets_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
98
|
+
dates_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
99
|
+
galleries_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id ],
|
100
|
+
repeaters_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :field_group_id ],
|
101
|
+
radios_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :choice_ids ],
|
102
|
+
selects_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
103
|
+
checkboxes_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ]
|
104
|
+
])
|
170
105
|
end
|
171
106
|
|
172
107
|
def repeater_params
|
173
108
|
params.require(:repeater).permit(
|
174
|
-
new_repeaters_attributes: [
|
175
|
-
:id,
|
176
|
-
:field_setting_id,
|
177
|
-
:
|
178
|
-
:fieldable_type,
|
179
|
-
:fieldable_id,
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
:fieldable_id,
|
185
|
-
:content
|
186
|
-
],
|
187
|
-
assets_attributes: [
|
188
|
-
:id,
|
189
|
-
:field_setting_id,
|
190
|
-
:fieldable_type,
|
191
|
-
:fieldable_id,
|
192
|
-
:image
|
193
|
-
],
|
194
|
-
dates_attributes: [
|
195
|
-
:id,
|
196
|
-
:field_setting_id,
|
197
|
-
:fieldable_type,
|
198
|
-
:fieldable_id,
|
199
|
-
:date
|
200
|
-
],
|
201
|
-
galleries_attributes: [
|
202
|
-
:id,
|
203
|
-
:field_setting_id,
|
204
|
-
:fieldable_type,
|
205
|
-
:fieldable_id
|
206
|
-
],
|
207
|
-
repeaters_attributes: [
|
208
|
-
:id,
|
209
|
-
:field_setting_id,
|
210
|
-
:field_group_id,
|
211
|
-
:fieldable_type,
|
212
|
-
:fieldable_id
|
213
|
-
]
|
214
|
-
])
|
109
|
+
new_repeaters_attributes: [ :id, :field_setting_id, :field_group_id, :fieldable_type, :fieldable_id,
|
110
|
+
texts_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :content ],
|
111
|
+
assets_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :image ],
|
112
|
+
dates_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :date ],
|
113
|
+
galleries_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id ],
|
114
|
+
repeaters_attributes: [ :id, :field_setting_id, :field_group_id, :fieldable_type, :fieldable_id ],
|
115
|
+
radios_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :choice_ids ],
|
116
|
+
selects_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
117
|
+
checkboxes_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ]
|
118
|
+
])
|
215
119
|
end
|
216
120
|
|
217
121
|
def set_position
|
@@ -42,6 +42,18 @@ module Binda
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
# Create new fields if any
|
46
|
+
unless new_params[:new_choices].nil?
|
47
|
+
new_params[:new_choices].each do |choice|
|
48
|
+
unless choice[:label].blank? || choice[:value].blank?
|
49
|
+
new_choice = Choice.create( choice )
|
50
|
+
unless new_choice
|
51
|
+
return redirect_to edit_structure_field_group_path( @structure.slug, @field_group.slug ), flash: { error: new_choice.errors }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
45
57
|
# Update the other ones
|
46
58
|
if @field_group.update(field_group_params)
|
47
59
|
reset_field_settings_cache
|
@@ -70,44 +82,20 @@ module Binda
|
|
70
82
|
# Only allow a trusted parameter "white list" through.
|
71
83
|
def field_group_params
|
72
84
|
params.require(:field_group).permit(
|
73
|
-
:name,
|
74
|
-
:slug,
|
75
|
-
|
76
|
-
:position,
|
77
|
-
:layout,
|
78
|
-
:structure_id,
|
79
|
-
field_settings_attributes: [
|
80
|
-
:id,
|
81
|
-
:field_group_id,
|
82
|
-
:field_setting_id,
|
83
|
-
:name,
|
84
|
-
:slug,
|
85
|
-
:description,
|
86
|
-
:field_type,
|
87
|
-
:position,
|
88
|
-
:required,
|
89
|
-
:default_text,
|
90
|
-
:ancestry
|
85
|
+
:name, :slug, :description, :position, :layout, :structure_id,
|
86
|
+
field_settings_attributes: [ :id, :field_group_id, :field_setting_id, :name, :slug, :description, :field_type, :position, :required, :default_text, :ancestry, choices: [], :default_choice_id_id, :allow_null,
|
87
|
+
choices_attributes: [ :field_setting_id, :label, :value ]
|
91
88
|
])
|
92
89
|
end
|
93
90
|
|
94
91
|
def new_params
|
95
92
|
params.require(:field_group).permit(
|
96
|
-
new_field_settings:[
|
97
|
-
|
98
|
-
:field_setting_id,
|
99
|
-
:name,
|
100
|
-
:slug,
|
101
|
-
:description,
|
102
|
-
:field_type,
|
103
|
-
:position,
|
104
|
-
:required,
|
105
|
-
:ancestry
|
106
|
-
])
|
93
|
+
new_field_settings:[ :field_group_id, :field_setting_id, :name, :slug, :description, :field_type, :position, :required, :ancestry, choices: [], :default_choice_id, :allow_null ],
|
94
|
+
new_choices: [ :field_setting_id, :label, :value ])
|
107
95
|
end
|
108
96
|
|
109
97
|
def reset_field_settings_cache
|
110
|
-
|
98
|
+
FieldSetting.reset_field_settings_array
|
111
99
|
end
|
112
100
|
|
113
101
|
end
|
@@ -2,7 +2,7 @@ require_dependency "binda/application_controller"
|
|
2
2
|
|
3
3
|
module Binda
|
4
4
|
class StructuresController < ApplicationController
|
5
|
-
before_action :set_structure, only: [:show, :edit, :update, :destroy]
|
5
|
+
before_action :set_structure, only: [:show, :edit, :update, :destroy, :fields_update ]
|
6
6
|
|
7
7
|
def index
|
8
8
|
@structures = Structure.order('position').all
|
@@ -30,7 +30,7 @@ module Binda
|
|
30
30
|
return redirect_to structure_path( @structure.slug ), flash: { error: 'General Details group hasn\'t been created' }
|
31
31
|
end
|
32
32
|
# ... redirect to the new structure path
|
33
|
-
redirect_to structure_path( @structure.slug ), notice:
|
33
|
+
redirect_to structure_path( @structure.slug ), notice: "#{ @structure.name } structure was successfully created."
|
34
34
|
else
|
35
35
|
render :new
|
36
36
|
end
|
@@ -49,7 +49,7 @@ module Binda
|
|
49
49
|
|
50
50
|
# Update the other ones
|
51
51
|
if @structure.update(structure_params)
|
52
|
-
redirect_to structure_path( @structure.slug ), notice:
|
52
|
+
redirect_to structure_path( @structure.slug ), notice: "#{ @structure.name } structure was successfully updated."
|
53
53
|
else
|
54
54
|
render :edit
|
55
55
|
end
|
@@ -57,16 +57,16 @@ module Binda
|
|
57
57
|
|
58
58
|
def destroy
|
59
59
|
@structure.destroy
|
60
|
-
redirect_to structures_url, notice:
|
60
|
+
redirect_to structures_url, notice: "#{ @structure.name } structure was successfully destroyed."
|
61
61
|
end
|
62
62
|
|
63
63
|
def fields_update
|
64
|
-
redirect_to :back, notice:
|
64
|
+
redirect_to :back, notice: "#{ @structure.name } structure was successfully updated."
|
65
65
|
end
|
66
66
|
|
67
67
|
def sort
|
68
68
|
params[:structure].each_with_index do |id, i|
|
69
|
-
|
69
|
+
Structure.find( id ).update({ position: i + 1 })
|
70
70
|
end
|
71
71
|
head :ok
|
72
72
|
end
|