kono_utils_bootstrap_view4 0.1.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +21 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/config/kono_utils_bootstrap_view4_manifest.js +0 -0
  6. data/app/assets/javascripts/kono_utils_bootstrap_view4/application.js.erb +12 -0
  7. data/app/assets/javascripts/kono_utils_bootstrap_view4/kono_utils_bootstrap_view4.js +36 -0
  8. data/app/assets/stylesheets/kono_utils_bootstrap_view4/application.css.scss.erb +12 -0
  9. data/app/concepts/kono_utils/object/cell/base.rb +123 -0
  10. data/app/concepts/kono_utils/object/cell/buttons/base.rb +57 -0
  11. data/app/concepts/kono_utils/object/cell/buttons/collapse_search.rb +31 -0
  12. data/app/concepts/kono_utils/object/cell/buttons/create.rb +22 -0
  13. data/app/concepts/kono_utils/object/cell/buttons/delete.rb +32 -0
  14. data/app/concepts/kono_utils/object/cell/buttons/download.rb +23 -0
  15. data/app/concepts/kono_utils/object/cell/buttons/edit.rb +18 -0
  16. data/app/concepts/kono_utils/object/cell/buttons/list.rb +17 -0
  17. data/app/concepts/kono_utils/object/cell/buttons/reset_search.rb +21 -0
  18. data/app/concepts/kono_utils/object/cell/create/base.rb +8 -0
  19. data/app/concepts/kono_utils/object/cell/create/page_title.rb +10 -0
  20. data/app/concepts/kono_utils/object/cell/create/side_title.rb +5 -0
  21. data/app/concepts/kono_utils/object/cell/edits/base.rb +8 -0
  22. data/app/concepts/kono_utils/object/cell/edits/page_title.rb +10 -0
  23. data/app/concepts/kono_utils/object/cell/edits/side_title.rb +5 -0
  24. data/app/concepts/kono_utils/object/cell/form.rb +51 -0
  25. data/app/concepts/kono_utils/object/cell/forms/base.rb +13 -0
  26. data/app/concepts/kono_utils/object/cell/forms/container.rb +25 -0
  27. data/app/concepts/kono_utils/object/cell/forms/containers/layout.rb +16 -0
  28. data/app/concepts/kono_utils/object/cell/forms/containers/modal_layout.rb +7 -0
  29. data/app/concepts/kono_utils/object/cell/forms/containers/search_layout.rb +7 -0
  30. data/app/concepts/kono_utils/object/cell/forms/containers/table_layout.rb +8 -0
  31. data/app/concepts/kono_utils/object/cell/forms/field_selector.rb +77 -0
  32. data/app/concepts/kono_utils/object/cell/forms/field_selectors/layout.rb +7 -0
  33. data/app/concepts/kono_utils/object/cell/forms/field_selectors/modal_layout.rb +7 -0
  34. data/app/concepts/kono_utils/object/cell/forms/field_selectors/table_layout.rb +8 -0
  35. data/app/concepts/kono_utils/object/cell/forms/fields/association.rb +7 -0
  36. data/app/concepts/kono_utils/object/cell/forms/fields/base.rb +25 -0
  37. data/app/concepts/kono_utils/object/cell/forms/fields/bases/layout.rb +24 -0
  38. data/app/concepts/kono_utils/object/cell/forms/fields/bases/modal_layout.rb +7 -0
  39. data/app/concepts/kono_utils/object/cell/forms/fields/bases/table_layout.rb +11 -0
  40. data/app/concepts/kono_utils/object/cell/forms/fields/check_box.rb +10 -0
  41. data/app/concepts/kono_utils/object/cell/forms/fields/collection.rb +17 -0
  42. data/app/concepts/kono_utils/object/cell/forms/fields/date_field.rb +15 -0
  43. data/app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb +51 -0
  44. data/app/concepts/kono_utils/object/cell/forms/fields/enum.rb +20 -0
  45. data/app/concepts/kono_utils/object/cell/forms/fields/file_field.rb +31 -0
  46. data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrapper.rb +6 -0
  47. data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrappers/forms_container.rb +9 -0
  48. data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrappers/show.rb +14 -0
  49. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrapper.rb +63 -0
  50. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/form.rb +38 -0
  51. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/layout.rb +13 -0
  52. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/modal_layout.rb +7 -0
  53. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/table_layout.rb +7 -0
  54. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_container.rb +45 -0
  55. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/layout.rb +15 -0
  56. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/modal_layout.rb +9 -0
  57. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/table_layout.rb +16 -0
  58. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/header.rb +31 -0
  59. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_button.rb +44 -0
  60. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/layout.rb +10 -0
  61. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/modal_layout.rb +7 -0
  62. data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/table_layout.rb +7 -0
  63. data/app/concepts/kono_utils/object/cell/forms/fields/read_only.rb +15 -0
  64. data/app/concepts/kono_utils/object/cell/forms/fields/time_field.rb +11 -0
  65. data/app/concepts/kono_utils/object/cell/forms/layout.rb +7 -0
  66. data/app/concepts/kono_utils/object/cell/forms/submit.rb +22 -0
  67. data/app/concepts/kono_utils/object/cell/index/base.rb +12 -0
  68. data/app/concepts/kono_utils/object/cell/index/page_title.rb +10 -0
  69. data/app/concepts/kono_utils/object/cell/index/row.rb +40 -0
  70. data/app/concepts/kono_utils/object/cell/index/row_buttons.rb +7 -0
  71. data/app/concepts/kono_utils/object/cell/index/row_footer.rb +6 -0
  72. data/app/concepts/kono_utils/object/cell/index/row_header.rb +11 -0
  73. data/app/concepts/kono_utils/object/cell/index/side_title.rb +5 -0
  74. data/app/concepts/kono_utils/object/cell/index/table.rb +15 -0
  75. data/app/concepts/kono_utils/object/cell/inject.rb +122 -0
  76. data/app/concepts/kono_utils/object/cell/modals/base.rb +6 -0
  77. data/app/concepts/kono_utils/object/cell/modals/bodies/layout.rb +7 -0
  78. data/app/concepts/kono_utils/object/cell/modals/body.rb +6 -0
  79. data/app/concepts/kono_utils/object/cell/modals/container.rb +24 -0
  80. data/app/concepts/kono_utils/object/cell/modals/containers/layout.rb +10 -0
  81. data/app/concepts/kono_utils/object/cell/modals/footer.rb +6 -0
  82. data/app/concepts/kono_utils/object/cell/modals/footers/layout.rb +7 -0
  83. data/app/concepts/kono_utils/object/cell/modals/header.rb +6 -0
  84. data/app/concepts/kono_utils/object/cell/modals/headers/layout.rb +7 -0
  85. data/app/concepts/kono_utils/object/cell/search.rb +27 -0
  86. data/app/concepts/kono_utils/object/cell/searches/form.rb +14 -0
  87. data/app/concepts/kono_utils/object/cell/show.rb +26 -0
  88. data/app/concepts/kono_utils/object/cell/shows/base.rb +8 -0
  89. data/app/concepts/kono_utils/object/cell/shows/page_title.rb +10 -0
  90. data/app/concepts/kono_utils/object/cell/shows/side_title.rb +5 -0
  91. data/app/concepts/kono_utils/object/view/create/side_title.erb +1 -0
  92. data/app/concepts/kono_utils/object/view/edits/side_title.erb +1 -0
  93. data/app/concepts/kono_utils/object/view/form.erb +9 -0
  94. data/app/concepts/kono_utils/object/view/forms/container.erb +5 -0
  95. data/app/concepts/kono_utils/object/view/forms/containers/layout.erb +3 -0
  96. data/app/concepts/kono_utils/object/view/forms/containers/modal_layout.erb +5 -0
  97. data/app/concepts/kono_utils/object/view/forms/containers/search_layout.erb +1 -0
  98. data/app/concepts/kono_utils/object/view/forms/containers/table_layout.erb +1 -0
  99. data/app/concepts/kono_utils/object/view/forms/field_selector.erb +1 -0
  100. data/app/concepts/kono_utils/object/view/forms/field_selectors/layout.erb +1 -0
  101. data/app/concepts/kono_utils/object/view/forms/field_selectors/modal_layout.erb +1 -0
  102. data/app/concepts/kono_utils/object/view/forms/field_selectors/table_layout.erb +1 -0
  103. data/app/concepts/kono_utils/object/view/forms/fields/association.erb +1 -0
  104. data/app/concepts/kono_utils/object/view/forms/fields/base.erb +1 -0
  105. data/app/concepts/kono_utils/object/view/forms/fields/bases/layout.erb +3 -0
  106. data/app/concepts/kono_utils/object/view/forms/fields/bases/layout.scss +25 -0
  107. data/app/concepts/kono_utils/object/view/forms/fields/bases/modal_layout.erb +3 -0
  108. data/app/concepts/kono_utils/object/view/forms/fields/bases/table_layout.erb +3 -0
  109. data/app/concepts/kono_utils/object/view/forms/fields/check_box.erb +1 -0
  110. data/app/concepts/kono_utils/object/view/forms/fields/collection.erb +1 -0
  111. data/app/concepts/kono_utils/object/view/forms/fields/nested_modal_wrapper.erb +23 -0
  112. data/app/concepts/kono_utils/object/view/forms/fields/nested_modal_wrappers/forms_container.erb +12 -0
  113. data/app/concepts/kono_utils/object/view/forms/fields/nested_modal_wrappers/show.erb +28 -0
  114. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrapper.erb +18 -0
  115. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/form.erb +17 -0
  116. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms/layout.erb +18 -0
  117. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms/modal_layout.erb +4 -0
  118. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms/table_layout.erb +4 -0
  119. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms_container.erb +11 -0
  120. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms_containers/layout.erb +3 -0
  121. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms_containers/modal_layout.erb +3 -0
  122. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms_containers/table_layout.erb +14 -0
  123. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/header.erb +27 -0
  124. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/remove_button.erb +28 -0
  125. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/remove_buttons/layout.erb +1 -0
  126. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/remove_buttons/modal_layout.erb +1 -0
  127. data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/remove_buttons/table_layout.erb +3 -0
  128. data/app/concepts/kono_utils/object/view/forms/layout.erb +1 -0
  129. data/app/concepts/kono_utils/object/view/index/row.erb +10 -0
  130. data/app/concepts/kono_utils/object/view/index/row_buttons.erb +2 -0
  131. data/app/concepts/kono_utils/object/view/index/row_footer.erb +0 -0
  132. data/app/concepts/kono_utils/object/view/index/row_header.erb +8 -0
  133. data/app/concepts/kono_utils/object/view/index/side_title.erb +1 -0
  134. data/app/concepts/kono_utils/object/view/index/table.erb +9 -0
  135. data/app/concepts/kono_utils/object/view/inject.erb +8 -0
  136. data/app/concepts/kono_utils/object/view/modals/bodies/layout.erb +3 -0
  137. data/app/concepts/kono_utils/object/view/modals/body.erb +1 -0
  138. data/app/concepts/kono_utils/object/view/modals/container.erb +13 -0
  139. data/app/concepts/kono_utils/object/view/modals/containers/layout.erb +7 -0
  140. data/app/concepts/kono_utils/object/view/modals/footer.erb +1 -0
  141. data/app/concepts/kono_utils/object/view/modals/footers/layout.erb +3 -0
  142. data/app/concepts/kono_utils/object/view/modals/header.erb +1 -0
  143. data/app/concepts/kono_utils/object/view/modals/headers/layout.erb +3 -0
  144. data/app/concepts/kono_utils/object/view/search.erb +40 -0
  145. data/app/concepts/kono_utils/object/view/searches/form.erb +16 -0
  146. data/app/concepts/kono_utils/object/view/show.erb +6 -0
  147. data/app/concepts/kono_utils/object/view/shows/side_title.erb +1 -0
  148. data/app/inputs/file_input_download_input.rb +22 -0
  149. data/app/inputs/tempus_dominus_input.rb +38 -0
  150. data/app/views/kaminari/_first_page.html.erb +3 -0
  151. data/app/views/kaminari/_gap.html.erb +3 -0
  152. data/app/views/kaminari/_last_page.html.erb +3 -0
  153. data/app/views/kaminari/_next_page.html.erb +3 -0
  154. data/app/views/kaminari/_page.html.erb +9 -0
  155. data/app/views/kaminari/_paginator.html.erb +17 -0
  156. data/app/views/kaminari/_prev_page.html.erb +3 -0
  157. data/app/views/kono_utils/base_editing/edit.html.erb +8 -0
  158. data/app/views/kono_utils/base_editing/edit.inject.erb +2 -0
  159. data/app/views/kono_utils/base_editing/index.html.erb +10 -0
  160. data/app/views/kono_utils/base_editing/new.html.erb +9 -0
  161. data/app/views/kono_utils/base_editing/new.inject.erb +2 -0
  162. data/app/views/kono_utils/base_editing/show.html.erb +8 -0
  163. data/app/views/kono_utils/base_editing/success_create_show.inject.erb +6 -0
  164. data/app/views/kono_utils/base_editing/success_update_show.inject.erb +6 -0
  165. data/config/initializers/kaminari_config.rb +30 -0
  166. data/config/initializers/simple_form.rb +179 -0
  167. data/config/initializers/simple_form_bootstrap.rb +439 -0
  168. data/config/locales/kono_utils_bootstrap4.en.yml +15 -0
  169. data/config/locales/kono_utils_bootstrap4.it.yml +15 -0
  170. data/config/locales/simple_form.en.yml +31 -0
  171. data/config/routes.rb +2 -0
  172. data/lib/generators/kono_utils_bootstrap_view4/concept/concept_generator.rb +79 -0
  173. data/lib/generators/kono_utils_bootstrap_view4/concept/templates/form.template +8 -0
  174. data/lib/generators/kono_utils_bootstrap_view4/concept/templates/forms/field_selector.template +13 -0
  175. data/lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb +76 -0
  176. data/lib/generators/kono_utils_bootstrap_view4/install/templates/kono_utils_bootstrap_view4.js.erb.template +20 -0
  177. data/lib/generators/kono_utils_bootstrap_view4/install/templates/kono_utils_bootstrap_view4.template +5 -0
  178. data/lib/kono_utils_bootstrap_view4.rb +26 -0
  179. data/lib/kono_utils_bootstrap_view4/application_icon_helper.rb +31 -0
  180. data/lib/kono_utils_bootstrap_view4/base_class_concept_ns.rb +47 -0
  181. data/lib/kono_utils_bootstrap_view4/base_search.rb +5 -0
  182. data/lib/kono_utils_bootstrap_view4/configuration.rb +20 -0
  183. data/lib/kono_utils_bootstrap_view4/editable_field.rb +63 -0
  184. data/lib/kono_utils_bootstrap_view4/engine.rb +59 -0
  185. data/lib/kono_utils_bootstrap_view4/paginate_proxer.rb +11 -0
  186. data/lib/kono_utils_bootstrap_view4/search_form_builder.rb +14 -0
  187. data/lib/kono_utils_bootstrap_view4/version.rb +3 -0
  188. data/lib/tasks/kono_utils_bootstrap_view4_tasks.rake +4 -0
  189. data/lib/templates/erb/scaffold/_form.html.erb +15 -0
  190. metadata +391 -0
@@ -0,0 +1,15 @@
1
+ it:
2
+ kono_utils:
3
+ bootstrap4:
4
+ forms:
5
+ fields:
6
+ file_field:
7
+ purge_file:
8
+ label: "Rimuovi file"
9
+ buttons:
10
+ download:
11
+ alt: Download
12
+ collapse_search:
13
+ alt: "Ricerca"
14
+ delete:
15
+ title: Conferma
@@ -0,0 +1,31 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Examples
14
+ # labels:
15
+ # defaults:
16
+ # password: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+ # include_blanks:
27
+ # defaults:
28
+ # age: 'Rather not say'
29
+ # prompts:
30
+ # defaults:
31
+ # age: 'Select your age'
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,79 @@
1
+ require 'rails/generators'
2
+ module KonoUtilsBootstrapView4
3
+ class ConceptGenerator < Rails::Generators::Base
4
+ include ActiveSupport::Inflector
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ desc "Costruisce la struttura delle cartelle e il wrapper per la selezione dei campi da renderizzare\n" +
9
+ "Passando CELL viene anche generata la classe nella posizione corretta"
10
+ argument :model_name, type: :string, desc: 'ModelName'
11
+ argument :cell, type: :string, default: false, desc: "Nome cella da copiare"
12
+
13
+
14
+ def generate_folders
15
+
16
+ if safe_constantize(model_name)
17
+ FileUtils.mkdir_p(File.join(path, 'cell'))
18
+ FileUtils.mkdir_p(File.join(path, 'view'))
19
+ else
20
+ puts "Modello inesistente"
21
+ end
22
+
23
+ end
24
+
25
+ ##
26
+ # Automatismo non completo, TO_COMPLETE
27
+ # class_option :generate_view, type: :boolean, default: false, desc: "Per la cella passata viene copiato la view"
28
+ # class_option :generate_class, type: :boolean, default: false, desc: "Per la cella passata viene copiata la classe"
29
+ #
30
+ # def copy_cell
31
+ # unless cell.blank?
32
+ # dirs = []
33
+ #
34
+ # dirs << ['cell', 'view', 'erb'] if options.generate_view
35
+ # dirs << ['cell', 'cell', 'rb'] if options.generate_class
36
+ #
37
+ # puts "Devi selezionare almeno uno dei generatori: --generate-view o --generate-class" if dirs.empty?
38
+ #
39
+ #
40
+ # dirs.each do |c|
41
+ #
42
+ # component_to_override = "#{cell.gsub(/#{c[0]}/, c[1])}.#{c[2]}"
43
+ # path_src = File.join('app', 'concepts', 'kono_utils', component_to_override)
44
+ #
45
+ # path_dest = File.join('app', 'concepts', tableize(safe_constantize(model_name).name), component_to_override)
46
+ #
47
+ # puts path_src
48
+ # puts path_dest
49
+ #
50
+ # #copio i files
51
+ # copy_file(path_src, path_dest)
52
+ #
53
+ # end
54
+ # end
55
+ # end
56
+
57
+
58
+ class_option :field_selector, type: :boolean, default: false, desc: "Copia il template per il selettore dei campi"
59
+ class_option :form, type: :boolean, default: false, desc: "Copia il template della form"
60
+
61
+ def copy_templates
62
+ if options.field_selector
63
+ template 'forms/field_selector.template', File.join(path, "cell", "forms", "field_selector.rb")
64
+ end
65
+ if options.form
66
+ template 'form.template', File.join(path, "cell", "form.rb")
67
+ end
68
+ end
69
+
70
+
71
+ private
72
+
73
+ def path
74
+ Rails.application.root.join('app', 'concepts', tableize(safe_constantize(model_name).name))
75
+ end
76
+
77
+
78
+ end
79
+ end
@@ -0,0 +1,8 @@
1
+ class <%= model_name.pluralize %>::Cell::Form < KonoUtils::Object::Cell::Form
2
+
3
+ #def forms_options
4
+ # [model, _form_options]
5
+ #end
6
+
7
+
8
+ end
@@ -0,0 +1,13 @@
1
+ class <%= model_name.pluralize %>::Cell::Forms::FieldSelector < KonoUtils::Object::Cell::Forms::FieldSelector
2
+
3
+ def get_field
4
+ case model.name
5
+ #when :field_name
6
+ # concept("cell/forms/fields/association", model, field_options: {as: :check_boxes}, layout: get_layout('associations'))
7
+ else
8
+ super
9
+ end
10
+ end
11
+
12
+
13
+ end
@@ -0,0 +1,76 @@
1
+ require 'rails/generators'
2
+ module KonoUtilsBootstrapView4
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc "Installa l'inizializzatore"
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def install_kono_utils
9
+ run "rails g kono_utils:install"
10
+ end
11
+
12
+ def copy_initializer
13
+ template 'kono_utils_bootstrap_view4.template', Rails.root.join('config', 'initializers', 'kono_utils_bootstrap_view4.rb')
14
+ end
15
+
16
+ def install_node_dependency
17
+ yarn_packages = ['bootstrap@4.5.0', 'jquery@3.5.1', 'popper.js', 'moment', 'tempusdominus-bootstrap-4', '@fortawesome/fontawesome-free', 'data-confirm-modal']
18
+ run "yarn add #{yarn_packages.join(' ')}" unless yarn_packages.empty?
19
+ end
20
+
21
+ def install_cell_concept_namespacer_on_application_record
22
+ inject_into_file 'app/models/application_record.rb', "\n include KonoUtilsBootstrapView4::BaseClassConceptNs", after: "ActiveRecord::Base"
23
+ rescue Exception => e
24
+ say "Attenzione, includere a mano KonoUtilsBootstrapView4::BaseClassConceptNs
25
+ nel modello da cui darivano i modelli del base editing - #{e.message}", :red
26
+ end
27
+
28
+ def append_dependecy_to_assets
29
+ js_requirements = [
30
+ 'kono_utils_bootstrap_view4/application'
31
+ ]
32
+ KonoUtilsBootstrapView4.configuration.moment_js_locales.each do |l|
33
+ js_requirements << "moment/locale/#{l}.js"
34
+ end
35
+
36
+ rails6 = Gem::Version.new('6')
37
+ if rails6 <= Gem::Version.new(Rails.version)
38
+ say "in rails 6 dobbiamo avere webpacker che compila erb, creiamo un file erb che includa le nostre dipendenze", :yellow
39
+ run "rails webpacker:install:erb"
40
+ #cancelliamo il file di esempio
41
+ remove_file 'app/javascript/packs/hello_erb.js.erb'
42
+ template 'kono_utils_bootstrap_view4.js.erb.template', Rails.root.join('app', 'javascript', 'packs', 'application.js.erb')
43
+ say "Ricorda di aggiungere nel layout <%= javascript_pack_tag 'application' %>", :yellow
44
+ else
45
+ inject_into_file 'app/assets/javascripts/application.js',
46
+ "#{requirements.collect { |c| "\n//= require #{c}" }.join}\n",
47
+ before: "//= require_tree ."
48
+ end
49
+
50
+
51
+ requirements = [
52
+ 'kono_utils_bootstrap_view4/application'
53
+ ]
54
+ inject_into_file 'app/assets/stylesheets/application.css',
55
+ "#{requirements.collect { |c| "\n *= require #{c}" }.join}\n",
56
+ before: " *= require_tree ."
57
+
58
+ end
59
+
60
+ def append_gem_dependency
61
+
62
+ dips = [
63
+ 'cells-erb', # inserita in installazione come specificato qua http://trailblazer.to/gems/cells/rails.html#engine-render-problems
64
+ 'cells-rails',
65
+ 'kaminari-cells'
66
+ ]
67
+ say "AGGIUNGO dipendenze per concepts, #{dips.join(" ")}", :green
68
+
69
+ dips.each do |dip|
70
+ gem dip
71
+ end
72
+
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,20 @@
1
+ // To reference this file, add <\%= javascript_pack_tag 'kono_utils_bootstrap_view4' %> to the appropriate
2
+ // layout file, like app/views/layouts/application.html.erb
3
+
4
+ // RICORDARSI di mantenere sincronizzate le dipendenze tra la versione non webpack negli assets,i moduli richiesti ecc
5
+
6
+ // jquery risulta essere ancora una dipendenza per bootstrap4.
7
+ global.jQuery = global.$ = require('jquery'); // rails-js cerca jquery in modo globale, quindi noi lo rendiamo globale in questo modo
8
+
9
+ global.Rails = require("@rails/ujs") // serve per data-confirm-modal, rendere Rails globale
10
+ global.Rails.start()
11
+ require("@rails/activestorage").start()
12
+
13
+ // inizio dipendenza per interfaccia Bootstrap4
14
+ import "@fortawesome/fontawesome-free/css/all.css";
15
+ require('bootstrap');
16
+ require('popper.js');
17
+ global.moment = require('moment');
18
+ require('tempusdominus-bootstrap-4');
19
+ require('data-confirm-modal');
20
+ global.KonoUtilsBootstrap4 = require("<%%= KonoUtilsBootstrapView4::Engine.root.join('app','assets','javascripts','kono_utils_bootstrap_view4','kono_utils_bootstrap_view4.js') %>");
@@ -0,0 +1,5 @@
1
+ KonoUtilsBootstrapView4.configure do |config|
2
+
3
+ # config.moment_js_locales = [:it,:de]
4
+
5
+ end
@@ -0,0 +1,26 @@
1
+ require "zeitwerk"
2
+ loader = Zeitwerk::Loader.for_gem
3
+ loader.ignore("#{__dir__}/generators")
4
+ loader.enable_reloading # you need to opt-in before setup
5
+ loader.setup
6
+
7
+ # require "kono_utils_bootstrap_view4/engine"
8
+
9
+ module KonoUtilsBootstrapView4
10
+
11
+ class << self
12
+ attr_writer :configuration
13
+ end
14
+
15
+ # @return [Configuration]
16
+ def self.configuration
17
+ @configuration ||= Configuration.new
18
+ end
19
+
20
+ def self.configure
21
+ yield configuration
22
+ end
23
+
24
+ end
25
+
26
+ loader.eager_load
@@ -0,0 +1,31 @@
1
+ module KonoUtilsBootstrapView4
2
+ module ApplicationIconHelper
3
+
4
+ ##
5
+ # Funzione clonata da una gemma, le fontawesome lo stiamo già impostando con webpack
6
+ def icon(style, name, text = nil, html_options = {})
7
+ text, html_options = nil, text if text.is_a?(Hash)
8
+
9
+ content_class = "#{style} fa-#{name}"
10
+ content_class << " #{html_options[:class]}" if html_options.key?(:class)
11
+ html_options[:class] = content_class
12
+
13
+ html = content_tag(:i, nil, html_options)
14
+ html << ' ' << text.to_s unless text.blank?
15
+ html
16
+ end
17
+
18
+ def fa_icon(icon, text: nil, solid_regular:"s")
19
+ icon = content_tag(:i, nil, class: "fa#{solid_regular} fa-#{icon} fa-fw")
20
+ elements = [icon]
21
+ unless text.blank?
22
+ elements << text
23
+ elements.reverse!
24
+ end
25
+
26
+ safe_join(elements, " ")
27
+ end
28
+
29
+
30
+ end
31
+ end
@@ -0,0 +1,47 @@
1
+ module KonoUtilsBootstrapView4
2
+ module BaseClassConceptNs
3
+ extend ActiveSupport::Concern
4
+
5
+ class_methods do
6
+ include ActiveSupport::Inflector
7
+
8
+ ##
9
+ # Metodo richiamato per restituire un array di path in cui ricercare le view prima della ricerca delle altre view
10
+ # all'interno della gemma o altro, serve per poter fare override di view anche senza la presenza della relativa
11
+ # classe Cell overridata.
12
+ def concept_prefix
13
+ [Rails.application.root.join('app', 'concepts', tableize(self.name), 'view')]
14
+ end
15
+
16
+ def concept_ns(view)
17
+ @_memo_concept ||= {}
18
+ ns = "#{tableize(self.name)}/#{view}"
19
+
20
+ unless @_memo_concept.key?(ns)
21
+ if safe_constantize(ns.camelize)
22
+ KonoUtilsBootstrapView4.configuration.logger.info { "TROVATA CLASSE PER : #{ns.camelize} --->>>" }
23
+ @_memo_concept[ns] = ns
24
+ else
25
+ @_memo_concept[ns] = false
26
+ end
27
+ end
28
+
29
+ if @_memo_concept[ns]
30
+ return @_memo_concept[ns]
31
+ else
32
+ KonoUtilsBootstrapView4.configuration.logger.debug { "CLASSE OVERRIDE NON TROVATA PER : #{ns.camelize}" }
33
+
34
+ "kono_utils/object/#{view}"
35
+ end
36
+
37
+ end
38
+
39
+ ##
40
+ # Ritorna il corretto layout per il componente, tenendo conto delle view con override
41
+ def layout_ns(name)
42
+ concept_ns(name).camelize.constantize
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ module KonoUtilsBootstrapView4
2
+ class BaseSearch < KonoUtils::BaseSearch
3
+ include BaseClassConceptNs
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ class KonoUtilsBootstrapView4::Configuration
2
+ attr_accessor :moment_js_locales
3
+
4
+ #@return [ActiveSupport::TaggedLogging] log di kono utils bootstrap, default estende quello di rails
5
+ attr_reader :logger
6
+
7
+ def initialize
8
+ @moment_js_locales = I18n.available_locales
9
+ # inizializzo logger, come quello che mi verrebbe passato
10
+ self.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))
11
+ end
12
+
13
+ # @param [ActiveSupport::TaggedLogging] logger
14
+ # @return [ActiveSupport::TaggedLogging]
15
+ def logger=(logger)
16
+ raise "Not a ActiveSupport::TaggedLogging" unless logger.is_a? ActiveSupport::TaggedLogging
17
+ logger.push_tags("KonoUtils") unless logger.formatter.current_tags.include?("KonoUtils")
18
+ @logger = logger
19
+ end
20
+ end
@@ -0,0 +1,63 @@
1
+ module KonoUtilsBootstrapView4
2
+
3
+ ##
4
+ # PORO che si occupa di gestire un campo da editare.
5
+ # questo serve per poter gestire le casistiche provenienti dagli editable attributes, che consistono in semplisy symbols
6
+ # o in hash che rappresentano le relazioni
7
+ class EditableField
8
+
9
+
10
+ def initialize(f)
11
+ @field = f
12
+ end
13
+
14
+
15
+ ##
16
+ # Restituisce il symbol che rappresenta il campo da editare
17
+ #
18
+ def name
19
+
20
+ if @field.is_a?(Hash)
21
+ @field.keys.first
22
+ else
23
+ @field.to_sym
24
+ end
25
+
26
+ end
27
+
28
+
29
+ ##
30
+ # Solitamente questi campi sono da renderizzare come nascosti
31
+ # @return [TrueClass|FalseClass]
32
+ def is_hidden?
33
+ ['id', '_destroy'].include?(name.to_s)
34
+ end
35
+
36
+ ##
37
+ # Controlla se il campo è di tipo nested (un hash con chiave ed una serie di campi interni)
38
+ def is_nested?
39
+ @field.is_a?(Hash)
40
+ end
41
+
42
+ ##
43
+ # Nei casi di campi nested, questo metodo restituisce un array di campi interni, normalizzati a EditableField
44
+ def inner_fields
45
+ is_nested? ? self.class.editable_fields_to_field_array(@field[name]) : []
46
+ end
47
+
48
+
49
+ # @return [Array<KonoUtilsBootstrapView4::EditableField>]
50
+ def self.editable_fields_to_field_array(attributes)
51
+ attributes.collect do |s|
52
+
53
+ if s.is_a?(Hash)
54
+ s.collect {|k, v| KonoUtilsBootstrapView4::EditableField.new({k => v})}
55
+ else
56
+ KonoUtilsBootstrapView4::EditableField.new(s)
57
+ end
58
+
59
+ end.flatten
60
+ end
61
+
62
+ end
63
+ end