headmin 0.4.2 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -3
- data/Gemfile +14 -0
- data/Gemfile.lock +78 -1
- data/app/assets/javascripts/headmin/controllers/date_range_controller.js +12 -6
- data/app/assets/javascripts/headmin/controllers/filter_controller.js +61 -11
- data/app/assets/javascripts/headmin/controllers/filter_row_controller.js +50 -0
- data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +2 -6
- data/app/assets/javascripts/headmin/controllers/media_controller.js +237 -0
- data/app/assets/javascripts/headmin/controllers/media_modal_controller.js +110 -0
- data/app/assets/javascripts/headmin/controllers/popup_controller.js +3 -1
- data/app/assets/javascripts/headmin/controllers/remote_modal_controller.js +10 -0
- data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +16 -21
- data/app/assets/javascripts/headmin/controllers/textarea_controller.js +34 -0
- data/app/assets/javascripts/headmin/index.js +10 -0
- data/app/assets/javascripts/headmin.js +413 -38
- data/app/assets/stylesheets/headmin/filter.scss +74 -0
- data/app/assets/stylesheets/headmin/forms/file.scss +40 -5
- data/app/assets/stylesheets/headmin/forms/media.scss +10 -0
- data/app/assets/stylesheets/headmin/forms/repeater.scss +4 -0
- data/app/assets/stylesheets/headmin/forms.scss +7 -0
- data/app/assets/stylesheets/headmin/general.scss +0 -1
- data/app/assets/stylesheets/headmin/layout/body.scss +5 -0
- data/app/assets/stylesheets/headmin/layout/sidebar.scss +0 -1
- data/app/assets/stylesheets/headmin/media/index.scss +9 -0
- data/app/assets/stylesheets/headmin/media.scss +1 -0
- data/app/assets/stylesheets/headmin/popup.scss +0 -1
- data/app/assets/stylesheets/headmin/table.scss +15 -0
- data/app/assets/stylesheets/headmin.css +137 -9
- data/app/assets/stylesheets/headmin.scss +1 -0
- data/app/controllers/concerns/headmin/filterable.rb +27 -0
- data/app/controllers/headmin/media_controller.rb +52 -0
- data/app/controllers/headmin_controller.rb +2 -0
- data/app/models/concerns/headmin/field.rb +0 -1
- data/app/models/concerns/headmin/fieldable.rb +10 -1
- data/app/models/concerns/headmin/form/hintable.rb +6 -1
- data/app/models/headmin/blocks_view.rb +1 -1
- data/app/models/headmin/filter/base.rb +238 -0
- data/app/models/headmin/filter/base_view.rb +64 -0
- data/app/models/headmin/filter/boolean.rb +15 -0
- data/app/models/headmin/filter/boolean_view.rb +61 -0
- data/app/models/headmin/filter/button_view.rb +25 -0
- data/app/models/headmin/filter/conditional_view.rb +16 -0
- data/app/models/headmin/filter/date.rb +67 -0
- data/app/models/headmin/filter/date_view.rb +52 -0
- data/app/models/headmin/filter/flatpickr_view.rb +54 -0
- data/app/models/headmin/filter/menu_item_view.rb +6 -0
- data/app/models/headmin/filter/money.rb +13 -0
- data/app/models/headmin/filter/number.rb +27 -0
- data/app/models/headmin/filter/number_view.rb +54 -0
- data/app/models/headmin/filter/operator_view.rb +30 -0
- data/app/models/headmin/filter/options_view.rb +61 -0
- data/app/models/headmin/filter/row_view.rb +13 -0
- data/app/models/headmin/filter/search.rb +18 -0
- data/app/models/headmin/filter/search_view.rb +31 -0
- data/app/models/headmin/filter/text.rb +25 -0
- data/app/models/headmin/filter/text_view.rb +53 -0
- data/app/models/headmin/filters.rb +29 -0
- data/app/models/headmin/form/color_view.rb +48 -0
- data/app/models/headmin/form/datetime_range_view.rb +25 -0
- data/app/models/headmin/form/datetime_view.rb +45 -0
- data/app/models/headmin/form/flatpickr_range_view.rb +4 -15
- data/app/models/headmin/form/flatpickr_view.rb +3 -12
- data/app/models/headmin/form/media_view.rb +113 -0
- data/app/models/headmin/form/textarea_view.rb +6 -1
- data/app/models/view_model.rb +1 -1
- data/app/views/headmin/_blocks.html.erb +3 -3
- data/app/views/headmin/_breadcrumbs.html.erb +1 -1
- data/app/views/headmin/_dropdown.html.erb +1 -1
- data/app/views/headmin/_filters.html.erb +9 -9
- data/app/views/headmin/_heading.html.erb +1 -1
- data/app/views/headmin/_notifications.html.erb +1 -1
- data/app/views/headmin/_pagination.html.erb +2 -2
- data/app/views/headmin/dropdown/_devise.html.erb +7 -7
- data/app/views/headmin/dropdown/_list.html.erb +1 -1
- data/app/views/headmin/filters/_base.html.erb +95 -0
- data/app/views/headmin/filters/_boolean.html.erb +23 -0
- data/app/views/headmin/filters/_date.html.erb +14 -38
- data/app/views/headmin/filters/_flatpickr.html.erb +15 -48
- data/app/views/headmin/filters/_number.html.erb +23 -0
- data/app/views/headmin/filters/_options.html.erb +24 -0
- data/app/views/headmin/filters/_search.html.erb +14 -12
- data/app/views/headmin/filters/_text.html.erb +23 -0
- data/app/views/headmin/filters/filter/_button.html.erb +9 -10
- data/app/views/headmin/filters/filter/_conditional.html.erb +18 -0
- data/app/views/headmin/filters/filter/_menu_item.html.erb +5 -2
- data/app/views/headmin/filters/filter/_null_select.html.erb +8 -0
- data/app/views/headmin/filters/filter/_operator.html.erb +16 -0
- data/app/views/headmin/filters/filter/_row.html.erb +11 -0
- data/app/views/headmin/forms/_autocomplete.html.erb +2 -2
- data/app/views/headmin/forms/_blocks.html.erb +3 -3
- data/app/views/headmin/forms/_checkbox.html.erb +5 -5
- data/app/views/headmin/forms/_color.html.erb +32 -0
- data/app/views/headmin/forms/_date.html.erb +8 -8
- data/app/views/headmin/forms/_datetime.html.erb +41 -0
- data/app/views/headmin/forms/_datetime_range.html.erb +40 -0
- data/app/views/headmin/forms/_email.html.erb +9 -9
- data/app/views/headmin/forms/_file.html.erb +9 -9
- data/app/views/headmin/forms/_flatpickr.html.erb +1 -1
- data/app/views/headmin/forms/_flatpickr_range.html.erb +9 -10
- data/app/views/headmin/forms/_hidden.html.erb +1 -1
- data/app/views/headmin/forms/_hint.html.erb +7 -2
- data/app/views/headmin/forms/_media.html.erb +58 -0
- data/app/views/headmin/forms/_number.html.erb +8 -8
- data/app/views/headmin/forms/_password.html.erb +7 -7
- data/app/views/headmin/forms/_redactorx.html.erb +2 -2
- data/app/views/headmin/forms/_search.html.erb +9 -9
- data/app/views/headmin/forms/_select.html.erb +8 -8
- data/app/views/headmin/forms/_switch.html.erb +2 -2
- data/app/views/headmin/forms/_text.html.erb +9 -9
- data/app/views/headmin/forms/_textarea.html.erb +7 -7
- data/app/views/headmin/forms/_url.html.erb +9 -9
- data/app/views/headmin/forms/_validation.html.erb +1 -1
- data/app/views/headmin/forms/_wysiwyg.html.erb +2 -2
- data/app/views/headmin/forms/fields/_base.html.erb +1 -1
- data/app/views/headmin/forms/fields/_file.html.erb +1 -1
- data/app/views/headmin/forms/fields/_files.html.erb +1 -1
- data/app/views/headmin/forms/fields/_group.html.erb +2 -2
- data/app/views/headmin/forms/fields/_list.html.erb +1 -1
- data/app/views/headmin/forms/fields/_text.html.erb +1 -1
- data/app/views/headmin/forms/media/_item.html.erb +32 -0
- data/app/views/headmin/forms/media/_validation.html.erb +10 -0
- data/app/views/headmin/forms/repeater/_row.html.erb +12 -11
- data/app/views/headmin/layout/_footer.html.erb +1 -1
- data/app/views/headmin/layout/_main.html.erb +2 -0
- data/app/views/headmin/layout/_remote_modal.html.erb +1 -0
- data/app/views/headmin/layout/_sidebar.html.erb +1 -1
- data/app/views/headmin/media/_item.html.erb +17 -0
- data/app/views/headmin/media/_media_item_modal.html.erb +51 -0
- data/app/views/headmin/media/_modal.html.erb +35 -0
- data/app/views/headmin/media/create.turbo_stream.erb +5 -0
- data/app/views/headmin/media/index.html.erb +3 -0
- data/app/views/headmin/media/show.html.erb +9 -0
- data/app/views/headmin/media/update.turbo_stream.erb +3 -0
- data/app/views/headmin/nav/item/_devise.html.erb +7 -7
- data/app/views/headmin/table/_actions.html.erb +1 -4
- data/app/views/headmin/table/actions/_action.html.erb +3 -3
- data/app/views/headmin/table/actions/_delete.html.erb +2 -2
- data/app/views/headmin/table/actions/_export.html.erb +1 -1
- data/app/views/headmin/table/body/_color.html.erb +10 -0
- data/app/views/headmin/table/body/_image.html.erb +18 -0
- data/app/views/headmin/table/foot/_cell.html.erb +1 -1
- data/app/views/headmin/table/foot/_id.html.erb +1 -1
- data/app/views/headmin/views/devise/confirmations/_new.html.erb +2 -2
- data/app/views/headmin/views/devise/passwords/_edit.html.erb +2 -2
- data/app/views/headmin/views/devise/passwords/_new.html.erb +2 -2
- data/app/views/headmin/views/devise/registrations/_edit.html.erb +1 -1
- data/app/views/headmin/views/devise/registrations/_new.html.erb +2 -2
- data/app/views/headmin/views/devise/sessions/_new.html.erb +1 -1
- data/app/views/headmin/views/devise/unlocks/_new.html.erb +2 -2
- data/config/locales/devise/nl.yml +1 -1
- data/config/locales/en.yml +4 -0
- data/config/locales/headmin/dropdown/en.yml +6 -0
- data/config/locales/headmin/dropdown/nl.yml +6 -0
- data/config/locales/headmin/filters/en.yml +26 -1
- data/config/locales/headmin/filters/nl.yml +26 -1
- data/config/locales/headmin/forms/en.yml +8 -0
- data/config/locales/headmin/forms/nl.yml +8 -0
- data/config/locales/headmin/layout/en.yml +0 -9
- data/config/locales/headmin/layout/nl.yml +0 -9
- data/config/locales/headmin/media/en.yml +23 -0
- data/config/locales/headmin/media/nl.yml +22 -0
- data/config/locales/headmin/nav/en.yml +7 -0
- data/config/locales/headmin/nav/nl.yml +7 -0
- data/config/locales/headmin/table/en.yml +2 -0
- data/config/locales/headmin/table/nl.yml +2 -0
- data/config/locales/nl.yml +4 -0
- data/config/routes.rb +10 -0
- data/lib/generators/templates/views/auth/confirmations/new.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/confirmation_instructions.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/email_changed.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/password_change.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/reset_password_instructions.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/unlock_instructions.html.erb +1 -1
- data/lib/generators/templates/views/auth/passwords/edit.html.erb +1 -1
- data/lib/generators/templates/views/auth/passwords/new.html.erb +1 -1
- data/lib/generators/templates/views/auth/registrations/edit.html.erb +1 -1
- data/lib/generators/templates/views/auth/registrations/new.html.erb +1 -1
- data/lib/generators/templates/views/auth/sessions/new.html.erb +1 -1
- data/lib/generators/templates/views/auth/unlocks/new.html.erb +1 -1
- data/lib/headmin/version.rb +1 -1
- data/package.json +1 -1
- metadata +70 -7
- data/.lock-487e157d270f3062a98b7b2a012753708-1272821827 +0 -0
- data/app/controllers/concerns/headmin/filter.rb +0 -5
- data/app/controllers/concerns/headmin/searchable.rb +0 -15
- data/app/views/headmin/filters/_select.html.erb +0 -45
- data/app/views/headmin/filters/filter/_template.html.erb +0 -13
@@ -20,15 +20,15 @@
|
|
20
20
|
# ==== Examples
|
21
21
|
# Basic version
|
22
22
|
# <%= form_with do |form| %#>
|
23
|
-
# <%= render
|
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
|
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
|
32
|
-
<%= render
|
33
|
-
<%= render
|
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 %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/color
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
10
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
11
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
12
|
+
#
|
13
|
+
# ==== References
|
14
|
+
# https://headmin.dev/docs/forms/color
|
15
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/color
|
16
|
+
# https://apidock.com/rails/v5.2.3/ActionView/Helpers/FormHelper/color_field
|
17
|
+
#
|
18
|
+
# ==== Examples
|
19
|
+
# Basic version
|
20
|
+
# <%= form_with do |form| %#>
|
21
|
+
# <%= render 'headmin/forms/color', form: form, attribute: :active %#>
|
22
|
+
# <% end %#>
|
23
|
+
|
24
|
+
color = Headmin::Form::ColorView.new(local_assigns)
|
25
|
+
%>
|
26
|
+
|
27
|
+
<%= render 'headmin/forms/wrapper', color.wrapper_options do %>
|
28
|
+
<%= render 'headmin/forms/label', color.label_options if color.label? %>
|
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? %>
|
32
|
+
<% end %>
|
@@ -23,19 +23,19 @@
|
|
23
23
|
# ==== Examples
|
24
24
|
# Basic version
|
25
25
|
# <%= form_with do |form| %#>
|
26
|
-
# <%= render
|
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
|
33
|
-
<%= render
|
34
|
-
<%= render
|
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
|
36
|
+
<%= render 'headmin/forms/datalist', date.datalist_options if date.datalist? %>
|
37
37
|
<% end %>
|
38
|
-
<%= render
|
39
|
-
<%= render
|
40
|
-
<%= render
|
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 %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/datetime
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +append+ - Display as input group with text on the right-hand side
|
10
|
+
# * +float+ - Use floating labels. Defaults to false
|
11
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
12
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
13
|
+
# * +list+ - Options are passed through options_for_select
|
14
|
+
# * +plaintext+ - Render input as plain text.
|
15
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
16
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
17
|
+
#
|
18
|
+
# ==== References
|
19
|
+
# https://headmin.dev/docs/forms/datetime
|
20
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
|
21
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/datetime_field
|
22
|
+
#
|
23
|
+
# ==== Examples
|
24
|
+
# Basic version
|
25
|
+
# <%= form_with do |form| %#>
|
26
|
+
# <%= render 'headmin/forms/datetime', form: form, attribute: :deadline %#>
|
27
|
+
# <% end %#>
|
28
|
+
|
29
|
+
datetime = Headmin::Form::DatetimeView.new(local_assigns)
|
30
|
+
%>
|
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 %>
|
35
|
+
<%= form.datetime_field(datetime.attribute, datetime.input_options) %>
|
36
|
+
<%= render 'headmin/forms/datalist', datetime.datalist_options if datetime.datalist? %>
|
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? %>
|
41
|
+
<% end %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/datetime_range
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +start+ - Hash with all options for the start date input (:attribute is required)
|
7
|
+
# * +end+ - Hash with all options for the end date input (:attribute is required)
|
8
|
+
#
|
9
|
+
# ==== Optional parameters
|
10
|
+
# * +append+ - Display as input group with text on the right-hand side
|
11
|
+
# * +float+ - Use floating labels. Defaults to false
|
12
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
13
|
+
# * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
|
14
|
+
# * +plaintext+ - Render input as plain text.
|
15
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
16
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
17
|
+
#
|
18
|
+
# ==== References
|
19
|
+
# https://headmin.dev/docs/forms/datetime_range
|
20
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datetime-local
|
21
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/datetime_field
|
22
|
+
#
|
23
|
+
# ==== Examples
|
24
|
+
# Basic version
|
25
|
+
# <%= form_with do |form| %#>
|
26
|
+
# <%= render 'headmin/forms/datetime_range', form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %#>
|
27
|
+
# <% end %#>
|
28
|
+
|
29
|
+
datetime_range = Headmin::Form::DatetimeRangeView.new(local_assigns)
|
30
|
+
%>
|
31
|
+
|
32
|
+
<div class="row">
|
33
|
+
<div class="col">
|
34
|
+
<%= render 'headmin/forms/datetime', datetime_range.start_options %>
|
35
|
+
</div>
|
36
|
+
<div class="col">
|
37
|
+
<%= render 'headmin/forms/datetime', datetime_range.end_options %>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
@@ -24,20 +24,20 @@
|
|
24
24
|
# ==== Examples
|
25
25
|
# Basic version
|
26
26
|
# <%= form_with do |form| %#>
|
27
|
-
# <%= render
|
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
|
34
|
-
<%= render
|
35
|
-
<%= render
|
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
|
38
|
-
<%= render
|
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
|
41
|
-
<%= render
|
42
|
-
<%= render
|
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
|
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
|
34
|
-
<%= render
|
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
|
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,8 +48,8 @@
|
|
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) %>
|
51
|
+
<%= ff.hidden_field(:id, disabled: !file.destroy) %>
|
52
|
+
<%= ff.hidden_field(:_destroy, data: {'file-preview-target': 'thumbnailDestroy'}, disabled: !file.destroy) %>
|
53
53
|
<%= render 'headmin/thumbnail', src: src, width: file.thumbnail_width, height: file.thumbnail_height %>
|
54
54
|
|
55
55
|
<% if file.destroy %>
|
@@ -89,7 +89,7 @@
|
|
89
89
|
<%= form.file_field(attribute, file.input_options) %>
|
90
90
|
<% end %>
|
91
91
|
</div>
|
92
|
-
<%= render
|
93
|
-
<%= render
|
94
|
-
<%= render
|
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,7 +24,7 @@
|
|
24
24
|
# ==== Examples
|
25
25
|
# Basic version
|
26
26
|
# <%= form_with do |form| %#>
|
27
|
-
# <%= render
|
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)
|
@@ -26,16 +26,15 @@
|
|
26
26
|
flatpickr_range = Headmin::Form::FlatpickrRangeView.new(local_assigns)
|
27
27
|
%>
|
28
28
|
|
29
|
-
<%= render
|
30
|
-
<%=
|
31
|
-
<%=
|
32
|
-
|
33
|
-
<%= render "headmin/forms/label", flatpickr_range.label_options if flatpickr_range.prepend_label? %>
|
34
|
-
<%= 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 %>
|
35
32
|
<%= form.date_field(flatpickr_range.attribute, flatpickr_range.input_options) %>
|
33
|
+
<%= form.hidden_field(flatpickr_range.start[:attribute], flatpickr_range.start_options) %>
|
34
|
+
<%= form.hidden_field(flatpickr_range.end[:attribute], flatpickr_range.end_options) %>
|
36
35
|
<% end %>
|
37
|
-
<%= render
|
38
|
-
<%= render
|
39
|
-
<%= render
|
40
|
-
<%= render
|
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? %>
|
41
40
|
<% end %>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# ==== Examples
|
14
14
|
# Basic version
|
15
15
|
# <%= form_with do |form| %#>
|
16
|
-
# <%= render
|
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
|
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
|
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>
|
@@ -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
|
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
|
33
|
-
<%= render
|
34
|
-
<%= render
|
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
|
36
|
+
<%= render 'headmin/forms/datalist', number.datalist_options if number.datalist? %>
|
37
37
|
<% end %>
|
38
|
-
<%= render
|
39
|
-
<%= render
|
40
|
-
<%= render
|
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
|
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
|
32
|
-
<%= render
|
33
|
-
<%= render
|
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
|
37
|
-
<%= render
|
38
|
-
<%= render
|
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
|
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
|
31
|
+
<%= render 'headmin/forms/textarea', redactor.options %>
|
@@ -24,20 +24,20 @@
|
|
24
24
|
# ==== Examples
|
25
25
|
# Basic version
|
26
26
|
# <%= form_with do |form| %#>
|
27
|
-
# <%= render
|
27
|
+
# <%= render 'headmin/forms/search', form: form, attribute: "basic_example" %#>
|
28
28
|
# <% end %#>
|
29
29
|
|
30
30
|
search = Headmin::Form::SearchView.new(local_assigns)
|
31
31
|
%>
|
32
32
|
|
33
|
-
<%= render
|
34
|
-
<%= render
|
35
|
-
<%= render
|
33
|
+
<%= render 'headmin/forms/wrapper', search.wrapper_options do %>
|
34
|
+
<%= render 'headmin/forms/label', search.label_options if search.prepend_label? %>
|
35
|
+
<%= render 'headmin/forms/input_group', search.input_group_options do %>
|
36
36
|
<%= form.search_field(search.attribute, search.input_options) %>
|
37
|
-
<%= render
|
38
|
-
<%= render
|
37
|
+
<%= render 'headmin/forms/datalist', search.datalist_options if search.datalist? %>
|
38
|
+
<%= render 'headmin/forms/autocomplete', search.autocomplete_options if search.autocomplete? %>
|
39
39
|
<% end %>
|
40
|
-
<%= render
|
41
|
-
<%= render
|
42
|
-
<%= render
|
40
|
+
<%= render 'headmin/forms/validation', search.validation_options if search.validate? %>
|
41
|
+
<%= render 'headmin/forms/hint', search.hint_options if search.hint? %>
|
42
|
+
<%= render 'headmin/forms/label', search.label_options if search.append_label? %>
|
43
43
|
<% end %>
|
@@ -25,19 +25,19 @@
|
|
25
25
|
# ==== Examples
|
26
26
|
# Basic version
|
27
27
|
# <%= form_with do |form| %#>
|
28
|
-
# <%= render
|
28
|
+
# <%= render 'headmin/forms/select', form: form, attribute: :color, collection: %w[red green blue] %#>
|
29
29
|
# <% end %#>
|
30
30
|
|
31
31
|
select = Headmin::Form::SelectView.new(local_assigns)
|
32
32
|
%>
|
33
33
|
|
34
|
-
<%= render
|
35
|
-
<%= render
|
36
|
-
<%= render
|
34
|
+
<%= render 'headmin/forms/wrapper', select.wrapper_options do %>
|
35
|
+
<%= render 'headmin/forms/label', select.label_options if select.prepend_label? %>
|
36
|
+
<%= render 'headmin/forms/input_group', select.input_group_options do %>
|
37
37
|
<%= form.select(select.attribute, select.collection, select.select_options, select.input_options) %>
|
38
38
|
<% end %>
|
39
|
-
<%= render
|
40
|
-
<%= render
|
41
|
-
<%= render
|
42
|
-
<%= render
|
39
|
+
<%= render 'headmin/forms/validation', select.validation_options if select.validate? %>
|
40
|
+
<%= render 'headmin/forms/hint', select.hint_options if select.hint? %>
|
41
|
+
<%= render 'headmin/forms/datalist', select.datalist_options if select.datalist? %>
|
42
|
+
<%= render 'headmin/forms/label', select.label_options if select.append_label? %>
|
43
43
|
<% end %>
|
@@ -20,10 +20,10 @@
|
|
20
20
|
# ==== Examples
|
21
21
|
# Basic version
|
22
22
|
# <%= form_with do |form| %#>
|
23
|
-
# <%= render
|
23
|
+
# <%= render 'headmin/forms/switch', form: form, attribute: :active %#>
|
24
24
|
# <% end %#>
|
25
25
|
|
26
26
|
switch = Headmin::Form::SwitchView.new(local_assigns)
|
27
27
|
%>
|
28
28
|
|
29
|
-
<%= render
|
29
|
+
<%= render 'headmin/forms/checkbox', switch.options %>
|
@@ -24,20 +24,20 @@
|
|
24
24
|
# ==== Examples
|
25
25
|
# Basic version
|
26
26
|
# <%= form_with do |form| %#>
|
27
|
-
# <%= render
|
27
|
+
# <%= render 'headmin/forms/text', form: form, attribute: :title %#>
|
28
28
|
# <% end %#>
|
29
29
|
|
30
30
|
text = Headmin::Form::TextView.new(local_assigns)
|
31
31
|
%>
|
32
32
|
|
33
|
-
<%= render
|
34
|
-
<%= render
|
35
|
-
<%= render
|
33
|
+
<%= render 'headmin/forms/wrapper', text.wrapper_options do %>
|
34
|
+
<%= render 'headmin/forms/label', text.label_options if text.prepend_label? %>
|
35
|
+
<%= render 'headmin/forms/input_group', text.input_group_options do %>
|
36
36
|
<%= form.text_field(text.attribute, text.input_options) %>
|
37
|
-
<%= render
|
38
|
-
<%= render
|
37
|
+
<%= render 'headmin/forms/datalist', text.datalist_options if text.datalist? %>
|
38
|
+
<%= render 'headmin/forms/autocomplete', text.autocomplete_options if text.autocomplete? %>
|
39
39
|
<% end %>
|
40
|
-
<%= render
|
41
|
-
<%= render
|
42
|
-
<%= render
|
40
|
+
<%= render 'headmin/forms/validation', text.validation_options if text.validate? %>
|
41
|
+
<%= render 'headmin/forms/hint', text.hint_options if text.hint? %>
|
42
|
+
<%= render 'headmin/forms/label', text.label_options if text.append_label? %>
|
43
43
|
<% end %>
|
@@ -22,18 +22,18 @@
|
|
22
22
|
# ==== Examples
|
23
23
|
# Basic version
|
24
24
|
# <%= form_with do |form| %#>
|
25
|
-
# <%= render
|
25
|
+
# <%= render 'headmin/forms/textarea', form: form, attribute: :text %#>
|
26
26
|
# <% end %#>
|
27
27
|
|
28
28
|
textarea = Headmin::Form::TextareaView.new(local_assigns)
|
29
29
|
%>
|
30
30
|
|
31
|
-
<%= render
|
32
|
-
<%= render
|
33
|
-
<%= render
|
31
|
+
<%= render 'headmin/forms/wrapper', textarea.wrapper_options do %>
|
32
|
+
<%= render 'headmin/forms/label', textarea.label_options if textarea.prepend_label? %>
|
33
|
+
<%= render 'headmin/forms/input_group', textarea.input_group_options do %>
|
34
34
|
<%= form.text_area(textarea.attribute, textarea.input_options) %>
|
35
35
|
<% end %>
|
36
|
-
<%= render
|
37
|
-
<%= render
|
38
|
-
<%= render
|
36
|
+
<%= render 'headmin/forms/validation', textarea.validation_options if textarea.validate? %>
|
37
|
+
<%= render 'headmin/forms/hint', textarea.hint_options if textarea.hint? || textarea.maxlength? %>
|
38
|
+
<%= render 'headmin/forms/label', textarea.label_options if textarea.append_label? %>
|
39
39
|
<% end %>
|
@@ -24,20 +24,20 @@
|
|
24
24
|
# ==== Examples
|
25
25
|
# Basic version
|
26
26
|
# <%= form_with do |form| %#>
|
27
|
-
# <%= render
|
27
|
+
# <%= render 'headmin/forms/url', form: form, attribute: :website_url %#>
|
28
28
|
# <% end %#>
|
29
29
|
|
30
30
|
url = Headmin::Form::UrlView.new(local_assigns)
|
31
31
|
%>
|
32
32
|
|
33
|
-
<%= render
|
34
|
-
<%= render
|
35
|
-
<%= render
|
33
|
+
<%= render 'headmin/forms/wrapper', url.wrapper_options do %>
|
34
|
+
<%= render 'headmin/forms/label', url.label_options if url.prepend_label? %>
|
35
|
+
<%= render 'headmin/forms/input_group', url.input_group_options do %>
|
36
36
|
<%= form.url_field(url.attribute, url.input_options) %>
|
37
|
-
<%= render
|
38
|
-
<%= render
|
37
|
+
<%= render 'headmin/forms/datalist', url.datalist_options if url.datalist? %>
|
38
|
+
<%= render 'headmin/forms/autocomplete', url.autocomplete_options if url.autocomplete? %>
|
39
39
|
<% end %>
|
40
|
-
<%= render
|
41
|
-
<%= render
|
42
|
-
<%= render
|
40
|
+
<%= render 'headmin/forms/validation', url.validation_options if url.validate? %>
|
41
|
+
<%= render 'headmin/forms/hint', url.hint_options if url.hint? %>
|
42
|
+
<%= render 'headmin/forms/label', url.label_options if url.append_label? %>
|
43
43
|
<% end %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# ==== Examples
|
12
12
|
# Basic version
|
13
|
-
# <%= render
|
13
|
+
# <%= render 'headmin/forms/validation', id: id, message: message %#>
|
14
14
|
%>
|
15
15
|
|
16
16
|
<div class="<%= valid ? "valid-feedback" : "invalid-feedback" %>" id="<%= id %>">
|