kono_utils_bootstrap_view4 0.1.0.pre.rc.3 → 0.1.0
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 +102 -96
- 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/app/views/kono_utils/base_editing/edit.html.erb +3 -3
- data/app/views/kono_utils/base_editing/edit.inject.erb +1 -1
- data/app/views/kono_utils/base_editing/index.html.erb +4 -4
- data/app/views/kono_utils/base_editing/new.html.erb +3 -3
- data/app/views/kono_utils/base_editing/new.inject.erb +1 -1
- data/app/views/kono_utils/base_editing/show.html.erb +3 -3
- data/app/views/kono_utils/base_editing/success_create_show.inject.erb +1 -1
- data/app/views/kono_utils/base_editing/success_update_show.inject.erb +1 -1
- data/lib/kono_utils_bootstrap_view4.rb +14 -8
- data/lib/kono_utils_bootstrap_view4/engine.rb +0 -3
- data/lib/kono_utils_bootstrap_view4/version.rb +1 -1
- metadata +10 -18
@@ -1,25 +1,29 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
# Classe che si occupa di generare il container della form
|
6
|
+
class Container < Base
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def show(&block)
|
9
|
+
logger.tagged(dom_id(form.object)) do
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
##
|
15
|
+
# Gli attributi da stampare sono un elenco delle options oppure estrapolati tramite la policy
|
16
|
+
def form_attributes
|
17
|
+
options[:form_attributes] || KonoUtilsBootstrapView4::EditableField.editable_fields_to_field_array(policy(model).editable_attributes)
|
18
|
+
end
|
16
19
|
|
20
|
+
def field_selector_layout
|
21
|
+
layout = context[:overriden_layout].blank? ? "layout" : context[:overriden_layout]
|
22
|
+
layout_ns("cell/forms/field_selectors/#{layout}")
|
23
|
+
end
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
layout_ns("cell/forms/field_selectors/#{layout}")
|
25
|
+
end
|
26
|
+
end
|
21
27
|
end
|
22
|
-
|
23
|
-
|
24
28
|
end
|
25
29
|
end
|
@@ -1,16 +1,20 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms
|
5
|
+
# Layout Standard del contenitore della Form
|
6
|
+
class Containers::Layout < Base
|
4
7
|
|
8
|
+
def container_dom_id
|
9
|
+
options[:container_dom_id] || dom_id(form.object)
|
10
|
+
end
|
5
11
|
|
6
|
-
|
7
|
-
|
8
|
-
|
12
|
+
def container_classes
|
13
|
+
[:row] + (options[:container_classes] || [dom_class(form.object)])
|
14
|
+
end
|
9
15
|
|
10
|
-
|
11
|
-
|
16
|
+
end
|
17
|
+
end
|
12
18
|
end
|
13
|
-
|
14
|
-
|
15
19
|
end
|
16
20
|
end
|
@@ -1,7 +1,13 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms
|
5
|
+
module Containers
|
6
|
+
class ModalLayout < Layout
|
5
7
|
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
6
12
|
end
|
7
13
|
end
|
@@ -1,7 +1,13 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms
|
5
|
+
module Containers
|
6
|
+
class SearchLayout < Layout
|
7
|
+
end
|
5
8
|
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
6
12
|
end
|
7
13
|
end
|
@@ -1,8 +1,14 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms
|
5
|
+
module Containers
|
6
|
+
# Layout per la Tabella del contenitore della Form
|
7
|
+
class TableLayout < Layout
|
6
8
|
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
7
13
|
end
|
8
14
|
end
|
@@ -1,77 +1,81 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
# Classe che si occupa di selezionare il campo corretto nella form
|
6
|
+
#
|
7
|
+
# il model sarà un [KonoUtilsBootstrapView4::EditableField]
|
8
|
+
class FieldSelector < Base
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
##
|
11
|
+
# Questa funzione serve per essere sovrascritta dal field generico nella cella specifica del modello
|
12
|
+
# e quindi stampare un determinato campo in modo differente
|
13
|
+
# Viene normalizzato il campo in model contenente il KonoUtilsBootstrapView4::EditableField
|
14
|
+
def get_field
|
15
|
+
logger.debug { "SELECT_FIELD:#{form.object.class.name}->#{model.name}" }
|
16
|
+
if model.is_nested?
|
17
|
+
#devo nestarlo
|
18
|
+
concept("cell/forms/fields/nested_wrapper", model, layout: get_layout('nested_wrappers'))
|
19
|
+
else
|
20
|
+
# decidiamo se renderizzare un'associazione o meno
|
21
|
+
if form.object.class.reflect_on_association(model.name)
|
22
|
+
concept("cell/forms/fields/association", model, layout: get_layout('associations'))
|
23
|
+
else
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
# riconosciamo la tipologia di campo per renderizzare quello corretto
|
26
|
+
case attribute_type
|
27
|
+
when :date
|
28
|
+
concept("cell/forms/fields/date_field", model, layout: get_layout('bases'))
|
29
|
+
when :time
|
30
|
+
concept("cell/forms/fields/time_field", model, layout: get_layout('bases'))
|
31
|
+
when :datetime
|
32
|
+
concept("cell/forms/fields/date_time_field", model, layout: get_layout('bases'))
|
33
|
+
when :file
|
34
|
+
concept("cell/forms/fields/file_field", model, layout: get_layout('bases'))
|
35
|
+
when :enum
|
36
|
+
concept("cell/forms/fields/enum", model, layout: get_layout('bases'))
|
37
|
+
else
|
38
|
+
logger.debug { "TIPO non riconosciuto: #{form.object.class.type_for_attribute(model.name).type} -> #{form.object.class.type_for_attribute(model.name).inspect}" }
|
39
|
+
concept("cell/forms/fields/base", model, layout: get_layout('bases'))
|
40
|
+
end
|
38
41
|
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
def get_layout(field_ns)
|
47
|
+
layout = context[:overriden_layout].blank? ? "layout" : context[:overriden_layout]
|
48
|
+
layout_ns("cell/forms/fields/bases/#{layout}")
|
49
|
+
end
|
43
50
|
|
44
|
-
|
45
|
-
layout = context[:overriden_layout].blank? ? "layout" : context[:overriden_layout]
|
46
|
-
layout_ns("cell/forms/fields/bases/#{layout}")
|
47
|
-
end
|
51
|
+
private
|
48
52
|
|
49
|
-
|
53
|
+
##
|
54
|
+
# Deve ritornare il tipo di attributo per estrapolare i campi standard a disposizione:
|
55
|
+
# * :date
|
56
|
+
# * :time
|
57
|
+
# * :datetime
|
58
|
+
# * :file
|
59
|
+
# * :enum
|
60
|
+
# @return [Symbol]
|
61
|
+
def attribute_type
|
62
|
+
attribute_type = form.object.class.type_for_attribute(model.name).type
|
50
63
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
# * :file
|
57
|
-
# * :enum
|
58
|
-
# @return [Symbol]
|
59
|
-
def attribute_type
|
60
|
-
attribute_type = form.object.class.type_for_attribute(model.name).type
|
64
|
+
#riconosciamo se sono file allegati
|
65
|
+
file = form.object.send(model.name) if form.object.respond_to?(model.name)
|
66
|
+
if file && SimpleForm.file_methods.any? { |m| file.respond_to?(m) }
|
67
|
+
attribute_type = :file
|
68
|
+
end
|
61
69
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
# Riconoscimento degli enum
|
71
|
+
if form.object.class.type_for_attribute(model.name).is_a? ActiveRecord::Enum::EnumType
|
72
|
+
attribute_type = :enum
|
73
|
+
end
|
74
|
+
attribute_type
|
75
|
+
end
|
67
76
|
|
68
|
-
|
69
|
-
if form.object.class.type_for_attribute(model.name).is_a? ActiveRecord::Enum::EnumType
|
70
|
-
attribute_type = :enum
|
77
|
+
end
|
71
78
|
end
|
72
|
-
attribute_type
|
73
79
|
end
|
74
|
-
|
75
|
-
|
76
80
|
end
|
77
81
|
end
|
@@ -1,7 +1,12 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms
|
5
|
+
# Layout Standard del contenitore della Form
|
6
|
+
class FieldSelectors::Layout < Base
|
5
7
|
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
6
11
|
end
|
7
12
|
end
|
@@ -1,7 +1,13 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms
|
5
|
+
module FieldSelectors
|
6
|
+
class ModalLayout < Layout
|
5
7
|
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
6
12
|
end
|
7
13
|
end
|
@@ -1,8 +1,14 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms
|
5
|
+
module FieldSelectors
|
6
|
+
# Layout per la Tabella del contenitore della Form
|
7
|
+
class TableLayout < Layout
|
6
8
|
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
7
13
|
end
|
8
14
|
end
|
@@ -1,7 +1,14 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
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 Association < Base
|
5
8
|
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
6
13
|
end
|
7
14
|
end
|
@@ -1,25 +1,30 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
# La cella base dei componenti della form contiene sempre la form come model
|
6
|
+
class Fields::Base < Base
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
##
|
9
|
+
# Campo del record da visualizzare nella form
|
10
|
+
def attribute_name
|
11
|
+
model.name
|
12
|
+
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
def field_options
|
15
|
+
base_field_options.merge(options[:field_options] || {})
|
16
|
+
end
|
14
17
|
|
18
|
+
def base_field_options
|
19
|
+
out = {}
|
15
20
|
|
16
|
-
|
17
|
-
out = {}
|
21
|
+
out[:as] = :hidden if model.is_hidden?
|
18
22
|
|
19
|
-
|
23
|
+
out
|
24
|
+
end
|
20
25
|
|
21
|
-
|
26
|
+
end
|
27
|
+
end
|
22
28
|
end
|
23
|
-
|
24
29
|
end
|
25
30
|
end
|
@@ -1,24 +1,31 @@
|
|
1
|
-
module KonoUtils
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module KonoUtils
|
2
|
+
module Object
|
3
|
+
module Cell
|
4
|
+
module Forms # namespace
|
5
|
+
module Fields
|
6
|
+
# Classe contenitore del campo, serve per deviare nelle situazioni in cui non serve stampare un contenitore(id,_destroy) o campi hidden
|
7
|
+
# il model qua avremo un KonoUtilsBootstrapView4::EditableField
|
8
|
+
class Bases::Layout < Base
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
def cell_column_classes
|
11
|
+
["col-md-12"]
|
12
|
+
end
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
def show(&block)
|
15
|
+
logger.debug { "LAYOUT => #{self.class.name}" }
|
16
|
+
super
|
17
|
+
end
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
#ritorna la classe hidden da aggiungere nelle classi di layout nel caso il campo da renderizzare non sia da renderizzare
|
18
|
-
def hidden_class
|
19
|
-
model.is_hidden? ? ["kono_utils-hidden"] : []
|
20
|
-
end
|
19
|
+
private
|
21
20
|
|
21
|
+
#ritorna la classe hidden da aggiungere nelle classi di layout nel caso il campo da renderizzare non sia da renderizzare
|
22
|
+
def hidden_class
|
23
|
+
model.is_hidden? ? ["kono_utils-hidden"] : []
|
24
|
+
end
|
22
25
|
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|