headmin 0.3.4 → 0.4.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/.github/workflows/ci.yml +27 -0
- data/.gitignore +14 -0
- data/.lock-487e157d270f3062a98b7b2a012753708-1272821827 +0 -0
- data/.nvmrc +1 -0
- data/CHANGELOG.md +31 -0
- data/Gemfile +7 -4
- data/Gemfile.lock +191 -25
- data/README.md +7 -0
- data/Rakefile +1 -7
- data/app/assets/javascripts/headmin/config/i18n.js +9 -9
- data/app/assets/javascripts/headmin/controllers/autocomplete_controller.js +318 -0
- data/app/assets/javascripts/headmin/controllers/blocks_controller.js +74 -79
- data/app/assets/javascripts/headmin/controllers/date_range_controller.js +24 -24
- data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +23 -25
- data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +237 -237
- data/app/assets/javascripts/headmin/controllers/filter_controller.js +44 -44
- data/app/assets/javascripts/headmin/controllers/filters_controller.js +57 -61
- data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +29 -29
- data/app/assets/javascripts/headmin/controllers/hello_controller.js +3 -3
- data/app/assets/javascripts/headmin/controllers/notification_controller.js +7 -6
- data/app/assets/javascripts/headmin/controllers/popup_controller.js +57 -51
- data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +36 -9
- data/app/assets/javascripts/headmin/controllers/repeater_controller.js +122 -125
- data/app/assets/javascripts/headmin/controllers/select_controller.js +40 -39
- data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +100 -101
- data/app/assets/javascripts/headmin/controllers/table_controller.js +115 -115
- data/app/assets/javascripts/headmin/index.js +38 -35
- data/app/assets/javascripts/headmin.js +295 -37
- data/app/assets/stylesheets/headmin/forms/autocomplete.scss +21 -0
- data/app/assets/stylesheets/headmin/forms/file.scss +46 -0
- data/app/assets/stylesheets/headmin/forms/repeater.scss +62 -0
- data/app/assets/stylesheets/headmin/forms/search.scss +12 -0
- data/app/assets/stylesheets/headmin/forms.scss +11 -0
- data/app/assets/stylesheets/headmin/general.scss +14 -0
- data/app/assets/stylesheets/headmin/overrides/bootstrap.scss +5 -3
- data/app/assets/stylesheets/headmin/overrides/redactorx.scss +74 -0
- data/app/assets/stylesheets/headmin/popup.scss +1 -0
- data/app/assets/stylesheets/headmin/syntax.scss +36 -349
- data/app/assets/stylesheets/headmin/table.scss +1 -1
- data/app/assets/stylesheets/headmin/utilities/buttons.scss +19 -0
- data/app/assets/stylesheets/headmin/utilities/dropzone.scss +72 -0
- data/app/assets/stylesheets/headmin/utilities.scss +2 -68
- data/app/assets/stylesheets/headmin.css +209 -205
- data/app/assets/stylesheets/headmin.scss +1 -1
- data/app/helpers/headmin/admin_helper.rb +0 -1
- data/app/helpers/headmin/form_helper.rb +2 -8
- data/app/models/concerns/headmin/blockable.rb +1 -1
- data/app/models/concerns/headmin/field.rb +4 -1
- data/app/models/concerns/headmin/fieldable.rb +138 -44
- data/app/models/concerns/headmin/form/autocompletable.rb +38 -0
- data/app/models/concerns/headmin/form/hintable.rb +19 -0
- data/app/models/concerns/headmin/form/input_groupable.rb +23 -0
- data/app/models/concerns/headmin/form/labelable.rb +33 -0
- data/app/models/concerns/headmin/form/listable.rb +28 -0
- data/app/models/concerns/headmin/form/placeholderable.rb +13 -0
- data/app/models/concerns/headmin/form/validatable.rb +40 -0
- data/app/models/concerns/headmin/form/wrappable.rb +21 -0
- data/app/models/headmin/.DS_Store +0 -0
- data/app/models/headmin/blocks_view.rb +15 -0
- data/app/models/headmin/form/blocks_view.rb +29 -0
- data/app/models/headmin/form/checkbox_view.rb +52 -0
- data/app/models/headmin/form/date_range_view.rb +25 -0
- data/app/models/headmin/form/date_view.rb +45 -0
- data/app/models/headmin/form/email_view.rb +48 -0
- data/app/models/headmin/form/file_view.rb +116 -0
- data/app/models/headmin/form/flatpickr_range_view.rb +102 -0
- data/app/models/headmin/form/flatpickr_view.rb +37 -0
- data/app/models/headmin/form/hidden_view.rb +10 -0
- data/app/models/headmin/form/hint_view.rb +6 -0
- data/app/models/headmin/form/input_group_view.rb +19 -0
- data/app/models/headmin/form/label_view.rb +24 -0
- data/app/models/headmin/form/number_view.rb +49 -0
- data/app/models/headmin/form/password_view.rb +44 -0
- data/app/models/headmin/form/redactorx_view.rb +59 -0
- data/app/models/headmin/form/search_view.rb +48 -0
- data/app/models/headmin/form/select_view.rb +62 -0
- data/app/models/headmin/form/switch_view.rb +23 -0
- data/app/models/headmin/form/text_view.rb +48 -0
- data/app/models/headmin/form/textarea_view.rb +44 -0
- data/app/models/headmin/form/url_view.rb +48 -0
- data/app/models/headmin/form/wrapper_view.rb +19 -0
- data/app/models/headmin/form/wysiwyg_view.rb +17 -0
- data/app/models/headmin/{thumbnail.rb → thumbnail_view.rb} +6 -1
- data/app/models/view_model.rb +58 -0
- data/app/views/headmin/_blocks.html.erb +13 -9
- data/app/views/headmin/_heading.html.erb +7 -1
- data/app/views/headmin/_thumbnail.html.erb +1 -37
- data/app/views/headmin/forms/_autocomplete.html.erb +11 -0
- data/app/views/headmin/forms/_blocks.html.erb +16 -17
- data/app/views/headmin/forms/_checkbox.html.erb +24 -29
- data/app/views/headmin/forms/_datalist.html.erb +3 -0
- data/app/views/headmin/forms/_date.html.erb +24 -24
- data/app/views/headmin/forms/_date_range.html.erb +19 -21
- data/app/views/headmin/forms/_email.html.erb +27 -32
- data/app/views/headmin/forms/_errors.html.erb +2 -3
- data/app/views/headmin/forms/_file.html.erb +84 -181
- data/app/views/headmin/forms/_flatpickr.html.erb +19 -20
- data/app/views/headmin/forms/_flatpickr_range.html.erb +28 -37
- data/app/views/headmin/forms/_hidden.html.erb +9 -10
- data/app/views/headmin/forms/_hint.html.erb +16 -0
- data/app/views/headmin/forms/_input_group.html.erb +21 -0
- data/app/views/headmin/forms/_label.html.erb +5 -13
- data/app/views/headmin/forms/_number.html.erb +23 -35
- data/app/views/headmin/forms/_password.html.erb +21 -30
- data/app/views/headmin/forms/_redactorx.html.erb +21 -40
- data/app/views/headmin/forms/_repeater.html.erb +55 -60
- data/app/views/headmin/forms/_search.html.erb +43 -0
- data/app/views/headmin/forms/_select.html.erb +24 -49
- data/app/views/headmin/forms/_switch.html.erb +29 -0
- data/app/views/headmin/forms/_text.html.erb +42 -96
- data/app/views/headmin/forms/_textarea.html.erb +21 -32
- data/app/views/headmin/forms/_url.html.erb +26 -31
- data/app/views/headmin/forms/_validation.html.erb +10 -13
- data/app/views/headmin/forms/_wrapper.html.erb +9 -0
- data/app/views/headmin/forms/_wysiwyg.html.erb +28 -0
- data/app/views/headmin/forms/autocomplete/_item.html.erb +3 -0
- data/app/views/headmin/forms/autocomplete/_list.html.erb +3 -0
- data/app/views/headmin/forms/fields/_file.html.erb +1 -1
- data/app/views/headmin/forms/fields/_files.html.erb +17 -0
- data/app/views/headmin/forms/fields/_group.html.erb +9 -2
- data/app/views/headmin/forms/repeater/_row.html.erb +4 -4
- data/bin/console +0 -1
- data/config/locales/headmin/forms/en.yml +1 -12
- data/config/locales/headmin/forms/nl.yml +1 -12
- data/esbuild-css.js +18 -18
- data/esbuild-js.js +8 -8
- data/headmin.gemspec +1 -3
- data/lib/generators/templates/controllers/auth/confirmations_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/passwords_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/registrations_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/sessions_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/unlocks_controller.rb +0 -2
- data/lib/headmin/version.rb +1 -3
- data/lib/headmin.rb +0 -2
- data/package-lock.json +5359 -0
- data/package.json +12 -4
- data/view_model_benchmark.rb +74 -0
- data/yarn-error.log +17 -12
- data/yarn.lock +1575 -31
- metadata +64 -25
- data/app/assets/stylesheets/headmin/form.scss +0 -132
- data/app/assets/stylesheets/headmin/overrides/redactorx.css +0 -3
- data/app/helpers/headmin/documentation_helper.rb +0 -35
- data/app/models/headmin/documentation_renderer.rb +0 -32
- data/app/models/headmin/form/base.rb +0 -78
- data/app/models/headmin/form/text.rb +0 -51
- data/app/services/block_service.rb +0 -72
- data/app/views/headmin/_card.html.erb +0 -52
- data/app/views/headmin/forms/_actions.html.erb +0 -28
- data/app/views/headmin/forms/_base.html.erb +0 -114
- data/app/views/headmin/forms/_image.html.erb +0 -21
- data/app/views/headmin/forms/_video.html.erb +0 -21
- data/app/views/headmin/forms/actions/_destroy.html.erb +0 -13
- data/app/views/headmin/forms/actions/_save.html.erb +0 -12
- data/app/views/headmin/forms/actions/_view.html.erb +0 -15
- data/app/views/headmin/forms/fields/_image.html.erb +0 -17
- data/docs/blocks-and-fields.md +0 -54
- data/docs/blocks.md +0 -48
- data/docs/devise.md +0 -41
- data/docs/fields.md +0 -79
@@ -2,47 +2,38 @@
|
|
2
2
|
# headmin/forms/password
|
3
3
|
#
|
4
4
|
# ==== Required parameters
|
5
|
-
# * +form+ - Form object
|
6
5
|
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
7
|
#
|
8
8
|
# ==== Optional parameters
|
9
|
-
# * +
|
10
|
-
# * +
|
11
|
-
# * +
|
12
|
-
# * +
|
13
|
-
# * +
|
14
|
-
# * +
|
15
|
-
# * +
|
16
|
-
# * +maxlength+ - The maximum number of characters that the browser will allow the user to enter.
|
17
|
-
# * +minlength+ - The minimum number of characters that the browser will allow the user to enter.
|
18
|
-
# * +placeholder+ - Sets the placeholder of the field
|
19
|
-
# * +readonly+ - Sets the placeholder of the field
|
20
|
-
# * +required+ - Set to true to mark as required
|
21
|
-
# * +size+ - The number of visible characters that will fit in the input
|
22
|
-
# * +value+ - Overrides the value of the form
|
23
|
-
#
|
24
|
-
# ==== Extra parameters
|
25
|
-
# Listed in 'headmin/forms/base'
|
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
|
+
# * +plaintext+ - Render input as plain text.
|
14
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
15
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
26
16
|
#
|
27
17
|
# ==== References
|
18
|
+
# https://headmin.dev/docs/forms/password
|
28
19
|
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password
|
29
20
|
# https://apidock.com/rails/ActionView/Helpers/FormHelper/password_field
|
30
21
|
#
|
31
22
|
# ==== Examples
|
32
23
|
# Basic version
|
33
|
-
# <%=
|
34
|
-
|
35
|
-
|
24
|
+
# <%= form_with do |form| %#>
|
25
|
+
# <%= render "headmin/forms/password", form: form, attribute: :password %#>
|
26
|
+
# <% end %#>
|
36
27
|
|
37
|
-
|
38
|
-
options = local_assigns.slice(*option_keys).merge(
|
39
|
-
autocomplete: true,
|
40
|
-
aria: { describedby: form_field_validation_id(form, attribute) },
|
41
|
-
class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
|
42
|
-
placeholder: placeholder
|
43
|
-
)
|
28
|
+
password = Headmin::Form::PasswordView.new(local_assigns)
|
44
29
|
%>
|
45
30
|
|
46
|
-
<%= render
|
47
|
-
<%=
|
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
|
+
<%= form.password_field(password.attribute, password.input_options) %>
|
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? %>
|
48
39
|
<% end %>
|
@@ -1,50 +1,31 @@
|
|
1
1
|
<%
|
2
2
|
# headmin/forms/redactorx
|
3
3
|
#
|
4
|
-
# ====
|
5
|
-
# * +form+ - Form object
|
4
|
+
# ==== Required parameters
|
6
5
|
# * +attribute+ - Name of the attribute of the form model
|
7
|
-
# * +
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# * +
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +append+ - Display as input group with text on the right-hand side
|
10
|
+
# * +hint+ - Informative text to assist with data input. HTML markup is allowed.
|
11
|
+
# * +hybrid+ - Enables hybrid mode when set to true (default = false)
|
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
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
14
|
+
# * +redactor+ - Hash with all options you can pass to redactor JS config
|
15
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
16
|
+
#
|
17
|
+
# ==== References
|
18
|
+
# https://headmin.dev/docs/forms/redactorx
|
19
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
|
20
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/text_area
|
11
21
|
#
|
12
22
|
# ==== Examples
|
13
23
|
# Basic version
|
14
|
-
# <%=
|
15
|
-
|
16
|
-
|
17
|
-
data = local_assigns.has_key?(:data) ? data : {}
|
18
|
-
disabled = local_assigns.has_key?(:disabled) ? disabled : false
|
19
|
-
label = local_assigns.has_key?(:label) ? label : nil
|
20
|
-
readonly = local_assigns.has_key?(:readonly) ? readonly : false
|
21
|
-
required = local_assigns.has_key?(:required) ? required : false
|
22
|
-
addbar = local_assigns.has_key?(:addbar) ? addbar : ['paragraph', 'image', 'embed', 'table', 'quote', 'pre', 'line']
|
23
|
-
plugins = local_assigns.has_key?(:plugins) ? plugins : ['shortcut']
|
24
|
-
topbar = local_assigns.has_key?(:topbar) ? topbar : []
|
25
|
-
|
26
|
-
data = data.merge(
|
27
|
-
controller: 'redactorx',
|
28
|
-
'redactor-options': {
|
29
|
-
buttons: {
|
30
|
-
addbar: addbar,
|
31
|
-
plugins: plugins,
|
32
|
-
topbar: topbar,
|
33
|
-
}
|
34
|
-
}
|
35
|
-
)
|
24
|
+
# <%= form_with do |form| %#>
|
25
|
+
# <%= render "headmin/forms/redactorx", form: form, attribute: :text %#>
|
26
|
+
# <% end %#>
|
36
27
|
|
37
|
-
|
38
|
-
'aria-describedby': form_field_validation_id(form, attribute),
|
39
|
-
class: "form-control redactorx #{form_field_validation_class(form, attribute)} #{class_names}",
|
40
|
-
data: data,
|
41
|
-
disabled: disabled,
|
42
|
-
placeholder: attribute,
|
43
|
-
readonly: readonly,
|
44
|
-
required: required,
|
45
|
-
}
|
28
|
+
redactor = Headmin::Form::RedactorxView.new(local_assigns)
|
46
29
|
%>
|
47
30
|
|
48
|
-
<%= render
|
49
|
-
<%= form.text_area(attribute, options) %>
|
50
|
-
<% end %>
|
31
|
+
<%= render "headmin/forms/textarea", redactor.options %>
|
@@ -26,7 +26,7 @@
|
|
26
26
|
# <% end %#>
|
27
27
|
#
|
28
28
|
# # Allow more than one type of fields to be inserted. You must specify the templates as an array of view paths
|
29
|
-
# <% templates = ['admin/questions/fields/
|
29
|
+
# <% templates = ['admin/questions/fields/type_1', 'admin/questions/fields/type_2'] %#>
|
30
30
|
# <% render 'headmin/forms/repeater', form: form, attribute: :questions, templates: templates do |question| %#>
|
31
31
|
# <% render 'admin/questions/fields, form: :question' %#>
|
32
32
|
# <% end %#>
|
@@ -50,80 +50,75 @@
|
|
50
50
|
show_label = label != false
|
51
51
|
%>
|
52
52
|
|
53
|
-
|
53
|
+
<!-- Label -->
|
54
|
+
<% if show_label %>
|
55
|
+
<%= render 'headmin/forms/label', form: form, attribute: attribute, text: label, required: required %>
|
56
|
+
<% end %>
|
54
57
|
|
55
|
-
|
56
|
-
<% if show_label %>
|
57
|
-
<%= render 'headmin/forms/label', form: form, attribute: attribute, text: label, required: required %>
|
58
|
-
<% end %>
|
59
|
-
|
60
|
-
<ul class="list-group <%= 'list-group-flush' if flush %>" data-repeater-target="list">
|
58
|
+
<ul class="repeater list-group <%= 'list-group-flush' if flush %>" data-controller="repeater" data-repeater-target="list" data-repeater-id-value="<%= repeater_id %>">
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
<!-- Header -->
|
61
|
+
<% if header %>
|
62
|
+
<li class="list-group-item">
|
63
|
+
<%= render header %>
|
64
|
+
</li>
|
65
|
+
<% end %>
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<% end %>
|
67
|
+
<!-- Rows -->
|
68
|
+
<%= form.fields_for attribute, associations do |ff| %>
|
69
|
+
<%= render 'headmin/forms/repeater/row', pass_thru: pass_thru, form: ff, repeater_id: repeater_id do %>
|
70
|
+
<%= yield(ff) %>
|
74
71
|
<% end %>
|
72
|
+
<% end %>
|
75
73
|
|
76
|
-
|
77
|
-
|
74
|
+
<!-- Footer -->
|
75
|
+
<li class="list-group-item d-flex justify-content-between align-items-center" data-repeater-target="footer">
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
77
|
+
<!-- Empty notice -->
|
78
|
+
<div class="text-secondary invisible" data-repeater-target="empty">
|
79
|
+
<%= t('.empty') %>
|
80
|
+
</div>
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
82
|
+
<!-- Button -->
|
83
|
+
<div
|
84
|
+
class="btn btn-sm h-btn-outline-light"
|
85
|
+
data-repeater-target="addButton"
|
86
|
+
data-popup-target="button"
|
87
|
+
data-popup-id="<%= "repeater-buttons-#{repeater_id}" %>"
|
88
|
+
data-popup-pass-thru="<%= pass_thru %>"
|
89
|
+
data-action="click->repeater#resetButtonIndices click->popup#open"
|
90
|
+
>
|
91
|
+
<%= bootstrap_icon('plus') %>
|
92
|
+
<%= t('.add', name: association_model.model_name.human) %>
|
93
|
+
</div>
|
96
94
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
</li>
|
95
|
+
<!-- Popup -->
|
96
|
+
<%= render 'headmin/popup', id: "repeater-buttons-#{repeater_id}" do %>
|
97
|
+
<div class="d-grid gap-2">
|
98
|
+
<% template_names.each do |name| %>
|
99
|
+
<div
|
100
|
+
class="btn btn-sm h-btn-outline-light"
|
101
|
+
data-popup-target="button"
|
102
|
+
data-popup-id="<%= "repeater-buttons-#{repeater_id}" %>"
|
103
|
+
data-action="click->repeater#addRow click->popup#close"
|
104
|
+
data-row-index=""
|
105
|
+
data-template-name="<%= name %>"
|
106
|
+
>
|
107
|
+
<%= t("blocks.#{name}", default: name).humanize %>
|
108
|
+
</div>
|
109
|
+
<% end %>
|
110
|
+
</div>
|
111
|
+
<% end %>
|
115
112
|
|
116
113
|
<!-- Templates -->
|
117
114
|
<% template_names.each do |name| %>
|
118
115
|
<template data-repeater-target="template" data-template-name="<%= name %>" data-template-id-regex="<%= association_object.object_id %>">
|
119
116
|
<%= form.fields_for attribute, association_object, child_index: association_object.object_id do |ff| %>
|
120
117
|
<%= render 'headmin/forms/repeater/row', form: ff, pass_thru: pass_thru, repeater_id: repeater_id do %>
|
121
|
-
<%
|
122
|
-
<% yield(ff, template&.gsub('/_', '/')) %>
|
118
|
+
<% yield(ff, name) %>
|
123
119
|
<% end %>
|
124
120
|
<% end %>
|
125
121
|
</template>
|
126
122
|
<% end %>
|
127
|
-
|
128
|
-
|
129
|
-
</div>
|
123
|
+
</li>
|
124
|
+
</ul>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/search
|
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
|
+
# * +collection+ - Values to be suggested while typing. Can be an collection array or a remote URL.
|
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
|
+
# * +list+ - Options are passed through options_for_select
|
15
|
+
# * +plaintext+ - Render input as plain text.
|
16
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
17
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
18
|
+
#
|
19
|
+
# ==== Documentation
|
20
|
+
# https://headmin.dev/docs/forms/search
|
21
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/search
|
22
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/search_field
|
23
|
+
#
|
24
|
+
# ==== Examples
|
25
|
+
# Basic version
|
26
|
+
# <%= form_with do |form| %#>
|
27
|
+
# <%= render "headmin/forms/search", form: form, attribute: "basic_example" %#>
|
28
|
+
# <% end %#>
|
29
|
+
|
30
|
+
search = Headmin::Form::SearchView.new(local_assigns)
|
31
|
+
%>
|
32
|
+
|
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
|
+
<%= form.search_field(search.attribute, search.input_options) %>
|
37
|
+
<%= render "headmin/forms/datalist", search.datalist_options if search.datalist? %>
|
38
|
+
<%= render "headmin/forms/autocomplete", search.autocomplete_options if search.autocomplete? %>
|
39
|
+
<% end %>
|
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
|
+
<% end %>
|
@@ -2,67 +2,42 @@
|
|
2
2
|
# headmin/forms/select
|
3
3
|
#
|
4
4
|
# ==== Required parameters
|
5
|
-
# * +form+ - Form object
|
6
5
|
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
7
|
# * +collection+ - Values to create option tags for
|
8
8
|
#
|
9
9
|
# ==== Optional parameters
|
10
|
-
# * +
|
11
|
-
# * +
|
12
|
-
# * +
|
13
|
-
# * +
|
14
|
-
# * +
|
15
|
-
# * +
|
16
|
-
# * +
|
17
|
-
# * +
|
18
|
-
# * +
|
19
|
-
# * +size+ - The number of visible rows in a multiple select field
|
20
|
-
# * +tags+ - Set to true if new options are allowed to be created
|
21
|
-
#
|
22
|
-
# ==== Extra parameters
|
23
|
-
# Listed in 'headmin/forms/base'
|
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
|
+
# * +list+ - Options are passed through options_for_select
|
15
|
+
# * +plaintext+ - Render input as plain text.
|
16
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
17
|
+
# * +tags+ - Allow options to be created dynamically. This will set the multiple attribute to true
|
18
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
24
19
|
#
|
25
20
|
# ==== References
|
21
|
+
# https://headmin.dev/docs/forms/select
|
26
22
|
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
|
27
23
|
# https://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/select
|
28
24
|
#
|
29
25
|
# ==== Examples
|
30
26
|
# Basic version
|
31
|
-
# <%=
|
32
|
-
#
|
33
|
-
#
|
34
|
-
# <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], disabled: true %#>
|
35
|
-
#
|
36
|
-
# Disable specific options
|
37
|
-
# <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], disabled: ['red'] %#>
|
38
|
-
#
|
39
|
-
# Show blank option
|
40
|
-
# <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], include_blank: 'Pick a color' %#>
|
41
|
-
#
|
42
|
-
# Select a default option
|
43
|
-
# <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], selected: 'green' %#>
|
44
|
-
#
|
45
|
-
# Allow multiple options to be selected
|
46
|
-
# <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], multiple: true %#>
|
47
|
-
#
|
48
|
-
# Allow multiple options to be selected and new options to be created
|
49
|
-
# <%= render 'headmin/forms/select', form: form, attribute: :color, collection: ['red', 'green', 'blue'], tags: true %#>
|
50
|
-
|
51
|
-
options_keys = %i(include_blank selected disabled)
|
52
|
-
options = local_assigns.slice(*options_keys).merge(
|
53
|
-
selected: form.object&.send(attribute),
|
54
|
-
)
|
27
|
+
# <%= form_with do |form| %#>
|
28
|
+
# <%= render "headmin/forms/select", form: form, attribute: :color, collection: %w[red green blue] %#>
|
29
|
+
# <% end %#>
|
55
30
|
|
56
|
-
|
57
|
-
html_options = local_assigns.slice(*html_option_keys).merge(
|
58
|
-
aria: { describedby: form_field_validation_id(form, attribute) },
|
59
|
-
class: ['form-select', form_field_validation_class(form, attribute)].join(' '),
|
60
|
-
data: { tags: local_assigns[:tags], controller: 'select'},
|
61
|
-
disabled: local_assigns[:disabled] == true,
|
62
|
-
multiple: local_assigns[:multiple] || local_assigns[:tags],
|
63
|
-
)
|
31
|
+
select = Headmin::Form::SelectView.new(local_assigns)
|
64
32
|
%>
|
65
33
|
|
66
|
-
<%= render
|
67
|
-
<%=
|
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
|
+
<%= form.select(select.attribute, select.collection, select.select_options, select.input_options) %>
|
38
|
+
<% end %>
|
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? %>
|
68
43
|
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/switch
|
3
|
+
#
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +attribute+ - Name of the attribute of the form model
|
6
|
+
# * +form+ - Form object
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +checked_value+ - Value for checked state
|
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
|
+
# * +unchecked_value+ - Value for unchecked state
|
13
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
14
|
+
#
|
15
|
+
# ==== References
|
16
|
+
# https://headmin.dev/docs/forms/switch
|
17
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox
|
18
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/check_box
|
19
|
+
#
|
20
|
+
# ==== Examples
|
21
|
+
# Basic version
|
22
|
+
# <%= form_with do |form| %#>
|
23
|
+
# <%= render "headmin/forms/switch", form: form, attribute: :active %#>
|
24
|
+
# <% end %#>
|
25
|
+
|
26
|
+
switch = Headmin::Form::SwitchView.new(local_assigns)
|
27
|
+
%>
|
28
|
+
|
29
|
+
<%= render "headmin/forms/checkbox", switch.options %>
|
@@ -1,97 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
This view makes use of [headmin/forms/base](https://headmin.test/forms/base) for labels and appendages.
|
40
|
-
Take a look at its documentation to get a complete overview of all additional parameters.
|
41
|
-
|
42
|
-
## Examples
|
43
|
-
|
44
|
-
### Sizing
|
45
|
-
```erbx
|
46
|
-
<%= form_with do |form| %>
|
47
|
-
<%= render "headmin/forms/text", form: form, attribute: "Small", class: "input-group-sm", placeholder: ".input-group-sm" %>
|
48
|
-
<%= render "headmin/forms/text", form: form, attribute: "Medium", class: "input-group-md", placeholder: 'default size' %>
|
49
|
-
<%= render "headmin/forms/text", form: form, attribute: "Large", class: "input-group-lg", placeholder: ".input-group-lg" %>
|
50
|
-
<% end %>
|
51
|
-
```
|
52
|
-
|
53
|
-
### Labels
|
54
|
-
```erbx
|
55
|
-
<%= form_with do |form| %>
|
56
|
-
<%= render "headmin/forms/text", form: form, attribute: "no_label", label: false, placeholder: "Without label" %>
|
57
|
-
<%= render "headmin/forms/text", form: form, attribute: "floating_label", float: true %>
|
58
|
-
<%= render "headmin/forms/text", form: form, attribute: "custom_label", label: "Custom label" %>
|
1
|
+
<%
|
2
|
+
# headmin/forms/text
|
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
|
+
# * +collection+ - Values to be suggested while typing. Can be an collection array or a remote URL.
|
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
|
+
# * +list+ - Options are passed through options_for_select
|
15
|
+
# * +plaintext+ - Render input as plain text.
|
16
|
+
# * +prepend+ - Display as input group with text on the left-hand side
|
17
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
18
|
+
#
|
19
|
+
# ==== References
|
20
|
+
# https://headmin.dev/docs/forms/text
|
21
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
|
22
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/text_field
|
23
|
+
#
|
24
|
+
# ==== Examples
|
25
|
+
# Basic version
|
26
|
+
# <%= form_with do |form| %#>
|
27
|
+
# <%= render "headmin/forms/text", form: form, attribute: :title %#>
|
28
|
+
# <% end %#>
|
29
|
+
|
30
|
+
text = Headmin::Form::TextView.new(local_assigns)
|
31
|
+
%>
|
32
|
+
|
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
|
+
<%= form.text_field(text.attribute, text.input_options) %>
|
37
|
+
<%= render "headmin/forms/datalist", text.datalist_options if text.datalist? %>
|
38
|
+
<%= render "headmin/forms/autocomplete", text.autocomplete_options if text.autocomplete? %>
|
59
39
|
<% end %>
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
<%= form_with do |form| %>
|
65
|
-
<%= render "headmin/forms/text", form: form, attribute: "prepend", prepend: "€" %>
|
66
|
-
<%= render "headmin/forms/text", form: form, attribute: "append", append: "m²" %>
|
67
|
-
<%= render "headmin/forms/text", form: form, attribute: "prepend_and_append", prepend: "€", append: "m²" %>
|
68
|
-
<% end %>
|
69
|
-
```
|
70
|
-
|
71
|
-
### List
|
72
|
-
```erbx
|
73
|
-
<%= form_with do |form| %>
|
74
|
-
<%= render "headmin/forms/text", form: form, attribute: "list", list: %w[red green blue], placeholder: "With data list" %>
|
75
|
-
<% end %>
|
76
|
-
```
|
77
|
-
|
78
|
-
### States
|
79
|
-
```erbx
|
80
|
-
<%= form_with do |form| %>
|
81
|
-
<%= render "headmin/forms/text", form: form, attribute: "disabled", disabled: true, placeholder: "Disabled" %>
|
82
|
-
<%= render "headmin/forms/text", form: form, attribute: "readonly", readonly: true, placeholder: "Readonly" %>
|
83
|
-
<%= render "headmin/forms/text", form: form, attribute: "disabled_and_readonly", disabled: true, readonly: true, placeholder: "Disabled and readonly" %>
|
84
|
-
<% end %>
|
85
|
-
```
|
86
|
-
|
87
|
-
## References
|
88
|
-
- [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text)
|
89
|
-
- [APIdock](https://apidock.com/rails/ActionView/Helpers/FormHelper/text_field)
|
90
|
-
<% end %>
|
91
|
-
-->
|
92
|
-
|
93
|
-
<% text = Headmin::Form::Text.new(local_assigns, request) %>
|
94
|
-
|
95
|
-
<%= render "headmin/forms/base", text.local_assigns do |form| %>
|
96
|
-
<%= form.text_field(text.attribute, text.options) %>
|
97
|
-
<% end %>
|
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
|
+
<% end %>
|