headmin 0.2.7 → 0.3.3
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/.ruby-version +1 -1
- data/CHANGELOG.md +29 -3
- data/Gemfile +1 -1
- data/Gemfile.lock +39 -24
- data/README.md +64 -57
- data/app/assets/config/headmin_manifest.js +2 -0
- data/app/assets/images/document.docx +0 -0
- data/{src/scss/headmin/filters.scss → 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 +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 +9 -39
- data/{src/js → app/assets/javascripts}/headmin/controllers/table_controller.js +51 -16
- data/app/assets/javascripts/headmin/index.js +37 -0
- data/app/assets/javascripts/headmin.js +15271 -0
- data/{src/scss → app/assets/stylesheets}/headmin/filter.scss +0 -0
- data/app/assets/stylesheets/headmin/filters.scss +0 -0
- data/{src/scss → app/assets/stylesheets}/headmin/form.scss +57 -4
- 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 +536 -0
- data/app/assets/stylesheets/headmin.css +13454 -0
- data/app/assets/stylesheets/headmin.scss +65 -0
- 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 +2 -1
- data/app/helpers/headmin/bootstrap_helper.rb +4 -4
- data/app/helpers/headmin/documentation_helper.rb +35 -0
- data/app/helpers/headmin/filter_helper.rb +1 -1
- data/app/helpers/headmin/form_helper.rb +7 -3
- data/app/helpers/headmin/notification_helper.rb +21 -21
- data/app/helpers/headmin/request_helper.rb +5 -10
- data/app/models/concerns/headmin/block.rb +1 -2
- data/app/models/concerns/headmin/blockable.rb +1 -1
- data/app/models/concerns/headmin/field.rb +1 -1
- data/app/models/concerns/headmin/fieldable.rb +8 -8
- data/app/models/headmin/documentation_renderer.rb +32 -0
- data/app/models/headmin/form/base.rb +78 -0
- data/app/models/headmin/form/text.rb +51 -0
- data/app/models/headmin/thumbnail.rb +61 -0
- data/app/services/block_service.rb +53 -53
- 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 +47 -0
- data/app/views/headmin/dropdown/_devise.html.erb +2 -2
- data/app/views/headmin/dropdown/_item.html.erb +1 -1
- 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 +4 -4
- 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 +7 -7
- 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/actions/_destroy.html.erb +3 -3
- 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 +4 -4
- 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/nav/item/_devise.html.erb +1 -1
- 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/app/views/headmin/views/devise/registrations/_edit.html.erb +2 -2
- data/config/importmap.rb +2 -0
- data/config/initializers/customize_input_error.rb +4 -4
- 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/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 -1
- data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/passwords_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/registrations_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/sessions_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/unlocks_controller.rb +1 -1
- data/lib/generators/templates/models/block.rb +1 -1
- data/lib/headmin/engine.rb +18 -3
- data/lib/headmin/version.rb +1 -1
- data/lib/headmin.rb +1 -1
- data/package.json +17 -34
- data/src/js/headmin.js +1 -1
- data/src/scss/headmin.scss +1 -61
- data/yarn.lock +234 -5275
- metadata +198 -36
- data/.nvmrc +0 -1
- data/.rubocop.yml +0 -13
- 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,72 +1,72 @@
|
|
|
1
1
|
class BlockService
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
class << self
|
|
3
|
+
def block_names(path:)
|
|
4
|
+
form_views(path: path).map do |view|
|
|
5
|
+
view_name(view)
|
|
6
|
+
end
|
|
5
7
|
end
|
|
6
|
-
end
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
def form_view(name, path:)
|
|
10
|
+
view_by_name(name, form_view_paths(path))
|
|
11
|
+
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
def frontend_view(name, path:)
|
|
14
|
+
view_by_name(name, frontend_view_paths(path))
|
|
15
|
+
end
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
def frontend_views(path:)
|
|
18
|
+
views(frontend_view_paths(path))
|
|
19
|
+
end
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
def form_views(path:)
|
|
22
|
+
views(form_view_paths(path))
|
|
23
|
+
end
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
def view_name(view)
|
|
26
|
+
filename = File.basename(view.split(".")[0])
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
# Removes leading _ if exists
|
|
29
|
+
filename.sub(/^_/, "")
|
|
30
|
+
end
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
# Looks for a block view by its name.
|
|
33
|
+
#
|
|
34
|
+
# It will first search in a specified path and will fallback to the default path
|
|
35
|
+
# An exception will be raised if the view is nowhere to be found
|
|
36
|
+
def view_by_name(name, paths)
|
|
37
|
+
views = views(paths)
|
|
38
|
+
view = views.find { |view| view.include?("/_#{name}.html.erb") }
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def self.view_by_name(name, paths)
|
|
38
|
-
views = views(paths)
|
|
39
|
-
view = views.find { |view| view.include?("/_#{name}.html.erb") }
|
|
40
|
+
unless view
|
|
41
|
+
prefixes = paths.map { |path| path.split("app/views/").last }
|
|
42
|
+
raise ActionView::MissingTemplate.new(paths, name, prefixes, true, "headmin") unless view
|
|
43
|
+
end
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
prefixes = paths.map { |path| path.split('app/views/').last }
|
|
43
|
-
raise ActionView::MissingTemplate.new(paths, name, prefixes, true, "headmin") unless view
|
|
45
|
+
view
|
|
44
46
|
end
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def self.form_view_paths(path)
|
|
50
|
-
[app_view_path(path), app_view_path('admin/blocks')].uniq
|
|
51
|
-
end
|
|
48
|
+
def form_view_paths(path)
|
|
49
|
+
[app_view_path(path), app_view_path("admin/blocks")].uniq
|
|
50
|
+
end
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
def frontend_view_paths(path)
|
|
53
|
+
[app_view_path(path), app_view_path("website/blocks")].uniq
|
|
54
|
+
end
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
def app_view_path(path)
|
|
57
|
+
base_path = "app/views"
|
|
58
|
+
[base_path, path].join("/")
|
|
59
|
+
end
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
def views(paths)
|
|
62
|
+
paths.map { |path| views_in_path(path) }.flatten
|
|
63
|
+
end
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
def views_in_path(path)
|
|
66
|
+
files = Dir.glob("#{path}/*")
|
|
67
|
+
files.map do |file|
|
|
68
|
+
file.split("app/views/").last
|
|
69
|
+
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
|
-
end
|
|
72
|
+
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
# headmin/blocks
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
6
|
-
# *
|
|
5
|
+
# * +blockable</tt> - Object with blocks association
|
|
6
|
+
# * +path</tt> - Directory where to look for block templates
|
|
7
7
|
#
|
|
8
8
|
# ==== Examples
|
|
9
9
|
# Basic version. This will only look for blocks in 'website/blocks'
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
<% warn "[DEPRECATION] `headmin/card` is deprecated. Please use plain Bootstrap markup." %>
|
|
1
2
|
<%
|
|
3
|
+
# DEPRECATED in 0.3
|
|
2
4
|
# headmin/card
|
|
3
5
|
#
|
|
4
6
|
# ==== Options
|
|
5
|
-
# *
|
|
6
|
-
# *
|
|
7
|
-
# *
|
|
7
|
+
# * +title</tt> - Title for card
|
|
8
|
+
# * +description</tt> - Description for card
|
|
9
|
+
# * +id</tt> - HTML Id Attribute
|
|
10
|
+
# * +padded</tt> - Set to true if you want to render the block content inside the card-body element
|
|
8
11
|
#
|
|
9
12
|
# ==== Examples
|
|
10
13
|
# Basic version.
|
|
@@ -17,12 +20,13 @@
|
|
|
17
20
|
# Your content
|
|
18
21
|
# <% end %#>
|
|
19
22
|
|
|
23
|
+
id = local_assigns.has_key?(:id) ? id : nil
|
|
20
24
|
title = local_assigns.has_key?(:title) ? title : nil
|
|
21
25
|
description = local_assigns.has_key?(:description) ? description : nil
|
|
22
26
|
padded = local_assigns.has_key?(:padded) ? padded : true
|
|
23
27
|
%>
|
|
24
28
|
|
|
25
|
-
<div class="card mb-3 shadow-sm">
|
|
29
|
+
<div class="card mb-3 shadow-sm" id="<%= id %>">
|
|
26
30
|
|
|
27
31
|
<% if padded || title || description %>
|
|
28
32
|
<div class="card-body">
|
|
@@ -36,13 +40,13 @@
|
|
|
36
40
|
|
|
37
41
|
<!-- Render inside body-->
|
|
38
42
|
<% if padded %>
|
|
39
|
-
<%= yield
|
|
43
|
+
<%= yield %>
|
|
40
44
|
<% end %>
|
|
41
45
|
</div>
|
|
42
46
|
<% end %>
|
|
43
47
|
|
|
44
48
|
<!-- Render outside body-->
|
|
45
49
|
<% unless padded %>
|
|
46
|
-
<%= yield
|
|
50
|
+
<%= yield %>
|
|
47
51
|
<% end %>
|
|
48
52
|
</div>
|
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
# headmin/filters
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
5
|
+
# * +url</tt> - Base url to send filter query to. Defaults to current URL
|
|
6
6
|
#
|
|
7
7
|
# ==== Examples
|
|
8
8
|
# Basic version
|
|
9
|
-
# <%= render "headmin/filters" %#>
|
|
9
|
+
# <%= render "headmin/filters" do %#>
|
|
10
|
+
# <%= render "headmin/filters/select", name: 'color', options: ['red', 'green', 'blue'] %#>
|
|
11
|
+
# <% end %#>
|
|
10
12
|
#
|
|
11
13
|
# With custom URL
|
|
12
14
|
# <%= render "headmin/filters", url: admin_polls_path %#>
|
|
13
15
|
|
|
14
16
|
action = local_assigns.has_key?(:url) ? url : request.path
|
|
17
|
+
|
|
18
|
+
# Perform yield in order to capture content blocks
|
|
19
|
+
yield
|
|
15
20
|
%>
|
|
16
21
|
|
|
17
22
|
<form action="<%= action %>" data-controller="filters" data-filters-target="form">
|
|
@@ -21,24 +26,22 @@
|
|
|
21
26
|
<%= hidden_field_tag(name.to_sym, value) %>
|
|
22
27
|
<% end %>
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<div class="d-flex flex-column flex-md-row align-content-start align-items-md-center">
|
|
29
|
+
<div class="d-flex flex-column flex-md-row align-content-start align-items-md-start">
|
|
27
30
|
<div class="d-flex align-items-center">
|
|
28
31
|
|
|
29
32
|
<!-- Search -->
|
|
30
33
|
<div class="h-filters-search d-flex my-1 w-100">
|
|
31
|
-
<%=
|
|
34
|
+
<%= yield :filters_search %>
|
|
32
35
|
|
|
33
36
|
<!-- Separator -->
|
|
34
|
-
<% if content_for(:filters_menu) && content_for(:filters_search) %>
|
|
37
|
+
<% if content_for?(:filters_menu) && content_for?(:filters_search) %>
|
|
35
38
|
<div class="vr mx-2"></div>
|
|
36
39
|
<% end %>
|
|
37
40
|
</div>
|
|
38
41
|
|
|
39
42
|
<!-- Menu -->
|
|
40
43
|
<div class="h-filters-menu d-flex align-items-center w-auto my-1">
|
|
41
|
-
<% if content_for
|
|
44
|
+
<% if content_for?(:filters_menu) %>
|
|
42
45
|
<div class="btn-group">
|
|
43
46
|
<button type="button" class="btn h-btn-outline-light dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
|
44
47
|
<%= bootstrap_icon('funnel') %>
|
|
@@ -60,10 +63,19 @@
|
|
|
60
63
|
|
|
61
64
|
<!-- Filter list -->
|
|
62
65
|
<div class="h-filter-list d-flex ms-md-1 flex-wrap" data-filters-target="list">
|
|
63
|
-
<%=
|
|
66
|
+
<%= yield :filters_buttons %>
|
|
64
67
|
</div>
|
|
65
68
|
</div>
|
|
66
69
|
|
|
67
70
|
<!-- Filter templates -->
|
|
68
|
-
<%=
|
|
71
|
+
<%= yield :filters_templates %>
|
|
69
72
|
</form>
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
<%
|
|
76
|
+
# Clears content blocks to make this view reusable
|
|
77
|
+
content_for(:filters_search, flush: true) { concat(nil) }
|
|
78
|
+
content_for(:filters_menu, flush: true) { concat(nil) }
|
|
79
|
+
content_for(:filters_buttons, flush: true) { concat(nil) }
|
|
80
|
+
content_for(:filters_templates, flush: true) { concat(nil) }
|
|
81
|
+
%>
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
# headmin/form
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
6
|
-
# *
|
|
7
|
-
# *
|
|
8
|
-
# *
|
|
9
|
-
# *
|
|
10
|
-
# *
|
|
11
|
-
# *
|
|
12
|
-
# *
|
|
13
|
-
# *
|
|
14
|
-
# *
|
|
15
|
-
# *
|
|
16
|
-
# *
|
|
17
|
-
# *
|
|
18
|
-
# *
|
|
5
|
+
# * +model+ - A model to infer :url and :scope
|
|
6
|
+
# * +scope+ - The scope to prefix input field names with
|
|
7
|
+
# * +url+ - The URL the form submits to
|
|
8
|
+
# * +format+ - The format of the route the form submits to
|
|
9
|
+
# * +namespace+ - A namespace for your form to ensure uniqueness of id attributes on form elements
|
|
10
|
+
# * +method+ - The method to use when submitting the form
|
|
11
|
+
# * +authenticity_token+ - Authenticity token to use in the form
|
|
12
|
+
# * +local+ - By default form submits are remote and unobtrusive XHRs
|
|
13
|
+
# * +skip_enforcing_utf8+ - If set to true, a hidden input with name utf8 is not output
|
|
14
|
+
# * +builder+ - Override the object used to build the form
|
|
15
|
+
# * +html+ - Other optional HTML attributes for the form tag
|
|
16
|
+
# * +id+ - Optional HTML id attribute
|
|
17
|
+
# * +class+ - Optional HTML class attribute
|
|
18
|
+
# * +data+ - Optional HTML data attributes
|
|
19
19
|
#
|
|
20
20
|
# === Examples
|
|
21
21
|
# Basic version
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<div class="toast-container position-absolute top-0 end-0 p-3">
|
|
10
10
|
<% flash.each do |name, message| %>
|
|
11
|
-
<div class="toast align-items-center text-white show <%= notification_color(name.to_sym)[:background] %>" role="alert" aria-live="assertive" aria-atomic="true">
|
|
11
|
+
<div class="toast align-items-center text-white show <%= notification_color(name.to_sym)[:background] %>" role="alert" aria-live="assertive" aria-atomic="true" data-controller="toast">
|
|
12
12
|
<div class="d-flex">
|
|
13
13
|
<div class="toast-body <%= notification_color(name.to_sym)[:text] %>">
|
|
14
14
|
<%= message %>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# headmin/notifications
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
5
|
+
# * +collection</tt> - Kaminari collection that accepts a method .total_count
|
|
6
6
|
#
|
|
7
7
|
# ==== Examples
|
|
8
8
|
# Basic version
|
|
@@ -10,11 +10,9 @@
|
|
|
10
10
|
%>
|
|
11
11
|
|
|
12
12
|
<div class="d-flex flex-row-reverse flex-md-row align-items-center justify-content-between justify-content-md-end my-1">
|
|
13
|
-
<% content_for :collection_total_count
|
|
14
|
-
<%= collection.total_count %>
|
|
15
|
-
<% end %>
|
|
13
|
+
<% content_for :collection_total_count, collection.total_count.to_s unless content_for?(:collection_total_count) %>
|
|
16
14
|
<div class="ms-2 me-md-2 text-secondary">
|
|
17
|
-
<%= t('.items', count: content_for(:collection_total_count)) %>
|
|
15
|
+
<%= t('.items', count: content_for(:collection_total_count).to_i) %>
|
|
18
16
|
</div>
|
|
19
17
|
<%= paginate collection, views_prefix: 'headmin/pagination' %>
|
|
20
18
|
</div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# headmin/popup
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
5
|
+
# * +id</tt> - Identifier for this popup
|
|
6
6
|
#
|
|
7
7
|
# ==== Examples
|
|
8
8
|
# To trigger this popup create an element with a data attribute like this
|
|
@@ -19,8 +19,14 @@
|
|
|
19
19
|
# <%= render 'headmin/popup', id: 'popupId' do %#>
|
|
20
20
|
# <a href="https://example.com" id="link">
|
|
21
21
|
# <% end %#>
|
|
22
|
+
data = local_assigns.has_key?(:data) ? data : {}
|
|
23
|
+
|
|
24
|
+
options = {
|
|
25
|
+
class: ['h-popup', 'closed'],
|
|
26
|
+
data: data.merge('popup-target': 'popup', 'popup-id': id)
|
|
27
|
+
}
|
|
22
28
|
%>
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
<%= yield
|
|
26
|
-
|
|
30
|
+
<%= content_tag(:div, options) do %>
|
|
31
|
+
<%= yield %>
|
|
32
|
+
<% end %>
|
|
@@ -2,19 +2,25 @@
|
|
|
2
2
|
# headmin/table
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
5
|
+
# * +sort_url</tt> - Url to post object ids to in the order of positions
|
|
6
6
|
#
|
|
7
7
|
# ==== Examples
|
|
8
8
|
# <%= render 'headmin/table', sort_url: positions_admin_categories_path do %#>
|
|
9
9
|
# table content here
|
|
10
10
|
# <% end %#>
|
|
11
|
+
|
|
12
|
+
sort_url = local_assigns.has_key?(:sort_url) ? sort_url : nil
|
|
13
|
+
total_count = content_for(:collection_total_count).to_i || nil
|
|
11
14
|
%>
|
|
12
15
|
|
|
13
|
-
<% sort_url = local_assigns.has_key?(:sort_url) ? sort_url : nil %>
|
|
14
16
|
<div class="h-table card my-2 shadow-sm <%= 'table-drag-sort' if sort_url %>" data-sort-url="<%= sort_url %>">
|
|
15
17
|
<div class="table-responsive">
|
|
16
|
-
<table class="table table-hover m-0"
|
|
17
|
-
|
|
18
|
+
<table class="table table-hover m-0"
|
|
19
|
+
data-controller="table"
|
|
20
|
+
data-table-target="table"
|
|
21
|
+
data-table-url-value="<%= sort_url %>"
|
|
22
|
+
data-table-count-value="<%= total_count %>">
|
|
23
|
+
<%= yield %>
|
|
18
24
|
</table>
|
|
19
25
|
</div>
|
|
20
26
|
</div>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
<% documentation do %>
|
|
3
|
+
# Thumbnail
|
|
4
|
+
Render thumbnails for files. Whenever possible (e.g. images) previews are generated. Icons are used instead for other file types.
|
|
5
|
+
|
|
6
|
+
```erbx
|
|
7
|
+
<%= render 'headmin/thumbnail', src: image_path("image.jpg") %>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Parameters
|
|
11
|
+
| Name | Required | Type | Description |
|
|
12
|
+
| ------------ | -------- | ---------------- | ----------- |
|
|
13
|
+
| src | yes | String | Source of the file. Can be a local or external URL |
|
|
14
|
+
| width | no | Integer | Width of the thumbnail in px |
|
|
15
|
+
| height | no | Integer | Height of the thumbnail in px |
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Sizing
|
|
20
|
+
```erbx
|
|
21
|
+
<%= render 'headmin/thumbnail', src: image_path("image.jpg"), width: 300, height: 100 %>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Types
|
|
25
|
+
```erbx
|
|
26
|
+
<%= render 'headmin/thumbnail', src: asset_path("document.pdf"), width: 100, height: 100 %>
|
|
27
|
+
<%= render 'headmin/thumbnail', src: asset_path("document.docx"), width: 100, height: 100 %>
|
|
28
|
+
<%= render 'headmin/thumbnail', src: asset_path("spreadsheet.xls"), width: 100, height: 100 %>
|
|
29
|
+
<%= render 'headmin/thumbnail', src: asset_path("video.mp4"), width: 100, height: 100 %>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## References
|
|
33
|
+
- [Bootstrap](https://getbootstrap.com/docs/5.1/content/images/#image-thumbnails)
|
|
34
|
+
<% end %>
|
|
35
|
+
-->
|
|
36
|
+
|
|
37
|
+
<% thumbnail = Headmin::Thumbnail.new(local_assigns) %>
|
|
38
|
+
|
|
39
|
+
<div class="<%= thumbnail.class_names %>" style="width: <%= thumbnail.width %>px; height: <%= thumbnail.height %>px;">
|
|
40
|
+
<% if thumbnail.image? %>
|
|
41
|
+
<div class="h-thumbnail-bg" style="background-image: url('<%= thumbnail.src %>');"></div>
|
|
42
|
+
<% else %>
|
|
43
|
+
<div class="h-thumbnail-bg">
|
|
44
|
+
<%= bootstrap_icon(thumbnail.icon_name, class: 'h-thumbnail-icon') %>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
</div>
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
# headmin/dropdown/devise
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
6
|
-
# *
|
|
5
|
+
# * +scope</tt> - (symbol) devise scope, i.e. ':users' => current_user
|
|
6
|
+
# * +class</tt> - Custom class names to put on the dropdown
|
|
7
7
|
#
|
|
8
8
|
# ==== Examples
|
|
9
9
|
# Basic version
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<% name = local_assigns.has_key?(:name) ? name : '' %>
|
|
13
13
|
|
|
14
14
|
<li>
|
|
15
|
-
<a class="dropdown-item" href="<%= url %>" <%= "data-method=#{method}" if method %>>
|
|
15
|
+
<a class="dropdown-item" href="<%= url %>" <%= "data-turbo-method=#{method}" if method %>>
|
|
16
16
|
<%= name %>
|
|
17
17
|
</a>
|
|
18
18
|
</li>
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
# headmin/dropdown/list
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
6
|
-
# *
|
|
5
|
+
# * +id</tt> - unique identifier for the dropdown
|
|
6
|
+
# * +class</tt> - Custom class names to put on the dropdown menu
|
|
7
7
|
#
|
|
8
8
|
# ==== Examples
|
|
9
9
|
# Basic version
|
|
10
|
-
# <%= render "headmin/dropdown/
|
|
11
|
-
#
|
|
12
|
-
# Custom scope
|
|
13
|
-
# <%= render "headmin/dropdown/devise", scope: :admins %#>
|
|
10
|
+
# <%= render "headmin/dropdown/list", id: 'dropdown-1' %#>
|
|
14
11
|
|
|
15
12
|
class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : ''
|
|
16
13
|
id = local_assigns.has_key?(:id) ? id : 'dropdown-1'
|
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
# headmin/filters/date
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
6
|
-
# *
|
|
5
|
+
# * +name</tt> - Name of the filter parameter
|
|
6
|
+
# * +label</tt> - Display name
|
|
7
7
|
#
|
|
8
8
|
# ==== Examples
|
|
9
9
|
# Basic version
|
|
10
10
|
# <%= render "headmin/filters/date", name: :created_at, label: 'Created at' %#>
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
name = local_assigns.has_key?(:name) ? name.to_sym : nil
|
|
13
|
+
label = local_assigns.has_key?(:label) ? label : name.to_s.humanize
|
|
14
14
|
|
|
15
15
|
input_options = {
|
|
16
16
|
placeholder: 'dd/mm/yyyy',
|
|
17
|
-
class: "form-control
|
|
17
|
+
class: "form-control",
|
|
18
18
|
required: true,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
data: {
|
|
20
|
+
'filters-target': 'input',
|
|
21
|
+
'action': 'change->filters#update',
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
%>
|
|
23
25
|
|
|
@@ -28,9 +30,6 @@
|
|
|
28
30
|
<%= content_for :filters_templates do %>
|
|
29
31
|
<%= render 'headmin/filters/filter/template', name: name, label: label do %>
|
|
30
32
|
<div class="input-group">
|
|
31
|
-
<span class="input-group-text">
|
|
32
|
-
<%= bootstrap_icon('calendar') %>
|
|
33
|
-
</span>
|
|
34
33
|
<%= date_field_tag(name, nil, input_options) %>
|
|
35
34
|
</div>
|
|
36
35
|
<% end %>
|
|
@@ -41,9 +40,6 @@
|
|
|
41
40
|
<% value_formatted = Date.parse(params[name]).strftime('%d/%m/%Y') %>
|
|
42
41
|
<%= render 'headmin/filters/filter/button', name: name, label: label, value: value_formatted do %>
|
|
43
42
|
<div class="input-group">
|
|
44
|
-
<span class="input-group-text">
|
|
45
|
-
<%= bootstrap_icon('calendar') %>
|
|
46
|
-
</span>
|
|
47
43
|
<%= date_field_tag(name, params[name], input_options) %>
|
|
48
44
|
</div>
|
|
49
45
|
<% end %>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<%
|
|
2
|
+
# headmin/filters/flatpickr
|
|
3
|
+
#
|
|
4
|
+
# ==== Options
|
|
5
|
+
# * +name</tt> - Name of the filter parameter
|
|
6
|
+
# * +label</tt> - Display name
|
|
7
|
+
#
|
|
8
|
+
# ==== Examples
|
|
9
|
+
# Basic version
|
|
10
|
+
# <%= render "headmin/filters/flatpickr", name: :created_at, label: 'Created at' %#>
|
|
11
|
+
|
|
12
|
+
name = local_assigns.has_key?(:name) ? name.to_sym : nil
|
|
13
|
+
label = local_assigns.has_key?(:label) ? label : name.to_s.humanize
|
|
14
|
+
|
|
15
|
+
input_options = {
|
|
16
|
+
placeholder: 'dd/mm/yyyy',
|
|
17
|
+
class: "form-control",
|
|
18
|
+
required: true,
|
|
19
|
+
data: {
|
|
20
|
+
'filters-target': 'input',
|
|
21
|
+
'flatpickr-target': 'input',
|
|
22
|
+
'action': 'change->filters#update',
|
|
23
|
+
'flatpickr-options': {
|
|
24
|
+
defaultDate: params[name]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
%>
|
|
29
|
+
|
|
30
|
+
<%= content_for :filters_menu do %>
|
|
31
|
+
<%= render 'headmin/filters/filter/menu_item', name: name, label: label %>
|
|
32
|
+
<% end %>
|
|
33
|
+
|
|
34
|
+
<%= content_for :filters_templates do %>
|
|
35
|
+
<%= render 'headmin/filters/filter/template', name: name, label: label do %>
|
|
36
|
+
<div class="input-group" data-controller="flatpickr">
|
|
37
|
+
<span class="input-group-text">
|
|
38
|
+
<%= bootstrap_icon('calendar') %>
|
|
39
|
+
</span>
|
|
40
|
+
<%= date_field_tag(name, nil, input_options) %>
|
|
41
|
+
</div>
|
|
42
|
+
<% end %>
|
|
43
|
+
<% end %>
|
|
44
|
+
|
|
45
|
+
<%= content_for :filters_buttons do %>
|
|
46
|
+
<% if filter_param_exists?(name) %>
|
|
47
|
+
<% value_formatted = Date.parse(params[name]).strftime('%d/%m/%Y') %>
|
|
48
|
+
<%= render 'headmin/filters/filter/button', name: name, label: label, value: value_formatted do %>
|
|
49
|
+
<div class="input-group" data-controller="flatpickr">
|
|
50
|
+
<span class="input-group-text">
|
|
51
|
+
<%= bootstrap_icon('calendar') %>
|
|
52
|
+
</span>
|
|
53
|
+
<%= date_field_tag(name, params[name], input_options) %>
|
|
54
|
+
</div>
|
|
55
|
+
<% end %>
|
|
56
|
+
<% end %>
|
|
57
|
+
<% end %>
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
# headmin/filters/search
|
|
3
3
|
#
|
|
4
4
|
# ==== Options
|
|
5
|
-
# *
|
|
6
|
-
# *
|
|
7
|
-
# *
|
|
5
|
+
# * +name</tt> - Name of the filter parameter
|
|
6
|
+
# * +label</tt> - Name of the resource to be used in the placeholder (search in ...)
|
|
7
|
+
# * +placeholder</tt> - Placeholder in the search field
|
|
8
8
|
#
|
|
9
9
|
# ==== Examples
|
|
10
10
|
# Basic version.
|
|
11
11
|
# <%= render 'headmin/filters/search', name: :search, label: Poll.model_name.human(count: 2) %#>
|
|
12
12
|
|
|
13
13
|
name = local_assigns.has_key?(:name) ? name : :search
|
|
14
|
-
label = local_assigns.has_key?(:label) ? label :
|
|
14
|
+
label = local_assigns.has_key?(:label) ? label : name.to_s.humanize
|
|
15
15
|
placeholder = local_assigns.has_key?(:placeholder) ? placeholder : t('.placeholder', resource: label)
|
|
16
16
|
|
|
17
17
|
value = filter_param_exists?(name) ? params[name] : nil
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
|
|
20
20
|
<% content_for :filters_search do %>
|
|
21
21
|
<input class="form-control" type="search" placeholder="<%= raw placeholder.capitalize %>" aria-label="Search" name="<%= name %>" value="<%= value %>">
|
|
22
|
-
<% end %>
|
|
22
|
+
<% end %>
|