headmin 0.1.2 → 0.2.0

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 (210) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -15
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +24 -2
  5. data/README.md +5 -34
  6. data/app/controllers/concerns/headmin/authentication.rb +0 -8
  7. data/app/controllers/concerns/headmin/pagination.rb +1 -1
  8. data/app/helpers/headmin/admin_helper.rb +4 -4
  9. data/app/models/concerns/headmin/block.rb +11 -0
  10. data/app/models/concerns/headmin/blockable.rb +10 -0
  11. data/app/models/concerns/headmin/field.rb +17 -0
  12. data/app/models/concerns/headmin/fieldable.rb +44 -0
  13. data/app/services/block_service.rb +68 -0
  14. data/app/views/{layouts → examples}/admin.html.erb +0 -0
  15. data/app/views/{layouts/admin → examples}/auth.html.erb +0 -0
  16. data/app/views/headmin/_blocks.html.erb +24 -0
  17. data/app/views/headmin/_breadcrumbs.html.erb +9 -5
  18. data/app/views/headmin/_card.html.erb +48 -0
  19. data/app/views/headmin/_dropdown.html.erb +18 -0
  20. data/app/views/headmin/_filters.html.erb +56 -34
  21. data/app/views/headmin/_form.html.erb +60 -6
  22. data/app/views/headmin/_heading.html.erb +8 -4
  23. data/app/views/headmin/_index.html.erb +9 -8
  24. data/app/views/headmin/_notifications.html.erb +8 -0
  25. data/app/views/headmin/_pagination.html.erb +11 -7
  26. data/app/views/headmin/_popup.html.erb +26 -0
  27. data/app/views/headmin/_table.html.erb +11 -4
  28. data/app/views/headmin/dropdown/_button.html.erb +13 -0
  29. data/app/views/headmin/dropdown/_devise.html.erb +21 -0
  30. data/app/views/headmin/{layout/dropdown → dropdown}/_divider.html.erb +1 -1
  31. data/app/views/headmin/dropdown/_item.html.erb +18 -0
  32. data/app/views/headmin/dropdown/_list.html.erb +11 -0
  33. data/app/views/headmin/dropdown/_locale.html.erb +17 -0
  34. data/app/views/headmin/filters/_date.html.erb +21 -16
  35. data/app/views/headmin/filters/_search.html.erb +18 -18
  36. data/app/views/headmin/filters/_select.html.erb +28 -23
  37. data/app/views/headmin/filters/filter/_button.html.erb +15 -6
  38. data/app/views/headmin/filters/filter/_menu_item.html.erb +2 -2
  39. data/app/views/headmin/filters/filter/_template.html.erb +2 -2
  40. data/app/views/headmin/forms/_actions.html.erb +4 -8
  41. data/app/views/headmin/forms/_base.html.erb +60 -0
  42. data/app/views/headmin/forms/_blocks.html.erb +32 -0
  43. data/app/views/headmin/forms/_checkbox.html.erb +39 -0
  44. data/app/views/headmin/forms/_ckeditor.html.erb +42 -0
  45. data/app/views/headmin/forms/_date.html.erb +45 -0
  46. data/app/views/headmin/forms/_email.html.erb +39 -0
  47. data/app/views/headmin/forms/_file.html.erb +40 -0
  48. data/app/views/headmin/forms/_image.html.erb +55 -0
  49. data/app/views/headmin/forms/_label.html.erb +24 -0
  50. data/app/views/headmin/forms/_number.html.erb +50 -0
  51. data/app/views/headmin/forms/_password.html.erb +69 -0
  52. data/app/views/headmin/forms/_redactorx.html.erb +49 -0
  53. data/app/views/headmin/forms/_repeater.html.erb +133 -0
  54. data/app/views/headmin/forms/_select.html.erb +70 -0
  55. data/app/views/headmin/forms/_text.html.erb +62 -0
  56. data/app/views/headmin/forms/_textarea.html.erb +39 -0
  57. data/app/views/headmin/forms/_url.html.erb +39 -0
  58. data/app/views/headmin/forms/_validation.html.erb +21 -0
  59. data/app/views/headmin/forms/actions/_destroy.html.erb +13 -0
  60. data/app/views/headmin/forms/actions/_save.html.erb +12 -0
  61. data/app/views/headmin/forms/actions/_view.html.erb +15 -0
  62. data/app/views/headmin/forms/fields/_base.html.erb +25 -0
  63. data/app/views/headmin/forms/fields/_file.html.erb +15 -22
  64. data/app/views/headmin/forms/fields/_group.html.erb +38 -0
  65. data/app/views/headmin/forms/fields/_image.html.erb +15 -35
  66. data/app/views/headmin/forms/fields/_list.html.erb +26 -0
  67. data/app/views/headmin/forms/fields/_text.html.erb +15 -37
  68. data/app/views/headmin/forms/repeater/_row.html.erb +51 -0
  69. data/app/views/headmin/heading/_title.html.erb +1 -1
  70. data/app/views/headmin/layout/_body.html.erb +1 -1
  71. data/app/views/headmin/layout/_content.html.erb +1 -1
  72. data/app/views/headmin/layout/_footer.html.erb +1 -1
  73. data/app/views/headmin/layout/_header.html.erb +1 -1
  74. data/app/views/headmin/layout/_main.html.erb +2 -2
  75. data/app/views/headmin/layout/_sidebar.html.erb +1 -1
  76. data/app/views/headmin/layout/sidebar/{_menu.html.erb → _nav.html.erb} +1 -1
  77. data/app/views/headmin/nav/_item.html.erb +21 -0
  78. data/app/views/headmin/nav/item/_devise.html.erb +21 -0
  79. data/app/views/headmin/nav/item/_locale.html.erb +17 -0
  80. data/app/views/headmin/pagination/_per_page.html.erb +18 -0
  81. data/app/views/headmin/{kaminari → pagination/kaminari}/_first_page.html.erb +0 -0
  82. data/app/views/headmin/{kaminari → pagination/kaminari}/_gap.html.erb +0 -0
  83. data/app/views/headmin/{kaminari → pagination/kaminari}/_last_page.html.erb +0 -0
  84. data/app/views/headmin/{kaminari → pagination/kaminari}/_next_page.html.erb +0 -0
  85. data/app/views/headmin/{kaminari → pagination/kaminari}/_page.html.erb +1 -1
  86. data/app/views/headmin/{kaminari → pagination/kaminari}/_paginator.html.erb +0 -0
  87. data/app/views/headmin/{kaminari → pagination/kaminari}/_prev_page.html.erb +0 -0
  88. data/app/views/headmin/table/_actions.html.erb +24 -17
  89. data/app/views/headmin/table/_body.html.erb +12 -10
  90. data/app/views/headmin/table/_foot.html.erb +8 -4
  91. data/app/views/headmin/table/_footer.html.erb +3 -7
  92. data/app/views/headmin/table/_head.html.erb +3 -1
  93. data/app/views/headmin/table/_header.html.erb +3 -7
  94. data/app/views/headmin/table/actions/_action.html.erb +26 -9
  95. data/app/views/headmin/table/actions/_delete.html.erb +11 -7
  96. data/app/views/headmin/table/actions/_export.html.erb +11 -7
  97. data/app/views/headmin/table/body/_association.html.erb +1 -1
  98. data/app/views/headmin/table/body/_boolean.erb +1 -1
  99. data/app/views/headmin/table/body/_currency.html.erb +1 -1
  100. data/app/views/headmin/table/body/_date.html.erb +1 -1
  101. data/app/views/headmin/table/body/_id.html.erb +2 -2
  102. data/app/views/headmin/table/body/_row.html.erb +1 -1
  103. data/app/views/headmin/table/body/_string.html.erb +1 -1
  104. data/app/views/headmin/table/body/_text.html.erb +1 -1
  105. data/app/views/headmin/table/foot/_cell.html.erb +1 -1
  106. data/app/views/headmin/table/foot/_id.html.erb +2 -2
  107. data/app/views/headmin/table/head/_cell.html.erb +1 -1
  108. data/app/views/headmin/table/head/_id.html.erb +3 -3
  109. data/app/views/headmin/views/devise/confirmations/_new.html.erb +9 -0
  110. data/app/views/headmin/views/devise/passwords/_edit.html.erb +12 -0
  111. data/app/views/headmin/views/devise/passwords/_new.html.erb +9 -0
  112. data/app/views/{admin/users/registrations/edit.html.erb → headmin/views/devise/registrations/_edit.html.erb} +5 -5
  113. data/app/views/headmin/views/devise/registrations/_new.html.erb +11 -0
  114. data/app/views/headmin/views/devise/sessions/_new.html.erb +13 -0
  115. data/app/views/{admin/users → headmin/views/devise}/shared/_error_messages.html.erb +0 -0
  116. data/app/views/{admin/users → headmin/views/devise}/shared/_links.html.erb +0 -0
  117. data/app/views/headmin/views/devise/unlocks/_new.html.erb +10 -0
  118. data/config/initializers/customize_input_error.rb +9 -0
  119. data/config/locales/devise/en.yml +65 -0
  120. data/config/locales/en.yml +2 -134
  121. data/config/locales/headmin/filters/en.yml +13 -0
  122. data/config/locales/headmin/filters/nl.yml +13 -0
  123. data/config/locales/headmin/forms/en.yml +34 -0
  124. data/config/locales/headmin/forms/nl.yml +33 -0
  125. data/config/locales/headmin/heading/en.yml +5 -0
  126. data/config/locales/headmin/heading/nl.yml +5 -0
  127. data/config/locales/headmin/layout/en.yml +14 -0
  128. data/config/locales/headmin/layout/nl.yml +14 -0
  129. data/config/locales/headmin/pagination/en.yml +21 -0
  130. data/config/locales/headmin/pagination/nl.yml +21 -0
  131. data/config/locales/headmin/table/en.yml +23 -0
  132. data/config/locales/headmin/table/nl.yml +23 -0
  133. data/config/locales/headmin/views/en.yml +58 -0
  134. data/config/locales/headmin/views/nl.yml +58 -0
  135. data/config/locales/nl.yml +2 -135
  136. data/dist/css/headmin.css +3182 -743
  137. data/dist/js/headmin.js +729 -33
  138. data/docs/README.md +2 -1
  139. data/docs/blocks.md +70 -85
  140. data/docs/devise.md +1 -60
  141. data/docs/fields.md +57 -0
  142. data/lib/generators/headmin/blocks_generator.rb +19 -0
  143. data/lib/generators/headmin/fields_generator.rb +19 -0
  144. data/lib/generators/templates/migrations/create_blocks.rb +10 -0
  145. data/lib/generators/templates/migrations/create_fields.rb +13 -0
  146. data/lib/generators/templates/models/block.rb +3 -0
  147. data/lib/generators/templates/models/field.rb +3 -0
  148. data/lib/headmin/version.rb +1 -1
  149. data/package.json +6 -6
  150. data/src/js/headmin/controllers/blocks_controller.js +103 -0
  151. data/src/js/headmin/controllers/filters_controller.js +23 -12
  152. data/src/js/headmin/controllers/popup_controller.js +68 -0
  153. data/src/js/headmin/controllers/repeater_controller.js +117 -11
  154. data/src/js/headmin/controllers/table_actions_controller.js +16 -5
  155. data/src/js/headmin/controllers/table_controller.js +84 -1
  156. data/src/js/headmin/headmin.js +29 -56
  157. data/src/scss/headmin/filters.scss +0 -14
  158. data/src/scss/headmin/form.scss +43 -3
  159. data/src/scss/headmin/popup.scss +17 -0
  160. data/src/scss/headmin/table.scss +9 -6
  161. data/src/scss/headmin.scss +7 -4
  162. data/src/scss/vendor/redactorx/override.css +3 -0
  163. data/src/scss/vendor/redactorx/redactorx.css +1460 -0
  164. data/yarn.lock +105 -2210
  165. metadata +93 -61
  166. data/app/controllers/admin/users/confirmations_controller.rb +0 -31
  167. data/app/controllers/admin/users/omniauth_callbacks_controller.rb +0 -31
  168. data/app/controllers/admin/users/passwords_controller.rb +0 -35
  169. data/app/controllers/admin/users/registrations_controller.rb +0 -63
  170. data/app/controllers/admin/users/sessions_controller.rb +0 -28
  171. data/app/controllers/admin/users/unlocks_controller.rb +0 -31
  172. data/app/views/admin/users/confirmations/new.html.erb +0 -9
  173. data/app/views/admin/users/mailer/confirmation_instructions.html.erb +0 -5
  174. data/app/views/admin/users/mailer/email_changed.html.erb +0 -7
  175. data/app/views/admin/users/mailer/password_change.html.erb +0 -3
  176. data/app/views/admin/users/mailer/reset_password_instructions.html.erb +0 -8
  177. data/app/views/admin/users/mailer/unlock_instructions.html.erb +0 -7
  178. data/app/views/admin/users/passwords/edit.html.erb +0 -12
  179. data/app/views/admin/users/passwords/new.html.erb +0 -9
  180. data/app/views/admin/users/registrations/new.html.erb +0 -11
  181. data/app/views/admin/users/sessions/new.html.erb +0 -13
  182. data/app/views/admin/users/unlocks/new.html.erb +0 -10
  183. data/app/views/headmin/forms/_group.html.erb +0 -36
  184. data/app/views/headmin/forms/fields/_checkbox.html.erb +0 -23
  185. data/app/views/headmin/forms/fields/_ckeditor.html.erb +0 -28
  186. data/app/views/headmin/forms/fields/_currency.html.erb +0 -24
  187. data/app/views/headmin/forms/fields/_date.html.erb +0 -36
  188. data/app/views/headmin/forms/fields/_email.html.erb +0 -39
  189. data/app/views/headmin/forms/fields/_label.html.erb +0 -9
  190. data/app/views/headmin/forms/fields/_multiple_select.html.erb +0 -37
  191. data/app/views/headmin/forms/fields/_password.html.erb +0 -39
  192. data/app/views/headmin/forms/fields/_repeater.html.erb +0 -48
  193. data/app/views/headmin/forms/fields/_select.html.erb +0 -36
  194. data/app/views/headmin/forms/fields/_select_tags.html.erb +0 -32
  195. data/app/views/headmin/forms/fields/_textarea.html.erb +0 -29
  196. data/app/views/headmin/forms/fields/_url.html.erb +0 -38
  197. data/app/views/headmin/forms/fields/_validation.html.erb +0 -12
  198. data/app/views/headmin/forms/fields/repeater/_row.html.erb +0 -16
  199. data/app/views/headmin/layout/dropdown/_item.html.erb +0 -17
  200. data/app/views/headmin/layout/header/_account.html.erb +0 -25
  201. data/app/views/headmin/layout/header/_locale.html.erb +0 -19
  202. data/app/views/headmin/layout/sidebar/menu/_account.html.erb +0 -25
  203. data/app/views/headmin/layout/sidebar/menu/_item.html.erb +0 -16
  204. data/app/views/headmin/layout/sidebar/menu/_locale.html.erb +0 -18
  205. data/src/js/headmin/controllers/index_controller.js +0 -79
  206. data/src/js/headmin/controllers/repeater_row_controller.js +0 -54
  207. data/src/scss/vendor/choices/cross-inverse.svg +0 -6
  208. data/src/scss/vendor/choices/cross.svg +0 -6
  209. data/src/scss/vendor/choices/custom.scss +0 -28
  210. data/src/scss/vendor/choices/variables.scss +0 -16
@@ -0,0 +1,39 @@
1
+ <%
2
+ # headmin/forms/textarea
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>attribute<tt> - Name of the attribute of the form model
7
+ # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
8
+ # * <tt>float<tt> - Set to true if you want to show floating labels
9
+ # * <tt>append<tt> - Text or icon to be shown on the left hand side of the input, Doesn't work with float
10
+ # * <tt>prepend<tt> - Text or icon to be shown on the right hand side of the input, Doesn't work with float
11
+ #
12
+ # ==== Examples
13
+ # Basic version
14
+ # <%= render 'headmin/forms/textarea', form: form, attribute: :title %#>
15
+
16
+ append = local_assigns.has_key?(:append) ? append : nil
17
+ class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
18
+ data = local_assigns.has_key?(:data) ? data : nil
19
+ disabled = local_assigns.has_key?(:disabled) ? disabled : false
20
+ float = local_assigns.has_key?(:float) ? float : false
21
+ label = local_assigns.has_key?(:label) ? label : nil
22
+ readonly = local_assigns.has_key?(:readonly) ? readonly : false
23
+ required = local_assigns.has_key?(:required) ? required : false
24
+ prepend = local_assigns.has_key?(:prepend) ? prepend : nil
25
+
26
+ options = {
27
+ 'aria-describedby': form_field_validation_id(form, attribute),
28
+ class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
29
+ data: data,
30
+ disabled: disabled,
31
+ placeholder: attribute,
32
+ readonly: readonly,
33
+ required: required,
34
+ }
35
+ %>
36
+
37
+ <%= render 'headmin/forms/base', form: form, attribute: attribute, append: append, prepend: prepend, float: float, label: label, required: required do |form| %>
38
+ <%= form.text_area(attribute, options) %>
39
+ <% end %>
@@ -0,0 +1,39 @@
1
+ <%
2
+ # headmin/forms/url
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>attribute<tt> - Name of the attribute of the form model
7
+ # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
8
+ # * <tt>float<tt> - Set to true if you want to show floating labels
9
+ # * <tt>append<tt> - Text or icon to be shown on the left hand side of the input, Doesn't work with float
10
+ # * <tt>prepend<tt> - Text or icon to be shown on the right hand side of the input, Doesn't work with float
11
+ #
12
+ # ==== Examples
13
+ # Basic version
14
+ # <%= render 'headmin/forms/url', form: form, attribute: :website_url %#>
15
+
16
+ append = local_assigns.has_key?(:append) ? append : nil
17
+ class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
18
+ data = local_assigns.has_key?(:data) ? data : nil
19
+ disabled = local_assigns.has_key?(:disabled) ? disabled : false
20
+ float = local_assigns.has_key?(:float) ? float : false
21
+ label = local_assigns.has_key?(:label) ? label : nil
22
+ prepend = local_assigns.has_key?(:prepend) ? prepend : nil
23
+ readonly = local_assigns.has_key?(:readonly) ? readonly : false
24
+ required = local_assigns.has_key?(:required) ? required : false
25
+
26
+ options = {
27
+ 'aria-describedby': form_field_validation_id(form, attribute),
28
+ class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
29
+ data: data,
30
+ disabled: disabled,
31
+ placeholder: attribute,
32
+ readonly: readonly,
33
+ required: required,
34
+ }
35
+ %>
36
+
37
+ <%= render 'headmin/forms/base', form: form, attribute: attribute, append: append, prepend: prepend, float: float, label: label, required: required do |form| %>
38
+ <%= form.url_field(attribute, options) %>
39
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <%
2
+ # headmin/forms/validation
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>attribute<tt> - Name of the attribute of the form model
7
+ #
8
+ # ==== Examples
9
+ # Basic version
10
+ # <%= render 'headmin/forms/validation', form: form, attribute: attribute %#>
11
+
12
+ show_feedback = form.object && !form_field_valid?(form, attribute)
13
+ id = form_field_validation_id(form, attribute)
14
+ message = form.object.errors[attribute].join(', ')
15
+ %>
16
+
17
+ <% if show_feedback %>
18
+ <div class="invalid-feedback" id="<%= id %>">
19
+ <%= message %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <%#
2
+ name: headmin/forms/actions/views
3
+ accepts block: true
4
+ parameters:
5
+ form: (object) Form object
6
+ %>
7
+
8
+ <div class="d-grid">
9
+ <%= link_to([:admin, form.object], class: 'btn btn-outline-danger', method: :delete, data: {confirm: t('.confirm')}) do %>
10
+ <%= bootstrap_icon('trash') %>
11
+ <%= t('.title') %>
12
+ <% end %>
13
+ </div>
@@ -0,0 +1,12 @@
1
+ <%#
2
+ name: headmin/forms/actions/views
3
+ accepts block: true
4
+ parameters:
5
+ form: (object) Form object
6
+ %>
7
+
8
+ <div class="d-grid">
9
+ <%= form.button type: :submit, class: 'btn btn-lg btn-primary' do %>
10
+ <%= t('.title') %>
11
+ <% end %>
12
+ </div>
@@ -0,0 +1,15 @@
1
+ <%#
2
+ name: headmin/forms/actions/views
3
+ accepts block: true
4
+ parameters:
5
+ url: (string) Url for preview
6
+ %>
7
+
8
+ <% url = local_assigns.has_key?(:url) ? url : nil %>
9
+
10
+ <div class="d-grid mb-2">
11
+ <a href="<%= url %>" target="_blank" class="btn h-btn-outline-light">
12
+ <%= bootstrap_icon('eye') %>
13
+ <%= t('.title') %>
14
+ </a>
15
+ </div>
@@ -0,0 +1,25 @@
1
+ <%
2
+ # name: headmin/forms/fields/base
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>name<tt> - Name for the field
7
+ # * <tt>field_type<tt> - Type of the field. Options: [:text, :image, :file, :list, :group]
8
+ #
9
+ # ==== Examples
10
+ # Basic version
11
+ # <%= render 'headmin/forms/fields/base', form: form, field_type: :text, name: name do |field, label| %#>
12
+ # <%= render "headmin/forms/text", form: field, attribute: :value, label: label %#>
13
+ # <% end %#>
14
+
15
+ field = form.object.fields.detect { |field| field.name.to_s == name.to_s }
16
+ field = field ? field : form.object.fields.new(field_type: field_type, name: name)
17
+ label = t("attributes.#{name.to_s.parameterize}", default: field.name.to_s)
18
+ %>
19
+
20
+ <%= form.fields_for :fields, field do |ff| %>
21
+ <%= ff.hidden_field :id %>
22
+ <%= ff.hidden_field :name %>
23
+ <%= ff.hidden_field :field_type %>
24
+ <%= yield ff, label %>
25
+ <% end %>
@@ -1,24 +1,17 @@
1
- <%#
2
- name: headmin/fields/file
3
- accepts block: no
4
- parameters:
5
- form: Form object
6
- attribute: (string) Name of the attribute of the form model
7
- label: (bool) Label will not be displayed if value is false
1
+ <%
2
+ # name: headmin/forms/fields/file
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>name<tt> - Name for the field
7
+ #
8
+ # ==== Examples
9
+ # Basic version
10
+ # <%= render 'headmin/forms/fields/file', form: group, name: :file do |field, attribute, label| %#>
11
+ # <%= render "headmin/forms/file", form: field, attribute: attribute, label: label %#>
12
+ # <% end %#>
8
13
  %>
9
14
 
10
- <% label = local_assigns.has_key?(:label) ? label : true %>
11
- <% disabled = local_assigns.has_key?(:disabled) ? disabled : false %>
12
- <% required = local_assigns.has_key?(:required) ? required : false %>
13
- <div class="<%= ('mb-3' if label) %>">
14
- <%= render 'headmin/forms/fields/label', form: form, attribute: attribute, required: required if label %>
15
- <%= form.file_field(
16
- attribute,
17
- class: "form-control #{form_field_validation_class(form, attribute)}",
18
- disabled: disabled,
19
- required: required,
20
- 'aria-describedby': form_field_validation_id(form, attribute)
21
- )
22
- %>
23
- <%= render 'headmin/forms/fields/validation', form: form, attribute: attribute %>
24
- </div>
15
+ <%= render 'headmin/forms/fields/base', form: form, field_type: :file, name: name do |field, label| %>
16
+ <% yield field, :file, label %>
17
+ <% end %>
@@ -0,0 +1,38 @@
1
+ <%
2
+ # name: headmin/forms/fields/group
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>name<tt> - Name for the field
7
+ # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
8
+ #
9
+ # ==== Examples
10
+ # Basic version
11
+ # <%= render 'headmin/forms/fields/group', form: form, name: :button do |group| %#>
12
+ # <div class="row">
13
+ # <div class="col-md-6">
14
+ # <%= render 'headmin/forms/fields/text', form: group, name: :name do |field, attribute, label| %#>
15
+ # <%= render "headmin/forms/text", form: field, attribute: attribute, label: label %#>
16
+ # <% end %#>
17
+ # </div>
18
+ # <div class="col-md-6">
19
+ # <%= render 'headmin/forms/fields/text', form: group, name: :url do |field, attribute, label| %#>
20
+ # <%= render "headmin/forms/text", form: field, attribute: attribute, label: label %#>
21
+ # <% end %#>
22
+ # </div>
23
+ # </div>
24
+ # <% end %#>
25
+
26
+ label = local_assigns.has_key?(:label) ? label : nil
27
+ show_label = label != false
28
+ %>
29
+
30
+ <%= render 'headmin/forms/fields/base', form: form, name: name, field_type: :group do |group, field_label| %>
31
+ <% if show_label %>
32
+ <%= render 'headmin/forms/label', form: form, attribute: :value, name: label || field_label %>
33
+ <% end %>
34
+
35
+ <li class="list-group-item mb-3">
36
+ <%= yield group %>
37
+ </li>
38
+ <% end %>
@@ -1,37 +1,17 @@
1
- <%#
2
- name: headmin/fields/file
3
- accepts block: no
4
- parameters:
5
- form: Form object
6
- attribute: (string) Name of the attribute of the form model
7
- label: (bool) Label will not be displayed if value is false
1
+ <%
2
+ # name: headmin/forms/fields/image
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>name<tt> - Name for the field
7
+ #
8
+ # ==== Examples
9
+ # Basic version
10
+ # <%= render 'headmin/forms/fields/image', form: group, name: :image do |field, attribute, label| %#>
11
+ # <%= render "headmin/forms/image", form: field, attribute: attribute, label: label %#>
12
+ # <% end %#>
8
13
  %>
9
14
 
10
- <% has_image = form.object.send(attribute) %>
11
- <% label = local_assigns.has_key?(:label) ? label : true %>
12
- <% disabled = local_assigns.has_key?(:disabled) ? disabled : false %>
13
- <% required = local_assigns.has_key?(:required) && !has_image ? required : false %>
14
- <div class="<%= ('mb-3' if label) %>">
15
- <%= render 'headmin/forms/fields/label', form: form, attribute: attribute, required: required if label %>
16
-
17
- <div class="mb-2">
18
- <% if form.object.send(attribute).attached? %>
19
- <%= image_tag(form.object.send(attribute).variant(resize_to_limit: [200, 200], quality: 70), class: 'img-thumbnail') %>
20
- <% else %>
21
- <svg class="img-thumbnail" width="200" height="200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera: 200x200" preserveAspectRatio="xMidYMid slice" focusable="false">
22
- <title>A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera</title>
23
- <rect width="100%" height="100%" fill="#e9ecef"></rect>
24
- <text x="35%" y="50%" fill="#212529" dy=".3em">200x200</text>
25
- </svg>
26
- <% end %>
27
- </div>
28
-
29
- <%= form.file_field(
30
- attribute,
31
- class: "form-control #{form_field_validation_class(form, attribute)}",
32
- disabled: disabled,
33
- required: required,
34
- 'aria-describedby': form_field_validation_id(form, attribute))
35
- %>
36
- <%= render 'headmin/forms/fields/validation', form: form, attribute: attribute %>
37
- </div>
15
+ <%= render 'headmin/forms/fields/base', form: form, field_type: :image, name: name do |field, label| %>
16
+ <% yield field, :file, label %>
17
+ <% end %>
@@ -0,0 +1,26 @@
1
+ <%
2
+ # name: headmin/forms/fields/list
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>name<tt> - Name for the field
7
+ # * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
8
+ #
9
+ # ==== Examples
10
+ # Basic version
11
+ # <%= render 'headmin/forms/fields/list', form: form, name: :websites do |list| %#>
12
+ # <%= render 'headmin/forms/fields/text', form: list, name: :url do |field, attribute, label| %#>
13
+ # <%= render "headmin/forms/text", form: field, attribute: attribute, label: label %#>
14
+ # <% end %#>
15
+ # <% end %#>
16
+
17
+ label = local_assigns.has_key?(:label) ? label : nil
18
+ show_label = label != false
19
+ %>
20
+
21
+ <%= render 'headmin/forms/fields/base', form: form, name: name, field_type: :list do |list, field_label| %>
22
+ <%= render 'headmin/forms/repeater', form: list, attribute: :fields, label: show_label ? label || field_label : false, flush: false do |field| %>
23
+ <%= field.hidden_field :field_type, value: :group %>
24
+ <%= yield field %>
25
+ <% end %>
26
+ <% end %>
@@ -1,39 +1,17 @@
1
- <%#
2
- name: headmin/fields/text
3
- accepts block: no
4
- parameters:
5
- form: Form object
6
- attribute: (string) Name of the attribute of the form model
7
- label: (bool | string) Label will not be displayed if value is false or accepts a string 'float' to get a "floating label"
1
+ <%
2
+ # name: headmin/forms/fields/text
3
+ #
4
+ # ==== Options
5
+ # * <tt>form<tt> - Form object
6
+ # * <tt>name<tt> - Name for the field
7
+ #
8
+ # ==== Examples
9
+ # Basic version
10
+ # <%= render 'headmin/forms/fields/text', form: group, name: :name do |field, attribute, label| %#>
11
+ # <%= render "headmin/forms/text", form: field, attribute: attribute, label: label %#>
12
+ # <% end %#>
8
13
  %>
9
14
 
10
- <% label = local_assigns.has_key?(:label) ? label : true %>
11
- <% float_label = label == :float %>
12
- <% disabled = local_assigns.has_key?(:disabled) ? disabled : false %>
13
- <% required = local_assigns.has_key?(:required) ? required : false %>
14
- <% readonly = local_assigns.has_key?(:readonly) ? readonly : false %>
15
- <% class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false %>
16
- <% has_list = local_assigns.has_key?(:collection) %>
17
- <div class="<%= 'form-floating' if float_label %> <%= ('mb-3 text-start' if label) %>">
18
- <%= render 'headmin/forms/fields/label', form: form, attribute: attribute, required: required if label && !float_label %>
19
- <%= form.text_field(
20
- attribute,
21
- class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
22
- list: has_list ? attribute : nil,
23
- disabled: disabled,
24
- required: required,
25
- placeholder: attribute,
26
- readonly: readonly,
27
- 'aria-describedby': form_field_validation_id(form, attribute)
28
- )
29
- %>
30
- <%= render 'headmin/forms/fields/label', form: form, attribute: attribute, required: required if label && float_label %>
31
- <% if has_list %>
32
- <datalist id="<%= attribute %>">
33
- <% collection.each do |key, value| %>
34
- <option value="<%= value %>"><%= key %></option>
35
- <% end %>
36
- </datalist>
37
- <% end %>
38
- <%= render 'headmin/forms/fields/validation', form: form, attribute: attribute %>
39
- </div>
15
+ <%= render 'headmin/forms/fields/base', form: form, field_type: :text, name: name do |field, label| %>
16
+ <% yield field, :value, label %>
17
+ <% end %>
@@ -0,0 +1,51 @@
1
+ <%
2
+ # headmin/fields/repeater/row
3
+ # accepts block: yes
4
+ # parameters:
5
+ # form: Form object
6
+ # pass_thru: (string) Pass thru for add button if needed
7
+
8
+ draggable = form.object.respond_to?(:position)
9
+ destroyable = form.object.respond_to?(:destroy)
10
+ %>
11
+
12
+ <div class="repeater-row list-group-item"
13
+ data-repeater-target="row"
14
+ data-row-index="<%= form.options[:child_index] %>"
15
+ data-new-record="<%= form.object.new_record? %>"
16
+ >
17
+
18
+ <%= form.hidden_field :id %>
19
+ <%= form.hidden_field :_destroy if destroyable %>
20
+ <%= form.hidden_field :position if draggable %>
21
+ <%= yield if block_given? %>
22
+
23
+ <!-- Drag handle -->
24
+ <% if draggable %>
25
+ <div class="repeater-row-handle">
26
+ <%= bootstrap_icon('grip-vertical') %>
27
+ </div>
28
+ <% end %>
29
+
30
+ <!-- Add button-->
31
+ <a href="#"
32
+ class="repeater-row-add btn btn-link"
33
+ title="<%= t('.add') %>"
34
+ data-repeater-target="addButton"
35
+ data-popup-target="button"
36
+ data-popup-id="<%= "repeater-buttons-#{repeater_id}" %>"
37
+ data-popup-pass-thru="<%= pass_thru %>"
38
+ data-action="click->repeater#resetButtonIndices click->popup#open"
39
+ >
40
+ <%= bootstrap_icon('plus-circle') %>
41
+ </a>
42
+
43
+ <!-- Remove button-->
44
+ <a href="#"
45
+ class="repeater-row-remove btn btn-link"
46
+ title="<%= t('.remove') %>"
47
+ data-action="click->repeater#removeRow"
48
+ >
49
+ <%= bootstrap_icon('dash-circle') %>
50
+ </a>
51
+ </div>
@@ -1,5 +1,5 @@
1
1
  <%#
2
- name: headmin/heading/title
2
+ headmin/heading/title
3
3
  accepts block: no
4
4
  parameters:
5
5
  title: (string) Title to be displayed
@@ -1,5 +1,5 @@
1
1
  <%#
2
- name: headmin/layout/body
2
+ headmin/layout/body
3
3
  accepts block: yes
4
4
  parameters: none
5
5
  %>
@@ -1,5 +1,5 @@
1
1
  <%#
2
- name: headmin/layout/content
2
+ headmin/layout/content
3
3
  accepts block: yes
4
4
  parameters: none
5
5
  %>
@@ -1,5 +1,5 @@
1
1
  <%#
2
- name: headmin/layout/footer
2
+ headmin/layout/footer
3
3
  accepts block: yes
4
4
  parameters: none
5
5
  %>
@@ -1,5 +1,5 @@
1
1
  <%#
2
- name: headmin/layout/header
2
+ headmin/layout/header
3
3
  accepts block: yes
4
4
  parameters: none
5
5
  %>
@@ -1,10 +1,10 @@
1
1
  <%#
2
- name: headmin/layout/main
2
+ headmin/layout/main
3
3
  accepts block: yes
4
4
  parameters: none
5
5
  %>
6
6
 
7
- <div class="main">
7
+ <div class="main" data-controller="popup">
8
8
  <div class="container-fluid">
9
9
  <div class="row">
10
10
  <%= yield if block_given? %>
@@ -1,5 +1,5 @@
1
1
  <%#
2
- name: headmin/layout/sidebar
2
+ headmin/layout/sidebar
3
3
  accepts block: yes
4
4
  parameters:
5
5
  logo: image path to logo
@@ -1,5 +1,5 @@
1
1
  <%#
2
- name: headmin/layout/sidebar/menu
2
+ headmin/layout/sidebar/menu
3
3
  accepts block: yes
4
4
  parameters: none
5
5
  %>
@@ -0,0 +1,21 @@
1
+ <%#
2
+ headmin/nav/item
3
+ accepts block: yes
4
+ parameters:
5
+ url: (string) Url to be used as anchor in link tag
6
+ name: (string) Name to be displayed inside link
7
+ active: (boolean) Whether to highlight the item or not
8
+ %>
9
+ <% name = local_assigns.has_key?(:name) ? name : '' %>
10
+ <% icon = local_assigns.has_key?(:icon) ? icon : nil %>
11
+ <% url = local_assigns.has_key?(:url) ? url : '' %>
12
+ <% active = local_assigns.has_key?(:active) ? current_url?(url) : false %>
13
+
14
+ <li class="nav-item">
15
+ <a class="nav-link d-flex align-items-center <%= 'active' if active %>" aria-current="page" href="<%= url %>">
16
+ <%= bootstrap_icon(icon, class: 'me-2') if icon %>
17
+ <span class="d-block d-md-none d-lg-block">
18
+ <%= name %>
19
+ </span>
20
+ </a>
21
+ </li>
@@ -0,0 +1,21 @@
1
+ <%#
2
+ headmin/layout/sidebar/menu/account
3
+ accepts block: yes
4
+ parameters:
5
+ scope: (symbol) devise scope, i.e. ':users' => current_user
6
+ %>
7
+
8
+ <% scope = local_assigns.has_key?(:scope) ? scope : 'users' %>
9
+ <% singular = scope.to_s.singularize.to_sym %>
10
+ <% user = send("current_#{singular}") %>
11
+
12
+ <%= render 'headmin/dropdown', class: 'nav-item' do %>
13
+ <%= render 'headmin/dropdown/button', class: 'nav-link', id: 'nav-item-devise' do %>
14
+ <%= user.to_s %>
15
+ <% end %>
16
+ <%= render 'headmin/dropdown/list', id: 'nav-item-devise' do %>
17
+ <%= render 'headmin/dropdown/item', name: t('.edit_profile'), url: polymorphic_path([:edit, singular, :registration]) %>
18
+ <%= render 'headmin/dropdown/divider' %>
19
+ <%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), method: :delete %>
20
+ <% end %>
21
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <%#
2
+ headmin/layout/sidebar/menu/locale
3
+ accepts block: no
4
+ parameters: none
5
+ %>
6
+
7
+ <%= render 'headmin/dropdown', class: 'nav-item' do %>
8
+ <%= render 'headmin/dropdown/button', class: 'nav-link', id: 'nav-item-locale' do %>
9
+ <%= bootstrap_icon('globe', class: 'me-2') %>
10
+ <%= t('language_name', locale: ::I18n.locale) %>
11
+ <% end %>
12
+ <%= render 'headmin/dropdown/list', id: 'nav-item-locale' do %>
13
+ <% I18n.available_locales.each do |locale| %>
14
+ <%= render 'headmin/dropdown/item', name: t('language_name', locale: locale), url: url_for({locale: locale.to_s}) %>
15
+ <% end %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <% per_page = params[:per_page] ? params[:per_page].to_i : 24 %>
2
+
3
+ <div class="d-flex flex-row-reverse flex-md-row align-items-center justify-content-between justify-content-md-end my-1">
4
+ <ul class="pagination pagination-sm my-0" role="group" aria-label="...">
5
+ <li class="page-item <%= 'active' if per_page == 12 %>">
6
+ <%= link_to 12, url_for(params.merge(per_page: 12)), class: 'page-link' %>
7
+ </li>
8
+ <li class="page-item <%= 'active' if per_page == 24 %>">
9
+ <%= link_to 24, url_for(params.merge(per_page: nil)), class: 'page-link' %>
10
+ </li>
11
+ <li class="page-item <%= 'active' if per_page == 48 %>">
12
+ <%= link_to 48, url_for(params.merge(per_page: 48)), class: 'page-link' %>
13
+ </li>
14
+ </ul>
15
+ <div class="d-none d-md-block ms-2 me-md-2 text-secondary">
16
+ <%= t('.title') %>
17
+ </div>
18
+ </div>
@@ -7,6 +7,6 @@
7
7
  per_page: number of items to fetch per page
8
8
  remote: data-remote
9
9
  -%>
10
- <li class="page-item<%= ' active' if page.current? %>">
10
+ <li class="page-item <%= 'active' if page.current? %>">
11
11
  <%= link_to page, url, opts = {remote: remote, class: 'page-link', rel: page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
12
12
  </li>