binda 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/Rakefile +2 -1
- data/app/assets/javascripts/binda/dist/binda.bundle.js +75 -75
- data/app/assets/stylesheets/binda/settings/common.scss +4 -0
- data/app/controllers/binda/application_controller.rb +1 -1
- data/app/controllers/binda/boards_controller.rb +73 -0
- data/app/controllers/binda/components_controller.rb +18 -44
- data/app/controllers/binda/field_groups_controller.rb +36 -24
- data/app/controllers/binda/field_settings_controller.rb +5 -5
- data/app/controllers/binda/manage/users_controller.rb +2 -9
- data/app/controllers/binda/structures_controller.rb +6 -13
- data/app/controllers/concerns/binda/default_helpers.rb +226 -0
- data/app/controllers/concerns/binda/fieldable_helpers.rb +44 -0
- data/app/helpers/binda/boards_helper.rb +13 -0
- data/app/helpers/binda/components_helper.rb +0 -5
- data/app/helpers/binda/field_settings_helper.rb +1 -1
- data/app/models/binda/asset.rb +0 -8
- data/app/models/binda/binda.rb +7 -0
- data/app/models/binda/binding.rb +4 -4
- data/app/models/binda/board.rb +41 -0
- data/app/models/binda/category.rb +7 -3
- data/app/models/binda/checkbox.rb +1 -3
- data/app/models/binda/choice.rb +31 -1
- data/app/models/binda/component.rb +7 -22
- data/app/models/binda/field_group.rb +13 -7
- data/app/models/binda/field_setting.rb +40 -29
- data/app/models/binda/gallery.rb +0 -7
- data/app/models/binda/radio.rb +1 -1
- data/app/models/binda/repeater.rb +13 -20
- data/app/models/binda/selection.rb +17 -0
- data/app/models/binda/string.rb +4 -0
- data/app/models/binda/structure.rb +65 -7
- data/app/models/concerns/binda/{component_model_helper.rb → fieldable_associations.rb} +102 -31
- data/app/views/binda/boards/edit.html.erb +7 -0
- data/app/views/binda/components/edit.html.erb +4 -1
- data/app/views/binda/components/index.html.erb +2 -0
- data/app/views/binda/components/new.html.erb +1 -1
- data/app/views/binda/field_groups/_form_body.html.erb +8 -8
- data/app/views/binda/field_groups/_form_item.html.erb +3 -3
- data/app/views/binda/field_groups/_form_item_choice.erb +11 -8
- data/app/views/binda/field_groups/_form_section.html.erb +5 -5
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +3 -3
- data/app/views/binda/field_groups/edit.html.erb +1 -1
- data/app/views/binda/field_groups/new.html.erb +1 -1
- data/app/views/binda/{components → fieldable}/_form_body.html.erb +9 -9
- data/app/views/binda/{components → fieldable}/_form_item_asset.html.erb +0 -0
- data/app/views/binda/{components → fieldable}/_form_item_date.html.erb +0 -0
- data/app/views/binda/{components → fieldable}/_form_item_gallery.html.erb +0 -0
- data/app/views/binda/{components → fieldable}/_form_item_new_repeater.html.erb +5 -5
- data/app/views/binda/{components → fieldable}/_form_item_repeater.html.erb +8 -9
- data/app/views/binda/fieldable/_form_item_selections.html.erb +99 -0
- data/app/views/binda/fieldable/_form_item_string.html.erb +19 -0
- data/app/views/binda/{components → fieldable}/_form_item_text.html.erb +2 -11
- data/app/views/binda/fieldable/_form_section.html.erb +52 -0
- data/app/views/binda/fieldable/_form_section_repeater.html.erb +48 -0
- data/app/views/binda/fieldable/_form_sidebar.html.erb +35 -0
- data/app/views/binda/structures/_form_body.html.erb +6 -0
- data/app/views/binda/structures/_form_section.html.erb +1 -1
- data/app/views/binda/structures/edit.html.erb +3 -0
- data/app/views/binda/structures/index.html.erb +2 -0
- data/app/views/layouts/binda/_flash.html.erb +3 -3
- data/app/views/layouts/binda/_sidebar.html.erb +20 -15
- data/config/locales/en.yml +4 -0
- data/config/routes.rb +18 -21
- data/db/migrate/1_create_binda_tables.rb +12 -6
- data/lib/binda/engine.rb +5 -1
- data/lib/binda/version.rb +1 -1
- data/lib/generators/binda/install/install_generator.rb +9 -0
- data/lib/generators/binda/setup/setup_generator.rb +50 -7
- data/lib/tasks/binda.rake +78 -24
- metadata +100 -31
- data/app/controllers/binda/settings_controller.rb +0 -75
- data/app/controllers/concerns/binda/component_controller_helper.rb +0 -16
- data/app/helpers/binda/settings_helper.rb +0 -13
- data/app/models/binda/select.rb +0 -7
- data/app/models/binda/setting.rb +0 -42
- data/app/views/binda/components/_form_item_selectable.html.erb +0 -72
- data/app/views/binda/components/_form_section.html.erb +0 -42
- data/app/views/binda/components/_form_section_repeater.html.erb +0 -41
- data/app/views/binda/components/_form_sidebar.html.erb +0 -34
- data/app/views/binda/settings/_dashboard_form.html.erb +0 -51
- data/app/views/binda/settings/_form.html.erb +0 -52
- data/app/views/binda/settings/dashboard.html.erb +0 -9
- data/app/views/binda/settings/edit.html.erb +0 -8
- data/app/views/binda/settings/index.html.erb +0 -34
- data/app/views/binda/settings/new.html.erb +0 -8
@@ -1,38 +1,31 @@
|
|
1
1
|
module Binda
|
2
2
|
class Repeater < ApplicationRecord
|
3
3
|
|
4
|
-
include
|
4
|
+
include FieldableAssociations
|
5
5
|
|
6
6
|
# Associations
|
7
7
|
belongs_to :fieldable, polymorphic: true
|
8
8
|
belongs_to :field_setting
|
9
9
|
|
10
|
-
# Fields Associations
|
11
|
-
#
|
12
|
-
# If you add a new field remember to update:
|
13
|
-
# - get_fieldables (see here below)
|
14
|
-
# - get_field_types (see here below)
|
15
|
-
# - component_params (app/controllers/binda/components_controller.rb)
|
16
|
-
has_many :texts, as: :fieldable, dependent: :delete_all
|
17
|
-
has_many :dates, as: :fieldable, dependent: :delete_all
|
18
|
-
has_many :galleries, as: :fieldable, dependent: :delete_all
|
19
|
-
has_many :assets, as: :fieldable, dependent: :delete_all
|
20
|
-
has_many :radios, as: :fieldable, dependent: :delete_all
|
21
|
-
has_many :selects, as: :fieldable, dependent: :delete_all
|
22
|
-
has_many :checkboxes, as: :fieldable, dependent: :delete_all
|
23
|
-
# Repeaters need destroy_all, not delete_all
|
24
|
-
has_many :repeaters, as: :fieldable, dependent: :destroy
|
25
|
-
|
26
|
-
accepts_nested_attributes_for :texts, :dates, :assets, :galleries, :repeaters, :radios, :selects, :checkboxes, allow_destroy: true
|
27
|
-
|
28
10
|
# The following direct association is used to securely delete associated fields
|
29
11
|
# Infact via `fieldable` the associated fields might not be deleted
|
30
12
|
# as the fieldable_id is related to the `component` rather than the `field_setting`
|
31
13
|
|
32
14
|
after_create :set_default_position
|
33
15
|
|
16
|
+
|
17
|
+
# Set default position after create
|
18
|
+
#
|
19
|
+
# This methods ensure that every repeater instance has an explicit position.
|
20
|
+
# The latest repeater created gets the highest position number.
|
21
|
+
#
|
22
|
+
# @return [object] Repeater instance
|
34
23
|
def set_default_position
|
35
|
-
|
24
|
+
# apparently `self.fieldable != self.fieldable_type.constantize.find( self.fieldable_id )`
|
25
|
+
# as the former has always one repeater, the latter has all repeaters created so far
|
26
|
+
# that's way we use the longer version
|
27
|
+
instance = self.fieldable_type.constantize.find( self.fieldable_id )
|
28
|
+
position = instance.repeaters.find_all{ |r| r.field_setting_id == self.field_setting.id }.length
|
36
29
|
self.update_attribute 'position', position
|
37
30
|
end
|
38
31
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Binda
|
2
|
+
class Selection < ApplicationRecord
|
3
|
+
|
4
|
+
has_and_belongs_to_many :choices
|
5
|
+
belongs_to :field_setting
|
6
|
+
|
7
|
+
after_create :set_choice
|
8
|
+
|
9
|
+
# Set the default choice if the field must have at least one.
|
10
|
+
# This method run after the record is created.
|
11
|
+
def set_choice
|
12
|
+
return if self.field_setting.allow_null
|
13
|
+
self.choices << self.field_setting.default_choice if self.choices.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -3,29 +3,87 @@ module Binda
|
|
3
3
|
|
4
4
|
# Associations
|
5
5
|
has_many :components
|
6
|
+
has_one :board
|
6
7
|
has_many :categories
|
7
8
|
has_many :field_groups
|
8
9
|
|
9
10
|
# Validations
|
10
11
|
validates :name, presence: true
|
11
12
|
validates :slug, uniqueness: true
|
13
|
+
validates :instance_type, presence: true, inclusion: { in: %w(component board), message: "%{value} is not a valid instance" }
|
12
14
|
accepts_nested_attributes_for :field_groups, allow_destroy: true, reject_if: :is_rejected
|
13
15
|
|
14
16
|
# Slug
|
15
17
|
extend FriendlyId
|
16
|
-
friendly_id :
|
18
|
+
friendly_id :default_slug, use: [:slugged, :finders]
|
17
19
|
|
20
|
+
after_create :add_default_field_group
|
21
|
+
after_create :add_instance_details
|
22
|
+
after_create :set_default_position
|
18
23
|
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
# Friendly id preference on slug generation
|
25
|
+
#
|
26
|
+
# Method inherited from friendly id
|
27
|
+
# @see https://github.com/norman/friendly_id/issues/436
|
28
|
+
def should_generate_new_friendly_id?
|
29
|
+
slug.blank? || name_changed?
|
30
|
+
end
|
25
31
|
|
32
|
+
#
|
33
|
+
# Sets the validation rules to accept and save an attribute
|
26
34
|
def is_rejected( attributes )
|
27
35
|
attributes['name'].blank?
|
28
36
|
end
|
29
37
|
|
38
|
+
# Set slug name
|
39
|
+
#
|
40
|
+
# It generates 4 possible slugs before falling back to FriendlyId default behaviour
|
41
|
+
def default_slug
|
42
|
+
[ "#{ self.name }",
|
43
|
+
"#{ self.name }-1",
|
44
|
+
"#{ self.name }-2",
|
45
|
+
"#{ self.name }-3" ]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Add a field group as a default
|
49
|
+
#
|
50
|
+
# In order to speed up the setup process Binda will automatically provide a
|
51
|
+
# field group called 'General Details' after the structure is created.
|
52
|
+
# @return [redirect]
|
53
|
+
def add_default_field_group
|
54
|
+
# Creates a default empty field group
|
55
|
+
field_group = self.field_groups.build( name: 'General Details', position: 1 )
|
56
|
+
# Unless there is a problem...
|
57
|
+
unless field_group.save
|
58
|
+
return redirect_to structure_path( self.slug ), flash: { error: 'General Details group hasn\'t been created' }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add details based on instance type
|
63
|
+
#
|
64
|
+
# If instance_type is set to 'setting' it generates a default Binda::Setting instance after creation.
|
65
|
+
# The generated instance will be associated to the structure and named after it.
|
66
|
+
# It also disable categories (this could be a different method, or method could be more explicit)
|
67
|
+
def add_instance_details
|
68
|
+
if self.instance_type == 'board'
|
69
|
+
self.update_attribute 'has_categories', false
|
70
|
+
board = self.build_board( name: self.name )
|
71
|
+
unless board.save
|
72
|
+
return redirect_to structure_path( self.slug ), flash: { error: 'The board instance hasn\'t been created' }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Set default position after create
|
78
|
+
#
|
79
|
+
# This methods ensure that every repeater instance has an explicit position.
|
80
|
+
# The latest repeater created gets the highest position number.
|
81
|
+
#
|
82
|
+
# @return [object] Repeater instance
|
83
|
+
def set_default_position
|
84
|
+
position = Structure.all.length
|
85
|
+
self.update_attribute 'position', position
|
86
|
+
end
|
87
|
+
|
30
88
|
end
|
31
89
|
end
|
@@ -1,20 +1,56 @@
|
|
1
1
|
module Binda
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
# Fieldable associations are Binda's core feature.
|
3
|
+
#
|
4
|
+
# They provide model classes with a collection of fields (texts, assets, dates and so on)
|
5
|
+
# to store data in a simple yet powerful way. It's possible to make use of a set of helpers to
|
6
|
+
# retrieve fields data belonging to each model instance. See the following methods.
|
7
|
+
module FieldableAssociations
|
6
8
|
|
7
9
|
extend ActiveSupport::Concern
|
8
10
|
|
11
|
+
included do
|
12
|
+
# Fieldable Associations
|
13
|
+
#
|
14
|
+
# If you add a new field remember to update:
|
15
|
+
# - get_fieldables (see here below)
|
16
|
+
# - get_field_types (see here below)
|
17
|
+
# - component_params (app/controllers/binda/components_controller.rb)
|
18
|
+
has_many :texts, as: :fieldable, dependent: :delete_all
|
19
|
+
has_many :strings, as: :fieldable, dependent: :delete_all
|
20
|
+
has_many :dates, as: :fieldable, dependent: :delete_all
|
21
|
+
has_many :galleries, as: :fieldable, dependent: :delete_all
|
22
|
+
has_many :assets, as: :fieldable, dependent: :delete_all
|
23
|
+
has_many :radios, as: :fieldable, dependent: :delete_all
|
24
|
+
has_many :selections, as: :fieldable, dependent: :delete_all
|
25
|
+
has_many :checkboxes, as: :fieldable, dependent: :delete_all
|
26
|
+
# Repeaters need destroy_all, not delete_all
|
27
|
+
has_many :repeaters, as: :fieldable, dependent: :destroy
|
28
|
+
|
29
|
+
# has_many :bindings
|
30
|
+
# has_many :assets, class_name: 'Admin::Asset', through: :bindings
|
31
|
+
|
32
|
+
accepts_nested_attributes_for :texts, :strings, :dates, :assets, :galleries, :repeaters, :radios, :selections, :checkboxes, allow_destroy: true
|
33
|
+
|
34
|
+
end
|
35
|
+
|
9
36
|
# Get the object related to that field setting
|
10
37
|
# If the object doesn't exists yet it will return nil
|
11
38
|
#
|
12
39
|
# @param field_slug [string] The slug of the field setting
|
13
|
-
# @return [string] Returns the content of the
|
14
|
-
# @return [
|
40
|
+
# @return [string] Returns the content of the text
|
41
|
+
# @return [error] Raise an error if no record is found
|
15
42
|
def get_text field_slug
|
16
|
-
obj = self.texts.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) }
|
17
|
-
|
43
|
+
obj = self.texts.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) && t.type = 'Binda::Text' }
|
44
|
+
unless obj.nil?
|
45
|
+
obj.content
|
46
|
+
else
|
47
|
+
you_mean_string = !self.strings.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) && t.type = 'Binda::String' }.nil?
|
48
|
+
if you_mean_string
|
49
|
+
raise ArgumentError, "This slug is associated to a string not a text. Use get_string() instead.", caller
|
50
|
+
else
|
51
|
+
raise ArgumentError, "There isn't any text associated to the current slug.", caller
|
52
|
+
end
|
53
|
+
end
|
18
54
|
end
|
19
55
|
|
20
56
|
# Get the object related to that field setting
|
@@ -22,7 +58,40 @@ module Binda
|
|
22
58
|
# @param field_slug [string] The slug of the field setting
|
23
59
|
# @return [boolean]
|
24
60
|
def has_text field_slug
|
25
|
-
obj = self.texts.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) }
|
61
|
+
obj = self.texts.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) && t.type = 'Binda::Text' }
|
62
|
+
if obj.present?
|
63
|
+
return !obj.content.blank?
|
64
|
+
else
|
65
|
+
return false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Get the object related to that field setting
|
70
|
+
# If the object doesn't exists yet it will return nil
|
71
|
+
#
|
72
|
+
# @param field_slug [string] The slug of the field setting
|
73
|
+
# @return [string] Returns the content of the string
|
74
|
+
# @return [error] Raise an error if no record is found
|
75
|
+
def get_string field_slug
|
76
|
+
obj = self.strings.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) && t.type = 'Binda::String' }
|
77
|
+
unless obj.nil?
|
78
|
+
obj.content
|
79
|
+
else
|
80
|
+
you_mean_text = !self.strings.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) && t.type = 'Binda::Text' }.nil?
|
81
|
+
if you_mean_text
|
82
|
+
raise ArgumentError, "This slug is associated to a text not a string. Use get_text() instead.", caller
|
83
|
+
else
|
84
|
+
raise ArgumentError, "There isn't any string associated to the current slug.", caller
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Get the object related to that field setting
|
90
|
+
#
|
91
|
+
# @param field_slug [string] The slug of the field setting
|
92
|
+
# @return [boolean]
|
93
|
+
def has_string field_slug
|
94
|
+
obj = self.strings.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) && t.type = 'Binda::String' }
|
26
95
|
if obj.present?
|
27
96
|
return !obj.content.blank?
|
28
97
|
else
|
@@ -121,50 +190,52 @@ module Binda
|
|
121
190
|
obj.sort_by(&:position) unless obj.nil?
|
122
191
|
end
|
123
192
|
|
124
|
-
# Find or create a field by field setting and field type
|
125
|
-
# This is used in Binda's form
|
126
|
-
#
|
127
|
-
# @param field_setting_id [string] The field setting id
|
128
|
-
# @param field_type [string] THe field type
|
129
|
-
def find_or_create_a_field_by field_setting_id, field_type
|
130
|
-
if FieldSetting.get_fieldables.include?( field_type.capitalize ) && field_setting_id.is_a?( Integer )
|
131
|
-
self.send( field_type.pluralize ).find_or_create_by( field_setting_id: field_setting_id )
|
132
|
-
else
|
133
|
-
raise ArgumentError, "One parameter of find_or_create_a_field_by() is not correct.", caller
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
193
|
# Get the radio choice
|
138
194
|
#
|
139
195
|
# If by mistake the Radio instance has many choices associated,
|
140
196
|
# only the first one will be retrieved.
|
141
197
|
#
|
142
198
|
# @param field_slug [string] The slug of the field setting
|
143
|
-
# @return [
|
199
|
+
# @return [hash] A hash of containing the label and value of the selected choice.
|
144
200
|
def get_radio_choice field_slug
|
145
201
|
obj = self.radios.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) }
|
146
|
-
obj.choices.first
|
202
|
+
return { label: obj.choices.first.label, value: obj.choices.first.value }
|
147
203
|
end
|
148
204
|
|
149
205
|
# Get the select choices
|
150
206
|
#
|
151
207
|
# @param field_slug [string] The slug of the field setting
|
152
|
-
# @return [
|
153
|
-
def
|
208
|
+
# @return [hash] A hash of containing the label and value of the selected choice.
|
209
|
+
def get_selection_choice field_slug
|
154
210
|
# select cannot be chosen has variable name, therefore is prefixed with 's'
|
155
|
-
obj = self.
|
156
|
-
obj.choices
|
211
|
+
obj = self.selections.find{ |t| t.field_setting_id = FieldSetting.get_id( field_slug ) }
|
212
|
+
return { label: obj.choices.first.label, value: obj.choices.first.value }
|
157
213
|
end
|
158
214
|
|
159
215
|
# Get the checkbox choice
|
160
216
|
#
|
161
217
|
# @param field_slug [string] The slug of the field setting
|
162
|
-
# @return [
|
218
|
+
# @return [hash] A hash of labels and values of the selected choices.
|
163
219
|
def get_checkbox_choices field_slug
|
164
|
-
# select cannot be chosen has variable name, therefore is prefixed with '_'
|
165
220
|
obj = self.checkboxes.find{ |t| t.field_setting_id = FieldSetting.get_id( field_slug ) }
|
166
|
-
|
221
|
+
obj_hash = {}
|
222
|
+
obj.choices.order('label').each do |o|
|
223
|
+
obj_hash << { label: obj.choices.first.label, value: obj.choices.first.value }
|
224
|
+
end
|
225
|
+
return obj_hash
|
167
226
|
end
|
168
227
|
|
228
|
+
# Find or create a field by field setting and field type
|
229
|
+
# This is used in Binda's form
|
230
|
+
#
|
231
|
+
# @param field_setting_id [string] The field setting id
|
232
|
+
# @param field_type [string] THe field type
|
233
|
+
def find_or_create_a_field_by field_setting_id, field_type
|
234
|
+
if FieldSetting.get_field_classes.include?( field_type.capitalize ) && field_setting_id.is_a?( Integer )
|
235
|
+
self.send( field_type.pluralize ).find_or_create_by( field_setting_id: field_setting_id )
|
236
|
+
else
|
237
|
+
raise ArgumentError, "One parameter in find_or_create_a_field_by() is not correct.", caller
|
238
|
+
end
|
239
|
+
end
|
169
240
|
end
|
170
241
|
end
|
@@ -1,8 +1,11 @@
|
|
1
1
|
<% content_for :header do %>
|
2
|
+
<div class="main-header--buttons">
|
3
|
+
<%= link_to "New #{ @structure.name.humanize.split.map(&:capitalize).join(' ') }", new_structure_component_path , class: 'main-header--link btn btn-primary' %>
|
4
|
+
</div>
|
2
5
|
<h3><%= "#{ t :edit }".capitalize %> <%= @structure.name.humanize.split.map(&:capitalize).join(' ') %></h3>
|
3
6
|
<a href="<%= structure_components_path %>" class="main-header--back"><span class="glyphicon glyphicon-list"></span> <%= "#{ t :back_to_index }".capitalize %></a>
|
4
7
|
<% end %>
|
5
8
|
|
6
9
|
<% content_for :content do %>
|
7
|
-
<%= render 'form_body' %>
|
10
|
+
<%= render 'binda/fieldable/form_body' %>
|
8
11
|
<% end %>
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<div class="row">
|
2
2
|
<div class="form-body--container col-sm-12">
|
3
3
|
|
4
|
-
<%= simple_form_for field_group, url: get_form_field_group_url, defaults: { label: false }, html: { class: 'form-body' } do |f| %>
|
4
|
+
<%= simple_form_for @field_group, url: get_form_field_group_url, defaults: { label: false }, html: { class: 'form-body' } do |f| %>
|
5
5
|
|
6
|
-
<% if field_group.errors.any? %>
|
6
|
+
<% if @field_group.errors.any? %>
|
7
7
|
<div id="error_explanation">
|
8
|
-
<h2><%= pluralize( field_group.errors.count, "error") %> prohibited this field_group from being saved:</h2>
|
8
|
+
<h2><%= pluralize( @field_group.errors.count, "error") %> prohibited this field_group from being saved:</h2>
|
9
9
|
|
10
10
|
<ul>
|
11
|
-
<% field_group.errors.full_messages.each do |message| %>
|
11
|
+
<% @field_group.errors.full_messages.each do |message| %>
|
12
12
|
<li><%= message %></li>
|
13
13
|
<% end %>
|
14
14
|
</ul>
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<h5><%= "#{ t :title }".capitalize %></h5>
|
26
26
|
<%= f.input :name %>
|
27
27
|
|
28
|
-
<% if field_group.slug.nil? %>
|
28
|
+
<% if @field_group.slug.nil? %>
|
29
29
|
<%= f.input :slug, as: :hidden %>
|
30
30
|
<% else %>
|
31
31
|
<h5><%= "#{ t :slug }".capitalize %></h5>
|
@@ -37,17 +37,17 @@
|
|
37
37
|
<div class="form-section--wide-container row">
|
38
38
|
<div class="col-sm-12 form-section">
|
39
39
|
|
40
|
-
<%= render "form_section",
|
40
|
+
<%= render "form_section", f: f %>
|
41
41
|
|
42
42
|
</div>
|
43
43
|
</div>
|
44
|
-
<% field_group.field_settings.where( field_type: 'repeater' ).order( :position ).each do |repeater| %>
|
44
|
+
<% @field_group.field_settings.where( field_type: 'repeater' ).order( :position, :id ).each do |repeater| %>
|
45
45
|
<div class="form-section--wide-container row">
|
46
46
|
<div class="col-sm-12 form-section">
|
47
47
|
|
48
48
|
<h4><%= repeater.name.capitalize %></h4>
|
49
49
|
|
50
|
-
<%= render "form_section_repeater",
|
50
|
+
<%= render "form_section_repeater", f: f, repeater: repeater %>
|
51
51
|
|
52
52
|
</div>
|
53
53
|
</div>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<% if ff.object.slug.nil? %>
|
9
9
|
<a class="form-item--remove-item-with-js" data-confirm="This operation will delete this setting and all related component content. Are you ok with that?"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
|
10
10
|
<% else %>
|
11
|
-
<a href="<%= structure_field_group_field_setting_path(
|
11
|
+
<a href="<%= structure_field_group_field_setting_path( @structure, @field_group, ff.object ) %>" data-method="delete" data-confirm="This operation will delete this setting and all related component content. Are you ok with that?"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
|
12
12
|
<a class="form-item--close-button"><span class="glyphicon glyphicon-chevron-up" aria-hidden="true"></span></a>
|
13
13
|
<a class="form-item--open-button"><span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span></a>
|
14
14
|
<div class="form-item--label">
|
@@ -74,13 +74,13 @@
|
|
74
74
|
<%= ff.input :position, as: :integer, input_html: { class: "form-item--input" } %>
|
75
75
|
</div>
|
76
76
|
|
77
|
-
<% choiceables = ['radio', '
|
77
|
+
<% choiceables = ['radio', 'selection', 'checkbox'] %>
|
78
78
|
<% if choiceables.include? ff.object.field_type %>
|
79
79
|
|
80
80
|
<%# - - - - - - - - - - - - %>
|
81
81
|
<%# CHOICES %>
|
82
82
|
<%# - - - - - - - - - - - - %>
|
83
|
-
<%= render 'form_item_choice', f: f, ff: ff
|
83
|
+
<%= render 'form_item_choice', f: f, ff: ff %>
|
84
84
|
|
85
85
|
<% end %>
|
86
86
|
|