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