binda 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -2,6 +2,7 @@
|
|
2
2
|
<%# CHOICES %>
|
3
3
|
<%# - - - - - - - - - - - - %>
|
4
4
|
<h5><%= t(:choices).capitalize %></h5>
|
5
|
+
|
5
6
|
<div class="form-item--choices">
|
6
7
|
|
7
8
|
<%= ff.simple_fields_for :choices, ff.object.choices.order( :label ) do |fff| %>
|
@@ -82,15 +83,17 @@
|
|
82
83
|
<% if ff.object.choices.find_all{|c| c.persisted? }.any? %>
|
83
84
|
<div class="form-item--half-size">
|
84
85
|
<h5><%= t(:default_choice).capitalize %></h5>
|
85
|
-
<%= ff.input :default_choice_id, as: :select, collection: ff.object.choices.find_all{|c| c.persisted? }, label_method: :label, include_blank: false, selected: ff.object.
|
86
|
+
<%= ff.input :default_choice_id, as: :select, collection: ff.object.choices.find_all{|c| c.persisted? }, label_method: :label, include_blank: false, selected: ff.object.default_choice_id, hint: t(:default_choice_description).capitalize %>
|
86
87
|
</div>
|
87
88
|
<% end %>
|
88
89
|
|
89
90
|
|
90
|
-
|
91
|
-
<%#
|
92
|
-
<%#
|
93
|
-
|
94
|
-
<
|
95
|
-
|
96
|
-
|
91
|
+
<% if ff.object.field_type == 'checkbox' %>
|
92
|
+
<%# - - - - - - - - - - - - %>
|
93
|
+
<%# ALLOW NULL %>
|
94
|
+
<%# - - - - - - - - - - - - %>
|
95
|
+
<div class="form-item--half-size">
|
96
|
+
<h5><%= t(:allow_null).capitalize %></h5>
|
97
|
+
<%= ff.input :allow_null, as: :boolean, boolean_style: :inline, input_html: { class: "form-item--input" }, checked_value: true, unchecked_value: false, selected: ff.object.allow_null, default: false %>
|
98
|
+
</div>
|
99
|
+
<% end %>
|
@@ -6,9 +6,9 @@
|
|
6
6
|
<%# - - - - - - - - - - - - %>
|
7
7
|
<%# This form is only for settings which are not part of any repeater. %>
|
8
8
|
<%# This is done using `where( ancestry: nil )` %>
|
9
|
-
<%= f.simple_fields_for :field_settings, f.object.field_settings.where( ancestry: nil ).order( :position ) do |ff| %>
|
9
|
+
<%= f.simple_fields_for :field_settings, f.object.field_settings.where( ancestry: nil ).order( :position, :name ) do |ff| %>
|
10
10
|
<div class="form-item <%= "form-item--#{ ff.object.field_type }" unless ff.object.field_type.nil? %>">
|
11
|
-
<%= render 'form_item', f: f, ff: ff
|
11
|
+
<%= render 'form_item', f: f, ff: ff %>
|
12
12
|
</div>
|
13
13
|
<% end %>
|
14
14
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<%# - - - - - - - - - - - - %>
|
19
19
|
<%= f.simple_fields_for 'new_field_settings[]', @field_group.field_settings.build( field_group: @field_group ) do |ff| %>
|
20
20
|
<div id="new-child-<%= f.object.id %>" class="form-item form-item--new">
|
21
|
-
<%= render 'form_item', f: f, ff: ff
|
21
|
+
<%= render 'form_item', f: f, ff: ff %>
|
22
22
|
</div>
|
23
23
|
<% end %>
|
24
24
|
|
@@ -26,12 +26,12 @@
|
|
26
26
|
<%# - - - - - - - - - - - - - - %>
|
27
27
|
<%# 'ADD NEW FORM ITEM' BUTTON %>
|
28
28
|
<%# - - - - - - - - - - - - - - %>
|
29
|
-
<% if
|
29
|
+
<% if @field_group.slug.nil? %>
|
30
30
|
<h5>
|
31
31
|
<%= t( :hint_create_parent_before_child, arg1: "#{ t :field_group }", arg2: "#{ t :field_setting }" ).capitalize %>
|
32
32
|
</h5>
|
33
33
|
<% else %>
|
34
|
-
<a class="form-item--add-new main-header--link btn btn-default" href="<%= new_structure_field_group_field_setting_path( field_group_id:
|
34
|
+
<a class="form-item--add-new main-header--link btn btn-default" href="<%= new_structure_field_group_field_setting_path( field_group_id: @field_group.slug ) %>" data-new-child-id="new-child-<%= f.object.id %>">
|
35
35
|
<%= "#{ t :new }".capitalize %> <%= t :field_setting %>
|
36
36
|
</a>
|
37
37
|
<% end %>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%# - - - - - - - - - - - - %>
|
2
2
|
<%# FORM ITEMS %>
|
3
3
|
<%# - - - - - - - - - - - - %>
|
4
|
-
<%= f.simple_fields_for :field_settings, repeater.children.order( :position ) do |ff| %>
|
4
|
+
<%= f.simple_fields_for :field_settings, repeater.children.order( :position, :name ) do |ff| %>
|
5
5
|
<div class="form-item <%= "form-item--#{ ff.object.field_type }" unless ff.object.field_type.nil? %>">
|
6
|
-
<%= render 'form_item', f: f, ff: ff
|
6
|
+
<%= render 'form_item', f: f, ff: ff %>
|
7
7
|
</div>
|
8
8
|
<% end %>
|
9
9
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<%# - - - - - - - - - - - - %>
|
13
13
|
<%= f.simple_fields_for 'new_field_settings[]', repeater.children.build( field_group: @field_group ) do |ff| %>
|
14
14
|
<div id="new-child--repeater-<%= repeater.id %>" class="form-item form-item--new">
|
15
|
-
<%= render 'form_item', f: f, ff: ff
|
15
|
+
<%= render 'form_item', f: f, ff: ff %>
|
16
16
|
</div>
|
17
17
|
<% end %>
|
18
18
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<div class="row">
|
2
2
|
<div class="form-body--container col-sm-12">
|
3
3
|
|
4
|
-
<%= simple_form_for @
|
4
|
+
<%= simple_form_for [ @instance.structure, @instance ], defaults: { label: false }, html: { class: 'form-body' } do |f| %>
|
5
5
|
<%= f.error_notification %>
|
6
6
|
|
7
7
|
<%# - - - - - - - - - - - - %>
|
8
8
|
<%# SET POSITION %>
|
9
9
|
<%# - - - - - - - - - - - - %>
|
10
|
-
<% unless
|
10
|
+
<% unless f.object.new_record? %>
|
11
11
|
<%= f.input :position, as: :hidden %>
|
12
12
|
<% end %>
|
13
13
|
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<h5><%= "#{ t :title }".capitalize %></h5>
|
26
26
|
<%= f.input :name %>
|
27
27
|
|
28
|
-
<% if
|
28
|
+
<% if f.object.slug.nil? %>
|
29
29
|
<%= f.input :slug, as: :hidden %>
|
30
30
|
<% else %>
|
31
31
|
<h5><%= "#{ t :slug }".capitalize %></h5>
|
@@ -40,21 +40,21 @@
|
|
40
40
|
<%# - - - - - - - - - - - - %>
|
41
41
|
<%# FIELD GROUP LOOP %>
|
42
42
|
<%# - - - - - - - - - - - - %>
|
43
|
-
<% @structure.field_groups.order( :position ).each_with_index do |field_group, index| %>
|
43
|
+
<% @structure.field_groups.order( :position, :name ).each_with_index do |field_group, index| %>
|
44
44
|
<div class="form-section--wide-container row">
|
45
45
|
<div class="col-sm-12">
|
46
46
|
|
47
47
|
<h4><%= field_group.name.capitalize %></h4>
|
48
48
|
|
49
|
-
<% if
|
49
|
+
<% if f.object.new_record? %>
|
50
50
|
|
51
|
-
<h5><%= t( :hint_create_parent_before_child, arg1: "#{ t :
|
51
|
+
<h5><%= t( :hint_create_parent_before_child, arg1: "#{ t :instance }", arg2: "#{ t :detail }" ).capitalize %></h5>
|
52
52
|
|
53
53
|
<% else %>
|
54
54
|
|
55
|
-
<% field_group.field_settings.order( :position ).each do |field_setting| %>
|
55
|
+
<% field_group.field_settings.order( :position, :name ).each do |field_setting| %>
|
56
56
|
<% next unless field_setting.is_root? %>
|
57
|
-
<%= render "form_section", f: f, field_setting: field_setting %>
|
57
|
+
<%= render "binda/fieldable/form_section", f: f, field_setting: field_setting %>
|
58
58
|
<% end %>
|
59
59
|
|
60
60
|
<% end %>
|
@@ -72,7 +72,7 @@
|
|
72
72
|
<div class="form-section--narrow-container row">
|
73
73
|
<div class="col-sm-12">
|
74
74
|
|
75
|
-
<%= render "form_sidebar", f: f %>
|
75
|
+
<%= render "binda/fieldable/form_sidebar", f: f %>
|
76
76
|
|
77
77
|
</div>
|
78
78
|
</div>
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%# - - - - - - - - - - - - - - %>
|
2
2
|
<%# REPEATER NEW FIELDS %>
|
3
3
|
<%# - - - - - - - - - - - - - - %>
|
4
|
-
<%= simple_form_for @
|
4
|
+
<%= simple_form_for [@instance.structure, @instance], defaults: { label: false } do |f| %>
|
5
5
|
<!-- SPLIT -->
|
6
6
|
<li id="repeater_<%= @repeater.id %>">
|
7
7
|
|
@@ -14,13 +14,13 @@
|
|
14
14
|
<%# FIRST REPEATER %>
|
15
15
|
<%# - - - - - - - - - - - - - - %>
|
16
16
|
<div class="form-item--repeater-fields">
|
17
|
-
<%= f.simple_fields_for "repeaters_attributes[]", repeater do |ff| %>
|
17
|
+
<%= f.simple_fields_for "repeaters_attributes[]", @repeater do |ff| %>
|
18
18
|
<%= ff.input :fieldable_id, as: :hidden %>
|
19
19
|
<%= ff.input :fieldable_type, as: :hidden %>
|
20
|
-
<%= ff.input :field_setting_id, as: :hidden, input_html: { value:
|
20
|
+
<%= ff.input :field_setting_id, as: :hidden, input_html: { value: ff.object.field_setting.id } %>
|
21
21
|
<%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %>
|
22
|
-
<%
|
23
|
-
<%= render "form_section_repeater", f: ff, repeater_setting_child: repeater_setting_child
|
22
|
+
<% ff.object.field_setting.children.order( :position, :id ).each do |repeater_setting_child| %>
|
23
|
+
<%= render "binda/fieldable/form_section_repeater", f: ff, repeater_setting_child: repeater_setting_child %>
|
24
24
|
<% end %>
|
25
25
|
<% end %>
|
26
26
|
</div>
|
@@ -8,11 +8,11 @@
|
|
8
8
|
<%= repeater_setting.name %>
|
9
9
|
</h5>
|
10
10
|
|
11
|
-
<ul id="form-item--repeater-setting-<%= repeater_setting.id %>" class="sortable sortable--disabled" data-update-url="<%=
|
11
|
+
<ul id="form-item--repeater-setting-<%= repeater_setting.id %>" class="sortable sortable--disabled" data-update-url="<%= url_for([@structure, @instance, :sort_repeaters]) %>">
|
12
12
|
|
13
13
|
<% if repeaters.size == 0 %>
|
14
14
|
|
15
|
-
<% repeater = @
|
15
|
+
<% repeater = @instance.find_or_create_a_field_by( repeater_setting.id, 'repeater' ) %>
|
16
16
|
|
17
17
|
<li id="repeater_<%= repeater.id %>">
|
18
18
|
|
@@ -30,8 +30,8 @@
|
|
30
30
|
<%= ff.input :fieldable_type, as: :hidden %>
|
31
31
|
<%= ff.input :field_setting_id, as: :hidden, input_html: { value: repeater_setting.id } %>
|
32
32
|
<%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %>
|
33
|
-
<% repeater_setting.children.order( :position ).each do |repeater_setting_child| %>
|
34
|
-
<%= render "form_section_repeater", f: ff, repeater_setting_child: repeater_setting_child
|
33
|
+
<% repeater_setting.children.order( :position, :id ).each do |repeater_setting_child| %>
|
34
|
+
<%= render "binda/fieldable/form_section_repeater", f: ff, repeater_setting_child: repeater_setting_child %>
|
35
35
|
<% end %>
|
36
36
|
<% end %>
|
37
37
|
</div>
|
@@ -52,12 +52,12 @@
|
|
52
52
|
<%# - - - - - - - - - - - - - - %>
|
53
53
|
<div class="form-item--repeater-fields">
|
54
54
|
<%= f.simple_fields_for "repeaters_attributes[]", repeater do |ff| %>
|
55
|
-
<%= ff.input :field_setting_id, as: :hidden, input_html: { value:
|
55
|
+
<%= ff.input :field_setting_id, as: :hidden, input_html: { value: ff.object.field_setting.id } %>
|
56
56
|
<%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %>
|
57
57
|
<%= ff.input :fieldable_id, as: :hidden %>
|
58
58
|
<%= ff.input :fieldable_type, as: :hidden %>
|
59
|
-
<%
|
60
|
-
<%= render "form_section_repeater", f: ff, repeater_setting_child: repeater_setting_child, repeater: repeater %>
|
59
|
+
<% ff.object.field_setting.children.order( :position, :id ).each do |repeater_setting_child| %>
|
60
|
+
<%= render "binda/fieldable/form_section_repeater", f: ff, repeater_setting_child: repeater_setting_child, repeater: repeater %>
|
61
61
|
<% end %>
|
62
62
|
<% end %>
|
63
63
|
</div>
|
@@ -74,8 +74,7 @@
|
|
74
74
|
<%# - - - - - - - - - - - - - - %>
|
75
75
|
<%# ADD NEW REPEATER FIELDS %>
|
76
76
|
<%# - - - - - - - - - - - - - - %>
|
77
|
-
<a class="form-item--repeater-section--add-new main-header--link btn btn-default" href="#" data-url="<%=
|
77
|
+
<a class="form-item--repeater-section--add-new main-header--link btn btn-default" href="#" data-url="<%= url_for([@structure, @instance, :new_repeater]) %>" data-id="<%= repeater_setting.id %>">
|
78
78
|
<%= t(:new_item_in_repeater, arg1: repeater_setting.name.capitalize ) %>
|
79
79
|
</a>
|
80
|
-
|
81
80
|
<hr>
|
@@ -0,0 +1,99 @@
|
|
1
|
+
<%# HEADING %>
|
2
|
+
<h5 class="form-item--<%= field_setting.field_type.underscore %>-caption"><%= field_setting.name.capitalize %></h5>
|
3
|
+
|
4
|
+
<% unless field_setting.description.blank? %>
|
5
|
+
<small class="text-muted"><%= field_setting.description %></small>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% if field_setting.choices.any? %>
|
9
|
+
|
10
|
+
<%# - - - - - - - - - - - - %>
|
11
|
+
<%# RADIO %>
|
12
|
+
<%# - - - - - - - - - - - - %>
|
13
|
+
<% if field_setting.field_type === 'radio' %>
|
14
|
+
<% current = f.object.find_or_create_a_field_by( field_setting.id, 'radio' ) %>
|
15
|
+
<%= f.simple_fields_for "radios_attributes[]", current do |ff| %>
|
16
|
+
<% if ff.object.choices.any? %>
|
17
|
+
<% unless field_setting.allow_null %>
|
18
|
+
<%= ff.input :choice_ids, as: :radio_buttons, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: ff.object.choices.first.id %>
|
19
|
+
<% else %>
|
20
|
+
<%= ff.input :choice_ids, as: :radio_buttons, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: ff.object.choices.first.id, include_blank: false %>
|
21
|
+
<% end %>
|
22
|
+
<% else %>
|
23
|
+
<% unless field_setting.allow_null %>
|
24
|
+
<%= ff.input :choice_ids, as: :radio_buttons, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: field_setting.default_choice.id %>
|
25
|
+
<% else %>
|
26
|
+
<%= ff.input :choice_ids, as: :radio_buttons, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: field_setting.default_choice.id, include_blank: false %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
<%= ff.input :field_setting_id, as: :hidden, input_html: { value: field_setting.id } %>
|
30
|
+
<%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %>
|
31
|
+
<%= ff.input :fieldable_id, as: :hidden %>
|
32
|
+
<%= ff.input :fieldable_type, as: :hidden %>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
|
36
|
+
<%# - - - - - - - - - - - - %>
|
37
|
+
<%# SELECT %>
|
38
|
+
<%# - - - - - - - - - - - - %>
|
39
|
+
<% elsif field_setting.field_type === 'selection' %>
|
40
|
+
<% current = f.object.find_or_create_a_field_by( field_setting.id, 'selection' ) %>
|
41
|
+
<%= f.simple_fields_for "selections_attributes[]", current do |ff| %>
|
42
|
+
<% if ff.object.choices.any? %>
|
43
|
+
<% unless field_setting.allow_null %>
|
44
|
+
<%= ff.input :choice_ids, as: :select, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, selected: ff.object.choices.first.id %>
|
45
|
+
<% else %>
|
46
|
+
<%= ff.input :choice_ids, as: :select, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, selected: ff.object.choices.first.id, include_blank: false %>
|
47
|
+
<% end %>
|
48
|
+
<% else %>
|
49
|
+
<% unless field_setting.allow_null %>
|
50
|
+
<%= ff.input :choice_ids, as: :select, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, selected: field_setting.default_choice.id %>
|
51
|
+
<% else %>
|
52
|
+
<%= ff.input :choice_ids, as: :select, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, selected: field_setting.default_choice.id, include_blank: false %>
|
53
|
+
<% end %>
|
54
|
+
<% end %>
|
55
|
+
<%= ff.input :field_setting_id, as: :hidden, input_html: { value: field_setting.id } %>
|
56
|
+
<%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %>
|
57
|
+
<%= ff.input :fieldable_id, as: :hidden %>
|
58
|
+
<%= ff.input :fieldable_type, as: :hidden %>
|
59
|
+
<% end %>
|
60
|
+
|
61
|
+
|
62
|
+
<%# - - - - - - - - - - - - %>
|
63
|
+
<%# CHECKBOX %>
|
64
|
+
<%# - - - - - - - - - - - - %>
|
65
|
+
<% elsif field_setting.field_type === 'checkbox' %>
|
66
|
+
<% current = f.object.find_or_create_a_field_by( field_setting.id, 'checkbox' ) %>
|
67
|
+
<%= f.simple_fields_for "checkboxes_attributes[]", current do |ff| %>
|
68
|
+
<% if ff.object.choices.any? %>
|
69
|
+
<% if field_setting.allow_null %>
|
70
|
+
<%= ff.input :choice_ids, as: :check_boxes, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id %>
|
71
|
+
<% else %>
|
72
|
+
<small class="text-muted"><%= t('null_is_not_allowed') %></small>
|
73
|
+
<%= ff.input :choice_ids, as: :check_boxes, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: ff.object.choice_ids, include_blank: false, include_hidden: false %>
|
74
|
+
<% end %>
|
75
|
+
<% else %>
|
76
|
+
<% if field_setting.allow_null %>
|
77
|
+
<%= ff.input :choice_ids, as: :check_boxes, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id %>
|
78
|
+
<% else %>
|
79
|
+
<small class="text-muted"><%= t('null_is_not_allowed') %></small>
|
80
|
+
<%= ff.input :choice_ids, as: :check_boxes, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: field_setting.default_choice.id, include_blank: false, include_hidden: false %>
|
81
|
+
<% end %>
|
82
|
+
<% end %>
|
83
|
+
<%= ff.input :field_setting_id, as: :hidden, input_html: { value: field_setting.id } %>
|
84
|
+
<%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %>
|
85
|
+
<%= ff.input :fieldable_id, as: :hidden %>
|
86
|
+
<%= ff.input :fieldable_type, as: :hidden %>
|
87
|
+
<% end %>
|
88
|
+
<% end %>
|
89
|
+
|
90
|
+
<% else %>
|
91
|
+
<p>Sorry, no choice is available.
|
92
|
+
<% if current_user.is_superadmin %>
|
93
|
+
Please ensure you setup at least two possible choices in the <a href="<%= edit_structure_field_group_path( structure_id: @structure.id, id: field_setting.field_group.id )%>">field group setup</a>.
|
94
|
+
<% else %>
|
95
|
+
Please contact the administrator.
|
96
|
+
<% end %>
|
97
|
+
</p>
|
98
|
+
<% end %>
|
99
|
+
<hr>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%# HEADING %>
|
2
|
+
<h5 class="form-item--<%= field_setting.field_type.underscore %>-caption"><%= field_setting.name.capitalize %></h5>
|
3
|
+
|
4
|
+
<% unless field_setting.description.blank? %>
|
5
|
+
<small class="text-muted"><%= field_setting.description %></small>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
|
9
|
+
<% if @instance.has_string( field_setting.slug ) %>
|
10
|
+
<%= ff.input :content, input_html: { value: @instance.get_string( field_setting.slug ) }, as: :string %>
|
11
|
+
<% else %>
|
12
|
+
<%= ff.input :content, as: :string %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
|
16
|
+
<%= ff.input :field_setting_id, as: :hidden, input_html: { value: field_setting.id } %>
|
17
|
+
<%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %>
|
18
|
+
<%= ff.input :fieldable_id, as: :hidden %>
|
19
|
+
<%= ff.input :fieldable_type, as: :hidden %>
|
@@ -6,19 +6,10 @@
|
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
<% if field_setting.field_type == 'text' %>
|
12
|
-
<%= ff.input :content, input_html: { value: @component.get_text( field_setting.slug ), class: 'tinymce' }, as: :text %>
|
13
|
-
<% else %>
|
14
|
-
<%= ff.input :content, input_html: { value: @component.get_text( field_setting.slug ) }, as: :string %>
|
15
|
-
<% end %>
|
9
|
+
<% if @instance.has_text( field_setting.slug ) %>
|
10
|
+
<%= ff.input :content, input_html: { value: @instance.get_text( field_setting.slug ), class: 'tinymce' }, as: :text %>
|
16
11
|
<% else %>
|
17
|
-
<% if field_setting.field_type == 'text' %>
|
18
12
|
<%= ff.input :content, input_html: { class: 'tinymce' }, as: :text %>
|
19
|
-
<% else %>
|
20
|
-
<%= ff.input :content, as: :string %>
|
21
|
-
<% end %>
|
22
13
|
<% end %>
|
23
14
|
|
24
15
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<%# - - - - - - - - - - - - %>
|
2
|
+
<%# TEXT %>
|
3
|
+
<%# - - - - - - - - - - - - %>
|
4
|
+
<% if field_setting.field_type == 'text' %>
|
5
|
+
<% current = @instance.find_or_create_a_field_by( field_setting.id, 'text' ) %>
|
6
|
+
<%= f.simple_fields_for "texts_attributes[]", current do |ff| %>
|
7
|
+
<%= render 'binda/fieldable/form_item_text', ff: ff, field_setting: field_setting %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
|
11
|
+
<%# - - - - - - - - - - - - %>
|
12
|
+
<%# STRING %>
|
13
|
+
<%# - - - - - - - - - - - - %>
|
14
|
+
<% elsif field_setting.field_type == 'string' %>
|
15
|
+
<% current = @instance.find_or_create_a_field_by( field_setting.id, 'string' ) %>
|
16
|
+
<%= f.simple_fields_for "strings_attributes[]", current do |ff| %>
|
17
|
+
<%= render 'binda/fieldable/form_item_string', ff: ff, field_setting: field_setting %>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
|
21
|
+
<%# - - - - - - - - - - - - %>
|
22
|
+
<%# DATE %>
|
23
|
+
<%# - - - - - - - - - - - - %>
|
24
|
+
<% elsif field_setting.field_type == 'date' %>
|
25
|
+
<% current = @instance.find_or_create_a_field_by( field_setting.id, 'date' ) %>
|
26
|
+
<%= f.simple_fields_for "dates_attributes[]", current do |ff| %>
|
27
|
+
<%= render 'binda/fieldable/form_item_date', ff: ff, field_setting: field_setting %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
|
31
|
+
<%# - - - - - - - - - - - - %>
|
32
|
+
<%# ASSET %>
|
33
|
+
<%# - - - - - - - - - - - - %>
|
34
|
+
<% elsif field_setting.field_type == 'asset' %>
|
35
|
+
<% current = @instance.find_or_create_a_field_by( field_setting.id, 'asset' ) %>
|
36
|
+
<%= f.simple_fields_for "assets_attributes[]", current do |ff| %>
|
37
|
+
<%= render 'binda/fieldable/form_item_asset', ff: ff, field_setting: field_setting %>
|
38
|
+
<% end %>
|
39
|
+
|
40
|
+
|
41
|
+
<%# - - - - - - - - - - - - %>
|
42
|
+
<%# REPEATER %>
|
43
|
+
<%# - - - - - - - - - - - - %>
|
44
|
+
<% elsif field_setting.field_type == 'repeater' %>
|
45
|
+
<% repeaters = @instance.repeaters.where( field_setting: field_setting ).order('position') %>
|
46
|
+
<%= render 'binda/fieldable/form_item_repeater', f: f, repeater_setting: field_setting, repeaters: repeaters %>
|
47
|
+
|
48
|
+
|
49
|
+
<% elsif ['radio', 'selection', 'checkbox'].include? field_setting.field_type %>
|
50
|
+
<%= render 'binda/fieldable/form_item_selections', f: f, field_setting: field_setting %>
|
51
|
+
|
52
|
+
<% end %>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<%# - - - - - - - - - - - - %>
|
2
|
+
<%# TEXT / STRING %>
|
3
|
+
<%# - - - - - - - - - - - - %>
|
4
|
+
<% if repeater_setting_child.field_type == 'text' %>
|
5
|
+
<% current = f.object.find_or_create_a_field_by( repeater_setting_child.id, 'text' ) %>
|
6
|
+
<%= f.simple_fields_for "texts_attributes[]", current do |ff| %>
|
7
|
+
<%= render 'binda/fieldable/form_item_text', ff: ff, field_setting: repeater_setting_child %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
|
11
|
+
<%# - - - - - - - - - - - - %>
|
12
|
+
<%# STRING %>
|
13
|
+
<%# - - - - - - - - - - - - %>
|
14
|
+
<% elsif repeater_setting_child.field_type == 'string' %>
|
15
|
+
<% current = f.object.find_or_create_a_field_by( repeater_setting_child.id, 'string' ) %>
|
16
|
+
<%= f.simple_fields_for "strings_attributes[]", current do |ff| %>
|
17
|
+
<%= render 'binda/fieldable/form_item_string', ff: ff, field_setting: repeater_setting_child %>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
|
21
|
+
<%# - - - - - - - - - - - - %>
|
22
|
+
<%# DATE %>
|
23
|
+
<%# - - - - - - - - - - - - %>
|
24
|
+
<% elsif repeater_setting_child.field_type == 'date' %>
|
25
|
+
<% current = f.object.find_or_create_a_field_by( repeater_setting_child.id, 'date' ) %>
|
26
|
+
<%= f.simple_fields_for "dates_attributes[]", current do |ff| %>
|
27
|
+
<%= render 'binda/fieldable/form_item_date', ff: ff, field_setting: repeater_setting_child %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
|
31
|
+
<%# - - - - - - - - - - - - %>
|
32
|
+
<%# ASSET %>
|
33
|
+
<%# - - - - - - - - - - - - %>
|
34
|
+
<% elsif repeater_setting_child.field_type == 'asset' %>
|
35
|
+
<% current = f.object.find_or_create_a_field_by( repeater_setting_child.id, 'asset' ) %>
|
36
|
+
<%= f.simple_fields_for "assets_attributes[]", current do |ff| %>
|
37
|
+
<%= render 'binda/fieldable/form_item_asset', ff: ff, field_setting: repeater_setting_child %>
|
38
|
+
<% end %>
|
39
|
+
|
40
|
+
|
41
|
+
<%# - - - - - - - - - - - - %>
|
42
|
+
<%# SELECTABLES %>
|
43
|
+
<%# - - - - - - - - - - - - %>
|
44
|
+
<% elsif ['radio', 'select', 'checkbox'].include? repeater_setting_child.field_type %>
|
45
|
+
<%# current = f.object.find_or_create_a_field_by( repeater_setting_child.id, 'radio' ) %>
|
46
|
+
<%= render 'binda/fieldable/form_item_selectable', f: f, field_setting: repeater_setting_child %>
|
47
|
+
|
48
|
+
<% end %>
|