headmin 0.2.6 → 0.3.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 +29 -3
- data/Gemfile.lock +14 -3
- data/README.md +64 -57
- data/app/assets/config/headmin_manifest.js +2 -0
- data/app/assets/javascripts/headmin/config/i18n.js +11 -0
- data/{src/js → app/assets/javascripts}/headmin/controllers/blocks_controller.js +0 -1
- data/app/assets/javascripts/headmin/controllers/date_range_controller.js +32 -0
- data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +33 -0
- data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +244 -0
- data/{src/js → app/assets/javascripts}/headmin/controllers/filter_controller.js +12 -6
- data/{src/js → app/assets/javascripts}/headmin/controllers/filters_controller.js +0 -0
- data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +39 -0
- data/app/assets/javascripts/headmin/controllers/hello_controller.js +7 -0
- data/app/assets/javascripts/headmin/controllers/notification_controller.js +8 -0
- data/{src/js → app/assets/javascripts}/headmin/controllers/popup_controller.js +0 -1
- data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +13 -0
- data/{src/js → app/assets/javascripts}/headmin/controllers/repeater_controller.js +0 -1
- data/app/assets/javascripts/headmin/controllers/select_controller.js +48 -0
- data/{src/js → app/assets/javascripts}/headmin/controllers/table_actions_controller.js +7 -37
- data/{src/js → app/assets/javascripts}/headmin/controllers/table_controller.js +23 -3
- data/app/assets/javascripts/headmin/index.js +41 -0
- data/app/assets/javascripts/headmin.js +15934 -0
- data/{src/scss → app/assets/stylesheets}/headmin/filter.scss +0 -0
- data/{src/scss → app/assets/stylesheets}/headmin/filters.scss +0 -0
- data/{src/scss → app/assets/stylesheets}/headmin/form.scss +55 -2
- data/{src/scss → app/assets/stylesheets}/headmin/general.scss +0 -0
- data/{src/scss → app/assets/stylesheets}/headmin/layout/body.scss +0 -0
- data/{src/scss → app/assets/stylesheets}/headmin/layout/sidebar.scss +0 -0
- data/{src/scss → app/assets/stylesheets}/headmin/layout.scss +0 -0
- data/{src/scss → app/assets/stylesheets}/headmin/login.scss +0 -0
- data/{src/scss/vendor/bootstrap/variables.scss → app/assets/stylesheets/headmin/overrides/bootstrap.scss} +0 -0
- data/{src/scss/vendor/redactorx/override.css → app/assets/stylesheets/headmin/overrides/redactorx.css} +0 -0
- data/{src/scss → app/assets/stylesheets}/headmin/popup.scss +0 -0
- data/app/assets/stylesheets/headmin/syntax.scss +349 -0
- data/{src/scss → app/assets/stylesheets}/headmin/table.scss +0 -0
- data/app/assets/stylesheets/headmin/thumbnail.scss +20 -0
- data/app/assets/stylesheets/headmin/utilities.scss +68 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_accordion.scss +118 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_alert.scss +57 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_badge.scss +29 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_breadcrumb.scss +28 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_button-group.scss +139 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_buttons.scss +111 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_card.scss +216 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_carousel.scss +229 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_close.scss +40 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_containers.scss +41 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_dropdown.scss +240 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_forms.scss +9 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_functions.scss +302 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_grid.scss +33 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_helpers.scss +9 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_images.scss +42 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_list-group.scss +174 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_mixins.scss +43 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_modal.scss +209 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_nav.scss +139 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_navbar.scss +335 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_offcanvas.scss +83 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_pagination.scss +64 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_placeholders.scss +51 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_popover.scss +158 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_progress.scss +48 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_reboot.scss +625 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_root.scss +54 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_spinners.scss +69 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_tables.scss +155 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_toasts.scss +51 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_tooltip.scss +115 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_transitions.scss +27 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_type.scss +104 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_utilities.scss +630 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/_variables.scss +1641 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-grid.scss +67 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-reboot.scss +13 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap-utilities.scss +18 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/bootstrap.scss +53 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_floating-labels.scss +63 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-check.scss +152 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-control.scss +219 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-range.scss +91 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-select.scss +72 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_form-text.scss +11 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_input-group.scss +121 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_labels.scss +36 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/forms/_validation.scss +12 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_clearfix.scss +3 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_colored-links.scss +12 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_position.scss +30 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_ratio.scss +26 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_stacks.scss +15 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_stretched-link.scss +15 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_text-truncation.scss +7 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/helpers/_vr.scss +8 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_alert.scss +11 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_backdrop.scss +14 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_border-radius.scss +78 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_box-shadow.scss +18 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_breakpoints.scss +127 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_buttons.scss +133 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_caret.scss +64 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_clearfix.scss +9 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_color-scheme.scss +7 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_container.scss +9 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_deprecate.scss +10 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_forms.scss +144 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_gradients.scss +47 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_grid.scss +151 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_image.scss +16 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_list-group.scss +24 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_lists.scss +7 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_pagination.scss +31 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_reset-text.scss +17 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_resize.scss +6 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_table-variants.scss +21 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_text-truncate.scss +8 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_transition.scss +26 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_utilities.scss +89 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/mixins/_visually-hidden.scss +29 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/utilities/_api.scss +47 -0
- data/app/assets/stylesheets/headmin/vendor/bootstrap/scss/vendor/_rfs.scss +354 -0
- data/app/assets/stylesheets/headmin/vendor/flatpickr.css +903 -0
- data/{src/scss/vendor/redactorx → app/assets/stylesheets/headmin/vendor}/redactorx.css +0 -0
- data/app/assets/stylesheets/headmin/vendor/tom-select-bootstrap.css +537 -0
- data/app/assets/stylesheets/headmin.css +13454 -0
- data/app/assets/stylesheets/headmin.scss +65 -0
- data/app/helpers/headmin/admin_helper.rb +1 -0
- data/app/helpers/headmin/bootstrap_helper.rb +25 -3
- data/app/helpers/headmin/documentation_helper.rb +35 -0
- data/app/helpers/headmin/form_helper.rb +4 -0
- data/app/helpers/headmin/request_helper.rb +3 -8
- data/app/models/headmin/documentation_renderer.rb +32 -0
- data/app/models/headmin/form/base.rb +79 -0
- data/app/models/headmin/form/text.rb +53 -0
- data/app/services/block_service.rb +1 -1
- data/app/views/examples/admin.html.erb +1 -1
- data/app/views/headmin/_blocks.html.erb +2 -2
- data/app/views/headmin/_breadcrumbs.html.erb +1 -1
- data/app/views/headmin/_card.html.erb +10 -6
- data/app/views/headmin/_dropdown.html.erb +1 -1
- data/app/views/headmin/_filters.html.erb +22 -10
- data/app/views/headmin/_form.html.erb +14 -14
- 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 +3 -5
- data/app/views/headmin/_popup.html.erb +10 -4
- data/app/views/headmin/_table.html.erb +10 -4
- data/app/views/headmin/_thumbnail.html.erb +45 -0
- data/app/views/headmin/dropdown/_devise.html.erb +2 -2
- data/app/views/headmin/dropdown/_list.html.erb +3 -6
- data/app/views/headmin/filters/_date.html.erb +9 -13
- data/app/views/headmin/filters/_flatpickr.html.erb +57 -0
- data/app/views/headmin/filters/_search.html.erb +5 -5
- data/app/views/headmin/filters/_select.html.erb +6 -6
- data/app/views/headmin/filters/filter/_button.html.erb +7 -7
- data/app/views/headmin/filters/filter/_template.html.erb +1 -1
- data/app/views/headmin/forms/_actions.html.erb +1 -1
- data/app/views/headmin/forms/_base.html.erb +100 -46
- data/app/views/headmin/forms/_blocks.html.erb +4 -4
- data/app/views/headmin/forms/_checkbox.html.erb +3 -3
- data/app/views/headmin/forms/_date.html.erb +30 -34
- data/app/views/headmin/forms/_date_range.html.erb +42 -0
- data/app/views/headmin/forms/_email.html.erb +35 -26
- data/app/views/headmin/forms/_file.html.erb +186 -34
- data/app/views/headmin/forms/_flatpickr.html.erb +34 -0
- data/app/views/headmin/forms/_flatpickr_range.html.erb +50 -0
- data/app/views/headmin/forms/_hidden.html.erb +24 -0
- data/app/views/headmin/forms/_image.html.erb +11 -45
- data/app/views/headmin/forms/_label.html.erb +18 -12
- data/app/views/headmin/forms/_number.html.erb +40 -37
- data/app/views/headmin/forms/_password.html.erb +37 -58
- data/app/views/headmin/forms/_redactorx.html.erb +8 -7
- data/app/views/headmin/forms/_repeater.html.erb +6 -6
- data/app/views/headmin/forms/_select.html.erb +43 -45
- data/app/views/headmin/forms/_text.html.erb +94 -59
- data/app/views/headmin/forms/_textarea.html.erb +37 -26
- data/app/views/headmin/forms/_url.html.erb +35 -26
- data/app/views/headmin/forms/_validation.html.erb +3 -3
- data/app/views/headmin/forms/_video.html.erb +21 -0
- data/app/views/headmin/forms/fields/_base.html.erb +3 -3
- data/app/views/headmin/forms/fields/_file.html.erb +2 -2
- data/app/views/headmin/forms/fields/_group.html.erb +3 -3
- data/app/views/headmin/forms/fields/_image.html.erb +2 -2
- data/app/views/headmin/forms/fields/_list.html.erb +3 -3
- data/app/views/headmin/forms/fields/_text.html.erb +2 -2
- data/app/views/headmin/forms/repeater/_row.html.erb +1 -1
- data/app/views/headmin/heading/_title.html.erb +1 -1
- data/app/views/headmin/layout/_body.html.erb +1 -1
- data/app/views/headmin/layout/_content.html.erb +1 -1
- data/app/views/headmin/layout/_footer.html.erb +1 -1
- data/app/views/headmin/layout/_header.html.erb +1 -1
- data/app/views/headmin/layout/_main.html.erb +12 -6
- data/app/views/headmin/layout/_sidebar.html.erb +3 -3
- data/app/views/headmin/layout/sidebar/_bottom.html.erb +1 -1
- data/app/views/headmin/layout/sidebar/_nav.html.erb +1 -1
- data/app/views/headmin/nav/_dropdown.html.erb +34 -0
- data/app/views/headmin/nav/_item.html.erb +22 -13
- data/app/views/headmin/table/_actions.html.erb +3 -5
- data/app/views/headmin/table/_body.html.erb +1 -1
- data/app/views/headmin/table/_foot.html.erb +1 -1
- data/app/views/headmin/table/_footer.html.erb +1 -1
- data/app/views/headmin/table/_head.html.erb +1 -1
- data/app/views/headmin/table/_header.html.erb +1 -1
- data/app/views/headmin/table/actions/_action.html.erb +4 -4
- data/app/views/headmin/table/actions/_delete.html.erb +1 -1
- data/app/views/headmin/table/actions/_export.html.erb +1 -1
- data/app/views/headmin/table/body/_row.html.erb +15 -7
- data/config/importmap.rb +2 -0
- data/config/locales/en.yml +0 -3
- data/config/locales/headmin/forms/en.yml +5 -0
- data/config/locales/headmin/forms/nl.yml +5 -0
- data/config/locales/headmin/popup/en.yml +4 -0
- data/config/locales/headmin/popup/nl.yml +4 -0
- data/config/locales/headmin/thumbnail/en.yml +4 -0
- data/config/locales/headmin/thumbnail/nl.yml +4 -0
- data/config/locales/nl.yml +0 -3
- data/esbuild-css.js +25 -0
- data/esbuild-js.js +11 -0
- data/headmin.gemspec +4 -1
- data/lib/headmin/engine.rb +15 -0
- data/lib/headmin/version.rb +1 -1
- data/lib/headmin.rb +1 -1
- data/package.json +18 -34
- data/src/js/headmin.js +1 -1
- data/src/scss/headmin.scss +1 -61
- data/yarn.lock +393 -5177
- metadata +191 -34
- data/.nvmrc +0 -1
- data/app/controllers/concerns/headmin/ckeditor.rb +0 -27
- data/app/views/headmin/forms/_ckeditor.html.erb +0 -42
- data/dist/css/headmin.css +0 -12354
- data/dist/js/headmin.js +0 -1080
- data/src/js/headmin/headmin.js +0 -141
- data/src/scss/headmin/utilities.scss +0 -19
- data/webpack.config.js +0 -30
@@ -1,39 +1,48 @@
|
|
1
1
|
<%
|
2
2
|
# headmin/forms/email
|
3
3
|
#
|
4
|
-
# ====
|
5
|
-
# *
|
6
|
-
# *
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# *
|
10
|
-
# *
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +attribute+ - Name of the attribute of the form model
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +aria+ - Provide a hash to define all aria attributes
|
10
|
+
# * +autocomplete+ - Value to be autofilled by the browser
|
11
|
+
# * +data+ - Provide a hash to define all data attributes
|
12
|
+
# * +disabled+ - Sets the placeholder of the field
|
13
|
+
# * +id+ - Input identifier
|
14
|
+
# * +list+ - Add array of options to show in a data list
|
15
|
+
# * +maxlength+ - Maximum amount of characters to be used
|
16
|
+
# * +minlength+ - Minimum amount of characters to be used
|
17
|
+
# * +multiple+ - Allow multiple comma-separated email addresses to be entered
|
18
|
+
# * +pattern+ -a A regular expression that the input's value must match
|
19
|
+
# * +placeholder+ - Sets the placeholder of the field
|
20
|
+
# * +readonly+ - Sets the placeholder of the field
|
21
|
+
# * +required+ - Set to true to mark as required
|
22
|
+
# * +size+ - How much of the input should be shown
|
23
|
+
# * +value+ - Overrides the value of the form
|
24
|
+
#
|
25
|
+
# ==== Extra parameters
|
26
|
+
# Listed in 'headmin/forms/base'
|
27
|
+
#
|
28
|
+
# ==== References
|
29
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
|
30
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/text_field
|
11
31
|
#
|
12
32
|
# ==== Examples
|
13
33
|
# Basic version
|
14
34
|
# <%= render 'headmin/forms/email', form: form, attribute: :email_address %#>
|
15
35
|
|
16
|
-
|
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
|
36
|
+
placeholder = local_assigns[:float] ? local_assigns[:placeholder] || attribute : local_assigns[:placeholder]
|
25
37
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
readonly: readonly,
|
33
|
-
required: required,
|
34
|
-
}
|
38
|
+
option_keys = %i(aria autocomplete data disabled id maxlenght minlength multiple pattern placeholder readonly required size value)
|
39
|
+
options = local_assigns.slice(*option_keys).merge(
|
40
|
+
aria: { describedby: form_field_validation_id(form, attribute) },
|
41
|
+
class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
|
42
|
+
placeholder: placeholder
|
43
|
+
)
|
35
44
|
%>
|
36
45
|
|
37
|
-
<%= render 'headmin/forms/base',
|
46
|
+
<%= render 'headmin/forms/base', local_assigns do |form| %>
|
38
47
|
<%= form.email_field(attribute, options) %>
|
39
48
|
<% end %>
|
@@ -1,40 +1,192 @@
|
|
1
|
+
<!--
|
2
|
+
<% documentation do %>
|
3
|
+
# File
|
4
|
+
This is a wrapper around the form helper `file_field()`.
|
5
|
+
You can pass all valid input attributes as parameters to this template and
|
6
|
+
they will be added directly to the input field.
|
7
|
+
|
8
|
+
```erbx
|
9
|
+
<%= form_with do |form| %>
|
10
|
+
<%= render "headmin/forms/file", form: form, attribute: "basic_example" %>
|
11
|
+
<% end %>
|
12
|
+
```
|
13
|
+
|
14
|
+
## Parameters
|
15
|
+
| Name | Required | Type | Description |
|
16
|
+
| ------------ | -------- | ---------------- | ----------- |
|
17
|
+
| form | yes | Object | Form object |
|
18
|
+
| attribute | yes | String, Symbol | Name of the attribute of the form model |
|
19
|
+
| accept | no | String | A comma-separated list of allowed file extensions or MIME types |
|
20
|
+
| aria | no | Hash | Provide a hash to define all aria attributes |
|
21
|
+
| autocomplete | no | String | Hint for form autofill feature |
|
22
|
+
| autofocus | no | Boolean | Automatically focus the form control when the page is loaded |
|
23
|
+
| capture | no | String | Allows selection of capturing device. Accepted: user, environment |
|
24
|
+
| data | no | Hash | Provide a hash to define all data attributes |
|
25
|
+
| disabled | no | Boolean | Whether the form control is disabled |
|
26
|
+
| destroy | no | Boolean | Adds delete buttons to the preview thumbnails |
|
27
|
+
| dropzone | no | Boolean | Add drag&drop interface. This setting automatically enables previews |
|
28
|
+
| id | no | String | Input identifier |
|
29
|
+
| multiple | no | Boolean | Allows the user to select more than one file. |
|
30
|
+
| preview | no | Boolean | Show file previews after selection and after upload |
|
31
|
+
| required | no | Boolean | A value is required or must be check for the form to be submittable |
|
32
|
+
| value | no | String | The initial value of the control |
|
33
|
+
|
34
|
+
**Additional parameters**
|
35
|
+
|
36
|
+
This view makes use of [headmin/forms/base](https://headmin.test/forms/base) for labels and appendages.
|
37
|
+
Take a look at its documentation to get a complete overview of all additional parameters.
|
38
|
+
|
39
|
+
## Examples
|
40
|
+
|
41
|
+
### Preview
|
42
|
+
```erbx
|
43
|
+
<%= form_with do |form| %>
|
44
|
+
<div class="row">
|
45
|
+
<div class="col-md-4">
|
46
|
+
<%= render "headmin/forms/file", form: form, attribute: "single", preview: true %>
|
47
|
+
</div>
|
48
|
+
<div class="col-md-4">
|
49
|
+
<%= render "headmin/forms/file", form: form, attribute: "multiple", preview: true, multiple: true %>
|
50
|
+
</div>
|
51
|
+
<div class="col-md-4">
|
52
|
+
<%= render "headmin/forms/file", form: form, attribute: "with_delete_button", preview: true, multiple: true, destroy: true %>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
<% end %>
|
56
|
+
```
|
57
|
+
|
58
|
+
### Drag & Drop
|
59
|
+
```erbx
|
60
|
+
<%= form_with do |form| %>
|
61
|
+
<%= render "headmin/forms/file", form: form, attribute: "single", dropzone: true %>
|
62
|
+
<%= render "headmin/forms/file", form: form, attribute: "multiple", dropzone: true, multiple: true %>
|
63
|
+
<%= render "headmin/forms/file", form: form, attribute: "with_delete_button", dropzone: true, multiple: true, destroy: true %>
|
64
|
+
<% end %>
|
65
|
+
```
|
66
|
+
|
67
|
+
### States
|
68
|
+
```erbx
|
69
|
+
<%= form_with do |form| %>
|
70
|
+
<%= render "headmin/forms/file", form: form, attribute: "disabled", disabled: true %>
|
71
|
+
<%= render "headmin/forms/file", form: form, attribute: "readonly", readonly: true %>
|
72
|
+
<%= render "headmin/forms/file", form: form, attribute: "disabled_and_readonly", disabled: true, readonly: true %>
|
73
|
+
<% end %>
|
74
|
+
```
|
75
|
+
|
76
|
+
## References
|
77
|
+
- [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file)
|
78
|
+
- [APIdock](https://apidock.com/rails/v5.2.3/ActionView/Helpers/FormHelper/file_field)
|
79
|
+
<% end %>
|
80
|
+
-->
|
1
81
|
<%
|
2
|
-
#
|
82
|
+
# ==== Examples
|
83
|
+
# Limit file types (e.g. only Microsoft Word files)
|
84
|
+
# <%= render 'headmin/forms/file', form: form, attribute: :file, accept: '.doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document' %#>
|
3
85
|
#
|
4
|
-
#
|
5
|
-
#
|
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
|
86
|
+
# Allow multiple file selection
|
87
|
+
# <%= render 'headmin/forms/file', form: form, attribute: :file, multiple: true %#>
|
8
88
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
89
|
+
# Allows specification of capturing device
|
90
|
+
# <%= render 'headmin/forms/file', form: form, attribute: :file, capture: 'user' %#>
|
91
|
+
#
|
92
|
+
# Show preview thumbnails
|
93
|
+
# <%= render 'headmin/forms/file', form: form, attribute: :file, preview: true %#>
|
94
|
+
#
|
95
|
+
# Allow deleting file(s). This makes use of nested attributes. Add the definition to your model and add them to the list of strong parameters.
|
96
|
+
# <%= render 'headmin/forms/file', form: form, attribute: :file, preview: true %#>
|
97
|
+
|
98
|
+
placeholder = local_assigns[:float] ? local_assigns[:placeholder] || attribute : local_assigns[:placeholder]
|
99
|
+
attached = form.object&.send(attribute)
|
100
|
+
attachments = attached&.attachments || []
|
101
|
+
dropzone = local_assigns[:dropzone]
|
102
|
+
preview = local_assigns[:preview] || dropzone
|
103
|
+
destroy = local_assigns[:destroy] || false
|
104
|
+
number_of_files = local_assigns[:multiple] ? 2 : 1
|
105
|
+
|
106
|
+
nested_attribute = attached.is_a?(ActiveStorage::Attached::Many) ? :"#{attribute.to_s}_attachments" : :"#{attribute.to_s}_attachment"
|
107
|
+
|
108
|
+
option_keys = %i(accept aria autocomplete autofocus capture data disabled id multiple required value)
|
109
|
+
options = local_assigns.slice(*option_keys).merge(
|
110
|
+
aria: { describedby: form_field_validation_id(form, attribute) },
|
111
|
+
class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
|
112
|
+
list: local_assigns[:list] ? "#{attribute}_list" : nil,
|
113
|
+
placeholder: placeholder,
|
114
|
+
required: attached ? false : local_assigns[:required]
|
115
|
+
)
|
116
|
+
|
117
|
+
if preview
|
118
|
+
local_assigns = local_assigns.merge(
|
119
|
+
data: {
|
120
|
+
controller: 'file-preview'
|
121
|
+
}
|
122
|
+
)
|
123
|
+
options = options.merge(
|
124
|
+
data: {
|
125
|
+
'file-preview-target': 'input',
|
126
|
+
'dropzone-target': 'input',
|
127
|
+
action: 'change->file-preview#preview dropEnd->file-preview#preview'
|
128
|
+
}
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
thumbnail_width = 100
|
133
|
+
thumbnail_height = 100
|
31
134
|
%>
|
32
135
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
136
|
+
<%= render 'headmin/forms/base', local_assigns do |form| %>
|
137
|
+
<div class="h-form-file" data-controller="<%= 'filePreview' if preview %> <%= 'dropzone' if dropzone %>">
|
138
|
+
|
139
|
+
<% if preview %>
|
140
|
+
<div class="h-form-file-thumbnails" data-file-preview-target="thumbnails">
|
141
|
+
|
142
|
+
<!-- Render previews for attachments -->
|
143
|
+
<%= form.fields_for(nested_attribute) do |ff| %>
|
144
|
+
<%
|
145
|
+
attachment = ff.object
|
146
|
+
next unless attachment
|
147
|
+
filename = attachment.blob.filename.to_s
|
148
|
+
size = number_to_human_size(attachment.blob.byte_size)
|
149
|
+
src = attachment.image? ? url_for(attachment.variant(resize_to_fill: [thumbnail_width, thumbnail_height], quality: 70)) : url_for(attachment)
|
150
|
+
%>
|
151
|
+
<div class="h-form-file-thumbnail" title="<%= "#{filename} (#{size})" %>" data-file-preview-target="thumbnail">
|
152
|
+
<%= ff.hidden_field(:id, disabled: destroy) %>
|
153
|
+
<%= ff.hidden_field(:_destroy, data: { 'file-preview-target': 'thumbnailDestroy' }, disabled: destroy) %>
|
154
|
+
<%= render 'headmin/thumbnail', src: src, width: thumbnail_width, height: thumbnail_height %>
|
155
|
+
|
156
|
+
<% if destroy %>
|
157
|
+
<div class="h-form-file-thumbnail-remove" data-action="click->file-preview#remove" data-file-preview-name-param="<%= filename %>">
|
158
|
+
<%= bootstrap_icon('x') %>
|
159
|
+
</div>
|
160
|
+
<% end %>
|
161
|
+
</div>
|
162
|
+
<% end %>
|
163
|
+
|
164
|
+
<!-- Placeholder -->
|
165
|
+
<% if dropzone %>
|
166
|
+
<div class="h-dropzone-placeholder <%= 'd-none' if attachments.any? %>" data-file-preview-target="placeholder" style="height: <%= thumbnail_height %>px;">
|
167
|
+
<%= t('headmin.forms.file.placeholder', count: number_of_files) %>
|
168
|
+
</div>
|
169
|
+
<% else %>
|
170
|
+
<div class="h-form-file-thumbnail <%= 'd-none' if attachments.any? %>" title="<%= t('headmin.forms.file.not_found') %>" data-file-preview-target="placeholder">
|
171
|
+
<%= render 'headmin/thumbnail', src: nil, width: thumbnail_width, height: thumbnail_height %>
|
172
|
+
</div>
|
173
|
+
<% end %>
|
174
|
+
</div>
|
175
|
+
<% end %>
|
176
|
+
|
177
|
+
<!-- Template -->
|
178
|
+
<template data-file-preview-target="template">
|
179
|
+
<div class="h-form-file-thumbnail" title="" data-file-preview-target="thumbnail">
|
180
|
+
<%= render 'headmin/thumbnail', src: nil, width: thumbnail_width, height: thumbnail_height %>
|
181
|
+
|
182
|
+
<% if destroy %>
|
183
|
+
<div class="h-form-file-thumbnail-remove" data-action="click->file-preview#remove">
|
184
|
+
<%= bootstrap_icon('x') %>
|
185
|
+
</div>
|
186
|
+
<% end %>
|
187
|
+
</div>
|
188
|
+
</template>
|
37
189
|
|
38
|
-
|
39
|
-
|
40
|
-
|
190
|
+
<%= form.file_field(attribute, options) %>
|
191
|
+
</div>
|
192
|
+
<% end %>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/flatpickr
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +attribute+ - Name of the attribute of the form model
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +aria+ - Provide a hash to define all aria attributes
|
10
|
+
# * +data+ - Optional HTML data attributes
|
11
|
+
# * +disabled+ - Set to true if the input should be shown as disabled
|
12
|
+
# * +readonly+ - Set to true if the value of the field can only be read and not be modified
|
13
|
+
# * +value+ - Overrides the value of the form
|
14
|
+
#
|
15
|
+
# ==== Extra parameters
|
16
|
+
# Listed in 'headmin/forms/base'
|
17
|
+
#
|
18
|
+
# ==== Examples
|
19
|
+
# Basic version
|
20
|
+
# <%= render 'headmin/forms/flatpickr', form: form, attribute: :date %#>
|
21
|
+
|
22
|
+
options = local_assigns.merge(
|
23
|
+
data: {
|
24
|
+
'flatpickr-target': 'input',
|
25
|
+
'flatpickr-options': {
|
26
|
+
defaultDate: form.object&.send(attribute)&.strftime('%d/%m/%Y')
|
27
|
+
}
|
28
|
+
}
|
29
|
+
)
|
30
|
+
%>
|
31
|
+
|
32
|
+
<div data-controller="flatpickr">
|
33
|
+
<%= render 'headmin/forms/date', options %>
|
34
|
+
</div>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/flatpickr_range
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +start_attribute+ - Name of the start date attribute of the form model
|
7
|
+
# * +end_attribute+ - Name of the end date attribute of the form model
|
8
|
+
#
|
9
|
+
# ==== Optional parameters
|
10
|
+
# * +aria+ - Provide a hash to define all aria attributes
|
11
|
+
# * +data+ - Optional HTML data attributes
|
12
|
+
# * +disabled+ - Set to true if the input should be shown as disabled
|
13
|
+
# * +end_label+ - Label for the end attribute
|
14
|
+
# * +label+ - Text to show as label. Label will be hidden if value is false
|
15
|
+
# * +readonly+ - Set to true if the value of the field can only be read and not be modified
|
16
|
+
# * +start_label+ - Label for the start attribute
|
17
|
+
# * +value+ - Overrides the value of the form
|
18
|
+
#
|
19
|
+
# ==== Extra parameters
|
20
|
+
# Listed in 'headmin/forms/base'
|
21
|
+
#
|
22
|
+
# ==== Examples
|
23
|
+
# Basic version
|
24
|
+
# <%= render 'headmin/forms/flatpickr_range', form: form, start_attribute: :start_date, end_attribute: :end_date %#>
|
25
|
+
|
26
|
+
start_attribute = local_assigns[:start_attribute]
|
27
|
+
end_attribute = local_assigns[:end_attribute]
|
28
|
+
options = local_assigns.merge(
|
29
|
+
attribute: local_assigns[:attribute] || :period,
|
30
|
+
data: {
|
31
|
+
action: 'change->date-range#update',
|
32
|
+
'flatpickr-target': 'input',
|
33
|
+
'flatpickr-options': {
|
34
|
+
mode: 'range',
|
35
|
+
defaultDate: [
|
36
|
+
form.object&.send(start_attribute)&.strftime('%d/%m/%Y'),
|
37
|
+
form.object&.send(end_attribute)&.strftime('%d/%m/%Y'),
|
38
|
+
]
|
39
|
+
}
|
40
|
+
}
|
41
|
+
)
|
42
|
+
%>
|
43
|
+
|
44
|
+
<div data-controller="flatpickr">
|
45
|
+
<div data-controller="date-range">
|
46
|
+
<%= render 'headmin/forms/hidden', form: form, attribute: start_attribute, data: { 'date-range-target': 'startDateInput' } %>
|
47
|
+
<%= render 'headmin/forms/hidden', form: form, attribute: end_attribute, data: { 'date-range-target': 'endDateInput' } %>
|
48
|
+
<%= render 'headmin/forms/date', options %>
|
49
|
+
</div>
|
50
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/hidden
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +attribute+ - Name of the attribute of the form model
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +autocomplete+ - Value to be autofilled by the browser
|
10
|
+
# * +data+ - Optional HTML data attributes
|
11
|
+
#
|
12
|
+
# ==== References
|
13
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden
|
14
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/text_field
|
15
|
+
#
|
16
|
+
# ==== Examples
|
17
|
+
# Basic version
|
18
|
+
# <%= render 'headmin/forms/hidden', form: form, attribute: :title %#>
|
19
|
+
|
20
|
+
option_keys = %i(autocomplete data)
|
21
|
+
options = local_assigns.slice(*option_keys)
|
22
|
+
%>
|
23
|
+
|
24
|
+
<%= form.hidden_field(attribute, options) %>
|
@@ -1,55 +1,21 @@
|
|
1
1
|
<%
|
2
2
|
# name: headmin/forms/image
|
3
3
|
#
|
4
|
-
# ====
|
5
|
-
# *
|
6
|
-
# *
|
7
|
-
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +attribute+ - Name of the attribute of the form model
|
7
|
+
#
|
8
|
+
# ==== Extra parameters
|
9
|
+
# Listed in 'headmin/forms/file'
|
10
|
+
# Listed in 'headmin/forms/base'
|
8
11
|
#
|
9
12
|
# ==== Examples
|
10
13
|
# Basic version
|
11
14
|
# <%= render 'headmin/forms/image', form: form, attribute: :image %#>
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
label = local_assigns.has_key?(:label) ? label : nil
|
17
|
-
readonly = local_assigns.has_key?(:readonly) ? readonly : false
|
18
|
-
required = local_assigns.has_key?(:required) ? required : false
|
19
|
-
|
20
|
-
has_image = form.object.send(attribute).attached?
|
21
|
-
|
22
|
-
options = {
|
23
|
-
'aria-describedby': form_field_validation_id(form, attribute),
|
24
|
-
class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
|
25
|
-
data: data,
|
26
|
-
disabled: disabled,
|
27
|
-
placeholder: attribute,
|
28
|
-
readonly: readonly,
|
29
|
-
required: has_image ? false : required,
|
30
|
-
}
|
31
|
-
|
32
|
-
show_label = label != false
|
16
|
+
options = local_assigns.merge(
|
17
|
+
accept: 'image/*'
|
18
|
+
)
|
33
19
|
%>
|
34
20
|
|
35
|
-
|
36
|
-
|
37
|
-
<% if show_label %>
|
38
|
-
<%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
|
39
|
-
<% end %>
|
40
|
-
|
41
|
-
<div class="mb-2">
|
42
|
-
<% if has_image %>
|
43
|
-
<%= image_tag(form.object.send(attribute).variant(resize_to_limit: [200, 200], quality: 70), class: 'img-thumbnail') %>
|
44
|
-
<% else %>
|
45
|
-
<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">
|
46
|
-
<title>A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera</title>
|
47
|
-
<rect width="100%" height="100%" fill="#e9ecef"></rect>
|
48
|
-
<text x="35%" y="50%" fill="#212529" dy=".3em">200x200</text>
|
49
|
-
</svg>
|
50
|
-
<% end %>
|
51
|
-
</div>
|
52
|
-
|
53
|
-
<%= form.file_field(attribute, options) %>
|
54
|
-
<%= render 'headmin/forms/validation', form: form, attribute: attribute %>
|
55
|
-
</div>
|
21
|
+
<%= render 'headmin/forms/file', options %>
|
@@ -1,24 +1,30 @@
|
|
1
1
|
<%
|
2
2
|
# name: headmin/forms/label
|
3
3
|
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +attribute+ - Name of the attribute of the form model
|
7
|
+
#
|
4
8
|
# ==== Options
|
5
|
-
# *
|
6
|
-
# *
|
7
|
-
# *
|
8
|
-
# *
|
9
|
+
# * +class+ - Optional HTML class attribute
|
10
|
+
# * +for+ - Set reference to the input id
|
11
|
+
# * +required+ - Set to true if you want to highlight the requirement
|
12
|
+
# * +text+ - Custom label to be used instead of the attribute
|
13
|
+
#
|
14
|
+
# ==== References
|
15
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
|
16
|
+
# https://apidock.com/rails/v5.2.3/ActionView/Helpers/FormHelper/label
|
9
17
|
#
|
10
18
|
# ==== Examples
|
11
19
|
# Basic version
|
12
20
|
# <%= render 'headmin/forms/label', form: form, attribute: :image %#>
|
13
21
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
options = {
|
19
|
-
class: "form-label #{class_names}",
|
20
|
-
required: required,
|
22
|
+
text = local_assigns[:text]
|
23
|
+
default_options = {
|
24
|
+
class: ['form-label', local_assigns[:class]].join(' '),
|
25
|
+
form: form.options[:id],
|
21
26
|
}
|
27
|
+
options = default_options.merge(local_assigns.slice(*%i(for required)).compact)
|
22
28
|
%>
|
23
29
|
|
24
|
-
<%= form.label attribute,
|
30
|
+
<%= form.label attribute, text, options %>
|
@@ -1,50 +1,53 @@
|
|
1
1
|
<%
|
2
2
|
# headmin/forms/number
|
3
3
|
#
|
4
|
-
# ====
|
5
|
-
# *
|
6
|
-
# *
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# *
|
10
|
-
# *
|
11
|
-
# *
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +form+ - Form object
|
6
|
+
# * +attribute+ - Name of the attribute of the form model
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +aria+ - Provide a hash to define all aria attributes
|
10
|
+
# * +autocomplete+ - Value to be autofilled by the browser
|
11
|
+
# * +autofocus+ - Set to true to focus on this field when the page renders
|
12
|
+
# * +data+ - Provide a hash to define all data attributes
|
13
|
+
# * +disabled+ - Sets the placeholder of the field
|
14
|
+
# * +id+ - Input identifier
|
15
|
+
# * +in+ - Range specifying the +min+ and +max+ values
|
16
|
+
# * +list+ - Add array of options to show in a data list
|
17
|
+
# * +max+ - The maximum acceptable value
|
18
|
+
# * +min+ - The minimum acceptable value
|
19
|
+
# * +placeholder+ - Sets the placeholder of the field
|
20
|
+
# * +readonly+ - Sets the placeholder of the field
|
21
|
+
# * +required+ - Set to true to mark as required
|
22
|
+
# * +step+ - The acceptable value granularity
|
23
|
+
# * +value+ - Overrides the value of the form
|
24
|
+
# * +within+ - Same as +in+
|
25
|
+
#
|
26
|
+
# ==== Extra parameters
|
27
|
+
# Listed in 'headmin/forms/base'
|
28
|
+
#
|
29
|
+
# ==== References
|
30
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
|
31
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/number_field
|
12
32
|
#
|
13
33
|
# ==== Examples
|
14
34
|
# Basic version
|
15
35
|
# <%= render 'headmin/forms/number', form: form, attribute: :amount %#>
|
36
|
+
#
|
37
|
+
# With data-list
|
38
|
+
# <%= render 'headmin/forms/number', form: form, attribute: :amount, list: [2,4,6,8,10] %#>
|
16
39
|
|
17
|
-
|
18
|
-
class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
|
19
|
-
collection = local_assigns.has_key?(:collection) ? collection : nil
|
20
|
-
data = local_assigns.has_key?(:data) ? data : nil
|
21
|
-
disabled = local_assigns.has_key?(:disabled) ? disabled : false
|
22
|
-
float = local_assigns.has_key?(:float) ? float : false
|
23
|
-
label = local_assigns.has_key?(:label) ? label : nil
|
24
|
-
prepend = local_assigns.has_key?(:prepend) ? prepend : nil
|
25
|
-
readonly = local_assigns.has_key?(:readonly) ? readonly : false
|
26
|
-
required = local_assigns.has_key?(:required) ? required : false
|
40
|
+
placeholder = local_assigns[:float] ? local_assigns[:placeholder] || attribute : local_assigns[:placeholder]
|
27
41
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
readonly: readonly,
|
36
|
-
required: required,
|
37
|
-
}
|
42
|
+
option_keys = %i(aria autocomplete autofocus data disabled id in list max min placeholder readonly required step value within)
|
43
|
+
options = local_assigns.slice(*option_keys).merge(
|
44
|
+
aria: { describedby: form_field_validation_id(form, attribute) },
|
45
|
+
class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
|
46
|
+
list: local_assigns[:list] ? "#{attribute}_list" : nil,
|
47
|
+
placeholder: placeholder
|
48
|
+
)
|
38
49
|
%>
|
39
50
|
|
40
|
-
<%= render 'headmin/forms/base',
|
51
|
+
<%= render 'headmin/forms/base', local_assigns do |form| %>
|
41
52
|
<%= form.number_field(attribute, options) %>
|
42
53
|
<% end %>
|
43
|
-
|
44
|
-
<% if collection %>
|
45
|
-
<datalist id="<%= attribute %>">
|
46
|
-
<% collection.each do |key, value| %>
|
47
|
-
<option value="<%= value %>"><%= key %></option>
|
48
|
-
<% end %>
|
49
|
-
</datalist>
|
50
|
-
<% end %>
|