kono_utils_bootstrap_view4 0.1.0.pre.rc.3 → 0.1.0.pre.rc.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/concepts/kono_utils/object/cell/base.rb +99 -97
- data/app/concepts/kono_utils/object/cell/buttons/base.rb +55 -54
- data/app/concepts/kono_utils/object/cell/buttons/collapse_search.rb +29 -23
- data/app/concepts/kono_utils/object/cell/buttons/create.rb +20 -15
- data/app/concepts/kono_utils/object/cell/buttons/delete.rb +29 -24
- data/app/concepts/kono_utils/object/cell/buttons/download.rb +22 -16
- data/app/concepts/kono_utils/object/cell/buttons/edit.rb +17 -12
- data/app/concepts/kono_utils/object/cell/buttons/list.rb +17 -11
- data/app/concepts/kono_utils/object/cell/buttons/reset_search.rb +21 -15
- data/app/concepts/kono_utils/object/cell/create/base.rb +6 -5
- data/app/concepts/kono_utils/object/cell/create/page_title.rb +11 -6
- data/app/concepts/kono_utils/object/cell/create/side_title.rb +8 -2
- data/app/concepts/kono_utils/object/cell/edits/base.rb +6 -5
- data/app/concepts/kono_utils/object/cell/edits/page_title.rb +11 -6
- data/app/concepts/kono_utils/object/cell/edits/side_title.rb +9 -3
- data/app/concepts/kono_utils/object/cell/form.rb +51 -48
- data/app/concepts/kono_utils/object/cell/forms/base.rb +12 -10
- data/app/concepts/kono_utils/object/cell/forms/container.rb +22 -18
- data/app/concepts/kono_utils/object/cell/forms/containers/layout.rb +14 -10
- data/app/concepts/kono_utils/object/cell/forms/containers/modal_layout.rb +10 -4
- data/app/concepts/kono_utils/object/cell/forms/containers/search_layout.rb +10 -4
- data/app/concepts/kono_utils/object/cell/forms/containers/table_layout.rb +11 -5
- data/app/concepts/kono_utils/object/cell/forms/field_selector.rb +68 -64
- data/app/concepts/kono_utils/object/cell/forms/field_selectors/layout.rb +9 -4
- data/app/concepts/kono_utils/object/cell/forms/field_selectors/modal_layout.rb +10 -4
- data/app/concepts/kono_utils/object/cell/forms/field_selectors/table_layout.rb +11 -5
- data/app/concepts/kono_utils/object/cell/forms/fields/association.rb +11 -4
- data/app/concepts/kono_utils/object/cell/forms/fields/base.rb +21 -16
- data/app/concepts/kono_utils/object/cell/forms/fields/bases/layout.rb +24 -17
- data/app/concepts/kono_utils/object/cell/forms/fields/bases/modal_layout.rb +14 -4
- data/app/concepts/kono_utils/object/cell/forms/fields/bases/table_layout.rb +17 -7
- data/app/concepts/kono_utils/object/cell/forms/fields/check_box.rb +14 -6
- data/app/concepts/kono_utils/object/cell/forms/fields/collection.rb +20 -12
- data/app/concepts/kono_utils/object/cell/forms/fields/date_field.rb +18 -10
- data/app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb +34 -30
- data/app/concepts/kono_utils/object/cell/forms/fields/enum.rb +23 -15
- data/app/concepts/kono_utils/object/cell/forms/fields/file_field.rb +29 -21
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrapper.rb +10 -3
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrappers/forms_container.rb +13 -5
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrappers/show.rb +19 -10
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrapper.rb +54 -49
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/form.rb +41 -35
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/layout.rb +17 -8
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/modal_layout.rb +14 -4
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/table_layout.rb +14 -4
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_container.rb +44 -36
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/layout.rb +17 -10
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/modal_layout.rb +17 -6
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/table_layout.rb +20 -11
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/header.rb +31 -23
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_button.rb +46 -40
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/layout.rb +14 -7
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/modal_layout.rb +14 -4
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/table_layout.rb +14 -4
- data/app/concepts/kono_utils/object/cell/forms/fields/read_only.rb +16 -9
- data/app/concepts/kono_utils/object/cell/forms/fields/time_field.rb +14 -7
- data/app/concepts/kono_utils/object/cell/forms/layout.rb +8 -4
- data/app/concepts/kono_utils/object/cell/forms/submit.rb +21 -16
- data/app/concepts/kono_utils/object/cell/index/base.rb +9 -7
- data/app/concepts/kono_utils/object/cell/index/page_title.rb +11 -6
- data/app/concepts/kono_utils/object/cell/index/row.rb +38 -36
- data/app/concepts/kono_utils/object/cell/index/row_buttons.rb +8 -4
- data/app/concepts/kono_utils/object/cell/index/row_footer.rb +8 -3
- data/app/concepts/kono_utils/object/cell/index/row_header.rb +13 -7
- data/app/concepts/kono_utils/object/cell/index/side_title.rb +8 -2
- data/app/concepts/kono_utils/object/cell/index/table.rb +12 -9
- data/app/concepts/kono_utils/object/cell/inject.rb +103 -102
- data/app/concepts/kono_utils/object/cell/modals/base.rb +7 -3
- data/app/concepts/kono_utils/object/cell/modals/bodies/layout.rb +9 -4
- data/app/concepts/kono_utils/object/cell/modals/body.rb +7 -3
- data/app/concepts/kono_utils/object/cell/modals/container.rb +5 -1
- data/app/concepts/kono_utils/object/cell/modals/containers/layout.rb +12 -6
- data/app/concepts/kono_utils/object/cell/modals/footer.rb +5 -2
- data/app/concepts/kono_utils/object/cell/modals/footers/layout.rb +9 -4
- data/app/concepts/kono_utils/object/cell/modals/header.rb +6 -3
- data/app/concepts/kono_utils/object/cell/modals/headers/layout.rb +9 -4
- data/app/concepts/kono_utils/object/cell/search.rb +22 -19
- data/app/concepts/kono_utils/object/cell/searches/form.rb +12 -9
- data/app/concepts/kono_utils/object/cell/show.rb +25 -20
- data/app/concepts/kono_utils/object/cell/shows/base.rb +6 -5
- data/app/concepts/kono_utils/object/cell/shows/page_title.rb +11 -6
- data/app/concepts/kono_utils/object/cell/shows/side_title.rb +8 -2
- data/lib/kono_utils_bootstrap_view4/version.rb +1 -1
- metadata +1 -1
@@ -1,7 +1,17 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
module Bases # namespace
|
7
|
+
# Classe contenitore del campo, serve per deviare nelle situazioni in cui non serve stampare un contenitore(id,_destroy) o campi hidden
|
8
|
+
# il model qua avremo un KonoUtilsBootstrapView4::EditableField
|
9
|
+
class ModalLayout < Layout
|
5
10
|
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
6
16
|
end
|
7
17
|
end
|
@@ -1,11 +1,21 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
module Bases # namespace
|
7
|
+
# Classe contenitore del campo, serve per deviare nelle situazioni in cui non serve stampare un contenitore(id,_destroy) o campi hidden
|
8
|
+
# il model qua avremo un KonoUtilsBootstrapView4::EditableField
|
9
|
+
class TableLayout < Layout
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
|
11
|
+
def cell_column_classes
|
12
|
+
[]
|
13
|
+
end
|
9
14
|
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
10
20
|
end
|
11
21
|
end
|
@@ -1,10 +1,18 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
# Campo checkbox
|
7
|
+
class CheckBox < Base
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
9
|
+
def base_field_options
|
10
|
+
super.merge(as: :boolean)
|
11
|
+
end
|
8
12
|
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
9
17
|
end
|
10
18
|
end
|
@@ -1,17 +1,25 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
#
|
7
|
+
# Classe per la gestione del campo collection
|
8
|
+
class Collection < Base
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
# @return [Hash]
|
11
|
+
def base_field_options
|
12
|
+
super.merge(as: :select, collection: collection)
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
# @return [Array,Hash]
|
16
|
+
def collection
|
17
|
+
options.fetch(:collection, [])
|
18
|
+
end
|
15
19
|
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
@@ -1,15 +1,23 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
# La cella base dei componenti della form contiene sempre la form come model
|
7
|
+
class DateField < DateTimeField
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
9
|
+
def input_picker_format
|
10
|
+
"L"
|
11
|
+
end
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
def input_value
|
14
|
+
value = form.object.send(attribute_name)
|
15
|
+
value.is_a?(Date) ? "date: moment('#{value&.rfc2822}')," : ''
|
16
|
+
end
|
13
17
|
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
14
22
|
end
|
15
23
|
end
|
@@ -1,16 +1,18 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
# La cella base dei componenti della form contiene sempre la form come model
|
7
|
+
class DateTimeField < Base
|
4
8
|
|
9
|
+
def show(&block)
|
5
10
|
|
6
|
-
|
11
|
+
bf = bf = ActiveSupport::SafeBuffer.new
|
12
|
+
bf << form.input(attribute_name, field_options)
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
bf << content_tag(:script, :type => "text/javascript") do
|
13
|
-
raw "(function(){
|
14
|
+
bf << content_tag(:script, :type => "text/javascript") do
|
15
|
+
raw "(function(){
|
14
16
|
$('##{datetime_picker_identifier}').datetimepicker({
|
15
17
|
#{ input_value }
|
16
18
|
locale: '#{I18n.locale}',
|
@@ -20,32 +22,34 @@ module KonoUtils::Object::Cell::Forms::Fields # namespace
|
|
20
22
|
});
|
21
23
|
})();
|
22
24
|
"
|
23
|
-
|
25
|
+
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
+
bf
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
##
|
31
|
+
# Carica il valore nel js per poterlo avere precaricato nel campo
|
32
|
+
#
|
33
|
+
def input_value
|
34
|
+
value = form.object.send(attribute_name)
|
35
|
+
value.is_a?(DateTime) ? "date: moment('#{value&.rfc2822}')," : ''
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
def input_picker_format
|
39
|
+
"L LT"
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
def base_field_options
|
43
|
+
super.merge(as: :tempus_dominus, date_time_picker_identifier: datetime_picker_identifier)
|
44
|
+
end
|
43
45
|
|
46
|
+
def datetime_picker_identifier
|
47
|
+
@_unique ||= SecureRandom.uuid
|
48
|
+
end
|
44
49
|
|
45
|
-
|
46
|
-
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
47
53
|
end
|
48
|
-
|
49
|
-
|
50
54
|
end
|
51
55
|
end
|
@@ -1,20 +1,28 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
#
|
7
|
+
# Classe per la gestione del campo Enum, semplicemente estendendo la collection, ed estrapolando automaticamente
|
8
|
+
# i valori della select e relative traduzioni
|
9
|
+
class Enum < Collection
|
10
|
+
include KonoUtils::ApplicationEnumHelper
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
##
|
13
|
+
# Ritorna la rappresentazione da utilizzare per stampare la select dell'enum
|
14
|
+
# @return [Hash]
|
15
|
+
def collection
|
16
|
+
enum_collection(form.object.class, model.name)
|
17
|
+
end
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
def show(&block)
|
20
|
+
render "forms/fields/collection"
|
21
|
+
end
|
18
22
|
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
@@ -1,31 +1,39 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
class FileField < Base
|
3
7
|
|
4
|
-
|
5
|
-
|
6
|
-
|
8
|
+
def show(&block)
|
9
|
+
form.input(attribute_name, field_options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def base_field_options
|
13
|
+
download_button = nil
|
14
|
+
remove_checkbox = remove_checkbox
|
15
|
+
if form.object.send(attribute_name).attached?
|
16
|
+
download_button = concept("cell/buttons/download", form.object.send(attribute_name), button_options: { class: 'btn-outline-secondary' })
|
17
|
+
if form.object.class.respond_to?(:attribute_purger_name)
|
18
|
+
attribute_purger_name = form.object.class.attribute_purger_name(attribute_name)
|
19
|
+
if form.object.respond_to?(attribute_purger_name)
|
7
20
|
|
8
|
-
|
9
|
-
|
10
|
-
remove_checkbox = remove_checkbox
|
11
|
-
if form.object.send(attribute_name).attached?
|
12
|
-
download_button = concept("cell/buttons/download", form.object.send(attribute_name), button_options: { class: 'btn-outline-secondary' })
|
13
|
-
if form.object.class.respond_to?(:attribute_purger_name)
|
14
|
-
attribute_purger_name = form.object.class.attribute_purger_name(attribute_name)
|
15
|
-
if form.object.respond_to?(attribute_purger_name)
|
21
|
+
label = form.object.class.han(attribute_purger_name,
|
22
|
+
default: I18n.t('kono_utils.bootstrap4.forms.fields.file_field.purge_file.label'))
|
16
23
|
|
17
|
-
|
18
|
-
|
24
|
+
remove_checkbox = concept("cell/forms/fields/check_box",
|
25
|
+
KonoUtilsBootstrapView4::EditableField.new(attribute_purger_name),
|
26
|
+
field_options: { label: label }
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
super.merge({ as: :file_input_download, download_button: download_button, remove_checkbox: remove_checkbox })
|
32
|
+
end
|
19
33
|
|
20
|
-
remove_checkbox = concept("cell/forms/fields/check_box",
|
21
|
-
KonoUtilsBootstrapView4::EditableField.new(attribute_purger_name),
|
22
|
-
field_options: { label: label }
|
23
|
-
)
|
24
34
|
end
|
25
35
|
end
|
26
36
|
end
|
27
|
-
super.merge({ as: :file_input_download, download_button: download_button, remove_checkbox: remove_checkbox })
|
28
37
|
end
|
29
|
-
|
30
38
|
end
|
31
39
|
end
|
@@ -1,6 +1,13 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
class NestedModalWrapper < NestedWrapper
|
4
7
|
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
5
12
|
end
|
6
13
|
end
|
data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrappers/forms_container.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
class NestedModalWrappers::FormsContainer < NestedWrappers::FormsContainer
|
3
7
|
|
4
|
-
|
5
|
-
|
6
|
-
|
8
|
+
def render_cell_container
|
9
|
+
"cell/forms/fields/nested_modal_wrappers/show"
|
10
|
+
end
|
7
11
|
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|
@@ -1,14 +1,23 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# end
|
7
|
+
##
|
8
|
+
# Rappresenta la classe che renderizza il contenitore della versione di visualizzazione del dato
|
9
|
+
##
|
10
|
+
class NestedModalWrappers::Show < NestedWrappers::Form
|
12
11
|
|
12
|
+
# nella show dobbiamo renderizzare nascosti solo i campi dell'ID del destroy
|
13
|
+
# FIXME serve questo codice?
|
14
|
+
# def form_attributes
|
15
|
+
# super.select { |v| v.name == :id or v.name == :_destroy }
|
16
|
+
# end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
@@ -1,63 +1,68 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
# La cella base dei componenti della form contiene sempre la form come model
|
7
|
+
# la base class di un nested diventa il modello della relazione
|
8
|
+
#
|
9
|
+
# ** Options:
|
10
|
+
# - as_display_list -> Boolean che mi definisce se renderizzare come solo display la lista dei componenti
|
11
|
+
class NestedWrapper < Base
|
8
12
|
|
13
|
+
alias_method :parent_base_class, :base_class
|
9
14
|
|
10
|
-
|
15
|
+
def base_class
|
16
|
+
reflection_association.klass
|
17
|
+
end
|
11
18
|
|
12
|
-
|
13
|
-
|
14
|
-
|
19
|
+
def show(&block)
|
20
|
+
initialize_first_nested
|
21
|
+
super
|
22
|
+
end
|
15
23
|
|
24
|
+
def forms_container_layout
|
25
|
+
layout = context[:nested_layout].blank? ? "layout" : context[:nested_layout]
|
26
|
+
layout_ns("cell/forms/fields/nested_wrappers/forms_containers/#{layout}")
|
27
|
+
end
|
16
28
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
29
|
+
##
|
30
|
+
# Semplicemente se è un has_many ha multipli elementi, altrimenti no
|
31
|
+
def has_multiple_elements?
|
32
|
+
reflection_association.macro == :has_many
|
33
|
+
end
|
21
34
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
##
|
36
|
+
# Inizializza un nuovo record se necessario.
|
37
|
+
# Si basa sulla reflection dell'associazione.
|
38
|
+
# reflections supportate:
|
39
|
+
# - has_one
|
40
|
+
# - has_many
|
41
|
+
def initialize_first_nested
|
42
|
+
case reflection_association.macro
|
43
|
+
when :has_one, :belongs_to
|
44
|
+
form.object.send("build_#{attribute_name}") if form.object.send(attribute_name).nil?
|
45
|
+
when :has_many
|
32
46
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# - has_many
|
39
|
-
def initialize_first_nested
|
40
|
-
case reflection_association.macro
|
41
|
-
when :has_one, :belongs_to
|
42
|
-
form.object.send("build_#{attribute_name}") if form.object.send(attribute_name).nil?
|
43
|
-
when :has_many
|
44
|
-
|
45
|
-
# form.object.send(attribute_name).build if form.object.send(attribute_name).empty?
|
46
|
-
else
|
47
|
-
raise "not defined - #{reflection_association.macro}"
|
48
|
-
end
|
49
|
-
end
|
47
|
+
# form.object.send(attribute_name).build if form.object.send(attribute_name).empty?
|
48
|
+
else
|
49
|
+
raise "not defined - #{reflection_association.macro}"
|
50
|
+
end
|
51
|
+
end
|
50
52
|
|
53
|
+
def target_container_for_new_nested
|
54
|
+
@_unique ||= SecureRandom.uuid
|
55
|
+
end
|
51
56
|
|
52
|
-
|
53
|
-
@_unique ||= SecureRandom.uuid
|
54
|
-
end
|
57
|
+
protected
|
55
58
|
|
56
|
-
|
59
|
+
def reflection_association
|
60
|
+
form.object.class.reflect_on_association(attribute_name)
|
61
|
+
end
|
57
62
|
|
58
|
-
|
59
|
-
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
60
66
|
end
|
61
|
-
|
62
67
|
end
|
63
68
|
end
|