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
|
@@ -1,62 +1,24 @@
|
|
|
1
1
|
= turbo_frame_tag "action-form-modal" do
|
|
2
|
-
.
|
|
3
|
-
%h1.
|
|
2
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-lg.mx-auto
|
|
3
|
+
%h1.mb-6{ class: "#{t.page_title} #{t.heading_font}" }= @action[:name].to_s.humanize
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
.p-6{ class: cp_card }
|
|
6
|
+
= form_tag @form_url, method: :post, class: "space-y-5", data: { turbo_frame: "_top" } do
|
|
7
|
+
%p.text-sm{ class: cp_muted_text }= I18n.t("iron_admin.resources.bulk_action_form.selected", count: @bulk_ids.size)
|
|
8
|
+
-# The selection and the index state it was made on go to the action, which returns to that index.
|
|
9
|
+
- @bulk_ids.each do |id|
|
|
10
|
+
= hidden_field_tag "ids[]", id, id: nil
|
|
11
|
+
- iron_admin_hidden_params(iron_admin_index_state).each do |name, value|
|
|
12
|
+
= hidden_field_tag name, value, id: nil
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
id: "action_form_#{field.name}",
|
|
17
|
-
class: cp_filter_input_class,
|
|
18
|
-
placeholder: field.placeholder,
|
|
19
|
-
required: field.required
|
|
20
|
-
- when :textarea
|
|
21
|
-
= text_area_tag "action_form[#{field.name}]", field.default,
|
|
22
|
-
id: "action_form_#{field.name}",
|
|
23
|
-
class: "#{cp_filter_input_class} h-24",
|
|
24
|
-
placeholder: field.placeholder,
|
|
25
|
-
required: field.required
|
|
26
|
-
- when :number
|
|
27
|
-
= number_field_tag "action_form[#{field.name}]", field.default,
|
|
28
|
-
id: "action_form_#{field.name}",
|
|
29
|
-
class: cp_filter_input_class,
|
|
30
|
-
placeholder: field.placeholder,
|
|
31
|
-
step: "any",
|
|
32
|
-
required: field.required
|
|
33
|
-
- when :boolean
|
|
34
|
-
.flex.items-center.gap-2
|
|
35
|
-
= check_box_tag "action_form[#{field.name}]", "1", field.default,
|
|
36
|
-
id: "action_form_#{field.name}",
|
|
37
|
-
class: "rounded border-gray-300"
|
|
38
|
-
%span.text-sm{ class: cp_body_text }= field.label
|
|
39
|
-
- when :date
|
|
40
|
-
= date_field_tag "action_form[#{field.name}]", field.default,
|
|
41
|
-
id: "action_form_#{field.name}",
|
|
42
|
-
class: cp_filter_input_class,
|
|
43
|
-
required: field.required
|
|
44
|
-
- when :datetime
|
|
45
|
-
= datetime_field_tag "action_form[#{field.name}]", field.default,
|
|
46
|
-
id: "action_form_#{field.name}",
|
|
47
|
-
class: cp_filter_input_class,
|
|
48
|
-
required: field.required
|
|
49
|
-
- when :select
|
|
50
|
-
%select{ name: "action_form[#{field.name}]", id: "action_form_#{field.name}",
|
|
51
|
-
class: cp_filter_input_class, required: field.required }
|
|
52
|
-
%option{ value: "" }= field.placeholder || "Select..."
|
|
53
|
-
- (field.options || []).each do |opt|
|
|
54
|
-
%option{ value: opt, selected: field.default == opt }= opt.to_s.humanize
|
|
14
|
+
- @form_fields.each do |field|
|
|
15
|
+
= render "iron_admin/form/action_field", field: field, scope: "action_form",
|
|
16
|
+
value: @form_values[field.name], errors: @form_errors[field.name]
|
|
55
17
|
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
18
|
+
-# The action's confirmation comes here, once the form is filled in.
|
|
19
|
+
- confirm = @action[:confirm_message].presence || I18n.t("iron_admin.resources.action.confirm")
|
|
20
|
+
.flex.items-center.gap-3.pt-5.border-t{ class: t.card_border }
|
|
21
|
+
%button{ type: "submit", class: cp_btn_primary, data: @action[:confirm] ? { turbo_confirm: confirm } : {} }= I18n.t("iron_admin.resources.action_form.submit", default: "Execute")
|
|
22
|
+
-# A whole-page visit: the index has no action-form-modal frame to load into.
|
|
23
|
+
= link_to I18n.t("iron_admin.form.cancel_button"), resources_path(@resource_class.resource_name, **iron_admin_index_state.symbolize_keys),
|
|
24
|
+
class: cp_btn_secondary, data: { turbo_frame: "_top" }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
- form_url = resource_path(@resource_class.resource_name, @record)
|
|
2
2
|
|
|
3
|
-
.
|
|
4
|
-
%h1.
|
|
3
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
4
|
+
%h1.mb-6{ class: "#{t.page_title} #{t.heading_font}" }
|
|
5
5
|
= I18n.t("iron_admin.resources.edit.title", model: @resource_class.model.model_name.human)
|
|
6
|
-
%span
|
|
6
|
+
%span{ class: cp_muted_text }= "##{@record.id}"
|
|
7
7
|
|
|
8
8
|
.p-6{ class: cp_card }
|
|
9
9
|
- if (form_component = iron_admin_form_component(@resource_class, record: @record, fields: @fields, url: form_url))
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
- filters = iron_admin_visible_filters
|
|
2
|
+
- styles = IronAdmin::Resources::Styles
|
|
3
|
+
- controls = IronAdmin::Filters::ControlStyles
|
|
2
4
|
|
|
3
|
-
.
|
|
5
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
4
6
|
.flex.items-center.justify-between.gap-3.flex-wrap.mb-6
|
|
5
|
-
%h1
|
|
7
|
+
%h1{ class: styles.page_title(t) }= @resource_class.label
|
|
6
8
|
.flex.items-center.gap-2
|
|
7
9
|
- if @resource_class.import_enabled? && @resource_class.crud_allowed?(:create, iron_admin_current_user)
|
|
8
10
|
= link_to resource_import_path(@resource_class.resource_name),
|
|
@@ -17,43 +19,44 @@
|
|
|
17
19
|
- if @resource_class.all_scopes.any? || @resource_class.searchable_columns.any?
|
|
18
20
|
.flex.items-center.justify-between.gap-3.flex-wrap.mb-4
|
|
19
21
|
- if @resource_class.all_scopes.any?
|
|
20
|
-
|
|
22
|
+
-# A tab keeps the search, filters and sort, and starts back at the first page.
|
|
23
|
+
- scope_tab_state = iron_admin_index_state.except("scope", "page").symbolize_keys
|
|
24
|
+
.flex.gap-1.border-b.overflow-x-auto.cp-scroll-fade{ class: t.card_border }
|
|
21
25
|
- @resource_class.all_scopes.each do |scope|
|
|
22
26
|
- active = @current_scope == scope[:name].to_s
|
|
23
|
-
= link_to scope
|
|
24
|
-
resources_path(@resource_class.resource_name, scope: scope[:name]
|
|
25
|
-
class: "px-
|
|
27
|
+
= link_to IronAdmin::ScopeCounts.label(scope, @scope_counts),
|
|
28
|
+
resources_path(@resource_class.resource_name, **scope_tab_state, scope: scope[:name]),
|
|
29
|
+
class: "px-3 py-2 text-sm font-medium border-b-2 -mb-px whitespace-nowrap #{active ? cp_scope_active : cp_scope_inactive}"
|
|
26
30
|
|
|
27
31
|
- if @resource_class.searchable_columns.any? && (search_component = iron_admin_search_component(@resource_class, scope: @current_scope))
|
|
28
32
|
= render search_component
|
|
29
33
|
- elsif @resource_class.searchable_columns.any?
|
|
30
|
-
= form_tag resources_path(@resource_class.resource_name), method: :get, class: "flex ml-auto" do
|
|
34
|
+
= form_tag resources_path(@resource_class.resource_name), method: :get, class: "flex w-full sm:w-auto sm:ml-auto" do
|
|
31
35
|
- iron_admin_search_hidden_params(@current_scope).each do |name, value|
|
|
32
36
|
= hidden_field_tag name, value, id: nil
|
|
33
|
-
.relative
|
|
34
|
-
.pointer-events-none.absolute.inset-y-0.left-0.flex.items-center
|
|
35
|
-
= heroicon "magnifying-glass", variant: :mini, options: { class: "h-4 w-4 #{
|
|
37
|
+
.relative.w-full.sm:w-64
|
|
38
|
+
.pointer-events-none.absolute.inset-y-0.left-0.flex.items-center.pl-3
|
|
39
|
+
= heroicon "magnifying-glass", variant: :mini, options: { class: "h-4 w-4 #{t.icon_muted}" }
|
|
36
40
|
= text_field_tag :q, params[:q],
|
|
37
41
|
placeholder: I18n.t("iron_admin.resources.index.search_placeholder"),
|
|
38
42
|
"aria-label": I18n.t("iron_admin.resources.index.search_label", resource: @resource_class.label),
|
|
39
|
-
class:
|
|
43
|
+
class: controls.search_input(t)
|
|
40
44
|
|
|
41
45
|
- if filters.any? && (filter_bar_component = iron_admin_filter_bar_component(@resource_class, filters: filters, scope: @current_scope))
|
|
42
46
|
= render filter_bar_component
|
|
43
47
|
- elsif filters.any?
|
|
44
48
|
- has_active_filters = filters.any? { |f| iron_admin_active_filter?(f) }
|
|
45
|
-
- select_chevron_style = "background-image: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e\"); background-position: right 0.5rem center; background-repeat: no-repeat; background-size: 1.5em 1.5em; padding-right: 2.5rem;"
|
|
46
49
|
.flex.justify-end.mb-4
|
|
47
50
|
%details.relative.group{ open: has_active_filters || nil }
|
|
48
|
-
%summary
|
|
49
|
-
= heroicon "funnel", variant: :mini, options: { class: "h-4 w-4 #{
|
|
51
|
+
%summary{ class: controls.trigger(t), style: "list-style: none;" }
|
|
52
|
+
= heroicon "funnel", variant: :mini, options: { class: "h-4 w-4 #{t.icon_muted}" }
|
|
50
53
|
%span= I18n.t("iron_admin.resources.index.filters_label")
|
|
51
54
|
- if has_active_filters
|
|
52
55
|
- active_count = filters.count { |f| iron_admin_active_filter?(f) }
|
|
53
|
-
%span{ class:
|
|
56
|
+
%span{ class: controls.count(t) }
|
|
54
57
|
= active_count
|
|
55
|
-
= heroicon "chevron-down", variant: :mini, options: { class: "h-4 w-4
|
|
56
|
-
|
|
58
|
+
= heroicon "chevron-down", variant: :mini, options: { class: "h-4 w-4 #{t.icon_muted} transition-transform group-open:rotate-180" }
|
|
59
|
+
%div{ class: controls.panel(t) }
|
|
57
60
|
= form_tag resources_path(@resource_class.resource_name), method: :get, class: "p-4" do
|
|
58
61
|
= hidden_field_tag :scope, @current_scope, id: nil
|
|
59
62
|
= hidden_field_tag :q, params[:q], id: nil
|
|
@@ -66,39 +69,39 @@
|
|
|
66
69
|
-# The label names the select, or the value input of an operator filter.
|
|
67
70
|
- label_for = { date_range: "#{filter_id}_from", string: "#{filter_id}_value", number: "#{filter_id}_value" }.fetch(filter[:type], filter_id)
|
|
68
71
|
.space-y-1
|
|
69
|
-
%label
|
|
72
|
+
%label{ for: label_for, class: controls.label(t) }
|
|
70
73
|
= filter_label
|
|
71
74
|
- case filter[:type]
|
|
72
|
-
- when :select
|
|
73
|
-
%select
|
|
74
|
-
%option{ value: "" }= I18n.t("iron_admin.resources.index.all_option")
|
|
75
|
-
- filter_options_for(@resource_class, filter).each do |label, value|
|
|
76
|
-
%option{ value: value, selected: iron_admin_filter_param(filter[:name]) == value.to_s }= label
|
|
77
|
-
- when :boolean
|
|
78
|
-
%select.block.w-full.appearance-none.border.px-3.py-2.text-sm.shadow-sm.outline-none.transition.duration-150.ease-in-out{ name: "filters[#{filter[:name]}]", id: filter_id, class: "#{t.border_radius} #{t.input_border} #{t.card_bg} #{cp_body_text} #{cp_focus}", style: select_chevron_style }
|
|
75
|
+
- when :select, :boolean
|
|
76
|
+
%select{ name: "filters[#{filter[:name]}]", id: filter_id, class: controls.select(t) }
|
|
79
77
|
%option{ value: "" }= I18n.t("iron_admin.resources.index.all_option")
|
|
80
78
|
- filter_options_for(@resource_class, filter).each do |label, value|
|
|
81
79
|
%option{ value: value, selected: iron_admin_filter_param(filter[:name]) == value.to_s }= label
|
|
82
80
|
- when :date_range
|
|
81
|
+
-# The inputs' names say which end each holds; the markers say it on screen.
|
|
83
82
|
.space-y-2
|
|
84
|
-
|
|
85
|
-
class:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
.flex.items-center.gap-2
|
|
84
|
+
%span{ "aria-hidden": "true", class: controls.range_marker(t) }= I18n.t("iron_admin.filters.from")
|
|
85
|
+
= date_field_tag "filters[#{filter[:name]}_from]", iron_admin_filter_param("#{filter[:name]}_from"),
|
|
86
|
+
class: controls.input(t),
|
|
87
|
+
"aria-label": I18n.t("iron_admin.filters.from_label", filter: filter_label),
|
|
88
|
+
placeholder: I18n.t("iron_admin.filters.from")
|
|
89
|
+
.flex.items-center.gap-2
|
|
90
|
+
%span{ "aria-hidden": "true", class: controls.range_marker(t) }= I18n.t("iron_admin.filters.to")
|
|
91
|
+
= date_field_tag "filters[#{filter[:name]}_to]", iron_admin_filter_param("#{filter[:name]}_to"),
|
|
92
|
+
class: controls.input(t),
|
|
93
|
+
"aria-label": I18n.t("iron_admin.filters.to_label", filter: filter_label),
|
|
94
|
+
placeholder: I18n.t("iron_admin.filters.to")
|
|
92
95
|
- when :string
|
|
93
96
|
- string_ops = %w[contains equals starts_with ends_with]
|
|
94
97
|
- current_op = iron_admin_filter_param(filter[:name].to_s, "op") || "contains"
|
|
95
98
|
- current_val = iron_admin_filter_param(filter[:name].to_s, "value") || ""
|
|
96
99
|
.space-y-2
|
|
97
|
-
%select
|
|
100
|
+
%select{ name: "filters[#{filter[:name]}][op]", id: "#{filter_id}_op", "aria-label": I18n.t("iron_admin.filters.operator_label", filter: filter_label), class: controls.select(t) }
|
|
98
101
|
- string_ops.each do |op|
|
|
99
102
|
%option{ value: op, selected: current_op == op }= I18n.t("iron_admin.filters.operators.#{op}")
|
|
100
103
|
= text_field_tag "filters[#{filter[:name]}][value]", current_val,
|
|
101
|
-
class:
|
|
104
|
+
class: controls.input(t),
|
|
102
105
|
placeholder: filter[:label] || filter[:name].to_s.humanize
|
|
103
106
|
- when :number
|
|
104
107
|
- number_ops = %w[equals greater_than less_than between]
|
|
@@ -106,90 +109,100 @@
|
|
|
106
109
|
- current_val = iron_admin_filter_param(filter[:name].to_s, "value") || ""
|
|
107
110
|
- current_val_upper = iron_admin_filter_param(filter[:name].to_s, "value_2") || ""
|
|
108
111
|
.space-y-2{ data: { controller: "filter-operator" } }
|
|
109
|
-
%select
|
|
112
|
+
%select{ name: "filters[#{filter[:name]}][op]", id: "#{filter_id}_op", "aria-label": I18n.t("iron_admin.filters.operator_label", filter: filter_label), class: controls.select(t), data: { action: "change->filter-operator#toggle", filter_operator_target: "opSelect" } }
|
|
110
113
|
- number_ops.each do |op|
|
|
111
114
|
%option{ value: op, selected: current_op == op }= I18n.t("iron_admin.filters.operators.#{op}")
|
|
112
115
|
= number_field_tag "filters[#{filter[:name]}][value]", current_val,
|
|
113
|
-
class:
|
|
116
|
+
class: controls.input(t), step: "any",
|
|
114
117
|
placeholder: filter[:label] || filter[:name].to_s.humanize
|
|
115
118
|
.flex.items-center.gap-2{ data: { filter_operator_target: "betweenRow" }, class: current_op == "between" ? "" : "hidden" }
|
|
116
|
-
%span.text-xs{ class:
|
|
119
|
+
%span.text-xs{ class: t.muted_text }= I18n.t("iron_admin.filters.between_separator")
|
|
117
120
|
= number_field_tag "filters[#{filter[:name]}][value_2]", current_val_upper,
|
|
118
|
-
class:
|
|
121
|
+
class: controls.input(t), step: "any",
|
|
119
122
|
"aria-label": I18n.t("iron_admin.filters.upper_value_label", filter: filter_label)
|
|
120
|
-
.
|
|
121
|
-
%button{ type: "submit", class:
|
|
123
|
+
%div{ class: controls.footer(t) }
|
|
124
|
+
%button{ type: "submit", class: controls.apply_button(t) }= I18n.t("iron_admin.resources.index.apply_button")
|
|
122
125
|
= link_to I18n.t("iron_admin.resources.index.clear_button"),
|
|
123
126
|
resources_path(@resource_class.resource_name, scope: @current_scope, q: params[:q], **iron_admin_index_state.slice("sort", "direction").symbolize_keys),
|
|
124
|
-
class:
|
|
127
|
+
class: controls.clear_button(t)
|
|
125
128
|
|
|
126
|
-
- has_bulk_actions = @
|
|
129
|
+
- has_bulk_actions = @permitted_bulk_actions.any?
|
|
127
130
|
= turbo_frame_tag "records", data: { turbo_action: "advance" } do
|
|
128
131
|
-# Submitted to the whole page, so the shell shows the redirect's flash message.
|
|
129
|
-
|
|
132
|
+
-# A bulk action with form fields opens its form with a GET; cp-bulk-select keeps the CSRF token out of its URL.
|
|
133
|
+
-# per_form_csrf_tokens would bind a token for action "#" to the index path. The global token validates on each bulk action route.
|
|
134
|
+
= form_tag "#", method: :post, id: "bulk-actions-form", authenticity_token: form_authenticity_token, data: { turbo_frame: "_top", **(has_bulk_actions ? { controller: "cp-bulk-select", action: "submit->cp-bulk-select#omitTokenFromGet" } : {}) } do
|
|
130
135
|
- if has_bulk_actions
|
|
131
136
|
- iron_admin_hidden_params(iron_admin_index_state).each do |name, value|
|
|
132
137
|
= hidden_field_tag name, value, id: nil
|
|
133
|
-
.hidden.items-center.gap-3.mb-4.px-4.py-
|
|
134
|
-
%span.text-sm.font-medium{ class:
|
|
135
|
-
%span{ data: { cp_bulk_select_target: "count" } } 0
|
|
138
|
+
.hidden.flex-wrap.items-center.gap-3.mb-4.px-4.py-2{ data: { cp_bulk_select_target: "bar" }, class: styles.panel(t) }
|
|
139
|
+
%span.text-sm.font-medium{ class: t.muted_text }
|
|
140
|
+
%span.tabular-nums{ data: { cp_bulk_select_target: "count" } } 0
|
|
136
141
|
= I18n.t("iron_admin.resources.index.selected_label", default: "selected")
|
|
137
|
-
.flex.items-center.gap-2
|
|
138
|
-
- @
|
|
139
|
-
|
|
140
|
-
|
|
142
|
+
.flex.flex-wrap.items-center.gap-2
|
|
143
|
+
- @permitted_bulk_actions.each do |action|
|
|
144
|
+
-# A bulk action with form fields takes the selection to its form instead of running, and the
|
|
145
|
+
-# form asks for the confirmation on submit. Turbo reads data-turbo-confirm from the button.
|
|
146
|
+
- if action[:form_fields].present?
|
|
147
|
+
- submission = { formaction: resource_bulk_action_form_path(@resource_class.resource_name, action[:name]), formmethod: "get" }
|
|
148
|
+
- else
|
|
149
|
+
- submission = { formaction: resource_bulk_action_path(@resource_class.resource_name, action[:name]) }
|
|
150
|
+
- submission[:data] = { turbo_confirm: action[:confirm_message].presence || I18n.t("iron_admin.resources.action.confirm") } if action[:confirm]
|
|
151
|
+
%button{ type: "submit", class: styles.secondary_button(t), **submission }
|
|
141
152
|
- if action[:icon]
|
|
142
153
|
= heroicon action[:icon], variant: :mini, options: { class: "h-4 w-4" }
|
|
143
154
|
= action[:name].to_s.humanize
|
|
144
|
-
- if (table_component = iron_admin_table_component(@resource_class, records: @records, fields: @fields, scope: @current_scope))
|
|
155
|
+
- if (table_component = iron_admin_table_component(@resource_class, records: @records, fields: @fields, scope: @current_scope, bulk_actions: @permitted_bulk_actions))
|
|
145
156
|
= render table_component
|
|
146
157
|
- else
|
|
147
158
|
- sticky = IronAdmin.configuration.sticky_actions_column
|
|
148
|
-
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
%table.min-w-full{ class: "#{cp_table_border} divide-y #{t.card_bg} #{t.border_radius} #{t.card_shadow}" }
|
|
153
|
-
%thead{ class: cp_table_header_bg }
|
|
159
|
+
- visible_fields = @fields.select { |field| field.visible?(iron_admin_current_user) }
|
|
160
|
+
%div{ class: styles.table_frame(t) }
|
|
161
|
+
%table{ class: styles.table(t) }
|
|
162
|
+
%thead{ class: t.table_header_bg }
|
|
154
163
|
%tr
|
|
155
164
|
- if has_bulk_actions
|
|
156
|
-
%th.
|
|
157
|
-
%input{ type: "checkbox", class:
|
|
165
|
+
%th.w-4{ scope: "col", class: t.table_cell_padding }
|
|
166
|
+
%input{ type: "checkbox", class: cp_checkbox_class,
|
|
158
167
|
"aria-label": I18n.t("iron_admin.resources.index.select_all"),
|
|
159
168
|
data: { cp_bulk_select_target: "selectAll", action: "change->cp-bulk-select#toggleAll" } }
|
|
160
|
-
-
|
|
161
|
-
- next unless field.visible?(iron_admin_current_user)
|
|
169
|
+
- visible_fields.each do |field|
|
|
162
170
|
- sorted = params[:sort] == field.name.to_s
|
|
163
171
|
- next_dir = sorted && params[:direction] == "asc" ? "desc" : "asc"
|
|
164
|
-
%th
|
|
172
|
+
%th{ scope: "col", class: styles.header_cell(t) }
|
|
165
173
|
-# A whole-page visit, so the search and filter forms outside the frame get the new sort.
|
|
166
174
|
= link_to iron_admin_sort_path(@resource_class, @current_scope, field.name, next_dir),
|
|
167
|
-
class: "inline-flex items-center gap-1
|
|
175
|
+
class: "group inline-flex items-center gap-1 #{t.focus_ring}", data: { turbo_frame: "_top" } do
|
|
168
176
|
= field.name.to_s.humanize
|
|
169
177
|
- if sorted
|
|
170
178
|
= heroicon(params[:direction] == "asc" ? "chevron-up" : "chevron-down", variant: :mini, options: { class: "h-3.5 w-3.5" })
|
|
171
179
|
- else
|
|
172
180
|
= heroicon "chevron-up-down", variant: :mini, options: { class: "h-3.5 w-3.5 opacity-0 group-hover:opacity-50 transition-opacity" }
|
|
173
181
|
-# sticky or relative keeps the absolutely positioned sr-only text inside the scrolling table.
|
|
174
|
-
%th{
|
|
182
|
+
%th{ scope: "col", class: "#{t.table_cell_padding} #{sticky ? styles.sticky_header_cell(t) : 'relative'}" }
|
|
183
|
+
-# The cell's own box-shadow would not be painted: an edge box inside it casts it.
|
|
184
|
+
- if sticky
|
|
185
|
+
%span{ "aria-hidden": "true", class: styles.sticky_edge(t) }
|
|
175
186
|
%span.sr-only= I18n.t("iron_admin.resources.show.actions_label")
|
|
176
|
-
%tbody{ class:
|
|
187
|
+
%tbody{ class: styles.divided(t) }
|
|
177
188
|
- if @records.empty?
|
|
178
189
|
%tr
|
|
179
|
-
%td.px-
|
|
190
|
+
%td.px-4.py-12.text-center.text-sm{ colspan: visible_fields.size + (has_bulk_actions ? 2 : 1), class: t.muted_text }
|
|
180
191
|
= I18n.t("iron_admin.resources.index.empty_state")
|
|
181
192
|
- @records.each do |record|
|
|
182
|
-
|
|
193
|
+
-# group/row lets the sticky actions cell follow the row's hover (table_sticky_row_hover).
|
|
194
|
+
%tr{ class: "group/row #{t.table_row_hover}", **(@resource_class.live_index_enabled? ? { id: "iron_admin_#{@resource_class.resource_name}_row_#{record.id}" } : {}) }
|
|
183
195
|
- if has_bulk_actions
|
|
184
|
-
%td.
|
|
185
|
-
%input{ type: "checkbox", name: "ids[]", value: record.id, class:
|
|
196
|
+
%td.w-4{ class: t.table_cell_padding }
|
|
197
|
+
%input{ type: "checkbox", name: "ids[]", value: record.id, class: cp_checkbox_class,
|
|
186
198
|
"aria-label": I18n.t("iron_admin.resources.index.select_record", record: display_record_label(record)),
|
|
187
199
|
data: { cp_bulk_select_target: "checkbox", action: "change->cp-bulk-select#toggle" } }
|
|
188
|
-
-
|
|
189
|
-
|
|
190
|
-
%td.px-6.py-4.whitespace-nowrap.text-sm{ class: cp_body_text }
|
|
200
|
+
- visible_fields.each do |field|
|
|
201
|
+
%td{ class: styles.cell(t, field) }
|
|
191
202
|
= display_index_field_value(record, field)
|
|
192
|
-
%td
|
|
203
|
+
%td{ class: "whitespace-nowrap text-right text-sm #{t.table_cell_padding} #{sticky ? styles.sticky_cell(t) : ''}" }
|
|
204
|
+
- if sticky
|
|
205
|
+
%span{ "aria-hidden": "true", class: styles.sticky_edge(t) }
|
|
193
206
|
= link_to I18n.t("iron_admin.resources.index.view_link"), resource_path(@resource_class.resource_name, record),
|
|
194
207
|
class: cp_link, data: { turbo_frame: "_top" }
|
|
195
208
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
- form_url = resources_path(@resource_class.resource_name)
|
|
2
2
|
|
|
3
|
-
.
|
|
4
|
-
%h1.
|
|
3
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
4
|
+
%h1.mb-6{ class: "#{t.page_title} #{t.heading_font}" }= I18n.t("iron_admin.resources.new.title", model: @resource_class.model.model_name.human)
|
|
5
5
|
|
|
6
6
|
.p-6{ class: cp_card }
|
|
7
7
|
- if (form_component = iron_admin_form_component(@resource_class, record: @record, fields: @fields, url: form_url))
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
- styles = IronAdmin::Resources::Styles
|
|
2
|
+
|
|
3
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
2
4
|
.flex.items-center.justify-between.gap-3.flex-wrap.mb-6
|
|
3
|
-
%h1
|
|
5
|
+
%h1{ class: styles.page_title(t) }
|
|
4
6
|
= @resource_class.model.model_name.human
|
|
5
|
-
%span
|
|
7
|
+
%span{ class: cp_muted_text }= "##{@record.id}"
|
|
6
8
|
.flex.gap-2.flex-wrap
|
|
7
9
|
- if @resource_class.crud_allowed?(:update, iron_admin_current_user) && @record_reachable
|
|
8
10
|
= link_to I18n.t("iron_admin.resources.show.edit_button"), edit_resource_path(@resource_class.resource_name, @record),
|
|
@@ -12,62 +14,72 @@
|
|
|
12
14
|
method: :delete, data: { turbo_confirm: I18n.t("iron_admin.resources.show.delete_confirm") },
|
|
13
15
|
class: cp_btn_danger
|
|
14
16
|
|
|
15
|
-
.overflow-hidden{ class:
|
|
16
|
-
%dl{ class:
|
|
17
|
+
.overflow-hidden{ class: styles.panel(t) }
|
|
18
|
+
%dl{ class: styles.divided(t) }
|
|
17
19
|
- @fields.each do |field|
|
|
18
20
|
- next unless field.visible?(iron_admin_current_user)
|
|
19
|
-
|
|
20
|
-
%dt.text-sm.font-medium{ class: "sm:w-1/3 #{
|
|
21
|
-
%dd.text-sm.break-words{ class: "sm:w-2/3 #{
|
|
21
|
+
%div{ class: styles::DETAIL_ROW }
|
|
22
|
+
%dt.text-sm.font-medium{ class: "sm:w-1/3 #{t.muted_text} #{t.field_label_transform}" }= field.name.to_s.humanize
|
|
23
|
+
%dd.text-sm.break-words{ class: "sm:w-2/3 #{t.body_text}" }= display_show_field_value(@record, field)
|
|
22
24
|
|
|
23
25
|
- @resource_class.has_one_associations.each do |assoc|
|
|
24
|
-
-
|
|
26
|
+
- next unless related_panel_readable?(assoc)
|
|
27
|
+
- related_record = self.related_record(@record, assoc)
|
|
25
28
|
- next unless related_record
|
|
26
|
-
.mt-6.overflow-hidden{ class:
|
|
27
|
-
|
|
28
|
-
%h2.
|
|
29
|
+
.mt-6.overflow-hidden{ class: styles.panel(t) }
|
|
30
|
+
%div{ class: styles.panel_header(t) }
|
|
31
|
+
%h2{ class: styles.panel_title(t) }= assoc[:name].to_s.humanize
|
|
29
32
|
= link_to I18n.t("iron_admin.resources.show.view_link"),
|
|
30
33
|
resource_path(assoc[:resource].resource_name, related_record),
|
|
31
34
|
class: "text-sm #{cp_link}"
|
|
32
|
-
%dl{ class:
|
|
35
|
+
%dl{ class: styles.divided(t) }
|
|
33
36
|
- assoc[:resource].resolved_fields.first(6).each do |field|
|
|
34
37
|
- next if field.name == :id
|
|
35
38
|
- next unless field.visible?(iron_admin_current_user)
|
|
36
|
-
|
|
37
|
-
%dt.text-sm.font-medium{ class: "sm:w-1/3 #{
|
|
38
|
-
%dd.text-sm.break-words{ class: "sm:w-2/3 #{
|
|
39
|
+
%div{ class: styles::DETAIL_ROW }
|
|
40
|
+
%dt.text-sm.font-medium{ class: "sm:w-1/3 #{t.muted_text} #{t.field_label_transform}" }= field.name.to_s.humanize
|
|
41
|
+
%dd.text-sm.break-words{ class: "sm:w-2/3 #{t.body_text}" }= display_show_field_value(related_record, field)
|
|
39
42
|
|
|
40
43
|
- @resource_class.habtm_associations.each do |assoc|
|
|
41
|
-
-
|
|
44
|
+
- next unless related_panel_readable?(assoc)
|
|
45
|
+
- related_records = self.related_records(@record, assoc)
|
|
42
46
|
- next if related_records.empty?
|
|
43
|
-
.mt-6
|
|
44
|
-
|
|
45
|
-
%h2.
|
|
46
|
-
.px-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
= display_record_label(related, display)
|
|
47
|
+
.mt-6{ class: styles.panel(t) }
|
|
48
|
+
%div{ class: styles.panel_header(t) }
|
|
49
|
+
%h2{ class: styles.panel_title(t) }= assoc[:name].to_s.humanize
|
|
50
|
+
.flex.flex-wrap.gap-2.px-4.py-3
|
|
51
|
+
- related_records.each do |related|
|
|
52
|
+
- display = assoc[:display]
|
|
53
|
+
- if assoc[:resource]
|
|
54
|
+
= link_to display_record_label(related, display),
|
|
55
|
+
resource_path(assoc[:resource].resource_name, related),
|
|
56
|
+
class: "inline-flex items-center px-2 py-0.5 text-xs transition-opacity hover:opacity-75 #{t.badge_shape} #{t.chip} #{t.focus_ring}"
|
|
57
|
+
- else
|
|
58
|
+
%span{ class: "inline-flex items-center px-2 py-0.5 text-xs #{t.badge_shape} #{t.chip}" }
|
|
59
|
+
= display_record_label(related, display)
|
|
57
60
|
|
|
58
61
|
- @resource_class.has_many_associations.each do |assoc|
|
|
62
|
+
- next unless related_panel_readable?(assoc)
|
|
59
63
|
= render IronAdmin::Resources::RelatedListComponent.new(association: assoc,
|
|
60
|
-
records: @record
|
|
64
|
+
records: self.related_records(@record, assoc), parent: @record)
|
|
61
65
|
|
|
62
66
|
- if @member_actions.any?
|
|
63
|
-
.mt-6.p-
|
|
64
|
-
%h2.
|
|
67
|
+
.mt-6.p-4{ class: styles.panel(t) }
|
|
68
|
+
%h2.mb-3{ class: styles.panel_title(t) }= I18n.t("iron_admin.resources.show.actions_label")
|
|
65
69
|
.flex.gap-2.flex-wrap
|
|
66
70
|
- @member_actions.each do |action|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
-# An action with form fields opens its form, which asks for the confirmation on submit.
|
|
72
|
+
- if action[:form_fields].present?
|
|
73
|
+
= link_to resource_action_form_path(@resource_class.resource_name, @record, action[:name]),
|
|
74
|
+
class: styles.secondary_button(t) do
|
|
75
|
+
- if action[:icon]
|
|
76
|
+
= heroicon action[:icon], variant: :outline, options: { class: "h-4 w-4", "stroke-width": IronAdmin::ApplicationHelper::SMALL_ICON_STROKE }
|
|
77
|
+
= action[:name].to_s.humanize
|
|
78
|
+
- else
|
|
79
|
+
- confirm = action[:confirm_message].presence || I18n.t("iron_admin.resources.action.confirm")
|
|
80
|
+
= button_to resource_action_path(@resource_class.resource_name, @record, action[:name]),
|
|
81
|
+
data: action[:confirm] ? { turbo_confirm: confirm } : {},
|
|
82
|
+
class: styles.secondary_button(t) do
|
|
83
|
+
- if action[:icon]
|
|
84
|
+
= heroicon action[:icon], variant: :outline, options: { class: "h-4 w-4", "stroke-width": IronAdmin::ApplicationHelper::SMALL_ICON_STROKE }
|
|
85
|
+
= action[:name].to_s.humanize
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
- styles = IronAdmin::Resources::Styles
|
|
2
|
+
|
|
3
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
4
|
+
%h1.mb-6{ class: styles.page_title(t) }
|
|
5
|
+
- if @query.present?
|
|
6
|
+
-# <q> draws the language's quotation marks; the query keeps the case it was typed in.
|
|
7
|
+
Search results for
|
|
8
|
+
%q.normal-case= @query
|
|
9
|
+
- else
|
|
10
|
+
Search results
|
|
3
11
|
- if @results&.any?
|
|
4
12
|
- @results.each do |group|
|
|
5
|
-
.mb-6
|
|
6
|
-
%h2.
|
|
7
|
-
.
|
|
13
|
+
%section.mb-6
|
|
14
|
+
%h2.mb-2{ class: styles.panel_title(t) }= group[:resource].label
|
|
15
|
+
%div{ class: "#{styles.panel(t)} #{styles.divided(t)}" }
|
|
8
16
|
- group[:records].each do |record|
|
|
9
|
-
= link_to resource_path(group[:resource].resource_name, record),
|
|
10
|
-
|
|
11
|
-
= display_record_label(record)
|
|
17
|
+
= link_to resource_path(group[:resource].resource_name, record), class: styles.list_row(t) do
|
|
18
|
+
-# In the link color, like the related records of a show page.
|
|
19
|
+
%span{ class: t.link }= display_record_label(record)
|
|
12
20
|
- elsif @query.present?
|
|
13
|
-
.text-center.
|
|
21
|
+
.text-center.py-12.text-sm{ class: t.muted_text } No results found.
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
-# locals: (pagy:)
|
|
2
2
|
- if pagy.pages > 1
|
|
3
|
-
|
|
3
|
+
- link_classes = "relative inline-flex h-8 items-center px-3 text-sm font-medium transition-colors duration-150 #{t.control_radius} #{t.btn_secondary} #{t.focus_ring}"
|
|
4
|
+
-# A link with no href, marked disabled: its faded text is exempt from WCAG contrast.
|
|
5
|
+
- disabled_classes = "relative inline-flex h-8 items-center px-3 text-sm font-medium cursor-not-allowed #{t.control_radius} #{t.border_width} #{t.card_border} #{t.card_bg} #{t.disabled_text}"
|
|
6
|
+
%nav.flex.items-center.justify-between.gap-3.py-1{ "aria-label": "Pagination" }
|
|
4
7
|
.hidden{ class: "sm:block" }
|
|
5
|
-
%p.text-sm.
|
|
8
|
+
%p.text-sm{ class: t.muted_text }
|
|
6
9
|
Showing
|
|
7
|
-
%span.font-medium= pagy.from
|
|
10
|
+
%span.font-medium.tabular-nums{ class: t.body_text }= pagy.from
|
|
8
11
|
to
|
|
9
|
-
%span.font-medium= pagy.to
|
|
12
|
+
%span.font-medium.tabular-nums{ class: t.body_text }= pagy.to
|
|
10
13
|
of
|
|
11
|
-
%span.font-medium= pagy.count
|
|
14
|
+
%span.font-medium.tabular-nums{ class: t.body_text }= pagy.count
|
|
12
15
|
results
|
|
13
16
|
|
|
14
|
-
.flex.flex-1.justify-between{ class: "sm:justify-end" }
|
|
17
|
+
.flex.flex-1.justify-between.gap-2{ class: "sm:justify-end" }
|
|
15
18
|
- if pagy.previous
|
|
16
|
-
= link_to url_for(request.query_parameters.merge(page: pagy.previous)), class:
|
|
19
|
+
= link_to url_for(request.query_parameters.merge(page: pagy.previous)), class: link_classes do
|
|
17
20
|
Previous
|
|
18
21
|
- else
|
|
19
|
-
%span
|
|
22
|
+
%span{ class: disabled_classes, role: "link", "aria-disabled": "true" }
|
|
20
23
|
Previous
|
|
21
24
|
|
|
22
25
|
- if pagy.next
|
|
23
|
-
= link_to url_for(request.query_parameters.merge(page: pagy.next)), class:
|
|
26
|
+
= link_to url_for(request.query_parameters.merge(page: pagy.next)), class: link_classes do
|
|
24
27
|
Next
|
|
25
28
|
- else
|
|
26
|
-
%span
|
|
29
|
+
%span{ class: disabled_classes, role: "link", "aria-disabled": "true" }
|
|
27
30
|
Next
|