iron_admin 0.7.0 → 0.8.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/CHANGELOG.md +129 -1
- data/README.md +48 -1
- data/UPGRADING.md +495 -8
- data/app/assets/tailwind/iron_admin/engine.css +79 -4
- data/app/components/iron_admin/dashboards/activity_feed_component/item_component.html.haml +6 -9
- data/app/components/iron_admin/dashboards/activity_feed_component.html.haml +6 -5
- data/app/components/iron_admin/dashboards/activity_feed_component.rb +21 -24
- data/app/components/iron_admin/dashboards/chart_component.html.haml +3 -5
- data/app/components/iron_admin/dashboards/chart_component.rb +86 -24
- data/app/components/iron_admin/dashboards/concerns/themed_card.rb +39 -0
- data/app/components/iron_admin/dashboards/metric_card_component.html.haml +8 -7
- data/app/components/iron_admin/dashboards/metric_card_component.rb +2 -0
- data/app/components/iron_admin/dashboards/progress_component.html.haml +11 -7
- data/app/components/iron_admin/dashboards/progress_component.rb +11 -6
- data/app/components/iron_admin/dashboards/quick_links_component/link_component.html.haml +8 -9
- data/app/components/iron_admin/dashboards/quick_links_component.html.haml +6 -5
- data/app/components/iron_admin/dashboards/quick_links_component.rb +4 -12
- data/app/components/iron_admin/dashboards/recent_table_component.html.haml +15 -10
- data/app/components/iron_admin/dashboards/recent_table_component.rb +49 -0
- data/app/components/iron_admin/dashboards/stats_grid_component/stat_component.html.haml +13 -14
- data/app/components/iron_admin/dashboards/stats_grid_component.html.haml +1 -0
- data/app/components/iron_admin/dashboards/stats_grid_component.rb +9 -11
- data/app/components/iron_admin/filters/bar_component.html.haml +8 -6
- data/app/components/iron_admin/filters/bar_component.rb +56 -9
- data/app/components/iron_admin/filters/control_styles.rb +82 -0
- data/app/components/iron_admin/filters/date_range_component.html.haml +9 -4
- data/app/components/iron_admin/filters/date_range_component.rb +10 -6
- data/app/components/iron_admin/filters/search_component.html.haml +4 -4
- data/app/components/iron_admin/filters/search_component.rb +3 -5
- data/app/components/iron_admin/filters/select_filter_component.html.haml +1 -1
- data/app/components/iron_admin/filters/select_filter_component.rb +5 -16
- data/app/components/iron_admin/form/belongs_to_autocomplete_component.html.haml +9 -5
- data/app/components/iron_admin/form/belongs_to_autocomplete_component.rb +10 -8
- data/app/components/iron_admin/form/belongs_to_component.html.haml +2 -2
- data/app/components/iron_admin/form/belongs_to_component.rb +4 -18
- data/app/components/iron_admin/form/checkbox_component.rb +2 -3
- data/app/components/iron_admin/form/concerns/form_input_behavior.rb +1 -1
- data/app/components/iron_admin/form/control_classes.rb +108 -0
- data/app/components/iron_admin/form/date_picker_component.rb +3 -7
- data/app/components/iron_admin/form/field_wrapper_component.html.haml +3 -3
- data/app/components/iron_admin/form/field_wrapper_component.rb +3 -3
- data/app/components/iron_admin/form/nested_form_component.html.haml +4 -5
- data/app/components/iron_admin/form/nested_form_component.rb +12 -2
- data/app/components/iron_admin/form/select_component.html.haml +1 -1
- data/app/components/iron_admin/form/select_component.rb +2 -16
- data/app/components/iron_admin/form/text_input_component.rb +1 -5
- data/app/components/iron_admin/form/textarea_component.rb +1 -5
- data/app/components/iron_admin/layout/flash_component.html.haml +1 -1
- data/app/components/iron_admin/layout/flash_component.rb +4 -3
- data/app/components/iron_admin/layout/navbar_component.html.haml +15 -9
- data/app/components/iron_admin/layout/navbar_component.rb +29 -1
- data/app/components/iron_admin/layout/shell_component.html.haml +4 -4
- data/app/components/iron_admin/layout/shell_component.rb +16 -3
- data/app/components/iron_admin/layout/sidebar_component.html.haml +21 -25
- data/app/components/iron_admin/layout/sidebar_component.rb +76 -1
- data/app/components/iron_admin/layout/theme_switcher_component.html.haml +15 -0
- data/app/components/iron_admin/layout/theme_switcher_component.rb +74 -0
- data/app/components/iron_admin/resources/actions_component.html.haml +15 -8
- data/app/components/iron_admin/resources/actions_component.rb +34 -2
- data/app/components/iron_admin/resources/breadcrumb_component.html.haml +3 -3
- data/app/components/iron_admin/resources/breadcrumb_component.rb +8 -7
- data/app/components/iron_admin/resources/bulk_actions_component.html.haml +9 -8
- data/app/components/iron_admin/resources/bulk_actions_component.rb +47 -4
- data/app/components/iron_admin/resources/data_table_component.html.haml +15 -15
- data/app/components/iron_admin/resources/data_table_component.rb +34 -3
- data/app/components/iron_admin/resources/related_list_component.html.haml +7 -7
- data/app/components/iron_admin/resources/related_list_component.rb +26 -2
- data/app/components/iron_admin/resources/show_field_component.html.haml +3 -3
- data/app/components/iron_admin/resources/show_field_component.rb +10 -4
- data/app/components/iron_admin/resources/styles.rb +136 -0
- data/app/components/iron_admin/ui/alert_component.html.haml +2 -2
- data/app/components/iron_admin/ui/alert_component.rb +27 -31
- data/app/components/iron_admin/ui/badge_component.rb +40 -20
- data/app/components/iron_admin/ui/button_component.rb +37 -11
- data/app/components/iron_admin/ui/card_component.rb +3 -3
- data/app/components/iron_admin/ui/dropdown_component.html.haml +1 -1
- data/app/components/iron_admin/ui/dropdown_component.rb +34 -13
- data/app/components/iron_admin/ui/empty_state_component.html.haml +4 -5
- data/app/components/iron_admin/ui/empty_state_component.rb +2 -2
- data/app/components/iron_admin/ui/modal_component.html.haml +5 -5
- data/app/components/iron_admin/ui/modal_component.rb +6 -4
- data/app/components/iron_admin/ui/pagination_component.html.haml +14 -14
- data/app/components/iron_admin/ui/pagination_component.rb +26 -9
- data/app/components/iron_admin/ui/scopes_component.html.haml +2 -2
- data/app/components/iron_admin/ui/scopes_component.rb +44 -11
- data/app/components/iron_admin/ui/tooltip_component.rb +11 -4
- data/app/controllers/iron_admin/application_controller.rb +58 -4
- data/app/controllers/iron_admin/audit_controller.rb +30 -6
- data/app/controllers/iron_admin/concerns/action_executable.rb +37 -0
- data/app/controllers/iron_admin/concerns/assignable_references.rb +149 -0
- data/app/controllers/iron_admin/concerns/authorizable.rb +11 -0
- data/app/controllers/iron_admin/concerns/blank_password_filterable.rb +21 -0
- data/app/controllers/iron_admin/concerns/event_emittable.rb +47 -7
- data/app/controllers/iron_admin/concerns/filterable.rb +34 -9
- data/app/controllers/iron_admin/concerns/nested_permittable.rb +5 -3
- data/app/controllers/iron_admin/concerns/nested_tenant_check.rb +159 -0
- data/app/controllers/iron_admin/concerns/polymorphic_references.rb +131 -0
- data/app/controllers/iron_admin/concerns/scopeable.rb +54 -7
- data/app/controllers/iron_admin/concerns/searchable.rb +3 -3
- data/app/controllers/iron_admin/concerns/tenant_assignable.rb +118 -0
- data/app/controllers/iron_admin/concerns/tenant_containment.rb +146 -0
- data/app/controllers/iron_admin/exports_controller.rb +2 -2
- data/app/controllers/iron_admin/imports_controller.rb +1 -1
- data/app/controllers/iron_admin/resources_controller.rb +48 -41
- data/app/controllers/iron_admin/search_controller.rb +1 -2
- data/app/controllers/iron_admin/themes_controller.rb +50 -0
- data/app/controllers/iron_admin/tools_controller.rb +58 -5
- data/app/helpers/iron_admin/action_form_helper.rb +19 -0
- data/app/helpers/iron_admin/application_helper.rb +93 -16
- data/app/helpers/iron_admin/assignable_records_helper.rb +32 -0
- data/app/helpers/iron_admin/component_overrides_helper.rb +9 -4
- data/app/helpers/iron_admin/field_display_helper.rb +88 -43
- data/app/helpers/iron_admin/related_records_helper.rb +51 -0
- data/app/helpers/iron_admin/theme_helper.rb +56 -46
- data/app/javascript/iron_admin/controllers/cp_bulk_select_controller.js +12 -0
- data/app/javascript/iron_admin/controllers/cp_chart_controller.js +4 -0
- data/app/javascript/iron_admin/controllers/cp_disclosure_controller.js +19 -0
- data/app/javascript/iron_admin/controllers/cp_search_shortcut_controller.js +39 -0
- data/app/javascript/iron_admin/index.js +4 -0
- data/app/views/iron_admin/audit/index.html.haml +78 -81
- data/app/views/iron_admin/dashboard/index.html.haml +10 -9
- data/app/views/iron_admin/form/_action_field.html.haml +50 -0
- data/app/views/iron_admin/form/_nested_row.html.haml +18 -13
- data/app/views/iron_admin/imports/new.html.haml +14 -13
- data/app/views/iron_admin/imports/preview.html.haml +24 -21
- data/app/views/iron_admin/resources/_form.html.haml +70 -68
- data/app/views/iron_admin/resources/action_form.html.haml +16 -59
- data/app/views/iron_admin/resources/bulk_action_form.html.haml +20 -58
- data/app/views/iron_admin/resources/edit.html.haml +3 -3
- data/app/views/iron_admin/resources/index.html.haml +87 -74
- data/app/views/iron_admin/resources/new.html.haml +2 -2
- data/app/views/iron_admin/resources/show.html.haml +53 -41
- data/app/views/iron_admin/search/index.html.haml +17 -9
- data/app/views/iron_admin/shared/_pagination.html.haml +13 -10
- data/app/views/iron_admin/shared/error.html.haml +16 -12
- data/app/views/iron_admin/tools/action_form.html.haml +9 -55
- data/app/views/iron_admin/tools/show.html.haml +4 -5
- data/app/views/layouts/iron_admin/_document_head.html.haml +24 -0
- data/app/views/layouts/iron_admin/application.html.haml +4 -17
- data/app/views/layouts/iron_admin/minimal.html.haml +7 -0
- data/config/importmap.rb +2 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +1 -0
- data/docs/FAQ.md +87 -37
- data/docs/README.md +8 -2
- data/docs/components/README.md +6 -2
- data/docs/components/dashboard-components.md +24 -35
- data/docs/components/filter-components.md +44 -92
- data/docs/components/form-components.md +16 -32
- data/docs/components/resource-components.md +46 -27
- data/docs/components/ui-components.md +44 -26
- data/docs/getting-started/installation.md +5 -1
- data/docs/getting-started/quick-start.md +36 -23
- data/docs/guides/authentication.md +182 -42
- data/docs/guides/components.md +97 -15
- data/docs/guides/custom-adapters.md +24 -4
- data/docs/guides/dashboard.md +68 -44
- data/docs/guides/export.md +24 -8
- data/docs/guides/extending.md +206 -51
- data/docs/guides/fields.md +229 -70
- data/docs/guides/imports.md +33 -18
- data/docs/guides/resources.md +333 -111
- data/docs/guides/theming.md +930 -58
- data/docs/guides/troubleshooting.md +7 -3
- data/docs/plugin-system-design.md +8 -7
- data/docs/reference/configuration.md +51 -16
- data/docs/reference/routes.md +1 -0
- data/docs/reference/theme-properties.md +101 -38
- data/lib/generators/iron_admin/install/templates/initializer.rb.tt +7 -2
- data/lib/generators/iron_admin/install_audit/templates/create_iron_admin_audit_entries.rb.tt +2 -0
- data/lib/iron_admin/action_field.rb +11 -0
- data/lib/iron_admin/adapters/active_record.rb +95 -0
- data/lib/iron_admin/adapters/base.rb +107 -0
- data/lib/iron_admin/adapters/http/query.rb +21 -0
- data/lib/iron_admin/adapters/http.rb +84 -4
- data/lib/iron_admin/adapters/mongoid.rb +96 -2
- data/lib/iron_admin/audit_log.rb +64 -6
- data/lib/iron_admin/authentication_warning.rb +31 -0
- data/lib/iron_admin/concerns/filter_definable.rb +15 -1
- data/lib/iron_admin/concerns/nestable.rb +25 -0
- data/lib/iron_admin/concerns/scope_countable.rb +56 -0
- data/lib/iron_admin/concerns/soft_deletable.rb +28 -9
- data/lib/iron_admin/configuration/components.rb +14 -3
- data/lib/iron_admin/configuration/theme/neutral_defaults.rb +179 -0
- data/lib/iron_admin/configuration/theme.rb +292 -87
- data/lib/iron_admin/configuration.rb +340 -45
- data/lib/iron_admin/dashboard.rb +22 -38
- data/lib/iron_admin/engine.rb +16 -2
- data/lib/iron_admin/errors.rb +3 -0
- data/lib/iron_admin/field.rb +78 -17
- data/lib/iron_admin/field_inferrer.rb +61 -3
- data/lib/iron_admin/field_override_warning.rb +67 -0
- data/lib/iron_admin/import/import_preview.rb +56 -7
- data/lib/iron_admin/import/importer.rb +91 -14
- data/lib/iron_admin/import/tenant_precheck.rb +67 -0
- data/lib/iron_admin/plugin/registration.rb +64 -0
- data/lib/iron_admin/plugin_registry.rb +3 -2
- data/lib/iron_admin/policy.rb +22 -12
- data/lib/iron_admin/policy_coverage_warning.rb +46 -0
- data/lib/iron_admin/request_context.rb +18 -0
- data/lib/iron_admin/resource.rb +218 -77
- data/lib/iron_admin/resource_registry.rb +86 -13
- data/lib/iron_admin/scope_counts.rb +73 -0
- data/lib/iron_admin/tenant_scope.rb +30 -0
- data/lib/iron_admin/tool.rb +61 -12
- data/lib/iron_admin/tool_context.rb +10 -6
- data/lib/iron_admin/version.rb +1 -1
- data/lib/iron_admin.rb +29 -2
- metadata +37 -7
|
@@ -6,38 +6,43 @@ module IronAdmin
|
|
|
6
6
|
# Provides convenience methods for generating Tailwind class strings
|
|
7
7
|
# based on the current theme configuration.
|
|
8
8
|
module ThemeHelper
|
|
9
|
-
# Returns the current theme
|
|
9
|
+
# Returns the theme of the current request (the default theme outside a request).
|
|
10
10
|
# @return [IronAdmin::Configuration::Theme]
|
|
11
11
|
def t
|
|
12
|
-
IronAdmin.
|
|
12
|
+
IronAdmin.current_theme
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @return [Boolean] Whether the theme's font stylesheet is on Google Fonts, whose
|
|
16
|
+
# hosts the layout preconnects to
|
|
17
|
+
def cp_google_fonts?
|
|
18
|
+
URI.parse(t.font_stylesheet_url.to_s).host == "fonts.googleapis.com"
|
|
19
|
+
rescue URI::InvalidURIError
|
|
20
|
+
false
|
|
13
21
|
end
|
|
14
22
|
|
|
15
23
|
# @return [String] Primary button classes
|
|
16
24
|
def cp_btn_primary
|
|
17
|
-
|
|
18
|
-
"transition duration-150 ease-in-out"
|
|
25
|
+
Form::ControlClasses.button(t, :primary)
|
|
19
26
|
end
|
|
20
27
|
|
|
21
|
-
# @return [String]
|
|
28
|
+
# @return [String] Classes of a form's submit button (the same as {#cp_btn_primary})
|
|
22
29
|
def cp_btn_primary_lg
|
|
23
|
-
|
|
24
|
-
"#{t.btn_primary} transition duration-150 ease-in-out cursor-pointer py-2.5"
|
|
30
|
+
cp_btn_primary
|
|
25
31
|
end
|
|
26
32
|
|
|
27
33
|
# @return [String] Secondary button classes
|
|
28
34
|
def cp_btn_secondary
|
|
29
|
-
|
|
30
|
-
"#{t.btn_secondary} transition duration-150 ease-in-out py-2.5"
|
|
35
|
+
Form::ControlClasses.button(t, :secondary)
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
# @return [String] Danger button classes
|
|
34
39
|
def cp_btn_danger
|
|
35
|
-
|
|
40
|
+
Form::ControlClasses.button(t, :danger)
|
|
36
41
|
end
|
|
37
42
|
|
|
38
43
|
# @return [String] Ghost button classes
|
|
39
44
|
def cp_btn_ghost
|
|
40
|
-
|
|
45
|
+
Form::ControlClasses.button(t, :ghost)
|
|
41
46
|
end
|
|
42
47
|
|
|
43
48
|
# @return [String] Link classes
|
|
@@ -55,48 +60,50 @@ module IronAdmin
|
|
|
55
60
|
t.input_focus
|
|
56
61
|
end
|
|
57
62
|
|
|
63
|
+
# @param error [Boolean] Whether the value failed validation
|
|
64
|
+
# @param padding [String] Horizontal padding, such as "pl-7 pr-3" after a prefix
|
|
58
65
|
# @return [String] Text input classes
|
|
59
|
-
def cp_input_class
|
|
60
|
-
|
|
61
|
-
"#{t.body_text} shadow-sm outline-none placeholder:text-gray-400 transition duration-150 ease-in-out #{t.input_focus}"
|
|
66
|
+
def cp_input_class(error: false, padding: Form::ControlClasses::INPUT_PADDING)
|
|
67
|
+
Form::ControlClasses.input(t, error:, padding:)
|
|
62
68
|
end
|
|
63
69
|
|
|
64
|
-
# @
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
# @param error [Boolean] Whether the value failed validation
|
|
71
|
+
# @return [String] Select input classes, with the engine's chevron
|
|
72
|
+
def cp_select_class(error: false)
|
|
73
|
+
Form::ControlClasses.select(t, error:)
|
|
68
74
|
end
|
|
69
75
|
|
|
76
|
+
# @param error [Boolean] Whether the value failed validation
|
|
70
77
|
# @return [String] Textarea classes
|
|
71
|
-
def cp_textarea_class
|
|
72
|
-
|
|
73
|
-
"#{t.body_text} shadow-sm outline-none placeholder:text-gray-400 transition duration-150 ease-in-out " \
|
|
74
|
-
"#{t.input_focus} resize-y"
|
|
78
|
+
def cp_textarea_class(error: false)
|
|
79
|
+
Form::ControlClasses.textarea(t, error:)
|
|
75
80
|
end
|
|
76
81
|
|
|
77
|
-
# @return [String] Checkbox classes
|
|
82
|
+
# @return [String] Checkbox classes, with the engine's check mark
|
|
78
83
|
def cp_checkbox_class
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
Form::ControlClasses.checkbox(t)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @return [String] Radio button classes, with the engine's dot
|
|
88
|
+
def cp_radio_class
|
|
89
|
+
Form::ControlClasses.radio(t)
|
|
81
90
|
end
|
|
82
91
|
|
|
83
92
|
# @return [String] Filter input classes
|
|
84
93
|
def cp_filter_input_class
|
|
85
|
-
|
|
86
|
-
"#{t.body_text} shadow-sm outline-none transition duration-150 ease-in-out #{t.input_focus}"
|
|
94
|
+
Form::ControlClasses.input(t)
|
|
87
95
|
end
|
|
88
96
|
|
|
89
|
-
# @return [String]
|
|
97
|
+
# @return [String] Classes of a search input with an icon on its left
|
|
90
98
|
def cp_search_class
|
|
91
|
-
|
|
92
|
-
"#{t.body_text} shadow-sm outline-none placeholder:text-gray-400 transition duration-150 ease-in-out #{t.input_focus}"
|
|
99
|
+
Form::ControlClasses.input(t, padding: "pl-9 pr-3")
|
|
93
100
|
end
|
|
94
101
|
|
|
95
|
-
# @return [String] Navbar search input classes
|
|
102
|
+
# @return [String] Navbar search input classes, which the built-in navbar uses too
|
|
96
103
|
def cp_navbar_search_class
|
|
97
|
-
"block w-full appearance-none
|
|
98
|
-
"#{t.
|
|
99
|
-
"#{t.input_focus} #{t.navbar_search_focus_bg}"
|
|
104
|
+
"block w-full h-9 appearance-none pl-9 pr-3 text-sm outline-hidden transition duration-150 ease-in-out " \
|
|
105
|
+
"#{t.control_radius} #{t.border_width} #{t.input_border} #{t.navbar_search_bg} #{t.body_text} " \
|
|
106
|
+
"#{t.placeholder_text} #{t.input_focus} #{t.navbar_search_focus_bg} #{t.control_shadow}"
|
|
100
107
|
end
|
|
101
108
|
|
|
102
109
|
# @return [String] Active scope tab classes
|
|
@@ -111,13 +118,12 @@ module IronAdmin
|
|
|
111
118
|
|
|
112
119
|
# @return [String] Badge count classes
|
|
113
120
|
def cp_badge_count
|
|
114
|
-
"inline-flex
|
|
121
|
+
"inline-flex h-5 min-w-5 items-center justify-center px-1.5 text-xs tabular-nums #{t.badge_shape} #{t.badge_count}"
|
|
115
122
|
end
|
|
116
123
|
|
|
117
|
-
# @return [String] Filter apply button classes
|
|
124
|
+
# @return [String] Filter apply button classes (a primary button)
|
|
118
125
|
def cp_btn_filter_apply
|
|
119
|
-
|
|
120
|
-
"text-sm font-medium transition duration-150 ease-in-out py-1.5"
|
|
126
|
+
cp_btn_primary
|
|
121
127
|
end
|
|
122
128
|
|
|
123
129
|
# @return [String] Sidebar background classes
|
|
@@ -135,19 +141,24 @@ module IronAdmin
|
|
|
135
141
|
"#{t.sidebar_link} #{t.sidebar_link_hover}"
|
|
136
142
|
end
|
|
137
143
|
|
|
144
|
+
# @return [String] Classes of the sidebar link for the current page
|
|
145
|
+
def cp_sidebar_link_active
|
|
146
|
+
t.sidebar_link_active
|
|
147
|
+
end
|
|
148
|
+
|
|
138
149
|
# @return [String] Sidebar group label classes
|
|
139
150
|
def cp_sidebar_group_label
|
|
140
151
|
t.sidebar_group_label
|
|
141
152
|
end
|
|
142
153
|
|
|
143
|
-
# @return [String] Heading classes
|
|
154
|
+
# @return [String] Heading classes: the heading weight and the heading font, or the body font without one
|
|
144
155
|
def cp_heading
|
|
145
|
-
"#{t.heading_weight} #{t.font_family}".strip
|
|
156
|
+
"#{t.heading_weight} #{t.heading_font.presence || t.font_family}".strip
|
|
146
157
|
end
|
|
147
158
|
|
|
148
|
-
# @return [String] Card classes
|
|
159
|
+
# @return [String] Card classes: background, border, radius and shadow
|
|
149
160
|
def cp_card
|
|
150
|
-
"#{t.card_bg} #{t.border_radius} #{t.card_shadow}"
|
|
161
|
+
"#{t.card_bg} #{t.border_width} #{t.card_border} #{t.border_radius} #{t.card_shadow}"
|
|
151
162
|
end
|
|
152
163
|
|
|
153
164
|
# @return [String] Body text classes
|
|
@@ -180,11 +191,10 @@ module IronAdmin
|
|
|
180
191
|
t.table_border
|
|
181
192
|
end
|
|
182
193
|
|
|
194
|
+
# @param error [Boolean] Whether the upload failed validation
|
|
183
195
|
# @return [String] File input classes
|
|
184
|
-
def cp_file_input_class
|
|
185
|
-
|
|
186
|
-
"file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 hover:file:bg-gray-200 " \
|
|
187
|
-
"file:cursor-pointer cursor-pointer"
|
|
196
|
+
def cp_file_input_class(error: false)
|
|
197
|
+
Form::ControlClasses.file_input(t, error:)
|
|
188
198
|
end
|
|
189
199
|
end
|
|
190
200
|
end
|
|
@@ -21,4 +21,16 @@ export default class extends Controller {
|
|
|
21
21
|
this.barTarget.style.display = checked > 0 ? "flex" : "none"
|
|
22
22
|
this.countTarget.textContent = checked
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
// A bulk action with form fields submits the selection with a GET (formmethod="get"), whose
|
|
26
|
+
// URL would carry the form's CSRF token. The token is disabled while the browser, or Turbo,
|
|
27
|
+
// reads the form, and enabled again for the next POST.
|
|
28
|
+
omitTokenFromGet(event) {
|
|
29
|
+
if (event.submitter?.getAttribute("formmethod")?.toLowerCase() !== "get") return
|
|
30
|
+
|
|
31
|
+
const param = document.querySelector("meta[name='csrf-param']")?.content || "authenticity_token"
|
|
32
|
+
const tokens = [...this.element.elements].filter((input) => input.name === param && !input.disabled)
|
|
33
|
+
tokens.forEach((input) => { input.disabled = true })
|
|
34
|
+
setTimeout(() => tokens.forEach((input) => { input.disabled = false }))
|
|
35
|
+
}
|
|
24
36
|
}
|
|
@@ -25,6 +25,10 @@ export default class extends Controller {
|
|
|
25
25
|
|
|
26
26
|
initChart() {
|
|
27
27
|
if (!this.hasCanvasTarget) return
|
|
28
|
+
// A canvas does not inherit CSS fonts: draw the chart in the theme font of its card,
|
|
29
|
+
// and redraw it once a web font such as Inter has loaded.
|
|
30
|
+
Chart.defaults.font.family = getComputedStyle(this.element).fontFamily
|
|
28
31
|
this.chart = new Chart(this.canvasTarget, this.configValue)
|
|
32
|
+
document.fonts?.ready.then(() => this.chart?.update("none"))
|
|
29
33
|
}
|
|
30
34
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Closes a <details> disclosure on Escape (focus returns to its summary) and on
|
|
4
|
+
// a click outside it. Opening, Tab and Enter/Space are the browser's own.
|
|
5
|
+
export default class extends Controller {
|
|
6
|
+
static targets = ["summary"]
|
|
7
|
+
|
|
8
|
+
closeOnEscape(event) {
|
|
9
|
+
if (event.key !== "Escape" || !this.element.open) return
|
|
10
|
+
|
|
11
|
+
event.preventDefault()
|
|
12
|
+
this.element.open = false
|
|
13
|
+
if (this.hasSummaryTarget) this.summaryTarget.focus()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
closeOnOutsideClick(event) {
|
|
17
|
+
if (this.element.open && !this.element.contains(event.target)) this.element.open = false
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Focuses and selects the navbar search box on ⌘K (Apple) or Ctrl+K, wherever the
|
|
4
|
+
// focus is, unless the focused field already handled it (Trix opens its link
|
|
5
|
+
// dialog), a modal is open or the box is inert (behind the sidebar drawer).
|
|
6
|
+
export default class extends Controller {
|
|
7
|
+
static targets = ["input", "hint"]
|
|
8
|
+
|
|
9
|
+
// Names the platform's shortcut in the hint, which stays hidden without JavaScript.
|
|
10
|
+
connect() {
|
|
11
|
+
const platform = navigator.userAgentData?.platform || navigator.platform || ""
|
|
12
|
+
this.apple = /mac|iphone|ipad|ipod/i.test(platform)
|
|
13
|
+
if (this.hasInputTarget) this.inputTarget.setAttribute("aria-keyshortcuts", this.apple ? "Meta+K" : "Control+K")
|
|
14
|
+
if (this.hasHintTarget) {
|
|
15
|
+
this.hintTarget.textContent = this.apple ? "⌘K" : "Ctrl K"
|
|
16
|
+
this.hintTarget.hidden = false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
focus(event) {
|
|
21
|
+
if (event.defaultPrevented || !this.isShortcut(event) || !this.hasInputTarget || this.isBlocked) return
|
|
22
|
+
|
|
23
|
+
event.preventDefault()
|
|
24
|
+
this.inputTarget.focus()
|
|
25
|
+
this.inputTarget.select()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
isShortcut(event) {
|
|
29
|
+
const modifier = this.apple ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey
|
|
30
|
+
return modifier && !event.altKey && !event.shiftKey && event.key?.toLowerCase() === "k"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get isBlocked() {
|
|
34
|
+
if (this.inputTarget.closest("[inert]")) return true
|
|
35
|
+
|
|
36
|
+
return Array.from(document.querySelectorAll("[aria-modal='true'], dialog:modal"))
|
|
37
|
+
.some((dialog) => (dialog.checkVisibility ? dialog.checkVisibility() : true))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -2,8 +2,10 @@ import CpAlertController from "iron_admin/controllers/cp_alert_controller"
|
|
|
2
2
|
import CpBulkSelectController from "iron_admin/controllers/cp_bulk_select_controller"
|
|
3
3
|
import CpChartController from "iron_admin/controllers/cp_chart_controller"
|
|
4
4
|
import CpColorFieldController from "iron_admin/controllers/cp_color_field_controller"
|
|
5
|
+
import CpDisclosureController from "iron_admin/controllers/cp_disclosure_controller"
|
|
5
6
|
import CpModalController from "iron_admin/controllers/cp_modal_controller"
|
|
6
7
|
import CpNestedFormController from "iron_admin/controllers/cp_nested_form_controller"
|
|
8
|
+
import CpSearchShortcutController from "iron_admin/controllers/cp_search_shortcut_controller"
|
|
7
9
|
import CpSidebarController from "iron_admin/controllers/cp_sidebar_controller"
|
|
8
10
|
import FilterOperatorController from "iron_admin/controllers/filter_operator_controller"
|
|
9
11
|
|
|
@@ -12,7 +14,9 @@ application.register("cp-alert", CpAlertController)
|
|
|
12
14
|
application.register("cp-bulk-select", CpBulkSelectController)
|
|
13
15
|
application.register("cp-chart", CpChartController)
|
|
14
16
|
application.register("cp-color-field", CpColorFieldController)
|
|
17
|
+
application.register("cp-disclosure", CpDisclosureController)
|
|
15
18
|
application.register("cp-modal", CpModalController)
|
|
16
19
|
application.register("cp-nested-form", CpNestedFormController)
|
|
20
|
+
application.register("cp-search-shortcut", CpSearchShortcutController)
|
|
17
21
|
application.register("cp-sidebar", CpSidebarController)
|
|
18
22
|
application.register("filter-operator", FilterOperatorController)
|
|
@@ -1,103 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
- styles = IronAdmin::Resources::Styles
|
|
2
|
+
- controls = IronAdmin::Filters::ControlStyles
|
|
3
|
+
- action_colors = { create: :green, update: :blue, destroy: :red }
|
|
4
|
+
|
|
5
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
2
6
|
.flex.items-center.justify-between.mb-6
|
|
3
|
-
%h1
|
|
7
|
+
%h1{ class: styles.page_title(t) } Audit Log
|
|
4
8
|
|
|
5
9
|
- unless IronAdmin.configuration.audit_enabled
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.ml-
|
|
11
|
-
%p.text-sm.text-yellow-700
|
|
12
|
-
Audit logging is currently disabled. Enable it in your IronAdmin configuration:
|
|
13
|
-
%code.ml-1.px-1.bg-yellow-100.rounded{ class: "py-0.5" } config.audit_enabled = true
|
|
10
|
+
.flex.gap-3.p-4.mb-6{ class: "#{t.border_width} #{t.border_radius} #{t.alert_shadow} #{t.alert_palette[:warning]}" }
|
|
11
|
+
= heroicon "exclamation-triangle", variant: :mini, options: { class: "h-5 w-5 shrink-0" }
|
|
12
|
+
%p.text-sm
|
|
13
|
+
Audit logging is currently disabled. Enable it in your IronAdmin configuration:
|
|
14
|
+
%code.ml-1.px-1{ class: "py-0.5 bg-current/10 #{t.control_radius} #{t.code_font}" } config.audit_enabled = true
|
|
14
15
|
|
|
15
16
|
- if @entries.any? || @filters_applied
|
|
16
|
-
-# One height for every control, so the labels above them and the buttons line up.
|
|
17
|
-
- filter_control_height = "h-10.5"
|
|
18
17
|
.mb-4
|
|
19
18
|
= form_tag audit_path, method: :get, class: "flex flex-col gap-4 sm:flex-row sm:items-end" do
|
|
20
19
|
.flex-1
|
|
21
|
-
%label.
|
|
22
|
-
%select#resource{ name: "resource", class:
|
|
20
|
+
%label.mb-1{ for: "resource", class: controls.label(t) } Resource
|
|
21
|
+
%select#resource{ name: "resource", class: controls.select(t) }
|
|
23
22
|
%option{ value: "" } All Resources
|
|
24
23
|
- @resource_options.each do |value, label|
|
|
25
24
|
%option{ value: value, selected: params[:resource] == value }= label
|
|
26
25
|
.flex-1
|
|
27
|
-
%label.
|
|
28
|
-
%select#action_filter{ name: "action_filter", class:
|
|
26
|
+
%label.mb-1{ for: "action_filter", class: controls.label(t) } Action
|
|
27
|
+
%select#action_filter{ name: "action_filter", class: controls.select(t) }
|
|
29
28
|
%option{ value: "" } All Actions
|
|
30
29
|
- @action_options.each do |action|
|
|
31
30
|
%option{ value: action, selected: params[:action_filter] == action }= action.humanize
|
|
32
31
|
.flex-1
|
|
33
|
-
%label.
|
|
34
|
-
= date_field_tag :from, params[:from], class:
|
|
32
|
+
%label.mb-1{ for: "from", class: controls.label(t) } From
|
|
33
|
+
= date_field_tag :from, params[:from], class: controls.input(t)
|
|
35
34
|
.flex-1
|
|
36
|
-
%label.
|
|
37
|
-
= date_field_tag :to, params[:to], class:
|
|
35
|
+
%label.mb-1{ for: "to", class: controls.label(t) } To
|
|
36
|
+
= date_field_tag :to, params[:to], class: controls.input(t)
|
|
38
37
|
.flex.gap-2
|
|
39
|
-
%button{ type: "submit", class:
|
|
40
|
-
= link_to "Clear", audit_path, class:
|
|
38
|
+
%button{ type: "submit", class: controls.apply_button(t) } Filter
|
|
39
|
+
= link_to "Clear", audit_path, class: styles.secondary_button(t)
|
|
41
40
|
|
|
42
41
|
- if @entries.any?
|
|
43
|
-
.
|
|
44
|
-
%
|
|
45
|
-
%
|
|
46
|
-
%
|
|
47
|
-
%
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
%
|
|
72
|
-
= entry.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
- else
|
|
97
|
-
%span{ class: cp_muted_text } -
|
|
42
|
+
%div{ class: styles.table_panel(t) }
|
|
43
|
+
%div{ class: styles::SCROLL_FRAME }
|
|
44
|
+
%table{ class: styles.table(t) }
|
|
45
|
+
%thead{ class: t.table_header_bg }
|
|
46
|
+
%tr
|
|
47
|
+
- ["Timestamp", "User", "Action", "Resource", "Record ID", "IP Address", "Changes"].each do |heading|
|
|
48
|
+
%th{ scope: "col", class: styles.header_cell(t) }= heading
|
|
49
|
+
%tbody{ class: styles.divided(t) }
|
|
50
|
+
- @entries.each do |entry|
|
|
51
|
+
%tr{ class: t.table_row_hover }
|
|
52
|
+
%td{ class: styles.cell(t) }
|
|
53
|
+
-# Dated like the other pages' datetime fields; the exact time is in the attributes.
|
|
54
|
+
%time{ datetime: entry.timestamp.utc.iso8601, title: entry.timestamp.utc.to_s }
|
|
55
|
+
= entry.timestamp.strftime(IronAdmin::FieldDisplayHelper::DATETIME_FORMAT).squish
|
|
56
|
+
%td{ class: styles.cell(t) }
|
|
57
|
+
- user_label = @user_labels[IronAdmin::AuditLog.user_identifier(entry.user)]
|
|
58
|
+
- if user_label
|
|
59
|
+
= user_label
|
|
60
|
+
- elsif entry.user.respond_to?(:email)
|
|
61
|
+
= entry.user.email
|
|
62
|
+
- elsif entry.user.respond_to?(:name)
|
|
63
|
+
= entry.user.name
|
|
64
|
+
- elsif entry.user.present?
|
|
65
|
+
= entry.user.to_s
|
|
66
|
+
- else
|
|
67
|
+
%span{ class: t.muted_text } Unknown
|
|
68
|
+
%td{ class: styles.cell(t) }
|
|
69
|
+
= render IronAdmin::Ui::BadgeComponent.new(text: entry.action.to_s.humanize, color: action_colors.fetch(entry.action.to_sym, :gray))
|
|
70
|
+
%td{ class: styles.cell(t) }
|
|
71
|
+
= @resource_labels.fetch(entry.resource.to_s, entry.resource)
|
|
72
|
+
%td{ class: "#{styles.cell(t)} tabular-nums" }
|
|
73
|
+
= entry.record_id
|
|
74
|
+
%td{ class: "#{styles.muted_cell(t)} tabular-nums" }
|
|
75
|
+
= entry.ip_address || "-"
|
|
76
|
+
%td{ class: "text-sm #{t.table_cell_padding} #{t.body_text}" }
|
|
77
|
+
- if entry.record_changes.present? && entry.record_changes.any?
|
|
78
|
+
%details
|
|
79
|
+
%summary.cursor-pointer.whitespace-nowrap{ class: "#{t.link} #{t.focus_ring}" }
|
|
80
|
+
= pluralize(entry.record_changes.keys.count, "field")
|
|
81
|
+
changed
|
|
82
|
+
.mt-2.p-2.max-w-md.overflow-auto.text-xs{ class: "#{t.control_radius} #{t.surface_muted} #{t.code_font}" }
|
|
83
|
+
- entry.record_changes.each do |field, values|
|
|
84
|
+
.mb-1
|
|
85
|
+
%strong= field
|
|
86
|
+
\:
|
|
87
|
+
- if values.is_a?(Array) && values.length == 2
|
|
88
|
+
%span.line-through{ class: t.error_text }= values[0].to_s.truncate(30)
|
|
89
|
+
= heroicon "arrow-right", variant: :mini, options: { class: "h-3 w-3 inline mx-1 #{t.icon_muted}" }
|
|
90
|
+
%span{ class: t.success_text }= values[1].to_s.truncate(30)
|
|
91
|
+
- else
|
|
92
|
+
= values.to_s.truncate(50)
|
|
93
|
+
- else
|
|
94
|
+
%span{ class: t.muted_text } -
|
|
98
95
|
|
|
99
96
|
- else
|
|
100
|
-
.text-center.py-12
|
|
101
|
-
= heroicon "clipboard-document-list", variant: :outline, options: { class: "h-
|
|
102
|
-
%p.text-
|
|
103
|
-
%p.text-sm.
|
|
97
|
+
.text-center.py-12
|
|
98
|
+
= heroicon "clipboard-document-list", variant: :outline, options: { class: "h-10 w-10 mx-auto mb-4 #{t.icon_muted}" }
|
|
99
|
+
%p.text-sm.font-medium{ class: t.body_text } No audit log entries found.
|
|
100
|
+
%p.mt-1.text-sm{ class: t.muted_text } Activity will appear here once users perform actions.
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
.
|
|
2
|
-
%h1.
|
|
1
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
2
|
+
%h1.mb-6{ class: "#{t.page_title} #{t.heading_font}" }= IronAdmin.configuration.title
|
|
3
3
|
|
|
4
4
|
- if @dashboard
|
|
5
5
|
- if @dashboard.defined_metrics.any?
|
|
6
|
-
.grid.grid-cols-1.md:grid-cols-2.xl:grid-cols-4.gap-
|
|
6
|
+
.grid.grid-cols-1.md:grid-cols-2.xl:grid-cols-4.gap-4.mb-6
|
|
7
7
|
- @dashboard.defined_metrics.each do |metric|
|
|
8
8
|
= render IronAdmin::Dashboards::MetricCardComponent.new(name: metric[:name], value: metric[:block].call, format: metric[:format], icon: metric[:icon], live: metric[:live])
|
|
9
9
|
|
|
10
10
|
- if @dashboard.defined_charts.any?
|
|
11
11
|
= javascript_include_tag "chart.min", defer: true, onload: "document.dispatchEvent(new CustomEvent('chartjs:loaded'))"
|
|
12
|
-
.
|
|
12
|
+
-# A last chart left alone in its row (an odd count) spans both columns.
|
|
13
|
+
.grid.grid-cols-1.lg:grid-cols-2.gap-4.mb-6{ class: "lg:[&>*:last-child:nth-child(odd)]:col-span-2" }
|
|
13
14
|
- @dashboard.defined_charts.each do |chart|
|
|
14
15
|
- chart_data = chart[:block].call
|
|
15
16
|
- labels = chart_data.keys
|
|
@@ -22,22 +23,22 @@
|
|
|
22
23
|
= render IronAdmin::Dashboards::ChartComponent.new(title: chart_title, type: chart[:type], data: data, labels: labels, colors: chart[:colors])
|
|
23
24
|
|
|
24
25
|
- if @dashboard.defined_progress_bars.any?
|
|
25
|
-
.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-3.gap-
|
|
26
|
+
.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-3.gap-4.mb-6
|
|
26
27
|
- @dashboard.defined_progress_bars.each do |bar|
|
|
27
28
|
- bar_title = bar[:label] || bar[:name].to_s.humanize
|
|
28
29
|
= render IronAdmin::Dashboards::ProgressComponent.new(title: bar_title, value: bar[:block].call, max: bar[:max], format: bar[:format], color: bar[:color])
|
|
29
30
|
|
|
30
31
|
- if @dashboard.defined_recents.any?
|
|
31
|
-
.space-y-
|
|
32
|
+
.space-y-4
|
|
32
33
|
- @dashboard.defined_recents.each do |recent|
|
|
33
34
|
- resource_class = IronAdmin::ResourceRegistry.find(recent[:resource_name].to_s.pluralize)
|
|
34
35
|
-# Like the index page: the read policy decides, and tenant_scope applies after the recent scope.
|
|
35
36
|
- if resource_class&.crud_allowed?(:read, iron_admin_current_user)
|
|
36
37
|
- scope = recent[:scope] ? resource_class.model.instance_exec(&recent[:scope]) : resource_class.model.all
|
|
37
|
-
- scope = IronAdmin.
|
|
38
|
+
- scope = IronAdmin::TenantScope.apply(scope)
|
|
38
39
|
- records = scope.limit(recent[:limit])
|
|
39
40
|
= render IronAdmin::Dashboards::RecentTableComponent.new(resource_name: recent[:resource_name], records: records, current_user: iron_admin_current_user)
|
|
40
41
|
|
|
41
42
|
- else
|
|
42
|
-
.p-12.text-center{ class:
|
|
43
|
-
%p{ class:
|
|
43
|
+
.p-12.text-center{ class: "#{t.card_bg} #{t.border_width} #{t.card_border} #{t.border_radius} #{t.card_shadow}" }
|
|
44
|
+
%p.text-sm{ class: t.muted_text } No dashboard configured. Create an AdminDashboard in app/iron_admin/.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
-# One field of an action form (resource, bulk and tool actions); scope is the params key.
|
|
2
|
+
-# value is the submitted value (the field's default when the form first shows), and errors
|
|
3
|
+
-# are the messages shown under the field, as resource forms show theirs.
|
|
4
|
+
- input_id = "#{scope}_#{field.name}"
|
|
5
|
+
- input_name = "#{scope}[#{field.name}]"
|
|
6
|
+
- value = local_assigns.fetch(:value, field.default)
|
|
7
|
+
- errors = Array(local_assigns[:errors])
|
|
8
|
+
- has_error = errors.any?
|
|
9
|
+
- error_id = "#{input_id}_error"
|
|
10
|
+
- invalid = has_error ? { invalid: true, describedby: error_id } : {}
|
|
11
|
+
%div{ class: "space-y-1.5" }
|
|
12
|
+
-# A checkbox is labelled by the text beside it, so its label is not written above it too.
|
|
13
|
+
- unless field.type == :boolean
|
|
14
|
+
%label.block.text-sm.font-medium{ class: "#{cp_label_text} #{t.field_label_transform}", for: input_id }
|
|
15
|
+
= field.label
|
|
16
|
+
- if field.required
|
|
17
|
+
%span{ class: t.error_text } *
|
|
18
|
+
|
|
19
|
+
- case field.type
|
|
20
|
+
- when :text
|
|
21
|
+
= text_field_tag input_name, value, id: input_id, class: cp_input_class(error: has_error),
|
|
22
|
+
placeholder: field.placeholder, required: field.required, aria: invalid
|
|
23
|
+
- when :textarea
|
|
24
|
+
= text_area_tag input_name, value, id: input_id, rows: 4, class: cp_textarea_class(error: has_error),
|
|
25
|
+
placeholder: field.placeholder, required: field.required, aria: invalid
|
|
26
|
+
- when :number
|
|
27
|
+
= number_field_tag input_name, value, id: input_id, class: cp_input_class(error: has_error),
|
|
28
|
+
placeholder: field.placeholder, step: "any", required: field.required, aria: invalid
|
|
29
|
+
- when :boolean
|
|
30
|
+
.flex.items-center.gap-2
|
|
31
|
+
= check_box_tag input_name, "1", ActiveModel::Type::Boolean.new.cast(value), id: input_id, class: cp_checkbox_class,
|
|
32
|
+
required: field.required, aria: invalid
|
|
33
|
+
%label.text-sm{ class: cp_body_text, for: input_id }
|
|
34
|
+
= field.label
|
|
35
|
+
- if field.required
|
|
36
|
+
%span{ class: t.error_text } *
|
|
37
|
+
- when :date
|
|
38
|
+
= date_field_tag input_name, value, id: input_id, class: cp_input_class(error: has_error), required: field.required, aria: invalid
|
|
39
|
+
- when :datetime
|
|
40
|
+
= datetime_field_tag input_name, value, id: input_id, class: cp_input_class(error: has_error), required: field.required, aria: invalid
|
|
41
|
+
- when :select
|
|
42
|
+
%select{ name: input_name, id: input_id, class: cp_select_class(error: has_error), required: field.required, aria: invalid }
|
|
43
|
+
%option{ value: "" }= field.placeholder || "Select..."
|
|
44
|
+
- (field.options || []).each do |opt|
|
|
45
|
+
%option{ value: opt, selected: value.to_s == opt.to_s }= opt.to_s.humanize
|
|
46
|
+
|
|
47
|
+
- if has_error
|
|
48
|
+
.flex.items-center{ class: "gap-1.5" }
|
|
49
|
+
= heroicon "exclamation-circle", variant: :mini, options: { class: "h-4 w-4 shrink-0 #{t.error_text}" }
|
|
50
|
+
%p.text-sm{ id: error_id, class: t.error_text }= errors.join(", ")
|