headmin 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +27 -0
- data/.gitignore +14 -0
- data/.nvmrc +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +24 -0
- data/Gemfile +8 -5
- data/Gemfile.lock +197 -25
- data/README.md +9 -1
- data/Rakefile +1 -7
- data/app/assets/images/document.docx +0 -0
- data/app/assets/images/document.pdf +0 -0
- data/app/assets/images/image.jpg +0 -0
- data/app/assets/images/spreadsheet.xls +0 -0
- data/app/assets/images/video.mp4 +0 -0
- data/app/assets/javascripts/headmin/config/i18n.js +9 -9
- data/app/assets/javascripts/headmin/controllers/autocomplete_controller.js +255 -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 +51 -52
- 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 +88 -77
- data/app/assets/javascripts/headmin/controllers/table_controller.js +103 -89
- data/app/assets/javascripts/headmin/index.js +38 -39
- data/app/assets/javascripts/headmin.js +287 -732
- 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 +5 -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/vendor/tom-select-bootstrap.css +1 -2
- data/app/assets/stylesheets/headmin.css +206 -206
- data/app/assets/stylesheets/headmin.scss +1 -1
- data/app/controllers/concerns/headmin/authentication.rb +1 -1
- data/app/controllers/concerns/headmin/searchable.rb +1 -1
- data/app/controllers/concerns/headmin/sortable.rb +7 -7
- data/app/helpers/headmin/admin_helper.rb +1 -2
- data/app/helpers/headmin/bootstrap_helper.rb +2 -24
- data/app/helpers/headmin/filter_helper.rb +1 -1
- data/app/helpers/headmin/form_helper.rb +5 -11
- data/app/helpers/headmin/notification_helper.rb +21 -21
- data/app/helpers/headmin/request_helper.rb +3 -3
- data/app/models/concerns/headmin/block.rb +1 -2
- data/app/models/concerns/headmin/blockable.rb +2 -2
- data/app/models/concerns/headmin/field.rb +2 -1
- data/app/models/concerns/headmin/fieldable.rb +8 -8
- 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_view.rb +66 -0
- 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 +5 -39
- data/app/views/headmin/dropdown/_item.html.erb +1 -1
- 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/_group.html.erb +6 -4
- data/app/views/headmin/forms/repeater/_row.html.erb +4 -4
- data/app/views/headmin/nav/item/_devise.html.erb +1 -1
- data/app/views/headmin/table/_actions.html.erb +1 -1
- data/app/views/headmin/table/actions/_action.html.erb +2 -1
- data/app/views/headmin/table/actions/_delete.html.erb +1 -1
- data/app/views/headmin/views/devise/registrations/_edit.html.erb +2 -2
- data/bin/console +0 -1
- data/config/initializers/customize_input_error.rb +4 -4
- data/config/locales/headmin/forms/en.yml +0 -11
- data/config/locales/headmin/forms/nl.yml +0 -11
- data/esbuild-css.js +18 -18
- data/esbuild-js.js +8 -8
- data/headmin.gemspec +1 -3
- data/lib/generators/headmin/blocks_generator.rb +8 -8
- data/lib/generators/headmin/devise_generator.rb +4 -4
- data/lib/generators/headmin/fields_generator.rb +9 -9
- data/lib/generators/templates/controllers/auth/confirmations_controller.rb +1 -3
- data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +1 -3
- data/lib/generators/templates/controllers/auth/passwords_controller.rb +1 -3
- data/lib/generators/templates/controllers/auth/registrations_controller.rb +1 -3
- data/lib/generators/templates/controllers/auth/sessions_controller.rb +1 -3
- data/lib/generators/templates/controllers/auth/unlocks_controller.rb +1 -3
- data/lib/generators/templates/models/block.rb +1 -1
- data/lib/headmin/engine.rb +6 -6
- data/lib/headmin/version.rb +1 -3
- data/lib/headmin.rb +0 -2
- data/package-lock.json +5359 -0
- data/package.json +13 -7
- data/view_model_benchmark.rb +74 -0
- data/yarn-error.log +367 -0
- data/yarn.lock +1448 -161
- metadata +69 -25
- data/.rubocop.yml +0 -13
- 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 -79
- data/app/models/headmin/form/text.rb +0 -53
- 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/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
@@ -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 %>
|
@@ -2,49 +2,38 @@
|
|
2
2
|
# headmin/forms/textarea
|
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+ - Maximum amount of characters to be used
|
17
|
-
# * +minlength+ - Minimum amount of characters to be used
|
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
|
-
# * +rows+ - Visible text lines
|
22
|
-
# * +spellcheck+ - Indicate whether or not to enable spell checking by the browser
|
23
|
-
# * +value+ - Overrides the value of the form
|
24
|
-
# * +wrap+ - How to wrap text. Soft (default), hard, or off
|
25
|
-
#
|
26
|
-
# ==== Extra parameters
|
27
|
-
# 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
|
28
16
|
#
|
29
17
|
# ==== References
|
18
|
+
# https://headmin.dev/docs/forms/textarea
|
30
19
|
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
|
31
20
|
# https://apidock.com/rails/ActionView/Helpers/FormHelper/text_area
|
32
21
|
#
|
33
22
|
# ==== Examples
|
34
23
|
# Basic version
|
35
|
-
# <%=
|
36
|
-
|
37
|
-
|
24
|
+
# <%= form_with do |form| %#>
|
25
|
+
# <%= render "headmin/forms/textarea", form: form, attribute: :text %#>
|
26
|
+
# <% end %#>
|
38
27
|
|
39
|
-
|
40
|
-
options = local_assigns.slice(*option_keys).merge(
|
41
|
-
aria: { describedby: form_field_validation_id(form, attribute) },
|
42
|
-
class: ['form-control', form_field_validation_class(form, attribute)].join(' '),
|
43
|
-
list: local_assigns[:list] ? "#{attribute}_list" : nil,
|
44
|
-
placeholder: placeholder
|
45
|
-
)
|
28
|
+
textarea = Headmin::Form::TextareaView.new(local_assigns)
|
46
29
|
%>
|
47
30
|
|
48
|
-
<%= render
|
49
|
-
<%=
|
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
|
+
<%= form.text_area(textarea.attribute, textarea.input_options) %>
|
35
|
+
<% end %>
|
36
|
+
<%= render "headmin/forms/validation", textarea.validation_options if textarea.validate? %>
|
37
|
+
<%= render "headmin/forms/hint", textarea.hint_options if textarea.hint? %>
|
38
|
+
<%= render "headmin/forms/label", textarea.label_options if textarea.append_label? %>
|
50
39
|
<% end %>
|
@@ -2,47 +2,42 @@
|
|
2
2
|
# headmin/forms/url
|
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
|
-
# * +
|
17
|
-
# * +
|
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'
|
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
|
27
18
|
#
|
28
19
|
# ==== References
|
29
|
-
# https://
|
20
|
+
# https://headmin.dev/docs/forms/url
|
21
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url
|
30
22
|
# https://apidock.com/rails/ActionView/Helpers/FormHelper/url_field
|
31
23
|
#
|
32
24
|
# ==== Examples
|
33
25
|
# Basic version
|
34
|
-
# <%=
|
35
|
-
|
36
|
-
|
26
|
+
# <%= form_with do |form| %#>
|
27
|
+
# <%= render "headmin/forms/url", form: form, attribute: :website_url %#>
|
28
|
+
# <% end %#>
|
37
29
|
|
38
|
-
|
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
|
-
)
|
30
|
+
url = Headmin::Form::UrlView.new(local_assigns)
|
44
31
|
%>
|
45
32
|
|
46
|
-
<%= render
|
47
|
-
<%=
|
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
|
+
<%= form.url_field(url.attribute, url.input_options) %>
|
37
|
+
<%= render "headmin/forms/datalist", url.datalist_options if url.datalist? %>
|
38
|
+
<%= render "headmin/forms/autocomplete", url.autocomplete_options if url.autocomplete? %>
|
39
|
+
<% end %>
|
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? %>
|
48
43
|
<% end %>
|
@@ -1,21 +1,18 @@
|
|
1
1
|
<%
|
2
2
|
# headmin/forms/validation
|
3
3
|
#
|
4
|
-
# ====
|
5
|
-
# * +
|
6
|
-
# * +
|
4
|
+
# ==== Required parameters
|
5
|
+
# * +id+ - Form object
|
6
|
+
# * +message+ - Name of the attribute of the form model
|
7
|
+
#
|
8
|
+
# ==== Optional parameters
|
9
|
+
# * +valid+ - Show success message when true, failure message when false (default: true)
|
7
10
|
#
|
8
11
|
# ==== Examples
|
9
12
|
# Basic version
|
10
|
-
# <%= render
|
11
|
-
|
12
|
-
show_feedback = form.object && !form_field_valid?(form, attribute)
|
13
|
-
id = form_field_validation_id(form, attribute)
|
14
|
-
message = form.object&.errors[attribute]&.join(', ')
|
13
|
+
# <%= render "headmin/forms/validation", id: id, message: message %#>
|
15
14
|
%>
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
</div>
|
21
|
-
<% end %>
|
16
|
+
<div class="<%= valid ? "valid-feedback" : "invalid-feedback" %>" id="<%= id %>">
|
17
|
+
<%= message %>
|
18
|
+
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/wysiwyg
|
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
|
+
# * +toolbar+ - Show toolbar (default true)
|
12
|
+
# * +wrapper+ - Hash with all options for the surrounding html tag
|
13
|
+
#
|
14
|
+
# ==== References
|
15
|
+
# https://headmin.dev/docs/forms/redactorx
|
16
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
|
17
|
+
# https://apidock.com/rails/ActionView/Helpers/FormHelper/text_area
|
18
|
+
#
|
19
|
+
# ==== Examples
|
20
|
+
# Basic version
|
21
|
+
# <%= form_with do |form| %#>
|
22
|
+
# <%= render "headmin/forms/redactorx", form: form, attribute: :text %#>
|
23
|
+
# <% end %#>
|
24
|
+
|
25
|
+
wysiwyg = Headmin::Form::WysiwygView.new(local_assigns)
|
26
|
+
%>
|
27
|
+
|
28
|
+
<%= render "headmin/forms/redactorx", wysiwyg.options %>
|
@@ -29,10 +29,12 @@
|
|
29
29
|
|
30
30
|
<%= render 'headmin/forms/fields/base', form: form, name: name, field_type: :group do |group, field_label| %>
|
31
31
|
<% if show_label %>
|
32
|
-
<%= render 'headmin/forms/label', form: form, attribute: :value,
|
32
|
+
<%= render 'headmin/forms/label', form: form, attribute: :value, text: label || field_label %>
|
33
33
|
<% end %>
|
34
34
|
|
35
|
-
<
|
36
|
-
|
37
|
-
|
35
|
+
<ul class="list-group mb-3">
|
36
|
+
<li class="list-group-item">
|
37
|
+
<%= yield group %>
|
38
|
+
</li>
|
39
|
+
</ul>
|
38
40
|
<% end %>
|
@@ -28,7 +28,7 @@
|
|
28
28
|
<% end %>
|
29
29
|
|
30
30
|
<!-- Add button-->
|
31
|
-
<
|
31
|
+
<div
|
32
32
|
class="repeater-row-add btn btn-link"
|
33
33
|
title="<%= t('.add') %>"
|
34
34
|
data-repeater-target="addButton"
|
@@ -38,14 +38,14 @@
|
|
38
38
|
data-action="click->repeater#resetButtonIndices click->popup#open"
|
39
39
|
>
|
40
40
|
<%= bootstrap_icon('plus-circle') %>
|
41
|
-
</
|
41
|
+
</div>
|
42
42
|
|
43
43
|
<!-- Remove button-->
|
44
|
-
<
|
44
|
+
<div
|
45
45
|
class="repeater-row-remove btn btn-link"
|
46
46
|
title="<%= t('.remove') %>"
|
47
47
|
data-action="click->repeater#removeRow"
|
48
48
|
>
|
49
49
|
<%= bootstrap_icon('dash-circle') %>
|
50
|
-
</
|
50
|
+
</div>
|
51
51
|
</div>
|
@@ -16,6 +16,6 @@
|
|
16
16
|
<%= render 'headmin/dropdown/list', id: 'nav-item-devise' do %>
|
17
17
|
<%= render 'headmin/dropdown/item', name: t('.edit_profile'), url: polymorphic_path([:edit, singular, :registration]) %>
|
18
18
|
<%= render 'headmin/dropdown/divider' %>
|
19
|
-
<%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), method:
|
19
|
+
<%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), data: { "turbo-method": "delete" } %>
|
20
20
|
<% end %>
|
21
21
|
<% end %>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
<% content_for :table_actions do %>
|
15
15
|
<th class="h-table-actions d-none" data-controller="table-actions" data-table-actions-target="wrapper" data-table-target="actions">
|
16
|
-
<%= form_with url: '', data: {
|
16
|
+
<%= form_with url: '', data: { "table-actions-target": 'form' } do |form| %>
|
17
17
|
<%= form.hidden_field :authenticity_token, value: form_authenticity_token %>
|
18
18
|
<%= form.hidden_field :_method, value: 'POST', 'data-table-actions-target': 'method' %>
|
19
19
|
<%= query_parameter_fields(form) %>
|
@@ -20,8 +20,9 @@
|
|
20
20
|
url = local_assigns.has_key?(:url) ? local_assigns[:url] : request.path
|
21
21
|
method = local_assigns.has_key?(:method) ? local_assigns[:method] : 'GET'
|
22
22
|
confirm = local_assigns.has_key?(:confirm) ? local_assigns[:confirm] : nil
|
23
|
+
turbo = confirm ? true : false
|
23
24
|
%>
|
24
25
|
|
25
|
-
<option value="<%= url %>" data-method="<%= method %>" <% if confirm %>data-confirm="<%= confirm %>"<%end %>>
|
26
|
+
<option value="<%= url %>" data-method="<%= method %>" <% if confirm %>data-turbo-confirm="<%= confirm %>"<% end %> <% unless turbo %>data-turbo="false"<%end %>>
|
26
27
|
<%= name %>
|
27
28
|
</option>
|
@@ -9,4 +9,4 @@
|
|
9
9
|
# <%= render "headmin/table/actions/delete", url: delete_admin_products_path %#>
|
10
10
|
%>
|
11
11
|
|
12
|
-
<%= render
|
12
|
+
<%= render "headmin/table/actions/action", name: t(".button"), url: url, method: "DELETE", confirm: t(".confirm") %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div>
|
2
|
-
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put}) do |f| %>
|
2
|
+
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
3
3
|
<%= render "headmin/views/devise/shared/error_messages", resource: resource %>
|
4
4
|
|
5
5
|
<%= render 'headmin/forms/email', form: f, attribute: :email, required: true, float: true %>
|
@@ -19,6 +19,6 @@
|
|
19
19
|
<h4><%= t('.cancel') %></h4>
|
20
20
|
|
21
21
|
<p><%= t('.unhappy') %></p>
|
22
|
-
<%= button_to t('.cancel'), registration_path(resource_name), class: 'btn btn-lg btn-danger w-100', data
|
22
|
+
<%= button_to t('.cancel'), registration_path(resource_name), class: 'btn btn-lg btn-danger w-100', "data-turbo-confirm": "Are you sure?", "data-turbo-method": "delete" %>
|
23
23
|
</div>
|
24
24
|
</div>
|
data/bin/console
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
ActionView::Base.field_error_proc =
|
1
|
+
ActionView::Base.field_error_proc = proc do |html_tag, instance|
|
2
2
|
class_attr_index = html_tag.index 'class="'
|
3
3
|
|
4
4
|
if class_attr_index
|
5
|
-
html_tag.insert class_attr_index+7,
|
5
|
+
html_tag.insert class_attr_index + 7, "error "
|
6
6
|
else
|
7
|
-
html_tag.insert html_tag.index(
|
7
|
+
html_tag.insert html_tag.index(">"), ' class="error"'
|
8
8
|
end
|
9
|
-
end
|
9
|
+
end
|
@@ -1,17 +1,6 @@
|
|
1
1
|
en:
|
2
2
|
headmin:
|
3
3
|
forms:
|
4
|
-
actions:
|
5
|
-
description: Status & visibility
|
6
|
-
destroy:
|
7
|
-
title: Delete
|
8
|
-
confirm: Are you sure you want to delete this?
|
9
|
-
format: '%m-%d-%Y %H:%M'
|
10
|
-
save:
|
11
|
-
title: Save
|
12
|
-
title: Status
|
13
|
-
view:
|
14
|
-
title: View
|
15
4
|
file:
|
16
5
|
not_found: Not available
|
17
6
|
placeholder:
|
@@ -1,17 +1,6 @@
|
|
1
1
|
nl:
|
2
2
|
headmin:
|
3
3
|
forms:
|
4
|
-
actions:
|
5
|
-
description: Status & zichtbaarheid
|
6
|
-
destroy:
|
7
|
-
title: Verwijderen
|
8
|
-
confirm: Ben je zeker dat je dit wil verwijderen?
|
9
|
-
format: '%d-%m-%Y %H:%M'
|
10
|
-
save:
|
11
|
-
title: Opslaan
|
12
|
-
title: Status
|
13
|
-
view:
|
14
|
-
title: Bekijken
|
15
4
|
file:
|
16
5
|
not_found: Niet beschikbaar
|
17
6
|
placeholder:
|
data/esbuild-css.js
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
const esbuild = require(
|
2
|
-
const sassPlugin = require(
|
1
|
+
const esbuild = require('esbuild')
|
2
|
+
const sassPlugin = require('esbuild-sass-plugin').sassPlugin
|
3
3
|
const watch = process.argv.includes('-w')
|
4
4
|
|
5
5
|
// Used to skip external URLs in scss files
|
6
6
|
const externalUrlPlugin = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
name: 'custom-resolver',
|
8
|
+
setup (build) {
|
9
|
+
build.onResolve({ filter: /^https?:\/\// }, ({ path }) => {
|
10
|
+
return { path, external: true, namespace: 'provided' }
|
11
|
+
})
|
12
|
+
}
|
13
13
|
}
|
14
14
|
|
15
15
|
esbuild.build({
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}).catch((e) => console.error(e.message))
|
16
|
+
entryPoints: ['src/scss/headmin.scss'],
|
17
|
+
outfile: 'app/assets/stylesheets/headmin.css',
|
18
|
+
bundle: true,
|
19
|
+
watch: watch,
|
20
|
+
allowOverwrite: true,
|
21
|
+
plugins: [
|
22
|
+
externalUrlPlugin,
|
23
|
+
sassPlugin()
|
24
|
+
]
|
25
|
+
}).catch((e) => console.error(e.message))
|
data/esbuild-js.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
const esbuild = require(
|
1
|
+
const esbuild = require('esbuild')
|
2
2
|
const watch = process.argv.includes('-w')
|
3
3
|
|
4
4
|
esbuild.build({
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}).catch((e) => console.error(e.message))
|
5
|
+
entryPoints: ['src/js/headmin.js'],
|
6
|
+
outfile: 'app/assets/javascripts/headmin.js',
|
7
|
+
bundle: true,
|
8
|
+
allowOverwrite: true,
|
9
|
+
format: 'esm',
|
10
|
+
watch: watch
|
11
|
+
}).catch((e) => console.error(e.message))
|
data/headmin.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require_relative "lib/headmin/version"
|
4
2
|
|
5
3
|
Gem::Specification.new do |spec|
|
@@ -32,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
32
30
|
spec.add_runtime_dependency "closure_tree", "~> 7.4"
|
33
31
|
spec.add_runtime_dependency "inline_svg", "~> 1.7"
|
34
32
|
spec.add_runtime_dependency "redcarpet", "~> 3.5"
|
35
|
-
spec.add_runtime_dependency "rouge", "~> 3.
|
33
|
+
spec.add_runtime_dependency "rouge", "~> 3.28"
|
36
34
|
|
37
35
|
# For more information and examples about making a new gem, checkout our
|
38
36
|
# guide at: https://bundler.io/guides/creating_gem.html
|