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,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dcc5fde1b46131a93c3a0ba6fbf644423892747fb407c39c5ce6c23b9a9416e6
4
+ data.tar.gz: bafc7d6a9ee09b7dcffab4851683cb5621840aaed5f79a366f7f441a094be9f1
5
+ SHA512:
6
+ metadata.gz: 1308a61a0646096c2174261df0ab8ca3503a9292d30a1d6c11511328aef345090feb157191fecb4d6fbbbaef8eefa03529e64da65b313f14c99a380e80f605e5
7
+ data.tar.gz: 59dc17ab4ea79cd9143c2a8caa06ccd8de26db1c9076cca666612cc7c5d40e8e07098a3c67e7d672ddd158d6814f09e84d545f0f31d85fae01e7825bad1b7695
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Marino Bonetti
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ # KonoUtilsBootstrapView4
2
+ Versione di KonoUtils per utilizzare Bootstrap 4 e TrailBlazer per il rendering
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'kono_utils_bootstrap_view4'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+
20
+ ## License
21
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'KonoUtilsBootstrapView4'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1,12 @@
1
+ // RICORDARSI di mantenere sincronizzate le dipendenze tra la versione non webpack negli assets,i moduli richiesti ecc
2
+ //= require kono_utils_bootstrap_view4/kono_utils_bootstrap_view4
3
+ //= require jquery/dist/jquery
4
+ //= require bootstrap/dist/js/bootstrap
5
+ //= require popper.js/dist/umd/popper.js
6
+ //= require moment/moment.js
7
+ //= require tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.js
8
+ //= require data-confirm-modal
9
+ // componenti cells
10
+ // require forms/fields/nested_wrappers/header
11
+
12
+
@@ -0,0 +1,36 @@
1
+ /**
2
+ * In questo modo possiamo avere il componente elaborato sia in una situazione browser, importandolo con sprockets
3
+ * che nella situazione attravero moduli
4
+ */
5
+ (function (global, factory) {
6
+
7
+ "use strict";
8
+
9
+ if (typeof module === "object" && typeof module.exports === "object") {
10
+
11
+ module.exports = factory(global, true);
12
+ } else {
13
+ factory(global);
14
+ }
15
+
16
+ // Pass this if window is not defined yet
17
+ })(typeof window !== "undefined" ? window : this, function (global, return_module = false) {
18
+
19
+ const b64DecodeUnicode = function (str) {
20
+ // Going backwards: from bytestream, to percent-encoding, to original string.
21
+ return decodeURIComponent(atob(str).split('').map(function (c) {
22
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
23
+ }).join(''));
24
+ }
25
+
26
+ const KonoUtilsBootstrap4={
27
+ b64DecodeUnicode: b64DecodeUnicode
28
+ }
29
+
30
+ if (return_module) {
31
+ return KonoUtilsBootstrap4
32
+ } else {
33
+ global["KonoUtilsBootstrap4"] = KonoUtilsBootstrap4;
34
+ }
35
+
36
+ })
@@ -0,0 +1,12 @@
1
+ /*
2
+ *= require bootstrap/dist/css/bootstrap
3
+ *= require kono_utils/core
4
+ *= require tempusdominus-bootstrap-4/build/css/tempusdominus-bootstrap-4
5
+ // componenti cells
6
+ *= require forms/fields/bases/layout
7
+ */
8
+ // non importiamo i font, quando siamo in rails 6, in quanto sono inclusi nel template di webpacker
9
+ <% require_asset "@fortawesome/fontawesome-free/css/all.css" if Gem::Version.new(Rails.version) < Gem::Version.new('6') %>
10
+
11
+
12
+
@@ -0,0 +1,123 @@
1
+ module KonoUtils::Object::Cell # namespace
2
+ class Base < Trailblazer::Cell # class
3
+ view_paths << "#{KonoUtilsBootstrapView4::Engine.root}/app/concepts"
4
+
5
+ include Pundit
6
+ include Kaminari::Helpers::HelperMethods
7
+ include KonoUtilsBootstrapView4::ApplicationIconHelper
8
+ include Kaminari::Cells
9
+
10
+
11
+ ##
12
+ # Helpers di controller
13
+ def base_class
14
+ context[:base_class] || (@_base_class ||= parent_controller.send(:base_class))
15
+ end
16
+
17
+ def new_custom_polymorphic_path(*base_class)
18
+ parent_controller.send(:new_custom_polymorphic_path, *base_class)
19
+ end
20
+
21
+ def edit_custom_polymorphic_path(*rec)
22
+ parent_controller.send(:edit_custom_polymorphic_path, *rec)
23
+ end
24
+
25
+ def index_custom_polymorphic_path(*rec)
26
+ parent_controller.send(:index_custom_polymorphic_path, *rec)
27
+ end
28
+
29
+ def destroy_custom_polymorphic_path(*rec)
30
+ parent_controller.send(:destroy_custom_polymorphic_path, *rec)
31
+ end
32
+
33
+
34
+ ##
35
+ # Registra il contenuto con una chiave, e lo renderizza poi dove è più necessario
36
+ # @param [String] name
37
+ # @param [String] content
38
+ # @param [Hash{null->null}] options
39
+ # @param [Proc] block
40
+ # @return [String]
41
+ def content_for_layout(name, content = nil, options = {}, &block)
42
+ context[:_view_layout_flow] ||= ActionView::OutputFlow.new
43
+ if content || block_given?
44
+ if block_given?
45
+ options = content if content
46
+ content = capture(&block)
47
+ end
48
+ if content
49
+ content = content.to_s.html_safe
50
+ options[:flush] ? context[:_view_layout_flow].set(name, content) : context[:_view_layout_flow].append(name, content)
51
+ end
52
+ nil
53
+ else
54
+ context[:_view_layout_flow].get(name).presence
55
+ end
56
+ end
57
+
58
+ def content_for_layout?(name)
59
+ context[:_view_layout_flow].get(name).present? rescue false
60
+ end
61
+
62
+ alias_method :legacy_concept, :concept
63
+
64
+ # def concept(name, model = nil, options = {}, &block)
65
+ def concept(name, *args, &block)
66
+ legacy_concept(base_class.concept_ns(name), *args, &block)
67
+ end
68
+
69
+ delegates :base_class, :layout_ns
70
+
71
+ # @return [Logger]
72
+ def self.logger
73
+ KonoUtilsBootstrapView4.configuration.logger
74
+ end
75
+
76
+ delegate :logger, to: :class
77
+
78
+ def _prefixes
79
+ base_class.concept_prefix + super + parent_controller.lookup_context.view_paths.collect(&:to_path)
80
+ end
81
+
82
+ def current_user
83
+ context[:current_user]
84
+ end
85
+
86
+ def title_mod
87
+ "#{t(:edit)} #{model.mn}"
88
+ end
89
+
90
+ def title_new
91
+ "#{t(:new)} #{model.mn}"
92
+ end
93
+
94
+ def title_newa
95
+ "#{t(:newa)} #{model.mn}"
96
+ end
97
+
98
+ def title_del
99
+ "#{t(:del)} #{model.mn}"
100
+ end
101
+
102
+ def title_edit_g
103
+ "#{t("edit_title_#{model_gender}", default: 'Modifica')} #{model.mn}"
104
+ end
105
+
106
+ def title_new_g
107
+ "#{t("new_title_#{model_gender}", default: 'Nuovo')} #{model.mn}"
108
+ end
109
+
110
+ def title_del_g
111
+ "#{t("del_title_#{model_gender}", default: 'Cancella')} #{model.mn}"
112
+ end
113
+
114
+ def title_show_g
115
+ "#{t("show_title_#{model_gender}", default: 'Visualizza')} #{model.mn}"
116
+ end
117
+
118
+ def model_gender
119
+ t("activerecord.modelgender.#{model.class.name.underscore.to_sym}", :default => :m).to_sym
120
+ end
121
+
122
+ end
123
+ end
@@ -0,0 +1,57 @@
1
+ module KonoUtils::Object::Cell # namespace
2
+ ##
3
+ # Options:
4
+ # - url_to -> Url verso dove mandare il bottone
5
+ # - content -> Contenuto del link del bottone
6
+ # - button_options -> possibili opzioni per il bottone fra cui:
7
+ # - class -> per la classe
8
+ class Buttons::Base < Base
9
+
10
+
11
+ # @return [String]
12
+ def url_to
13
+ options.fetch(:url_to, "#to_override_or_options-url_to")
14
+ end
15
+
16
+ def specific_button_class
17
+ nil
18
+ end
19
+
20
+ def button_title
21
+ nil
22
+ end
23
+
24
+ def button_size
25
+ "btn-sm"
26
+ end
27
+
28
+
29
+ def btn_opts(opts = {})
30
+ custom_options = options.dig(:button_options) || opts
31
+ opts = {
32
+ class: "btn #{specific_button_class} #{button_size} #{custom_options.delete(:class)}".split(' ').uniq.join(' '),
33
+ id: unique_dom_id
34
+ }
35
+ opts.merge!(custom_options)
36
+ opts[:title] = button_title unless base_class.nil?
37
+ opts
38
+ end
39
+
40
+ def show(&block)
41
+ link_to button_content, url_to, btn_opts
42
+ end
43
+
44
+ # @return [String] - contenuto del bottone/link
45
+ def button_content
46
+ options.fetch(:content, model.try(:to_s) || "options[:content]")
47
+ end
48
+
49
+ private
50
+
51
+ def unique_dom_id
52
+ @_unique_dom_id ||= SecureRandom.uuid
53
+ end
54
+
55
+
56
+ end
57
+ end
@@ -0,0 +1,31 @@
1
+ module KonoUtils::Object::Cell::Buttons # namespace
2
+ ##
3
+ # Bottone per la struttura del collapse search
4
+ # *Options*
5
+ # - collapsed_target -> identificativo del contenitore che devo espandere
6
+ class CollapseSearch < Base
7
+
8
+ def url_to
9
+ options.fetch(:collapsed_target, '#')
10
+ end
11
+
12
+ def specific_button_class
13
+ 'btn-light'
14
+ end
15
+
16
+ def btn_opts(opts = {})
17
+ {
18
+ data: {toggle: "collapse"}
19
+ }.merge(super)
20
+ end
21
+
22
+ def button_title
23
+ I18n.t('kono_utils.bootstrap4.buttons.collapse_search.alt')
24
+ end
25
+
26
+ def button_content
27
+ options.fetch(:content, fa_icon("search"))
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,22 @@
1
+ module KonoUtils::Object::Cell::Buttons # namespace
2
+ class Create < Base
3
+
4
+ def url_to
5
+ options[:url_to] || new_custom_polymorphic_path(model)
6
+ end
7
+
8
+ def specific_button_class
9
+ "btn-success"
10
+ end
11
+
12
+ def button_title
13
+ title_new
14
+ end
15
+
16
+ def button_content
17
+ options.fetch(:content, fa_icon("plus"))
18
+ end
19
+
20
+
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ module KonoUtils::Object::Cell::Buttons # namespace
2
+ class Delete < Base
3
+
4
+ def url_to
5
+ options[:url_to] || destroy_custom_polymorphic_path(model)
6
+ end
7
+
8
+ def specific_button_class
9
+ 'btn-danger'
10
+ end
11
+
12
+ def btn_opts(opts = {})
13
+ custom_options = options.dig(:button_options) || opts
14
+ super(automatic_remove_options.merge(custom_options))
15
+ end
16
+
17
+ ##
18
+ # Metodo che è possibili fare override per rimuovere le funzioni di rails di conferma automatica
19
+ def automatic_remove_options
20
+ {
21
+ method: :delete,
22
+ data: {confirm: t(:are_you_sure), title: I18n.t('kono_utils.bootstrap4.buttons.delete.title')},
23
+ }
24
+ end
25
+
26
+ def button_content
27
+ options.fetch(:content, fa_icon("trash"))
28
+ end
29
+
30
+
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ module KonoUtils::Object::Cell::Buttons # namespace
2
+ class Download < Base
3
+
4
+ def url_to
5
+ options[:url_to] || url_for(model)
6
+ end
7
+
8
+ def specific_button_class
9
+ 'btn-light'
10
+ end
11
+
12
+ def button_content
13
+ options.fetch(:content, fa_icon("download", text: I18n.t('kono_utils.bootstrap4.buttons.download.alt')))
14
+ end
15
+
16
+ def btn_opts(opts = {})
17
+ {
18
+ target: :_blank
19
+ }.merge(super)
20
+ end
21
+
22
+ end
23
+ end