headmin 0.2.5 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -3
  3. data/Gemfile.lock +13 -2
  4. data/README.md +64 -57
  5. data/app/assets/config/headmin_manifest.js +2 -0
  6. data/app/assets/javascripts/headmin/config/i18n.js +11 -0
  7. data/{src/js → app/assets/javascripts}/headmin/controllers/blocks_controller.js +1 -2
  8. data/app/assets/javascripts/headmin/controllers/date_range_controller.js +32 -0
  9. data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +33 -0
  10. data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +244 -0
  11. data/{src/js → app/assets/javascripts}/headmin/controllers/filter_controller.js +13 -7
  12. data/{src/js → app/assets/javascripts}/headmin/controllers/filters_controller.js +1 -1
  13. data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +39 -0
  14. data/app/assets/javascripts/headmin/controllers/hello_controller.js +7 -0
  15. data/app/assets/javascripts/headmin/controllers/notification_controller.js +8 -0
  16. data/{src/js → app/assets/javascripts}/headmin/controllers/popup_controller.js +1 -2
  17. data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +13 -0
  18. data/{src/js → app/assets/javascripts}/headmin/controllers/repeater_controller.js +8 -9
  19. data/app/assets/javascripts/headmin/controllers/select_controller.js +48 -0
  20. data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +98 -0
  21. data/app/assets/javascripts/headmin/controllers/table_controller.js +110 -0
  22. data/app/assets/javascripts/headmin/index.js +41 -0
  23. data/app/assets/javascripts/headmin.js +15934 -0
  24. data/{src/scss → app/assets/stylesheets}/headmin/filter.scss +0 -0
  25. data/{src/scss → app/assets/stylesheets}/headmin/filters.scss +0 -0
  26. data/{src/scss → app/assets/stylesheets}/headmin/form.scss +55 -2
  27. data/{src/scss → app/assets/stylesheets}/headmin/general.scss +0 -0
  28. data/{src/scss → app/assets/stylesheets}/headmin/layout/body.scss +0 -0
  29. data/{src/scss → app/assets/stylesheets}/headmin/layout/sidebar.scss +0 -0
  30. data/{src/scss → app/assets/stylesheets}/headmin/layout.scss +0 -0
  31. data/{src/scss → app/assets/stylesheets}/headmin/login.scss +0 -0
  32. data/{src/scss/vendor/bootstrap/variables.scss → app/assets/stylesheets/headmin/overrides/bootstrap.scss} +0 -0
  33. data/{src/scss/vendor/redactorx/override.css → app/assets/stylesheets/headmin/overrides/redactorx.css} +0 -0
  34. data/{src/scss → app/assets/stylesheets}/headmin/popup.scss +0 -0
  35. data/app/assets/stylesheets/headmin/syntax.scss +349 -0
  36. data/{src/scss → app/assets/stylesheets}/headmin/table.scss +1 -0
  37. data/app/assets/stylesheets/headmin/thumbnail.scss +20 -0
  38. data/app/assets/stylesheets/headmin/utilities.scss +68 -0
  39. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_accordion.scss +118 -0
  40. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_alert.scss +57 -0
  41. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_badge.scss +29 -0
  42. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_breadcrumb.scss +28 -0
  43. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_button-group.scss +139 -0
  44. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_buttons.scss +111 -0
  45. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_card.scss +216 -0
  46. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_carousel.scss +229 -0
  47. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_close.scss +40 -0
  48. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_containers.scss +41 -0
  49. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_dropdown.scss +240 -0
  50. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_forms.scss +9 -0
  51. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_functions.scss +302 -0
  52. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_grid.scss +33 -0
  53. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_helpers.scss +9 -0
  54. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_images.scss +42 -0
  55. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_list-group.scss +174 -0
  56. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_mixins.scss +43 -0
  57. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_modal.scss +209 -0
  58. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_nav.scss +139 -0
  59. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_navbar.scss +335 -0
  60. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_offcanvas.scss +83 -0
  61. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_pagination.scss +64 -0
  62. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_placeholders.scss +51 -0
  63. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_popover.scss +158 -0
  64. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_progress.scss +48 -0
  65. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_reboot.scss +625 -0
  66. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_root.scss +54 -0
  67. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_spinners.scss +69 -0
  68. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_tables.scss +155 -0
  69. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_toasts.scss +51 -0
  70. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_tooltip.scss +115 -0
  71. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_transitions.scss +27 -0
  72. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_type.scss +104 -0
  73. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_utilities.scss +630 -0
  74. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_variables.scss +1641 -0
  75. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-grid.scss +67 -0
  76. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-reboot.scss +13 -0
  77. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-utilities.scss +18 -0
  78. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap.scss +53 -0
  79. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_floating-labels.scss +63 -0
  80. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-check.scss +152 -0
  81. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-control.scss +219 -0
  82. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-range.scss +91 -0
  83. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-select.scss +72 -0
  84. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-text.scss +11 -0
  85. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_input-group.scss +121 -0
  86. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_labels.scss +36 -0
  87. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_validation.scss +12 -0
  88. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_clearfix.scss +3 -0
  89. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_colored-links.scss +12 -0
  90. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_position.scss +30 -0
  91. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_ratio.scss +26 -0
  92. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_stacks.scss +15 -0
  93. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_stretched-link.scss +15 -0
  94. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_text-truncation.scss +7 -0
  95. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
  96. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_vr.scss +8 -0
  97. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_alert.scss +11 -0
  98. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_backdrop.scss +14 -0
  99. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_border-radius.scss +78 -0
  100. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_box-shadow.scss +18 -0
  101. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_breakpoints.scss +127 -0
  102. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_buttons.scss +133 -0
  103. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_caret.scss +64 -0
  104. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_clearfix.scss +9 -0
  105. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_color-scheme.scss +7 -0
  106. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_container.scss +9 -0
  107. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_deprecate.scss +10 -0
  108. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_forms.scss +144 -0
  109. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_gradients.scss +47 -0
  110. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_grid.scss +151 -0
  111. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_image.scss +16 -0
  112. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_list-group.scss +24 -0
  113. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_lists.scss +7 -0
  114. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_pagination.scss +31 -0
  115. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_reset-text.scss +17 -0
  116. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_resize.scss +6 -0
  117. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_table-variants.scss +21 -0
  118. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_text-truncate.scss +8 -0
  119. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_transition.scss +26 -0
  120. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_utilities.scss +89 -0
  121. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_visually-hidden.scss +29 -0
  122. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/utilities/_api.scss +47 -0
  123. data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/vendor/_rfs.scss +354 -0
  124. data/app/assets/stylesheets/headmin/vendor/flatpickr.css +903 -0
  125. data/{src/scss/vendor/redactorx → app/assets/stylesheets/headmin/vendor}/redactorx.css +0 -0
  126. data/app/assets/stylesheets/headmin/vendor/tom-select-bootstrap.css +537 -0
  127. data/app/assets/stylesheets/headmin.css +13454 -0
  128. data/app/assets/stylesheets/headmin.scss +65 -0
  129. data/app/helpers/headmin/admin_helper.rb +4 -59
  130. data/app/helpers/headmin/bootstrap_helper.rb +31 -0
  131. data/app/helpers/headmin/documentation_helper.rb +35 -0
  132. data/app/helpers/headmin/filter_helper.rb +7 -3
  133. data/app/helpers/headmin/form_helper.rb +40 -0
  134. data/app/helpers/headmin/request_helper.rb +34 -0
  135. data/app/models/concerns/headmin/fieldable.rb +3 -1
  136. data/app/models/headmin/documentation_renderer.rb +32 -0
  137. data/app/models/headmin/form/base.rb +79 -0
  138. data/app/models/headmin/form/text.rb +53 -0
  139. data/app/services/block_service.rb +8 -4
  140. data/app/views/examples/admin.html.erb +1 -1
  141. data/app/views/headmin/_blocks.html.erb +2 -2
  142. data/app/views/headmin/_breadcrumbs.html.erb +1 -1
  143. data/app/views/headmin/_card.html.erb +10 -6
  144. data/app/views/headmin/_dropdown.html.erb +1 -1
  145. data/app/views/headmin/_filters.html.erb +23 -11
  146. data/app/views/headmin/_form.html.erb +14 -14
  147. data/app/views/headmin/_heading.html.erb +1 -1
  148. data/app/views/headmin/_notifications.html.erb +1 -1
  149. data/app/views/headmin/_pagination.html.erb +3 -2
  150. data/app/views/headmin/_popup.html.erb +10 -4
  151. data/app/views/headmin/_table.html.erb +10 -4
  152. data/app/views/headmin/_thumbnail.html.erb +47 -0
  153. data/app/views/headmin/dropdown/_devise.html.erb +20 -10
  154. data/app/views/headmin/dropdown/_list.html.erb +14 -7
  155. data/app/views/headmin/filters/_date.html.erb +9 -13
  156. data/app/views/headmin/filters/_flatpickr.html.erb +57 -0
  157. data/app/views/headmin/filters/_search.html.erb +5 -5
  158. data/app/views/headmin/filters/_select.html.erb +6 -6
  159. data/app/views/headmin/filters/filter/_button.html.erb +7 -7
  160. data/app/views/headmin/filters/filter/_template.html.erb +1 -1
  161. data/app/views/headmin/forms/_actions.html.erb +1 -1
  162. data/app/views/headmin/forms/_base.html.erb +100 -46
  163. data/app/views/headmin/forms/_blocks.html.erb +14 -7
  164. data/app/views/headmin/forms/_checkbox.html.erb +3 -3
  165. data/app/views/headmin/forms/_date.html.erb +30 -34
  166. data/app/views/headmin/forms/_date_range.html.erb +42 -0
  167. data/app/views/headmin/forms/_email.html.erb +35 -26
  168. data/app/views/headmin/forms/_file.html.erb +186 -34
  169. data/app/views/headmin/forms/_flatpickr.html.erb +34 -0
  170. data/app/views/headmin/forms/_flatpickr_range.html.erb +50 -0
  171. data/app/views/headmin/forms/_hidden.html.erb +24 -0
  172. data/app/views/headmin/forms/_image.html.erb +11 -45
  173. data/app/views/headmin/forms/_label.html.erb +18 -12
  174. data/app/views/headmin/forms/_number.html.erb +40 -37
  175. data/app/views/headmin/forms/_password.html.erb +37 -58
  176. data/app/views/headmin/forms/_redactorx.html.erb +8 -7
  177. data/app/views/headmin/forms/_repeater.html.erb +11 -14
  178. data/app/views/headmin/forms/_select.html.erb +43 -45
  179. data/app/views/headmin/forms/_text.html.erb +94 -59
  180. data/app/views/headmin/forms/_textarea.html.erb +37 -26
  181. data/app/views/headmin/forms/_url.html.erb +35 -26
  182. data/app/views/headmin/forms/_validation.html.erb +3 -3
  183. data/app/views/headmin/forms/_video.html.erb +21 -0
  184. data/app/views/headmin/forms/fields/_base.html.erb +3 -3
  185. data/app/views/headmin/forms/fields/_file.html.erb +2 -2
  186. data/app/views/headmin/forms/fields/_group.html.erb +3 -3
  187. data/app/views/headmin/forms/fields/_image.html.erb +2 -2
  188. data/app/views/headmin/forms/fields/_list.html.erb +3 -3
  189. data/app/views/headmin/forms/fields/_text.html.erb +2 -2
  190. data/app/views/headmin/forms/repeater/_row.html.erb +1 -1
  191. data/app/views/headmin/heading/_title.html.erb +1 -1
  192. data/app/views/headmin/layout/_body.html.erb +1 -1
  193. data/app/views/headmin/layout/_content.html.erb +1 -1
  194. data/app/views/headmin/layout/_footer.html.erb +1 -1
  195. data/app/views/headmin/layout/_header.html.erb +1 -1
  196. data/app/views/headmin/layout/_main.html.erb +12 -6
  197. data/app/views/headmin/layout/_sidebar.html.erb +3 -3
  198. data/app/views/headmin/layout/sidebar/_bottom.html.erb +1 -1
  199. data/app/views/headmin/layout/sidebar/_nav.html.erb +1 -1
  200. data/app/views/headmin/nav/_dropdown.html.erb +34 -0
  201. data/app/views/headmin/nav/_item.html.erb +22 -13
  202. data/app/views/headmin/table/_actions.html.erb +35 -11
  203. data/app/views/headmin/table/_body.html.erb +1 -1
  204. data/app/views/headmin/table/_foot.html.erb +1 -1
  205. data/app/views/headmin/table/_footer.html.erb +1 -1
  206. data/app/views/headmin/table/_head.html.erb +1 -1
  207. data/app/views/headmin/table/_header.html.erb +1 -1
  208. data/app/views/headmin/table/actions/_action.html.erb +4 -4
  209. data/app/views/headmin/table/actions/_delete.html.erb +1 -1
  210. data/app/views/headmin/table/actions/_export.html.erb +1 -1
  211. data/app/views/headmin/table/body/_row.html.erb +15 -7
  212. data/app/views/headmin/views/devise/confirmations/_new.html.erb +1 -1
  213. data/app/views/headmin/views/devise/passwords/_edit.html.erb +2 -2
  214. data/app/views/headmin/views/devise/passwords/_new.html.erb +1 -1
  215. data/app/views/headmin/views/devise/registrations/_edit.html.erb +4 -4
  216. data/app/views/headmin/views/devise/registrations/_new.html.erb +3 -3
  217. data/app/views/headmin/views/devise/shared/_links.html.erb +7 -7
  218. data/app/views/headmin/views/devise/unlocks/_new.html.erb +1 -1
  219. data/config/importmap.rb +2 -0
  220. data/config/locales/activerecord/en.yml +9 -0
  221. data/config/locales/activerecord/nl.yml +9 -0
  222. data/config/locales/en.yml +0 -3
  223. data/config/locales/headmin/forms/en.yml +5 -0
  224. data/config/locales/headmin/forms/nl.yml +5 -0
  225. data/config/locales/headmin/popup/en.yml +4 -0
  226. data/config/locales/headmin/popup/nl.yml +4 -0
  227. data/config/locales/headmin/table/en.yml +5 -1
  228. data/config/locales/headmin/table/nl.yml +5 -1
  229. data/config/locales/headmin/thumbnail/en.yml +4 -0
  230. data/config/locales/headmin/thumbnail/nl.yml +4 -0
  231. data/config/locales/headmin/views/en.yml +1 -1
  232. data/config/locales/headmin/views/nl.yml +14 -14
  233. data/config/locales/nl.yml +0 -3
  234. data/docs/blocks.md +0 -7
  235. data/esbuild-css.js +25 -0
  236. data/esbuild-js.js +11 -0
  237. data/headmin.gemspec +4 -1
  238. data/lib/generators/headmin/blocks_generator.rb +4 -1
  239. data/lib/generators/headmin/devise_generator.rb +5 -1
  240. data/lib/generators/headmin/fields_generator.rb +4 -1
  241. data/lib/generators/templates/controllers/auth/confirmations_controller.rb +31 -0
  242. data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +31 -0
  243. data/lib/generators/templates/controllers/auth/passwords_controller.rb +35 -0
  244. data/lib/generators/templates/controllers/auth/registrations_controller.rb +63 -0
  245. data/lib/generators/templates/controllers/auth/sessions_controller.rb +28 -0
  246. data/lib/generators/templates/controllers/auth/unlocks_controller.rb +31 -0
  247. data/lib/headmin/engine.rb +15 -0
  248. data/lib/headmin/version.rb +1 -1
  249. data/lib/headmin.rb +1 -1
  250. data/package.json +20 -35
  251. data/src/js/headmin.js +1 -1
  252. data/src/scss/headmin.scss +1 -61
  253. data/yarn.lock +443 -5345
  254. metadata +198 -30
  255. data/.nvmrc +0 -1
  256. data/app/controllers/concerns/headmin/ckeditor.rb +0 -27
  257. data/app/views/headmin/forms/_ckeditor.html.erb +0 -42
  258. data/dist/css/headmin.css +0 -12313
  259. data/dist/js/headmin.js +0 -1548
  260. data/src/js/headmin/controllers/table_actions_controller.js +0 -33
  261. data/src/js/headmin/controllers/table_controller.js +0 -119
  262. data/src/js/headmin/headmin.js +0 -141
  263. data/src/scss/headmin/utilities.scss +0 -19
  264. data/webpack.config.js +0 -30
@@ -2,20 +2,20 @@
2
2
  # headmin/form
3
3
  #
4
4
  # ==== Options
5
- # * <tt>model<tt> - A model to infer :url and :scope
6
- # * <tt>scope<tt> - The scope to prefix input field names with
7
- # * <tt>url<tt> - The URL the form submits to
8
- # * <tt>format<tt> - The format of the route the form submits to
9
- # * <tt>namespace<tt> - A namespace for your form to ensure uniqueness of id attributes on form elements
10
- # * <tt>method<tt> - The method to use when submitting the form
11
- # * <tt>authenticity_token<tt> - Authenticity token to use in the form
12
- # * <tt>local<tt> - By default form submits are remote and unobtrusive XHRs
13
- # * <tt>skip_enforcing_utf8<tt> - If set to true, a hidden input with name utf8 is not output
14
- # * <tt>builder<tt> - Override the object used to build the form
15
- # * <tt>html<tt> - Other optional HTML attributes for the form tag
16
- # * <tt>id<tt> - Optional HTML id attribute
17
- # * <tt>class<tt> - Optional HTML class attribute
18
- # * <tt>data<tt> - Optional HTML data attributes
5
+ # * +model+ - A model to infer :url and :scope
6
+ # * +scope+ - The scope to prefix input field names with
7
+ # * +url+ - The URL the form submits to
8
+ # * +format+ - The format of the route the form submits to
9
+ # * +namespace+ - A namespace for your form to ensure uniqueness of id attributes on form elements
10
+ # * +method+ - The method to use when submitting the form
11
+ # * +authenticity_token+ - Authenticity token to use in the form
12
+ # * +local+ - By default form submits are remote and unobtrusive XHRs
13
+ # * +skip_enforcing_utf8+ - If set to true, a hidden input with name utf8 is not output
14
+ # * +builder+ - Override the object used to build the form
15
+ # * +html+ - Other optional HTML attributes for the form tag
16
+ # * +id+ - Optional HTML id attribute
17
+ # * +class+ - Optional HTML class attribute
18
+ # * +data+ - Optional HTML data attributes
19
19
  #
20
20
  # === Examples
21
21
  # Basic version
@@ -9,5 +9,5 @@
9
9
  %>
10
10
 
11
11
  <div class="h-heading d-flex flex-column flex-md-row align-items-start align-items-md-end justify-content-between">
12
- <%= yield if block_given? %>
12
+ <%= yield %>
13
13
  </div>
@@ -8,7 +8,7 @@
8
8
 
9
9
  <div class="toast-container position-absolute top-0 end-0 p-3">
10
10
  <% flash.each do |name, message| %>
11
- <div class="toast align-items-center text-white show <%= notification_color(name.to_sym)[:background] %>" role="alert" aria-live="assertive" aria-atomic="true">
11
+ <div class="toast align-items-center text-white show <%= notification_color(name.to_sym)[:background] %>" role="alert" aria-live="assertive" aria-atomic="true" data-controller="toast">
12
12
  <div class="d-flex">
13
13
  <div class="toast-body <%= notification_color(name.to_sym)[:text] %>">
14
14
  <%= message %>
@@ -2,7 +2,7 @@
2
2
  # headmin/notifications
3
3
  #
4
4
  # ==== Options
5
- # * <tt>collection</tt> - Kaminari collection that accepts a method .total_count
5
+ # * +collection</tt> - Kaminari collection that accepts a method .total_count
6
6
  #
7
7
  # ==== Examples
8
8
  # Basic version
@@ -10,8 +10,9 @@
10
10
  %>
11
11
 
12
12
  <div class="d-flex flex-row-reverse flex-md-row align-items-center justify-content-between justify-content-md-end my-1">
13
+ <% content_for :collection_total_count, collection.total_count.to_s unless content_for?(:collection_total_count) %>
13
14
  <div class="ms-2 me-md-2 text-secondary">
14
- <%= t('.items', count: collection.total_count) %>
15
+ <%= t('.items', count: content_for(:collection_total_count).to_i) %>
15
16
  </div>
16
17
  <%= paginate collection, views_prefix: 'headmin/pagination' %>
17
18
  </div>
@@ -2,7 +2,7 @@
2
2
  # headmin/popup
3
3
  #
4
4
  # ==== Options
5
- # * <tt>id</tt> - Identifier for this popup
5
+ # * +id</tt> - Identifier for this popup
6
6
  #
7
7
  # ==== Examples
8
8
  # To trigger this popup create an element with a data attribute like this
@@ -19,8 +19,14 @@
19
19
  # <%= render 'headmin/popup', id: 'popupId' do %#>
20
20
  # <a href="https://example.com" id="link">
21
21
  # <% end %#>
22
+ data = local_assigns.has_key?(:data) ? data : {}
23
+
24
+ options = {
25
+ class: ['h-popup', 'closed'],
26
+ data: data.merge('popup-target': 'popup', 'popup-id': id)
27
+ }
22
28
  %>
23
29
 
24
- <div class="h-popup closed" data-popup-target="popup" data-popup-id="<%= id %>">
25
- <%= yield if block_given? %>
26
- </div>
30
+ <%= content_tag(:div, options) do %>
31
+ <%= yield %>
32
+ <% end %>
@@ -2,19 +2,25 @@
2
2
  # headmin/table
3
3
  #
4
4
  # ==== Options
5
- # * <tt>sort_url</tt> - U
5
+ # * +sort_url</tt> - Url to post object ids to in the order of positions
6
6
  #
7
7
  # ==== Examples
8
8
  # <%= render 'headmin/table', sort_url: positions_admin_categories_path do %#>
9
9
  # table content here
10
10
  # <% end %#>
11
+
12
+ sort_url = local_assigns.has_key?(:sort_url) ? sort_url : nil
13
+ total_count = content_for(:collection_total_count).to_i || nil
11
14
  %>
12
15
 
13
- <% sort_url = local_assigns.has_key?(:sort_url) ? sort_url : nil %>
14
16
  <div class="h-table card my-2 shadow-sm <%= 'table-drag-sort' if sort_url %>" data-sort-url="<%= sort_url %>">
15
17
  <div class="table-responsive">
16
- <table class="table table-hover m-0" data-controller="table" data-table-target="table" data-table-url-value="<%= sort_url %>">
17
- <%= yield if block_given? %>
18
+ <table class="table table-hover m-0"
19
+ data-controller="table"
20
+ data-table-target="table"
21
+ data-table-url-value="<%= sort_url %>"
22
+ data-table-count-value="<%= total_count %>">
23
+ <%= yield %>
18
24
  </table>
19
25
  </div>
20
26
  </div>
@@ -0,0 +1,47 @@
1
+ <%
2
+ # name: headmin/thumbnail
3
+ #
4
+ # ==== Required parameters
5
+ # * +src+ - Sourch path for the file
6
+ #
7
+ # ==== Optional parameters
8
+ # * +width+ - Width of the thumbnail
9
+ # * +height+ - Height of the thumbnail
10
+ #
11
+ # ==== References
12
+ # https://getbootstrap.com/docs/5.1/content/images/#image-thumbnails
13
+ #
14
+ # ==== Examples
15
+ # Basic version
16
+ # <%= render 'headmin/thumbnail', src: file %#>
17
+ #
18
+ # Custom width and height
19
+ # <%= render 'headmin/thumbnail', src: file, width: 300, height: 100 %#>
20
+
21
+ width = local_assigns[:width] || 150
22
+ height = local_assigns[:height] || 150
23
+ class_names = ['img-thumbnail h-thumbnail', local_assigns[:class]].join(' ')
24
+
25
+ mime_type = nil
26
+ if src
27
+ stripped_path = URI.parse(src).path
28
+ extension = File.extname(stripped_path)
29
+ mime_type = Rack::Mime.mime_type(extension)
30
+ end
31
+ %>
32
+
33
+ <div class="<%= class_names %>" style="width: <%= width %>px; height: <%= height %>px;">
34
+ <% if mime_type&.match?(/^image/) %>
35
+ <div class="h-thumbnail-bg" style="background-image: url('<%= src %>');"></div>
36
+ <% else %>
37
+ <div class="h-thumbnail-bg">
38
+ <%= src ? File.extname(src) : 'nil' %>
39
+ <%= mime_type %>
40
+ <% if mime_type %>
41
+ <%= bootstrap_icon_for_mime_type(mime_type, class: 'h-thumbnail-icon') %>
42
+ <% else %>
43
+ <%= bootstrap_icon('question', class: 'h-thumbnail-icon') %>
44
+ <% end %>
45
+ </div>
46
+ <% end %>
47
+ </div>
@@ -1,19 +1,29 @@
1
- <%#
2
- headmin/dropdown/locale
3
- accepts block: yes
4
- parameters:
5
- scope: (symbol) devise scope, i.e. ':users' => current_user
1
+ <%
2
+ # headmin/dropdown/devise
3
+ #
4
+ # ==== Options
5
+ # * +scope</tt> - (symbol) devise scope, i.e. ':users' => current_user
6
+ # * +class</tt> - Custom class names to put on the dropdown
7
+ #
8
+ # ==== Examples
9
+ # Basic version
10
+ # <%= render "headmin/dropdown/devise" %#>
11
+ #
12
+ # Custom scope
13
+ # <%= render "headmin/dropdown/devise", scope: :admins %#>
14
+
15
+ class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : ''
16
+ scope = local_assigns.has_key?(:scope) ? scope : :users
17
+ singular = scope.to_s.singularize.to_sym
18
+ user = send("current_#{singular}")
6
19
  %>
7
20
 
8
- <% scope = local_assigns.has_key?(:scope) ? scope : :users %>
9
- <% singular = scope.to_s.singularize.to_sym %>
10
- <% user = send("current_#{singular}") %>
11
21
 
12
- <%= render 'headmin/dropdown' do %>
22
+ <%= render 'headmin/dropdown', class: class_names do %>
13
23
  <%= render 'headmin/dropdown/button' do %>
14
24
  <%= user.to_s %>
15
25
  <% end %>
16
- <%= render 'headmin/dropdown/list' do %>
26
+ <%= render 'headmin/dropdown/list', class: 'dropdown-menu-end' do %>
17
27
  <%= render 'headmin/dropdown/item', name: t('.edit_profile'), url: polymorphic_path([:edit, singular, :registration]) %>
18
28
  <%= render 'headmin/dropdown/divider' %>
19
29
  <%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), method: :delete %>
@@ -1,11 +1,18 @@
1
- <%#
2
- headmin/dropdown/list
3
- accepts block: yes
4
- parameters:
5
- id: unique identifier for the dropdown
1
+ <%
2
+ # headmin/dropdown/list
3
+ #
4
+ # ==== Options
5
+ # * +id</tt> - unique identifier for the dropdown
6
+ # * +class</tt> - Custom class names to put on the dropdown menu
7
+ #
8
+ # ==== Examples
9
+ # Basic version
10
+ # <%= render "headmin/dropdown/list", id: 'dropdown-1' %#>
11
+
12
+ class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : ''
13
+ id = local_assigns.has_key?(:id) ? id : 'dropdown-1'
6
14
  %>
7
- <% id = local_assigns.has_key?(:id) ? id : 'dropdown-1' %>
8
15
 
9
- <ul class="dropdown-menu" aria-labelledby="<%= id %>">
16
+ <ul class="dropdown-menu <%= class_names %>" aria-labelledby="<%= id %>">
10
17
  <%= yield %>
11
18
  </ul>
@@ -2,22 +2,24 @@
2
2
  # headmin/filters/date
3
3
  #
4
4
  # ==== Options
5
- # * <tt>name</tt> - Name of the filter parameter
6
- # * <tt>label</tt> - Display name
5
+ # * +name</tt> - Name of the filter parameter
6
+ # * +label</tt> - Display name
7
7
  #
8
8
  # ==== Examples
9
9
  # Basic version
10
10
  # <%= render "headmin/filters/date", name: :created_at, label: 'Created at' %#>
11
11
 
12
- label = local_assigns.has_key?(:label) ? label : nil
13
- name = local_assigns.has_key?(:name) ? name : nil
12
+ name = local_assigns.has_key?(:name) ? name.to_sym : nil
13
+ label = local_assigns.has_key?(:label) ? label : name.to_s.humanize
14
14
 
15
15
  input_options = {
16
16
  placeholder: 'dd/mm/yyyy',
17
- class: "form-control flatpickr",
17
+ class: "form-control",
18
18
  required: true,
19
- 'data-filters-target': 'input',
20
- 'data-action': "change->filters#update"
19
+ data: {
20
+ 'filters-target': 'input',
21
+ 'action': 'change->filters#update',
22
+ }
21
23
  }
22
24
  %>
23
25
 
@@ -28,9 +30,6 @@
28
30
  <%= content_for :filters_templates do %>
29
31
  <%= render 'headmin/filters/filter/template', name: name, label: label do %>
30
32
  <div class="input-group">
31
- <span class="input-group-text">
32
- <%= bootstrap_icon('calendar') %>
33
- </span>
34
33
  <%= date_field_tag(name, nil, input_options) %>
35
34
  </div>
36
35
  <% end %>
@@ -41,9 +40,6 @@
41
40
  <% value_formatted = Date.parse(params[name]).strftime('%d/%m/%Y') %>
42
41
  <%= render 'headmin/filters/filter/button', name: name, label: label, value: value_formatted do %>
43
42
  <div class="input-group">
44
- <span class="input-group-text">
45
- <%= bootstrap_icon('calendar') %>
46
- </span>
47
43
  <%= date_field_tag(name, params[name], input_options) %>
48
44
  </div>
49
45
  <% end %>
@@ -0,0 +1,57 @@
1
+ <%
2
+ # headmin/filters/flatpickr
3
+ #
4
+ # ==== Options
5
+ # * +name</tt> - Name of the filter parameter
6
+ # * +label</tt> - Display name
7
+ #
8
+ # ==== Examples
9
+ # Basic version
10
+ # <%= render "headmin/filters/flatpickr", name: :created_at, label: 'Created at' %#>
11
+
12
+ name = local_assigns.has_key?(:name) ? name.to_sym : nil
13
+ label = local_assigns.has_key?(:label) ? label : name.to_s.humanize
14
+
15
+ input_options = {
16
+ placeholder: 'dd/mm/yyyy',
17
+ class: "form-control",
18
+ required: true,
19
+ data: {
20
+ 'filters-target': 'input',
21
+ 'flatpickr-target': 'input',
22
+ 'action': 'change->filters#update',
23
+ 'flatpickr-options': {
24
+ defaultDate: params[name]
25
+ }
26
+ }
27
+ }
28
+ %>
29
+
30
+ <%= content_for :filters_menu do %>
31
+ <%= render 'headmin/filters/filter/menu_item', name: name, label: label %>
32
+ <% end %>
33
+
34
+ <%= content_for :filters_templates do %>
35
+ <%= render 'headmin/filters/filter/template', name: name, label: label do %>
36
+ <div class="input-group" data-controller="flatpickr">
37
+ <span class="input-group-text">
38
+ <%= bootstrap_icon('calendar') %>
39
+ </span>
40
+ <%= date_field_tag(name, nil, input_options) %>
41
+ </div>
42
+ <% end %>
43
+ <% end %>
44
+
45
+ <%= content_for :filters_buttons do %>
46
+ <% if filter_param_exists?(name) %>
47
+ <% value_formatted = Date.parse(params[name]).strftime('%d/%m/%Y') %>
48
+ <%= render 'headmin/filters/filter/button', name: name, label: label, value: value_formatted do %>
49
+ <div class="input-group" data-controller="flatpickr">
50
+ <span class="input-group-text">
51
+ <%= bootstrap_icon('calendar') %>
52
+ </span>
53
+ <%= date_field_tag(name, params[name], input_options) %>
54
+ </div>
55
+ <% end %>
56
+ <% end %>
57
+ <% end %>
@@ -2,16 +2,16 @@
2
2
  # headmin/filters/search
3
3
  #
4
4
  # ==== Options
5
- # * <tt>name</tt> - Name of the filter parameter
6
- # * <tt>label</tt> - Name of the resource to be used in the placeholder (search in ...)
7
- # * <tt>placeholder</tt> - Placeholder in the search field
5
+ # * +name</tt> - Name of the filter parameter
6
+ # * +label</tt> - Name of the resource to be used in the placeholder (search in ...)
7
+ # * +placeholder</tt> - Placeholder in the search field
8
8
  #
9
9
  # ==== Examples
10
10
  # Basic version.
11
11
  # <%= render 'headmin/filters/search', name: :search, label: Poll.model_name.human(count: 2) %#>
12
12
 
13
13
  name = local_assigns.has_key?(:name) ? name : :search
14
- label = local_assigns.has_key?(:label) ? label : nil
14
+ label = local_assigns.has_key?(:label) ? label : name.to_s.humanize
15
15
  placeholder = local_assigns.has_key?(:placeholder) ? placeholder : t('.placeholder', resource: label)
16
16
 
17
17
  value = filter_param_exists?(name) ? params[name] : nil
@@ -19,4 +19,4 @@
19
19
 
20
20
  <% content_for :filters_search do %>
21
21
  <input class="form-control" type="search" placeholder="<%= raw placeholder.capitalize %>" aria-label="Search" name="<%= name %>" value="<%= value %>">
22
- <% end %>
22
+ <% end %>
@@ -2,16 +2,16 @@
2
2
  # headmin/filters/select
3
3
  #
4
4
  # ==== Options
5
- # * <tt>name</tt> - Name of the filter parameter
6
- # * <tt>label</tt> - Display name
7
- # * <tt>options</tt> - List of options to select from
5
+ # * +name</tt> - Name of the filter parameter
6
+ # * +label</tt> - Display name
7
+ # * +options</tt> - List of options to select from
8
8
  #
9
9
  # ==== Examples
10
10
  # Basic version
11
11
  # <%= render "headmin/filters/select", name: :poll_type, label: 'Type', options: [["General", "general", "Fun", "fun"]] %#>
12
12
 
13
- label = local_assigns.has_key?(:label) ? label : nil
14
- name = local_assigns.has_key?(:name) ? name : nil
13
+ name = local_assigns.has_key?(:name) ? name.to_sym : nil
14
+ label = local_assigns.has_key?(:label) ? label : name.to_s.humanize
15
15
  options = local_assigns.has_key?(:options) ? options : []
16
16
 
17
17
  select_options = {
@@ -38,7 +38,7 @@
38
38
  <% (params[name] || []).each_with_index do |param, index| %>
39
39
  <% selected_option = options.detect { |value, key, config| (key.present? ? key : value) == param } %>
40
40
  <% selected_value = selected_option.is_a?(Array) ? selected_option.first : selected_option %>
41
- <%= render 'headmin/filters/filter/button', name: name, label: label, value: selected_value, id: "#{name}_#{index}" do %>
41
+ <%= render 'headmin/filters/filter/button', name: name, label: label, value: selected_value, id: "#{name}_#{index}_#{SecureRandom.hex}" do %>
42
42
  <%= select_tag("#{name}[]", options_for_select(options, param), select_options) %>
43
43
  <% end %>
44
44
  <% end %>
@@ -6,15 +6,16 @@
6
6
  label: (string) Display name
7
7
  value: (string) Value of the parameter
8
8
  %>
9
- <% id = local_assigns.has_key?(:id) ? id : Time.now.utc.to_i %>
10
- <% name = local_assigns.has_key?(:name) ? name : nil %>
11
- <% label = local_assigns.has_key?(:label) ? label : nil %>
9
+ <% id = local_assigns.has_key?(:id) ? id : SecureRandom.hex %>
10
+ <% name = local_assigns.has_key?(:name) ? name.to_sym : nil %>
11
+ <% label = local_assigns.has_key?(:label) ? label : name.to_s.humanize %>
12
12
  <% value = local_assigns.has_key?(:value) ? value : nil %>
13
13
 
14
- <div class="h-filter me-1 my-1" data-filter-name="<%= name %>">
14
+ <div class="h-filter me-1 my-1" data-controller="filter" data-filter-name="<%= name %>">
15
15
  <button
16
16
  type="button"
17
17
  class="h-filter-button btn h-btn-outline-transparent"
18
+ data-filter-target="button"
18
19
  data-popup-target="button"
19
20
  data-popup-id="<%= id %>"
20
21
  data-action="click->popup#open"
@@ -23,8 +24,7 @@
23
24
  <span class="h-filter-remove" data-action="click->filters#remove"><%= bootstrap_icon('x-lg') %></span>
24
25
  </button>
25
26
 
26
- <%= render 'headmin/popup', id: "#{id}" do %>
27
- <%= yield if block_given? %>
27
+ <%= render 'headmin/popup', id: "#{id}", data: {'filter-target': 'popup'} do %>
28
+ <%= yield %>
28
29
  <% end %>
29
-
30
30
  </div>
@@ -8,6 +8,6 @@
8
8
 
9
9
  <template data-filter-name="<%= name %>" data-filters-target="template">
10
10
  <%= render 'headmin/filters/filter/button', name: name, label: label, value: nil, id: 'template_id' do %>
11
- <%= yield if block_given? %>
11
+ <%= yield %>
12
12
  <% end %>
13
13
  </template>
@@ -19,7 +19,7 @@
19
19
  </dl>
20
20
  <% end %>
21
21
 
22
- <%= yield if block_given? %>
22
+ <%= yield %>
23
23
 
24
24
  <%= render 'headmin/forms/actions/destroy', form: form %>
25
25
  <hr>
@@ -1,60 +1,114 @@
1
- <%
2
- # headmin/forms/base
3
- #
4
- # ==== Options
5
- # * <tt>form<tt> - Form object
6
- # * <tt>attribute<tt> - Name of the attribute of the form model
7
- # * <tt>options<tt> - Hash with all HTML options to pass to
8
- # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
9
- # * <tt>required<tt> - Set to true to mark as required
10
- # * <tt>float<tt> - Set to true if you want to show floating labels
11
- # * <tt>append<tt> - Text or icon to be shown on the left hand side of the input, Doesn't work with float
12
- # * <tt>prepend<tt> - Text or icon to be shown on the right hand side of the input, Doesn't work with float
13
- #
14
- # ==== Examples
15
- # Basic version
16
- # <%= render 'headmin/forms/date', form: form, attribute: :title %#>
17
- #
18
- # With datepicker
19
- # <%= render 'headmin/forms/text', form: form, attribute: :title, datepicker: true %#>
20
-
21
- append = local_assigns.has_key?(:append) ? append : nil
22
- float = local_assigns.has_key?(:float) ? float : false
23
- label = local_assigns.has_key?(:label) ? label : nil
24
- prepend = local_assigns.has_key?(:prepend) ? prepend : nil
25
- required = local_assigns.has_key?(:required) ? required : false
26
-
27
- show_label = label != false
28
- %>
29
-
30
- <div class="<%= 'form-floating' if float %> <%= ('mb-3 text-start' if show_label) %>">
31
- <% if show_label && !float %>
32
- <%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
33
- <% end %>
34
-
35
- <% if float %>
36
- <%= yield form %>
37
- <%= render 'headmin/forms/validation', form: form, attribute: attribute %>
38
- <% else %>
1
+ <!--
2
+ <% documentation do %>
3
+ # Base
4
+ This serves as a wrapper around most form views. It allows defining everything that happens outside the input field.
5
+ The main purpose of this view is to coordinate labels and appendages.
6
+
7
+ ```erbx
8
+ <%= form_with do |form| %>
9
+ <%= render "headmin/forms/base", form: form, attribute: "basic_example" do |form| %>
10
+ <%= form.text_field("attribute", class: 'form-control') %>
11
+ <% end %>
12
+ <% end %>
13
+ ```
14
+
15
+ # Parameters
16
+ | Name | Required | Type | Description |
17
+ | ------------ | -------- | ---------------- | ----------- |
18
+ | form | yes | Object | Form object |
19
+ | attribute | yes | String, Symbol | Name of the attribute of the form model |
20
+ | append | no | Boolean | Text or icon to be shown on the left hand side of the input, Doesn't work with float |
21
+ | class | no | String | A space separated string of HTML class names |
22
+ | float | no | Boolean | Set to true if you want to show floating labels |
23
+ | id | no | String | Input identifier to be used as "for" in the label |
24
+ | label | no | Hash | Text to show as label. Label will be hidden if value is false |
25
+ | prepend | no | Boolean | Text or icon to be shown on the right hand side of the input, Doesn't work with float |
26
+
27
+ ## Examples
28
+
29
+ ### Sizing
30
+ ```erbx
31
+ <%= form_with do |form| %>
32
+ <%= render "headmin/forms/base", form: form, attribute: "small", class: 'input-group-sm' do |form| %>
33
+ <%= form.text_field("attribute", class: 'form-control', placeholder: '.input-group-sm') %>
34
+ <% end %>
35
+ <%= render "headmin/forms/base", form: form, attribute: "medium" do |form| %>
36
+ <%= form.text_field("attribute", class: 'form-control', placeholder: 'Default size') %>
37
+ <% end %>
38
+ <%= render "headmin/forms/base", form: form, attribute: "large", class: 'input-group-lg' do |form| %>
39
+ <%= form.text_field("attribute", class: 'form-control', placeholder: '.input-group-lg') %>
40
+ <% end %>
41
+ <% end %>
42
+ ```
43
+
44
+ ### Labels
45
+ ```erbx
46
+ <%= form_with do |form| %>
47
+ <%= render "headmin/forms/base", form: form, attribute: "no_label", label: false do |form| %>
48
+ <%= form.text_field("attribute", class: 'form-control', placeholder: 'Without label') %>
49
+ <% end %>
50
+ <%= render "headmin/forms/base", form: form, attribute: "floating_label", float: true do |form| %>
51
+ <%= form.text_field("attribute", class: 'form-control', placeholder: 'Default size') %>
52
+ <% end %>
53
+ <%= render "headmin/forms/base", form: form, attribute: "custom_label", label: 'Custom label' do |form| %>
54
+ <%= form.text_field("attribute", class: 'form-control') %>
55
+ <% end %>
56
+ <% end %>
57
+ ```
58
+
59
+ ### Appendages
60
+ ```erbx
61
+ <%= form_with do |form| %>
62
+ <%= render "headmin/forms/base", form: form, attribute: "prepend", prepend: "€" do |form| %>
63
+ <%= form.text_field("attribute", class: 'form-control') %>
64
+ <% end %>
65
+ <%= render "headmin/forms/base", form: form, attribute: "append", append: "m²" do |form| %>
66
+ <%= form.text_field("attribute", class: 'form-control') %>
67
+ <% end %>
68
+ <%= render "headmin/forms/base", form: form, attribute: "prepend_and_append", prepend: "€", append: "m²" do |form| %>
69
+ <%= form.text_field("attribute", class: 'form-control') %>
70
+ <% end %>
71
+ <% end %>
72
+ ```
73
+ <% end %>
74
+ -->
75
+
76
+ <% base = Headmin::Form::Base.new(local_assigns) %>
77
+
78
+ <%= tag.div(class: base.class_names, data: base.data) do %>
79
+ <% if base.label != false && !base.float %>
80
+ <%= render 'headmin/forms/label', base.label_options %>
81
+ <% end %>
82
+
83
+ <% if base.append || base.prepend %>
39
84
  <div class="input-group w-100">
40
- <% if prepend %>
85
+ <% if base.prepend %>
41
86
  <span class="input-group-text">
42
- <%= prepend %>
87
+ <%= base.prepend %>
43
88
  </span>
44
89
  <% end %>
45
90
 
46
91
  <%= yield form %>
47
- <%= render 'headmin/forms/validation', form: form, attribute: attribute %>
92
+ <%= render 'headmin/forms/validation', base.validation_options if form.object.respond_to?(:errors) %>
48
93
 
49
- <% if append %>
94
+ <% if base.append %>
50
95
  <span class="input-group-text">
51
- <%= append %>
96
+ <%= base.append %>
52
97
  </span>
53
98
  <% end %>
54
99
  </div>
100
+ <% else %>
101
+ <%= yield form %>
102
+ <%= render 'headmin/forms/validation', base.validation_options if form.object.respond_to?(:errors) %>
103
+ <% end %>
104
+
105
+ <% if base.label != false && base.float %>
106
+ <%= render 'headmin/forms/label', base.label_options %>
55
107
  <% end %>
56
108
 
57
- <% if show_label && float %>
58
- <%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
109
+ <% if base.list %>
110
+ <datalist id="<%= base.list_id %>">
111
+ <%= options_for_select(base.list) %>
112
+ </datalist>
59
113
  <% end %>
60
- </div>
114
+ <% end %>