headmin 0.5.1 → 0.5.2

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 (142) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -2
  3. data/Gemfile +14 -0
  4. data/Gemfile.lock +77 -0
  5. data/app/assets/javascripts/headmin/controllers/media_controller.js +237 -0
  6. data/app/assets/javascripts/headmin/controllers/media_modal_controller.js +110 -0
  7. data/app/assets/javascripts/headmin/controllers/remote_modal_controller.js +10 -0
  8. data/app/assets/javascripts/headmin/controllers/textarea_controller.js +34 -0
  9. data/app/assets/javascripts/headmin/index.js +8 -0
  10. data/app/assets/javascripts/headmin.js +294 -0
  11. data/app/assets/stylesheets/headmin/forms/file.scss +40 -5
  12. data/app/assets/stylesheets/headmin/forms/media.scss +10 -0
  13. data/app/assets/stylesheets/headmin/forms/repeater.scss +4 -0
  14. data/app/assets/stylesheets/headmin/forms.scss +7 -0
  15. data/app/assets/stylesheets/headmin/layout/sidebar.scss +0 -1
  16. data/app/assets/stylesheets/headmin/media/index.scss +9 -0
  17. data/app/assets/stylesheets/headmin/media.scss +1 -0
  18. data/app/assets/stylesheets/headmin/table.scss +8 -0
  19. data/app/assets/stylesheets/headmin.css +64 -7
  20. data/app/assets/stylesheets/headmin.scss +1 -0
  21. data/app/controllers/headmin/media_controller.rb +52 -0
  22. data/app/controllers/headmin_controller.rb +2 -0
  23. data/app/models/concerns/headmin/field.rb +0 -1
  24. data/app/models/concerns/headmin/fieldable.rb +10 -1
  25. data/app/models/concerns/headmin/form/hintable.rb +6 -1
  26. data/app/models/headmin/filter/date.rb +49 -1
  27. data/app/models/headmin/form/media_view.rb +113 -0
  28. data/app/models/headmin/form/textarea_view.rb +6 -1
  29. data/app/views/examples/admin.html.erb +13 -13
  30. data/app/views/examples/auth.html.erb +1 -1
  31. data/app/views/headmin/_blocks.html.erb +2 -2
  32. data/app/views/headmin/_breadcrumbs.html.erb +1 -1
  33. data/app/views/headmin/_dropdown.html.erb +1 -1
  34. data/app/views/headmin/_filters.html.erb +3 -3
  35. data/app/views/headmin/_form.html.erb +2 -2
  36. data/app/views/headmin/_heading.html.erb +1 -1
  37. data/app/views/headmin/_index.html.erb +1 -1
  38. data/app/views/headmin/_notifications.html.erb +1 -1
  39. data/app/views/headmin/_pagination.html.erb +1 -1
  40. data/app/views/headmin/_popup.html.erb +2 -2
  41. data/app/views/headmin/_table.html.erb +1 -1
  42. data/app/views/headmin/dropdown/_devise.html.erb +8 -8
  43. data/app/views/headmin/dropdown/_list.html.erb +1 -1
  44. data/app/views/headmin/dropdown/_locale.html.erb +4 -4
  45. data/app/views/headmin/filters/_base.html.erb +20 -20
  46. data/app/views/headmin/filters/_boolean.html.erb +4 -4
  47. data/app/views/headmin/filters/_date.html.erb +4 -4
  48. data/app/views/headmin/filters/_flatpickr.html.erb +4 -4
  49. data/app/views/headmin/filters/_number.html.erb +4 -4
  50. data/app/views/headmin/filters/_options.html.erb +4 -4
  51. data/app/views/headmin/filters/_search.html.erb +3 -3
  52. data/app/views/headmin/filters/_text.html.erb +4 -4
  53. data/app/views/headmin/filters/filter/_button.html.erb +1 -1
  54. data/app/views/headmin/forms/_autocomplete.html.erb +2 -2
  55. data/app/views/headmin/forms/_blocks.html.erb +4 -4
  56. data/app/views/headmin/forms/_checkbox.html.erb +5 -5
  57. data/app/views/headmin/forms/_color.html.erb +5 -5
  58. data/app/views/headmin/forms/_date.html.erb +8 -8
  59. data/app/views/headmin/forms/_date_range.html.erb +3 -3
  60. data/app/views/headmin/forms/_datetime.html.erb +8 -8
  61. data/app/views/headmin/forms/_datetime_range.html.erb +3 -3
  62. data/app/views/headmin/forms/_email.html.erb +9 -9
  63. data/app/views/headmin/forms/_file.html.erb +12 -12
  64. data/app/views/headmin/forms/_flatpickr.html.erb +2 -2
  65. data/app/views/headmin/forms/_flatpickr_range.html.erb +8 -8
  66. data/app/views/headmin/forms/_hidden.html.erb +1 -1
  67. data/app/views/headmin/forms/_hint.html.erb +7 -2
  68. data/app/views/headmin/forms/_label.html.erb +1 -1
  69. data/app/views/headmin/forms/_media.html.erb +58 -0
  70. data/app/views/headmin/forms/_number.html.erb +8 -8
  71. data/app/views/headmin/forms/_password.html.erb +7 -7
  72. data/app/views/headmin/forms/_redactorx.html.erb +2 -2
  73. data/app/views/headmin/forms/_repeater.html.erb +12 -12
  74. data/app/views/headmin/forms/_search.html.erb +9 -9
  75. data/app/views/headmin/forms/_select.html.erb +8 -8
  76. data/app/views/headmin/forms/_switch.html.erb +2 -2
  77. data/app/views/headmin/forms/_text.html.erb +9 -9
  78. data/app/views/headmin/forms/_textarea.html.erb +7 -7
  79. data/app/views/headmin/forms/_url.html.erb +9 -9
  80. data/app/views/headmin/forms/_validation.html.erb +1 -1
  81. data/app/views/headmin/forms/_wysiwyg.html.erb +2 -2
  82. data/app/views/headmin/forms/fields/_base.html.erb +2 -2
  83. data/app/views/headmin/forms/fields/_file.html.erb +3 -3
  84. data/app/views/headmin/forms/fields/_files.html.erb +3 -3
  85. data/app/views/headmin/forms/fields/_group.html.erb +7 -7
  86. data/app/views/headmin/forms/fields/_list.html.erb +5 -5
  87. data/app/views/headmin/forms/fields/_text.html.erb +3 -3
  88. data/app/views/headmin/forms/media/_item.html.erb +32 -0
  89. data/app/views/headmin/forms/media/_validation.html.erb +10 -0
  90. data/app/views/headmin/forms/repeater/_row.html.erb +12 -11
  91. data/app/views/headmin/layout/_main.html.erb +3 -1
  92. data/app/views/headmin/layout/_remote_modal.html.erb +1 -0
  93. data/app/views/headmin/layout/_sidebar.html.erb +1 -1
  94. data/app/views/headmin/media/_item.html.erb +17 -0
  95. data/app/views/headmin/media/_media_item_modal.html.erb +51 -0
  96. data/app/views/headmin/media/_modal.html.erb +35 -0
  97. data/app/views/headmin/media/create.turbo_stream.erb +5 -0
  98. data/app/views/headmin/media/index.html.erb +3 -0
  99. data/app/views/headmin/media/show.html.erb +9 -0
  100. data/app/views/headmin/media/update.turbo_stream.erb +3 -0
  101. data/app/views/headmin/nav/_dropdown.html.erb +3 -3
  102. data/app/views/headmin/nav/_item.html.erb +2 -2
  103. data/app/views/headmin/nav/item/_devise.html.erb +6 -6
  104. data/app/views/headmin/nav/item/_locale.html.erb +4 -4
  105. data/app/views/headmin/table/_actions.html.erb +2 -2
  106. data/app/views/headmin/table/actions/_action.html.erb +3 -3
  107. data/app/views/headmin/table/actions/_delete.html.erb +2 -2
  108. data/app/views/headmin/table/actions/_export.html.erb +2 -2
  109. data/app/views/headmin/table/body/_image.html.erb +18 -0
  110. data/app/views/headmin/table/body/_row.html.erb +3 -3
  111. data/app/views/headmin/table/foot/_cell.html.erb +1 -1
  112. data/app/views/headmin/views/devise/confirmations/_new.html.erb +3 -3
  113. data/app/views/headmin/views/devise/passwords/_edit.html.erb +4 -4
  114. data/app/views/headmin/views/devise/passwords/_new.html.erb +3 -3
  115. data/app/views/headmin/views/devise/registrations/_edit.html.erb +5 -5
  116. data/app/views/headmin/views/devise/registrations/_new.html.erb +5 -5
  117. data/app/views/headmin/views/devise/sessions/_new.html.erb +4 -4
  118. data/app/views/headmin/views/devise/unlocks/_new.html.erb +3 -3
  119. data/config/locales/devise/nl.yml +1 -1
  120. data/config/locales/headmin/forms/en.yml +8 -0
  121. data/config/locales/headmin/forms/nl.yml +8 -0
  122. data/config/locales/headmin/media/en.yml +23 -0
  123. data/config/locales/headmin/media/nl.yml +22 -0
  124. data/config/locales/headmin/table/en.yml +2 -0
  125. data/config/locales/headmin/table/nl.yml +2 -0
  126. data/config/routes.rb +10 -0
  127. data/lib/generators/templates/views/auth/confirmations/new.html.erb +1 -1
  128. data/lib/generators/templates/views/auth/mailer/confirmation_instructions.html.erb +1 -1
  129. data/lib/generators/templates/views/auth/mailer/email_changed.html.erb +1 -1
  130. data/lib/generators/templates/views/auth/mailer/password_change.html.erb +1 -1
  131. data/lib/generators/templates/views/auth/mailer/reset_password_instructions.html.erb +1 -1
  132. data/lib/generators/templates/views/auth/mailer/unlock_instructions.html.erb +1 -1
  133. data/lib/generators/templates/views/auth/passwords/edit.html.erb +1 -1
  134. data/lib/generators/templates/views/auth/passwords/new.html.erb +1 -1
  135. data/lib/generators/templates/views/auth/registrations/edit.html.erb +1 -1
  136. data/lib/generators/templates/views/auth/registrations/new.html.erb +1 -1
  137. data/lib/generators/templates/views/auth/sessions/new.html.erb +1 -1
  138. data/lib/generators/templates/views/auth/unlocks/new.html.erb +1 -1
  139. data/lib/generators/templates/views/layouts/auth.html.erb +1 -1
  140. data/lib/headmin/version.rb +1 -1
  141. metadata +27 -3
  142. data/.lock-487e157d270f3062a98b7b2a012753708-1272821827 +0 -0
@@ -11,13 +11,13 @@
11
11
  #
12
12
  # ==== Examples
13
13
  # Basic version
14
- # <%= render "headmin/filters", url: admin_orders_path do |form| %#>
15
- # <%= render "headmin/filters/number", form: form, attribute: :beverages %#>
14
+ # <%= render 'headmin/filters', url: admin_orders_path do |form| %#>
15
+ # <%= render 'headmin/filters/number', form: form, attribute: :beverages %#>
16
16
  # <% end %#>
17
17
 
18
18
  number = Headmin::Filter::NumberView.new(local_assigns.merge(params: params))
19
19
  %>
20
20
 
21
- <%= render "headmin/filters/base", number.base_options do |value| %>
22
- <%= render "headmin/forms/number", number.input_options.merge({value: value}) %>
21
+ <%= render 'headmin/filters/base', number.base_options do |value| %>
22
+ <%= render 'headmin/forms/number', number.input_options.merge({value: value}) %>
23
23
  <% end %>
@@ -12,13 +12,13 @@
12
12
  #
13
13
  # ==== Examples
14
14
  # Basic version
15
- # <%= render "headmin/filters", url: admin_orders_path do |form| %#>
16
- # <%= render "headmin/filters/options", form: form, attribute: :category %#>
15
+ # <%= render 'headmin/filters', url: admin_orders_path do |form| %#>
16
+ # <%= render 'headmin/filters/options', form: form, attribute: :category %#>
17
17
  # <% end %#>
18
18
 
19
19
  options = Headmin::Filter::OptionsView.new(local_assigns.merge(params: params))
20
20
  %>
21
21
 
22
- <%= render "headmin/filters/base", options.base_options do |value| %>
23
- <%= render "headmin/forms/select", options.input_options.merge(selected: value) %>
22
+ <%= render 'headmin/filters/base', options.base_options do |value| %>
23
+ <%= render 'headmin/forms/select', options.input_options.merge(selected: value) %>
24
24
  <% end %>
@@ -12,13 +12,13 @@
12
12
  #
13
13
  # ==== Examples
14
14
  # Basic version.
15
- # <%= render "headmin/filters", url: admin_orders_path do |form| %#>
16
- # <%= render "headmin/filters/search", attribute: :search, label: Poll.model_name.human(count: 2) %#>
15
+ # <%= render 'headmin/filters', url: admin_orders_path do |form| %#>
16
+ # <%= render 'headmin/filters/search', attribute: :search, label: Poll.model_name.human(count: 2) %#>
17
17
  # <% end %#>
18
18
 
19
19
  search = Headmin::Filter::SearchView.new(local_assigns.merge(params: params))
20
20
  %>
21
21
 
22
22
  <% content_for :filters_search do %>
23
- <%= render "headmin/forms/search", search.input_options %>
23
+ <%= render 'headmin/forms/search', search.input_options %>
24
24
  <% end %>
@@ -11,13 +11,13 @@
11
11
  #
12
12
  # ==== Examples
13
13
  # Basic version
14
- # <%= render "headmin/filters", url: admin_orders_path do |form| %#>
15
- # <%= render "headmin/filters/text", form: form, attribute: :title %#>
14
+ # <%= render 'headmin/filters', url: admin_orders_path do |form| %#>
15
+ # <%= render 'headmin/filters/text', form: form, attribute: :title %#>
16
16
  # <% end %#>
17
17
 
18
18
  text = Headmin::Filter::TextView.new(local_assigns.merge(params: params))
19
19
  %>
20
20
 
21
- <%= render "headmin/filters/base", text.base_options do |value| %>
22
- <%= render "headmin/forms/text", text.input_options.merge({value: value}) %>
21
+ <%= render 'headmin/filters/base', text.base_options do |value| %>
22
+ <%= render 'headmin/forms/text', text.input_options.merge({value: value}) %>
23
23
  <% end %>
@@ -23,7 +23,7 @@
23
23
  </span>
24
24
  </button>
25
25
 
26
- <%= render "headmin/popup", id: "#{button_view.id}", data: {'filter-target': 'popup'} do %>
26
+ <%= render 'headmin/popup', id: "#{button_view.id}", data: {'filter-target': 'popup'} do %>
27
27
  <%= yield %>
28
28
  <% end %>
29
29
  </div>
@@ -1,8 +1,8 @@
1
1
  <div class="h-autocomplete d-none" data-autocomplete-target="dropdown">
2
2
  <% if collection.any? %>
3
- <%= render "headmin/forms/autocomplete/list" do %>
3
+ <%= render 'headmin/forms/autocomplete/list' do %>
4
4
  <% collection.each do |value, name| %>
5
- <%= render "headmin/forms/autocomplete/item", value: value do %>
5
+ <%= render 'headmin/forms/autocomplete/item', value: value do %>
6
6
  <%= name %>
7
7
  <% end %>
8
8
  <% end %>
@@ -10,19 +10,19 @@
10
10
  #
11
11
  # ==== Examples
12
12
  # Basic version. (looks in views/admin/blocks, views/blocks or views directory )
13
- # <%= render "headmin/forms/blocks", form: form, names: %w(text image button) %#>
13
+ # <%= render 'headmin/forms/blocks', form: form, names: %w(text image button) %#>
14
14
  #
15
15
  # Define one ore more path where the templates could be located:
16
- # <%= render "headmin/forms/blocks", form: form, names: %w(text image button), paths: %w(admin/pages/blocks) %#>
16
+ # <%= render 'headmin/forms/blocks', form: form, names: %w(text image button), paths: %w(admin/pages/blocks) %#>
17
17
  #
18
18
  # Limit the types of blocks
19
- # <%= render "headmin/forms/blocks", form: form, names: %w(text text_image list) %#>
19
+ # <%= render 'headmin/forms/blocks', form: form, names: %w(text text_image list) %#>
20
20
 
21
21
  blocks = Headmin::Form::BlocksView.new(local_assigns)
22
22
  @lookup_context.prefixes = @lookup_context.prefixes + blocks.prefixes
23
23
  %>
24
24
 
25
- <%= render "headmin/forms/repeater", blocks.repeater_options do |block_form, template| %>
25
+ <%= render 'headmin/forms/repeater', blocks.repeater_options do |block_form, template| %>
26
26
  <% name = template || block_form.object.name %>
27
27
 
28
28
  <!-- Name input of the block -->
@@ -20,15 +20,15 @@
20
20
  # ==== Examples
21
21
  # Basic version
22
22
  # <%= form_with do |form| %#>
23
- # <%= render "headmin/forms/checkbox", form: form, attribute: :active %#>
23
+ # <%= render 'headmin/forms/checkbox', form: form, attribute: :active %#>
24
24
  # <% end %#>
25
25
 
26
26
  checkbox = Headmin::Form::CheckboxView.new(local_assigns)
27
27
  %>
28
28
 
29
- <%= render "headmin/forms/wrapper", checkbox.wrapper_options do %>
29
+ <%= render 'headmin/forms/wrapper', checkbox.wrapper_options do %>
30
30
  <%= form.check_box(checkbox.attribute, checkbox.input_options, checkbox.checked_value, checkbox.unchecked_value) %>
31
- <%= render "headmin/forms/label", checkbox.label_options if checkbox.label? %>
32
- <%= render "headmin/forms/validation", checkbox.validation_options if checkbox.validate? %>
33
- <%= render "headmin/forms/hint", checkbox.hint_options if checkbox.hint? %>
31
+ <%= render 'headmin/forms/label', checkbox.label_options if checkbox.label? %>
32
+ <%= render 'headmin/forms/validation', checkbox.validation_options if checkbox.validate? %>
33
+ <%= render 'headmin/forms/hint', checkbox.hint_options if checkbox.hint? %>
34
34
  <% end %>
@@ -18,15 +18,15 @@
18
18
  # ==== Examples
19
19
  # Basic version
20
20
  # <%= form_with do |form| %#>
21
- # <%= render "headmin/forms/color", form: form, attribute: :active %#>
21
+ # <%= render 'headmin/forms/color', form: form, attribute: :active %#>
22
22
  # <% end %#>
23
23
 
24
24
  color = Headmin::Form::ColorView.new(local_assigns)
25
25
  %>
26
26
 
27
- <%= render "headmin/forms/wrapper", color.wrapper_options do %>
28
- <%= render "headmin/forms/label", color.label_options if color.label? %>
27
+ <%= render 'headmin/forms/wrapper', color.wrapper_options do %>
28
+ <%= render 'headmin/forms/label', color.label_options if color.label? %>
29
29
  <%= form.color_field(color.attribute, color.input_options) %>
30
- <%= render "headmin/forms/validation", color.validation_options if color.validate? %>
31
- <%= render "headmin/forms/hint", color.hint_options if color.hint? %>
30
+ <%= render 'headmin/forms/validation', color.validation_options if color.validate? %>
31
+ <%= render 'headmin/forms/hint', color.hint_options if color.hint? %>
32
32
  <% end %>
@@ -23,19 +23,19 @@
23
23
  # ==== Examples
24
24
  # Basic version
25
25
  # <%= form_with do |form| %#>
26
- # <%= render "headmin/forms/date", form: form, attribute: :date_of_birth %#>
26
+ # <%= render 'headmin/forms/date', form: form, attribute: :date_of_birth %#>
27
27
  # <% end %#>
28
28
 
29
29
  date = Headmin::Form::DateView.new(local_assigns)
30
30
  %>
31
31
 
32
- <%= render "headmin/forms/wrapper", date.wrapper_options do %>
33
- <%= render "headmin/forms/label", date.label_options if date.prepend_label? %>
34
- <%= render "headmin/forms/input_group", date.input_group_options do %>
32
+ <%= render 'headmin/forms/wrapper', date.wrapper_options do %>
33
+ <%= render 'headmin/forms/label', date.label_options if date.prepend_label? %>
34
+ <%= render 'headmin/forms/input_group', date.input_group_options do %>
35
35
  <%= form.date_field(date.attribute, date.input_options) %>
36
- <%= render "headmin/forms/datalist", date.datalist_options if date.datalist? %>
36
+ <%= render 'headmin/forms/datalist', date.datalist_options if date.datalist? %>
37
37
  <% end %>
38
- <%= render "headmin/forms/validation", date.validation_options if date.validate? %>
39
- <%= render "headmin/forms/hint", date.hint_options if date.hint? %>
40
- <%= render "headmin/forms/label", date.label_options if date.append_label? %>
38
+ <%= render 'headmin/forms/validation', date.validation_options if date.validate? %>
39
+ <%= render 'headmin/forms/hint', date.hint_options if date.hint? %>
40
+ <%= render 'headmin/forms/label', date.label_options if date.append_label? %>
41
41
  <% end %>
@@ -23,7 +23,7 @@
23
23
  # ==== Examples
24
24
  # Basic version
25
25
  # <%= form_with do |form| %#>
26
- # <%= render "headmin/forms/date_range", form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
26
+ # <%= render 'headmin/forms/date_range', form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
27
27
  # <% end %#>
28
28
 
29
29
  date_range = Headmin::Form::DateRangeView.new(local_assigns)
@@ -31,10 +31,10 @@
31
31
 
32
32
  <div class="row">
33
33
  <div class="col">
34
- <%= render "headmin/forms/date", date_range.start_options %>
34
+ <%= render 'headmin/forms/date', date_range.start_options %>
35
35
  </div>
36
36
  <div class="col">
37
- <%= render "headmin/forms/date", date_range.end_options %>
37
+ <%= render 'headmin/forms/date', date_range.end_options %>
38
38
  </div>
39
39
  </div>
40
40
 
@@ -23,19 +23,19 @@
23
23
  # ==== Examples
24
24
  # Basic version
25
25
  # <%= form_with do |form| %#>
26
- # <%= render "headmin/forms/datetime", form: form, attribute: :deadline %#>
26
+ # <%= render 'headmin/forms/datetime', form: form, attribute: :deadline %#>
27
27
  # <% end %#>
28
28
 
29
29
  datetime = Headmin::Form::DatetimeView.new(local_assigns)
30
30
  %>
31
31
 
32
- <%= render "headmin/forms/wrapper", datetime.wrapper_options do %>
33
- <%= render "headmin/forms/label", datetime.label_options if datetime.prepend_label? %>
34
- <%= render "headmin/forms/input_group", datetime.input_group_options do %>
32
+ <%= render 'headmin/forms/wrapper', datetime.wrapper_options do %>
33
+ <%= render 'headmin/forms/label', datetime.label_options if datetime.prepend_label? %>
34
+ <%= render 'headmin/forms/input_group', datetime.input_group_options do %>
35
35
  <%= form.datetime_field(datetime.attribute, datetime.input_options) %>
36
- <%= render "headmin/forms/datalist", datetime.datalist_options if datetime.datalist? %>
36
+ <%= render 'headmin/forms/datalist', datetime.datalist_options if datetime.datalist? %>
37
37
  <% end %>
38
- <%= render "headmin/forms/validation", datetime.validation_options if datetime.validate? %>
39
- <%= render "headmin/forms/hint", datetime.hint_options if datetime.hint? %>
40
- <%= render "headmin/forms/label", datetime.label_options if datetime.append_label? %>
38
+ <%= render 'headmin/forms/validation', datetime.validation_options if datetime.validate? %>
39
+ <%= render 'headmin/forms/hint', datetime.hint_options if datetime.hint? %>
40
+ <%= render 'headmin/forms/label', datetime.label_options if datetime.append_label? %>
41
41
  <% end %>
@@ -23,7 +23,7 @@
23
23
  # ==== Examples
24
24
  # Basic version
25
25
  # <%= form_with do |form| %#>
26
- # <%= render "headmin/forms/datetime_range", form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
26
+ # <%= render 'headmin/forms/datetime_range', form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
27
27
  # <% end %#>
28
28
 
29
29
  datetime_range = Headmin::Form::DatetimeRangeView.new(local_assigns)
@@ -31,10 +31,10 @@
31
31
 
32
32
  <div class="row">
33
33
  <div class="col">
34
- <%= render "headmin/forms/datetime", datetime_range.start_options %>
34
+ <%= render 'headmin/forms/datetime', datetime_range.start_options %>
35
35
  </div>
36
36
  <div class="col">
37
- <%= render "headmin/forms/datetime", datetime_range.end_options %>
37
+ <%= render 'headmin/forms/datetime', datetime_range.end_options %>
38
38
  </div>
39
39
  </div>
40
40
 
@@ -24,20 +24,20 @@
24
24
  # ==== Examples
25
25
  # Basic version
26
26
  # <%= form_with do |form| %#>
27
- # <%= render "headmin/forms/email", form: form, attribute: :email_address %#>
27
+ # <%= render 'headmin/forms/email', form: form, attribute: :email_address %#>
28
28
  # <% end %#>
29
29
 
30
30
  email = Headmin::Form::EmailView.new(local_assigns)
31
31
  %>
32
32
 
33
- <%= render "headmin/forms/wrapper", email.wrapper_options do %>
34
- <%= render "headmin/forms/label", email.label_options if email.prepend_label? %>
35
- <%= render "headmin/forms/input_group", email.input_group_options do %>
33
+ <%= render 'headmin/forms/wrapper', email.wrapper_options do %>
34
+ <%= render 'headmin/forms/label', email.label_options if email.prepend_label? %>
35
+ <%= render 'headmin/forms/input_group', email.input_group_options do %>
36
36
  <%= form.email_field(email.attribute, email.input_options) %>
37
- <%= render "headmin/forms/datalist", email.datalist_options if email.datalist? %>
38
- <%= render "headmin/forms/autocomplete", email.autocomplete_options if email.autocomplete? %>
37
+ <%= render 'headmin/forms/datalist', email.datalist_options if email.datalist? %>
38
+ <%= render 'headmin/forms/autocomplete', email.autocomplete_options if email.autocomplete? %>
39
39
  <% end %>
40
- <%= render "headmin/forms/validation", email.validation_options if email.validate? %>
41
- <%= render "headmin/forms/hint", email.hint_options if email.hint? %>
42
- <%= render "headmin/forms/label", email.label_options if email.append_label? %>
40
+ <%= render 'headmin/forms/validation', email.validation_options if email.validate? %>
41
+ <%= render 'headmin/forms/hint', email.hint_options if email.hint? %>
42
+ <%= render 'headmin/forms/label', email.label_options if email.append_label? %>
43
43
  <% end %>
@@ -24,16 +24,16 @@
24
24
  # ==== Examples
25
25
  # Basic version
26
26
  # <%= form_with do |form| %#>
27
- # <%= render "headmin/forms/file", form: form, attribute: :file %#>
27
+ # <%= render 'headmin/forms/file', form: form, attribute: :file %#>
28
28
  # <% end %#>
29
29
 
30
30
  file = Headmin::Form::FileView.new(local_assigns)
31
31
  %>
32
32
 
33
- <%= render "headmin/forms/wrapper", file.wrapper_options do %>
34
- <%= render "headmin/forms/label", file.label_options if file.prepend_label? %>
33
+ <%= render 'headmin/forms/wrapper', file.wrapper_options do %>
34
+ <%= render 'headmin/forms/label', file.label_options if file.prepend_label? %>
35
35
  <div <%= tag.attributes(file.dropzone_options) %>>
36
- <%= render "headmin/forms/input_group", file.input_group_options do %>
36
+ <%= render 'headmin/forms/input_group', file.input_group_options do %>
37
37
 
38
38
  <% if file.preview %>
39
39
  <div class="h-form-file-thumbnails" data-file-preview-target="thumbnails">
@@ -48,9 +48,9 @@
48
48
  src = attachment.image? ? url_for(attachment.variant(resize_to_fill: [file.thumbnail_width, file.thumbnail_height])) : url_for(attachment)
49
49
  %>
50
50
  <div class="h-form-file-thumbnail" title="<%= "#{filename} (#{size})" %>" data-file-preview-target="thumbnail">
51
- <%= ff.hidden_field(:id, disabled: file.destroy) %>
52
- <%= ff.hidden_field(:_destroy, data: {'file-preview-target': 'thumbnailDestroy'}, disabled: file.destroy) %>
53
- <%= render "headmin/thumbnail", src: src, width: file.thumbnail_width, height: file.thumbnail_height %>
51
+ <%= ff.hidden_field(:id, disabled: !file.destroy) %>
52
+ <%= ff.hidden_field(:_destroy, data: {'file-preview-target': 'thumbnailDestroy'}, disabled: !file.destroy) %>
53
+ <%= render 'headmin/thumbnail', src: src, width: file.thumbnail_width, height: file.thumbnail_height %>
54
54
 
55
55
  <% if file.destroy %>
56
56
  <div class="h-form-file-thumbnail-remove" data-action="click->file-preview#remove" data-file-preview-name-param="<%= filename %>">
@@ -67,7 +67,7 @@
67
67
  </div>
68
68
  <% else %>
69
69
  <div class="h-form-file-thumbnail <%= 'd-none' if file.attachments.any? %>" title="<%= t('headmin.forms.file.not_found') %>" data-file-preview-target="placeholder">
70
- <%= render "headmin/thumbnail", width: file.thumbnail_width, height: file.thumbnail_height, icon: "plus" %>
70
+ <%= render 'headmin/thumbnail', width: file.thumbnail_width, height: file.thumbnail_height, icon: "plus" %>
71
71
  </div>
72
72
  <% end %>
73
73
  </div>
@@ -76,7 +76,7 @@
76
76
  <!-- Template -->
77
77
  <template data-file-preview-target="template">
78
78
  <div class="h-form-file-thumbnail" title="" data-file-preview-target="thumbnail">
79
- <%= render "headmin/thumbnail", src: nil, width: file.thumbnail_width, height: file.thumbnail_height %>
79
+ <%= render 'headmin/thumbnail', src: nil, width: file.thumbnail_width, height: file.thumbnail_height %>
80
80
 
81
81
  <% if file.destroy %>
82
82
  <div class="h-form-file-thumbnail-remove" data-action="click->file-preview#remove">
@@ -89,7 +89,7 @@
89
89
  <%= form.file_field(attribute, file.input_options) %>
90
90
  <% end %>
91
91
  </div>
92
- <%= render "headmin/forms/validation", file.validation_options if file.validate? %>
93
- <%= render "headmin/forms/hint", file.hint_options if file.hint? %>
94
- <%= render "headmin/forms/label", file.label_options if file.append_label? %>
92
+ <%= render 'headmin/forms/validation', file.validation_options if file.validate? %>
93
+ <%= render 'headmin/forms/hint', file.hint_options if file.hint? %>
94
+ <%= render 'headmin/forms/label', file.label_options if file.append_label? %>
95
95
  <% end %>
@@ -24,10 +24,10 @@
24
24
  # ==== Examples
25
25
  # Basic version
26
26
  # <%= form_with do |form| %#>
27
- # <%= render "headmin/forms/date", form: form, attribute: :date_of_birth %#>
27
+ # <%= render 'headmin/forms/date', form: form, attribute: :date_of_birth %#>
28
28
  # <% end %#>
29
29
 
30
30
  flatpickr = Headmin::Form::FlatpickrView.new(local_assigns)
31
31
  %>
32
32
 
33
- <%= render "headmin/forms/date", flatpickr.options %>
33
+ <%= render 'headmin/forms/date', flatpickr.options %>
@@ -20,21 +20,21 @@
20
20
  # ==== Examples
21
21
  # Basic version
22
22
  # <%= form_with do |form| %#>
23
- # <%= render "headmin/forms/flatpickr_range", form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
23
+ # <%= render 'headmin/forms/flatpickr_range', form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
24
24
  # <% end %#>
25
25
 
26
26
  flatpickr_range = Headmin::Form::FlatpickrRangeView.new(local_assigns)
27
27
  %>
28
28
 
29
- <%= render "headmin/forms/wrapper", flatpickr_range.wrapper_options do %>
30
- <%= render "headmin/forms/label", flatpickr_range.label_options if flatpickr_range.prepend_label? %>
31
- <%= render "headmin/forms/input_group", flatpickr_range.input_group_options do %>
29
+ <%= render 'headmin/forms/wrapper', flatpickr_range.wrapper_options do %>
30
+ <%= render 'headmin/forms/label', flatpickr_range.label_options if flatpickr_range.prepend_label? %>
31
+ <%= render 'headmin/forms/input_group', flatpickr_range.input_group_options do %>
32
32
  <%= form.date_field(flatpickr_range.attribute, flatpickr_range.input_options) %>
33
33
  <%= form.hidden_field(flatpickr_range.start[:attribute], flatpickr_range.start_options) %>
34
34
  <%= form.hidden_field(flatpickr_range.end[:attribute], flatpickr_range.end_options) %>
35
35
  <% end %>
36
- <%= render "headmin/forms/validation", flatpickr_range.validation_options if flatpickr_range.validate? %>
37
- <%= render "headmin/forms/hint", flatpickr_range.hint_options if flatpickr_range.hint? %>
38
- <%= render "headmin/forms/datalist", flatpickr_range.datalist_options if flatpickr_range.datalist? %>
39
- <%= render "headmin/forms/label", flatpickr_range.label_options if flatpickr_range.append_label? %>
36
+ <%= render 'headmin/forms/validation', flatpickr_range.validation_options if flatpickr_range.validate? %>
37
+ <%= render 'headmin/forms/hint', flatpickr_range.hint_options if flatpickr_range.hint? %>
38
+ <%= render 'headmin/forms/datalist', flatpickr_range.datalist_options if flatpickr_range.datalist? %>
39
+ <%= render 'headmin/forms/label', flatpickr_range.label_options if flatpickr_range.append_label? %>
40
40
  <% end %>
@@ -13,7 +13,7 @@
13
13
  # ==== Examples
14
14
  # Basic version
15
15
  # <%= form_with do |form| %#>
16
- # <%= render "headmin/forms/hidden", form: form, attribute: :id %#>
16
+ # <%= render 'headmin/forms/hidden', form: form, attribute: :id %#>
17
17
  # <% end %#>
18
18
 
19
19
  hidden = Headmin::Form::HiddenView.new(local_assigns)
@@ -7,10 +7,15 @@
7
7
  # ==== Examples
8
8
  # Basic version
9
9
  # <%= form_with do |form| %#>
10
- # <%= render "headmin/forms/hint", content: "Hello" %#>
10
+ # <%= render 'headmin/forms/hint', content: "Hello" %#>
11
11
  # <% end %#>
12
12
 
13
13
  hint = Headmin::Form::HintView.new(local_assigns)
14
14
  %>
15
15
 
16
- <div class="form-text"><%= raw(hint.content) %></div>
16
+ <div class="form-text d-flex justify-content-between">
17
+ <div><%= raw(hint.content) %></div>
18
+ <% if hint.maxlength %>
19
+ <div data-textarea-target="count"></div>
20
+ <% end %>
21
+ </div>
@@ -15,7 +15,7 @@
15
15
  #
16
16
  # ==== Examples
17
17
  # Basic version
18
- # <%= render "headmin/forms/label", form: form, attribute: :image %#>
18
+ # <%= render 'headmin/forms/label', form: form, attribute: :image %#>
19
19
  %>
20
20
 
21
21
  <% label = Headmin::Form::LabelView.new(local_assigns) %>
@@ -0,0 +1,58 @@
1
+ <%
2
+ # headmin/forms/file
3
+ #
4
+ # ==== Required parameters
5
+ # * +attribute+ - Name of the attribute of the form model
6
+ # * +form+ - Form object
7
+ #
8
+ # ==== Optional parameters
9
+ # * +destroy+ - Adds delete buttons to the preview thumbnails
10
+ # * +hint+ - Informative text to assist with data input. HTML markup is allowed.
11
+ # * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
12
+ # * +min+ - Limit the selection to a minimum amount of items.
13
+ # * +max+ - Limit the selection to a maximum amount of items.
14
+ # * +sort+ - Allow sorting by dragging items. `active_storage_attachments` must have a position column.
15
+ # * +wrapper+ - Hash with all options for the surrounding html tag
16
+ #
17
+ # ==== References
18
+ # https://headmin.dev/docs/forms/media
19
+ #
20
+ # ==== Examples
21
+ # Basic version
22
+ # <%= form_with do |form| %#>
23
+ # <%= render 'headmin/forms/media', form: form, attribute: :file %#>
24
+ # <% end %#>
25
+
26
+ media = Headmin::Form::MediaView.new(local_assigns)
27
+ %>
28
+
29
+ <%= render 'headmin/forms/wrapper', media.wrapper_options do %>
30
+ <%= render 'headmin/forms/label', media.label_options if media.prepend_label? %>
31
+ <div class="h-form-file-thumbnails" data-media-target="thumbnails">
32
+ <%= render 'headmin/forms/media/validation', media.custom_validation_options %>
33
+
34
+ <!-- Render previews for attachments -->
35
+ <%= form.fields_for(media.nested_attribute, media.association_object) do |ff| %>
36
+ <%= render 'headmin/forms/media/item', form: ff, url: media.media_modal_url, sort: media.sort %>
37
+ <% end %>
38
+
39
+ <!-- Placeholder -->
40
+ <div class="<%= 'd-none' if media.attachments.any? %>" data-media-target="placeholder">
41
+ <a href="<%= media.media_modal_url %>" data-turbo-frame="remote_modal" data-media-target="modalButton">
42
+ <%= render 'headmin/thumbnail', src: nil, width: 100, height: 100, icon: 'plus' %>
43
+ </a>
44
+ </div>
45
+ </div>
46
+
47
+ <!-- Template -->
48
+ <% association_object = ActiveStorage::Attachment.new %>
49
+ <template data-media-target="template" data-template-id-regex="<%= association_object.object_id %>">
50
+ <%= form.fields_for(media.nested_attribute, ActiveStorage::Attachment.new, child_index: association_object.object_id) do |ff| %>
51
+ <%= render 'headmin/forms/media/item', form: ff, url: media.media_modal_url, sort: media.sort %>
52
+ <% end %>
53
+ </template>
54
+
55
+ <%= render 'headmin/forms/validation', media.validation_options if media.validate? %>
56
+ <%= render 'headmin/forms/hint', media.hint_options if media.hint? %>
57
+ <%= render 'headmin/forms/label', media.label_options if media.append_label? %>
58
+ <% end %>
@@ -23,19 +23,19 @@
23
23
  # ==== Examples
24
24
  # Basic version
25
25
  # <%= form_with do |form| %#>
26
- # <%= render "headmin/forms/number", form: form, attribute: :number %#>
26
+ # <%= render 'headmin/forms/number', form: form, attribute: :number %#>
27
27
  # <% end %#>
28
28
 
29
29
  number = Headmin::Form::NumberView.new(local_assigns)
30
30
  %>
31
31
 
32
- <%= render "headmin/forms/wrapper", number.wrapper_options do %>
33
- <%= render "headmin/forms/label", number.label_options if number.prepend_label? %>
34
- <%= render "headmin/forms/input_group", number.input_group_options do %>
32
+ <%= render 'headmin/forms/wrapper', number.wrapper_options do %>
33
+ <%= render 'headmin/forms/label', number.label_options if number.prepend_label? %>
34
+ <%= render 'headmin/forms/input_group', number.input_group_options do %>
35
35
  <%= form.number_field(number.attribute, number.input_options) %>
36
- <%= render "headmin/forms/datalist", number.datalist_options if number.datalist? %>
36
+ <%= render 'headmin/forms/datalist', number.datalist_options if number.datalist? %>
37
37
  <% end %>
38
- <%= render "headmin/forms/validation", number.validation_options if number.validate? %>
39
- <%= render "headmin/forms/hint", number.hint_options if number.hint? %>
40
- <%= render "headmin/forms/label", number.label_options if number.append_label? %>
38
+ <%= render 'headmin/forms/validation', number.validation_options if number.validate? %>
39
+ <%= render 'headmin/forms/hint', number.hint_options if number.hint? %>
40
+ <%= render 'headmin/forms/label', number.label_options if number.append_label? %>
41
41
  <% end %>
@@ -22,18 +22,18 @@
22
22
  # ==== Examples
23
23
  # Basic version
24
24
  # <%= form_with do |form| %#>
25
- # <%= render "headmin/forms/password", form: form, attribute: :password %#>
25
+ # <%= render 'headmin/forms/password', form: form, attribute: :password %#>
26
26
  # <% end %#>
27
27
 
28
28
  password = Headmin::Form::PasswordView.new(local_assigns)
29
29
  %>
30
30
 
31
- <%= render "headmin/forms/wrapper", password.wrapper_options do %>
32
- <%= render "headmin/forms/label", password.label_options if password.prepend_label? %>
33
- <%= render "headmin/forms/input_group", password.input_group_options do %>
31
+ <%= render 'headmin/forms/wrapper', password.wrapper_options do %>
32
+ <%= render 'headmin/forms/label', password.label_options if password.prepend_label? %>
33
+ <%= render 'headmin/forms/input_group', password.input_group_options do %>
34
34
  <%= form.password_field(password.attribute, password.input_options) %>
35
35
  <% end %>
36
- <%= render "headmin/forms/validation", password.validation_options if password.validate? %>
37
- <%= render "headmin/forms/hint", password.hint_options if password.hint? %>
38
- <%= render "headmin/forms/label", password.label_options if password.append_label? %>
36
+ <%= render 'headmin/forms/validation', password.validation_options if password.validate? %>
37
+ <%= render 'headmin/forms/hint', password.hint_options if password.hint? %>
38
+ <%= render 'headmin/forms/label', password.label_options if password.append_label? %>
39
39
  <% end %>
@@ -22,10 +22,10 @@
22
22
  # ==== Examples
23
23
  # Basic version
24
24
  # <%= form_with do |form| %#>
25
- # <%= render "headmin/forms/redactorx", form: form, attribute: :text %#>
25
+ # <%= render 'headmin/forms/redactorx', form: form, attribute: :text %#>
26
26
  # <% end %#>
27
27
 
28
28
  redactor = Headmin::Form::RedactorxView.new(local_assigns)
29
29
  %>
30
30
 
31
- <%= render "headmin/forms/textarea", redactor.options %>
31
+ <%= render 'headmin/forms/textarea', redactor.options %>