From ff35408db06888ef89862fc05c6d6400d888c417 Mon Sep 17 00:00:00 2001 From: binarygit <87677429+binarygit@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:36:18 +0545 Subject: [PATCH] Chore: Apply literal properties (#3102) * Add literal to alert_component * Add literal to backtrace_alert_component * Apply literal to button_component * Apply literal to cover_photo_component * Apply literal to divider_component * Apply literal to empty_state_component * Ensure Symbol is passed into empty_state_component because ./spec/system/avo/resource_index_map_spec.rb fails * Lint * Apply literal to field_wrapper_component * Apply literal to filters_component * Apply literal to flash_alerts_component * Apply literal to loading_component * Remove redundant var and apply literal to modal component * Lint * Apply literal to paginator_component * Apply literal to panel_component * Apply literal to referrer_params_component * Apply literal to resource_sidebar_component * Apply literal to row_component * Apply literal to row_selector_component * apply literal to sidebar_component * Apply literal to app/components/avo/sidebar_profile_component.rb * Apply literal to app/components/avo/tab_group_component.rb * Apply literal to app/components/avo/tab_switcher_component.rb * Apply literal to app/components/avo/turbo_frame_wrapper_component.rb * Apply literal to app/components/avo/index/field_wrapper_component.rb * Add note on breakage * Apply literal to app/components/avo/views/resource_edit_component.rb * Apply literal to app/components/avo/index/resource_table_component.rb * Apply literal to app/components/avo/index/grid_item_component.rb * Apply literal to app/components/avo/index/resource_controls_component.rb * Apply literal to app/components/avo/views/resource_show_component.rb * Make user nilable for sidebar_profile_component * Coerce to symbol * Coerce to Symbol * Apply literal to app/components/avo/profile_photo_component.rb * Apply literal to app/components/avo/panel_name_component.rb * Apply literal to app/components/avo/fields/show_component.rb * Revert "Apply literal to app/components/avo/fields/show_component.rb" because tests are failing * Apply literal to app/components/avo/fields/edit_component.rb * Revert "Apply literal to app/components/avo/fields/edit_component.rb" because of failing tests * Apply literal to app/components/avo/fields/tags_field/tag_component.rb * Apply literal to app/components/avo/fields/common/gravatar_viewer_component.rb * Apply literal to app/components/avo/fields/common/files/controls_component.rb * Use correct type * Apply literal to app/components/avo/fields/common/files/view_type/grid_item_component.rb * Apply literal to app/components/avo/fields/common/files/list_viewer_component.rb * Apply literal to app/components/avo/fields/common/badge_viewer_component.rb * Apply literal to app/components/avo/fields/common/status_viewer_component.rb * Apply literal to app/components/avo/fields/common/key_value_component.rb * Apply literal to app/components/avo/fields/common/boolean_check_component.rb * Apply literal to app/components/avo/fields/common/boolean_group_component.rb * Apply literal to app/components/avo/fields/common/progress_bar_component.rb * Apply literal to app/components/avo/fields/common/heading_component.rb * Apply literal to app/components/avo/index/resource_grid_component.rb * Apply literal to app/components/avo/index/table_row_component.rb * Apply literal to app/components/avo/views/resource_index_component.rb * Apply literal to app/components/avo/sidebar/link_component.rb * Fix tests * Apply literal to app/components/avo/items/panel_component.rb * Apply literal to app/components/avo/sidebar/base_item_component.rb * Apply literal to app/components/avo/sidebar/heading_component.rb * Apply literal to app/components/avo/items/visible_items_component.rb * Apply literal to app/components/avo/profile_item_component.rb * Fix * Lint * view must be an instance of Avo::ViewInquirer * Coerce value to symbol * Remove reader from resource_sidebar_component * Remove reader from app/components/avo/paginator_component.rb * Remove reader from app/components/avo/empty_state_component.rb * Remove reader from app/components/avo/row_component.rb * Remove reader from app/components/avo/modal_component.rb * Remove reader from app/components/avo/fields/tags_field/tag_component.rb * Remove reader from app/components/avo/fields/common/files/controls_component.rb * Remove reader from app/components/avo/fields/common/files/view_type/grid_item_component.rb * Remove reader from app/components/avo/fields/common/files/list_viewer_component.rb * Remove reader from app/components/avo/fields/common/key_value_component.rb * Remove reader from app/components/avo/fields/common/progress_bar_component.rb * Remove reader from app/components/avo/divider_component.rb * Remove reader from app/components/avo/alert_component.rb * Remove reader from app/components/avo/tab_switcher_component.rb * Remove reader from app/components/avo/index/resource_grid_component.rb * Revert because ./spec/features/avo/record_selector_spec.rb:20 fails * Remove reader from app/components/avo/index/grid_item_component.rb * Remove reader from app/components/avo/index/resource_table_component.rb * Remove reader from app/components/avo/index/resource_controls_component.rb * Remove reader from app/components/avo/index/field_wrapper_component.rb * Remove reader from app/components/avo/panel_component.rb * Remove reader from app/components/avo/views/resource_edit_component.rb * Revert because display_breadcrumbs needs to be a reader * Remove reader from app/components/avo/views/resource_edit_component.rb * Remove reader from app/components/avo/views/resource_index_component.rb * Remove reader from app/components/avo/sidebar_profile_component.rb * Remove reader from app/components/avo/sidebar/link_component.rb * Remove reader from app/components/avo/sidebar/base_item_component.rb * Remove reader from app/components/avo/turbo_frame_wrapper_component.rb * Remove reader from app/components/avo/referrer_params_component.rb * Remove reader from app/components/avo/field_wrapper_component.rb * Fix tests * Delegate id to @field * Fix tests * Fix tests * Set instance var without calling after_initialize * Remove after_initialize from app/components/avo/cover_photo_component.rb * Remove after_initialize for app/components/avo/fields/common/badge_viewer_component.rb * Remove after_initialize for app/components/avo/fields/common/boolean_check_component.rb * Remove after_initialize for app/components/avo/fields/common/heading_component.rb * Remove after_initialize for app/components/avo/button_component.rb * Remove after_initialize for app/components/avo/index/field_wrapper_component.rb * Remove after_initialize for app/components/avo/views/resource_edit_component.rb * Remove after_initialize for app/components/avo/field_wrapper_component.rb * lint * Update app/components/avo/fields/common/badge_viewer_component.rb * Update app/components/avo/button_component.rb * Update app/components/avo/fields/common/files/view_type/list_item_component.rb * Update app/views/avo/base/_new_via_belongs_to.html.erb * Update app/components/avo/index/field_wrapper_component.rb * tweaks * fixes * prop view to Avo::ViewInquirer * prop view to Avo::ViewInquirer * tweaks * tweaks --------- Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Co-authored-by: Paul Bob --- Gemfile | 2 +- Gemfile.lock | 6 +- app/components/avo/actions_component.rb | 6 +- app/components/avo/alert_component.html.erb | 2 +- app/components/avo/alert_component.rb | 19 ++--- .../avo/backtrace_alert_component.rb | 6 +- app/components/avo/button_component.rb | 31 +++----- app/components/avo/cover_photo_component.rb | 8 +- app/components/avo/divider_component.html.erb | 4 +- app/components/avo/divider_component.rb | 7 +- app/components/avo/empty_state_component.rb | 18 ++--- .../avo/field_wrapper_component.html.erb | 18 ++--- app/components/avo/field_wrapper_component.rb | 79 +++++++------------ .../fields/common/badge_viewer_component.rb | 7 +- .../fields/common/boolean_check_component.rb | 9 ++- .../fields/common/boolean_group_component.rb | 6 +- .../common/files/controls_component.html.erb | 4 +- .../fields/common/files/controls_component.rb | 13 ++- .../common/files/list_viewer_component.rb | 14 ++-- .../view_type/grid_item_component.html.erb | 4 +- .../files/view_type/grid_item_component.rb | 22 +++--- .../view_type/list_item_component.html.erb | 2 +- .../common/gravatar_viewer_component.rb | 16 ++-- .../avo/fields/common/heading_component.rb | 10 +-- .../common/key_value_component.html.erb | 4 +- .../avo/fields/common/key_value_component.rb | 10 +-- .../common/progress_bar_component.html.erb | 6 +- .../fields/common/progress_bar_component.rb | 18 ++--- .../fields/common/status_viewer_component.rb | 6 +- .../key_value_field/show_component.html.erb | 6 +- .../fields/tags_field/tag_component.html.erb | 6 +- .../avo/fields/tags_field/tag_component.rb | 9 +-- app/components/avo/filters_component.rb | 10 +-- app/components/avo/flash_alerts_component.rb | 4 +- .../avo/index/field_wrapper_component.rb | 27 ++++--- .../avo/index/grid_item_component.html.erb | 2 +- .../avo/index/grid_item_component.rb | 21 +++-- .../avo/index/resource_controls_component.rb | 14 ++-- .../avo/index/resource_grid_component.rb | 16 ++-- .../index/resource_table_component.html.erb | 4 +- .../avo/index/resource_table_component.rb | 26 +++--- .../avo/index/table_row_component.rb | 16 ++-- app/components/avo/items/panel_component.rb | 24 +++--- .../avo/items/visible_items_component.rb | 12 ++- app/components/avo/loading_component.rb | 4 +- app/components/avo/modal_component.rb | 13 +-- app/components/avo/paginator_component.rb | 14 ++-- app/components/avo/panel_component.rb | 26 +++--- app/components/avo/panel_name_component.rb | 10 +-- app/components/avo/profile_item_component.rb | 31 +++----- app/components/avo/profile_photo_component.rb | 6 +- .../avo/referrer_params_component.html.erb | 2 +- .../avo/referrer_params_component.rb | 6 +- .../avo/resource_sidebar_component.html.erb | 2 +- .../avo/resource_sidebar_component.rb | 21 ++--- app/components/avo/row_component.rb | 8 +- app/components/avo/row_selector_component.rb | 6 +- .../avo/sidebar/base_item_component.rb | 8 +- .../avo/sidebar/heading_component.html.erb | 10 +-- .../avo/sidebar/heading_component.rb | 18 ++--- .../avo/sidebar/link_component.html.erb | 16 ++-- app/components/avo/sidebar/link_component.rb | 25 +++--- app/components/avo/sidebar_component.rb | 6 +- .../avo/sidebar_profile_component.rb | 22 +++--- app/components/avo/tab_group_component.rb | 22 ++---- .../avo/tab_switcher_component.html.erb | 6 +- app/components/avo/tab_switcher_component.rb | 28 +++---- .../turbo_frame_wrapper_component.html.erb | 4 +- .../avo/turbo_frame_wrapper_component.rb | 6 +- .../avo/views/resource_edit_component.rb | 16 ++-- .../views/resource_index_component.html.erb | 14 ++-- .../avo/views/resource_index_component.rb | 73 +++++++---------- .../avo/views/resource_show_component.rb | 19 ++--- app/controllers/avo/actions_controller.rb | 3 +- .../avo/associations_controller.rb | 2 +- app/controllers/avo/base_controller.rb | 17 ++-- app/views/avo/associations/new.html.erb | 2 +- app/views/avo/base/preview.html.erb | 7 +- 78 files changed, 432 insertions(+), 595 deletions(-) diff --git a/Gemfile b/Gemfile index c863fe48cc..4e46904279 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,7 @@ gem 'redis', '~> 5.0' # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", ">= 1.4.2", require: false # Call 'byebug' anywhere in the code to stop execution and get a debugger console -gem "byebug", platforms: [:mri, :mingw, :x64_mingw] +gem "debug", platforms: [:mri, :mingw, :x64_mingw] gem "dotenv-rails" # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem "web-console", ">= 3.3.0" diff --git a/Gemfile.lock b/Gemfile.lock index 89c512e5f8..7637ec3aab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -194,7 +194,6 @@ GEM builder (3.3.0) bump (0.10.0) bundler-integrity (1.0.9) - byebug (11.1.3) capybara (3.40.0) addressable matrix @@ -228,6 +227,9 @@ GEM database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) devise (4.9.4) @@ -670,7 +672,6 @@ DEPENDENCIES bootsnap (>= 1.4.2) bump bundler-integrity (~> 1.0) - byebug capybara chartkick countries @@ -678,6 +679,7 @@ DEPENDENCIES csv cuprite database_cleaner-active_record + debug devise dotenv-rails erb-formatter diff --git a/app/components/avo/actions_component.rb b/app/components/avo/actions_component.rb index 732f12092d..1df28009c6 100644 --- a/app/components/avo/actions_component.rb +++ b/app/components/avo/actions_component.rb @@ -22,9 +22,7 @@ class Avo::ActionsComponent < Avo::BaseComponent Array(exclude).to_set end prop :resource, _Nilable(Avo::BaseResource) - prop :view, _Nilable(Symbol) do |view| - view&.to_sym - end + prop :view, _Nilable(Avo::ViewInquirer) def after_initialize filter_actions @@ -56,7 +54,7 @@ def is_disabled?(action) private def on_record_page? - @view.in?([:show, :edit, :new]) + @view.in?(["show", "edit", "new"]) end def on_index_page? diff --git a/app/components/avo/alert_component.html.erb b/app/components/avo/alert_component.html.erb index 6c945ad217..3c4466bd03 100644 --- a/app/components/avo/alert_component.html.erb +++ b/app/components/avo/alert_component.html.erb @@ -10,7 +10,7 @@

- <%= sanitize message.to_s %> + <%= sanitize @message.to_s %>

diff --git a/app/components/avo/alert_component.rb b/app/components/avo/alert_component.rb index 064da16068..1b64513ff2 100644 --- a/app/components/avo/alert_component.rb +++ b/app/components/avo/alert_component.rb @@ -3,13 +3,8 @@ class Avo::AlertComponent < Avo::BaseComponent include Avo::ApplicationHelper - attr_reader :type - attr_reader :message - - def initialize(type, message) - @type = type - @message = message - end + prop :type, Symbol, :positional + prop :message, String, :positional def icon return "heroicons/solid/exclamation-circle" if is_error? @@ -39,22 +34,22 @@ def classes end def is_error? - type.to_sym == :error || type.to_sym == :alert + @type.to_sym == :error || @type.to_sym == :alert end def is_success? - type.to_sym == :success + @type.to_sym == :success end def is_info? - type.to_sym == :notice || type.to_sym == :info + @type.to_sym == :notice || @type.to_sym == :info end def is_warning? - type.to_sym == :warning + @type.to_sym == :warning end def is_empty? - message.nil? + @message.nil? end end diff --git a/app/components/avo/backtrace_alert_component.rb b/app/components/avo/backtrace_alert_component.rb index f190e98b49..4c9dfe9026 100644 --- a/app/components/avo/backtrace_alert_component.rb +++ b/app/components/avo/backtrace_alert_component.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -class Avo::BacktraceAlertComponent < ViewComponent::Base +class Avo::BacktraceAlertComponent < Avo::BaseComponent include Avo::ApplicationHelper - def initialize(backtrace: nil) - @backtrace = backtrace - end + prop :backtrace, _Nilable(Array) def render? @backtrace.present? diff --git a/app/components/avo/button_component.rb b/app/components/avo/button_component.rb index b8fd68e1c9..0b22d398d0 100644 --- a/app/components/avo/button_component.rb +++ b/app/components/avo/button_component.rb @@ -4,25 +4,20 @@ class Avo::ButtonComponent < Avo::BaseComponent SIZE = _Union(:xs, :sm, :md, :lg, :xl) STYLE = _Union(:primary, :outline, :text, :icon) - def initialize(path = nil, size: :md, style: :outline, color: :gray, icon: nil, icon_class: "", is_link: false, rounded: true, compact: false, aria: {}, **args) - # Main settings - @size = size - @style = style - @color = color - - # Other things that appear in the button - @path = path - @icon = icon - @icon_class = icon_class - @rounded = rounded - @compact = compact - - # Other settings - @class = args[:class] - @is_link = is_link - @aria = aria - @args = args || {} + prop :path, _Nilable(String), :positional + prop :size, Symbol, default: :md + prop :style, Symbol, default: :outline + prop :color, Symbol, default: :gray + prop :icon, _Nilable(Symbol) do |value| + value&.to_sym end + prop :icon_class, String, default: "" + prop :is_link, _Boolean, default: false + prop :rounded, _Boolean, default: true + prop :compact, _Boolean, default: false + prop :aria, Hash, default: {}.freeze + prop :args, Hash, :**, default: {}.freeze + prop :class, _Nilable(String) def args if @args[:loading] diff --git a/app/components/avo/cover_photo_component.rb b/app/components/avo/cover_photo_component.rb index e79d869100..b264c67076 100644 --- a/app/components/avo/cover_photo_component.rb +++ b/app/components/avo/cover_photo_component.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -class Avo::CoverPhotoComponent < ViewComponent::Base - def initialize(cover_photo:) - @cover_photo = cover_photo - @size = cover_photo&.size +class Avo::CoverPhotoComponent < Avo::BaseComponent + prop :cover_photo, _Nilable(Avo::CoverPhoto) + prop :size, _Nilable(Symbol) do |value| + @cover_photo&.size end # aspect-cover-sm diff --git a/app/components/avo/divider_component.html.erb b/app/components/avo/divider_component.html.erb index bb46b1d866..e0b7ec5db2 100644 --- a/app/components/avo/divider_component.html.erb +++ b/app/components/avo/divider_component.html.erb @@ -1,7 +1,7 @@
- <% if label.present? %> + <% if @label.present? %>
- <%= label %> + <%= @label %>
<% end %>
diff --git a/app/components/avo/divider_component.rb b/app/components/avo/divider_component.rb index 31e877b9ea..8d505854f5 100644 --- a/app/components/avo/divider_component.rb +++ b/app/components/avo/divider_component.rb @@ -1,9 +1,6 @@ # frozen_string_literal: true class Avo::DividerComponent < Avo::BaseComponent - attr_reader :label - - def initialize(label = nil, **args) - @label = label - end + prop :label, _Nilable(String), :positional + prop :args, Hash, :** end diff --git a/app/components/avo/empty_state_component.rb b/app/components/avo/empty_state_component.rb index 37d5736a34..2c76abb999 100644 --- a/app/components/avo/empty_state_component.rb +++ b/app/components/avo/empty_state_component.rb @@ -1,26 +1,24 @@ # frozen_string_literal: true class Avo::EmptyStateComponent < Avo::BaseComponent - attr_reader :message, :view_type, :add_background, :by_association - - def initialize(message: nil, view_type: :table, add_background: false, by_association: false) - @message = message - @view_type = view_type - @add_background = add_background - @by_association = by_association + prop :message, _Nilable(String) + prop :view_type, Symbol, default: :table do |value| + value&.to_sym end + prop :add_background, _Boolean, default: false + prop :by_association, _Boolean, default: false def text - message || locale_message + @message || locale_message end def view_type_svg - "avo/#{view_type}-empty-state" + "avo/#{@view_type}-empty-state" end private def locale_message - helpers.t by_association ? "avo.no_related_item_found" : "avo.no_item_found" + helpers.t @by_association ? "avo.no_related_item_found" : "avo.no_item_found" end end diff --git a/app/components/avo/field_wrapper_component.html.erb b/app/components/avo/field_wrapper_component.html.erb index 031631de45..e0eedd610a 100644 --- a/app/components/avo/field_wrapper_component.html.erb +++ b/app/components/avo/field_wrapper_component.html.erb @@ -2,7 +2,7 @@ class: classes, style: style, data: data do %> - <%= content_tag :div, class: class_names("pt-4 flex self-start items-center flex-shrink-0 w-48 px-6 uppercase font-semibold text-gray-500 text-sm", @field.get_html(:classes, view: view, element: :label), { + <%= content_tag :div, class: class_names("pt-4 flex self-start items-center flex-shrink-0 w-48 px-6 uppercase font-semibold text-gray-500 text-sm", @field.get_html(:classes, view: @view, element: :label), { "md:pt-4 md:w-full": stacked?, "h-full md:pt-0": !stacked?, "md:h-10 ": !stacked? && short?, @@ -10,15 +10,15 @@ "md:w-48": compact?, "md:w-64": !compact?, }), data: {slot: "label"} do %> - <% if form.present? %> - <%= form.label label_for, label %> + <% if @form.present? %> + <%= @form.label label_for, label %> <% else %> - <%= field.name %> + <%= @field.name %> <% end %> - <% if on_edit? && field.is_required? %> * <% end %> + <% if on_edit? && @field.is_required? %> * <% end %> <% end %> <%= content_tag :div, class: class_names("flex-1 flex flex-row md:min-h-inherit px-6", - @field.get_html(:classes, view: view, element: :content), + @field.get_html(:classes, view: @view, element: :content), { "pb-4": stacked?, "py-2": !compact?, @@ -33,8 +33,8 @@ <% end %> <% elsif on_edit? %> <%= content %> - <% if record.present? and record.errors.include? field.id %> -
<%= record.errors.full_messages_for(field.id).to_sentence %>
+ <% if record.present? and record.errors.include? @field.id %> +
<%= record.errors.full_messages_for(@field.id).to_sentence %>
<% end %> <% if help.present? %>
<%= sanitize help %>
@@ -44,6 +44,6 @@ <% end %> <% if params[:avo_debug].present? %> - + <% end %> <% end %> diff --git a/app/components/avo/field_wrapper_component.rb b/app/components/avo/field_wrapper_component.rb index 1170edf5eb..fae0bce1ae 100644 --- a/app/components/avo/field_wrapper_component.rb +++ b/app/components/avo/field_wrapper_component.rb @@ -3,55 +3,36 @@ class Avo::FieldWrapperComponent < Avo::BaseComponent include Avo::Concerns::HasResourceStimulusControllers - attr_reader :dash_if_blank - attr_reader :compact - attr_reader :field - attr_reader :form - attr_reader :full_width - attr_reader :resource - attr_reader :view - - def initialize( - dash_if_blank: true, - data: {}, - compact: false, - help: nil, # do we really need it? - field: nil, - form: nil, - full_width: false, - label: nil, # do we really need it? - resource: nil, - short: false, - stacked: nil, - style: "", - view: :show, - label_for: nil, - **args - ) - @args = args - @classes = args[:class].present? ? args[:class] : "" - @dash_if_blank = dash_if_blank - @data = data - @compact = compact - @help = help - @field = field - @form = form - @full_width = full_width - @label = label - @resource = resource - @action = field.action - @short = short - @stacked = stacked - @style = style - @view = view - @label_for = label_for + prop :dash_if_blank, _Boolean, default: true + prop :data, Hash, default: {}.freeze + prop :compact, _Boolean, default: false + prop :help, _Nilable(String) + prop :field, _Nilable(Avo::Fields::BaseField) + prop :form, _Nilable(ActionView::Helpers::FormBuilder) + prop :full_width, _Boolean, default: false + prop :label, _Nilable(String) + prop :resource, _Nilable(Avo::BaseResource) + prop :short, _Boolean, default: false + prop :stacked, _Nilable(_Boolean) + prop :style, String, default: "" + prop :view, Avo::ViewInquirer, default: Avo::ViewInquirer.new(:show).freeze + prop :label_for, _Nilable(Symbol) do |value| + value&.to_sym + end + prop :args, Hash, :**, default: {}.freeze + prop :classes, _Nilable(String) do |value| + @args&.dig(:class) || "" + end + + def after_initialize + @action = @field.action end def classes(extra_classes = "") class_names("field-wrapper relative flex flex-col grow pb-2 md:pb-0 leading-tight h-full", @classes, extra_classes, - @field.get_html(:classes, view: view, element: :wrapper), + @field.get_html(:classes, view: @view, element: :wrapper), { "min-h-14": !short?, "min-h-10": short?, @@ -65,7 +46,7 @@ def classes(extra_classes = "") end def style - "#{@style} #{@field.get_html(:style, view: view, element: :wrapper)}" + "#{@style} #{@field.get_html(:style, view: @view, element: :wrapper)}" end def label @@ -76,14 +57,14 @@ def label_for @label_for || @field.form_field_label end - delegate :show?, :edit?, to: :view, prefix: :on + delegate :show?, :edit?, to: :@view, prefix: :on def help - Avo::ExecutionContext.new(target: @help || @field.help, record: record, resource: resource, view: view).handle + Avo::ExecutionContext.new(target: @help || @field.help, record: record, resource: @resource, view: @view).handle end def record - resource.present? ? resource.record : nil + @resource.present? ? @resource.record : nil end def data @@ -94,7 +75,7 @@ def data } # Fetch the data attributes off the html option - wrapper_data_attributes = @field.get_html :data, view: view, element: :wrapper + wrapper_data_attributes = @field.get_html :data, view: @view, element: :wrapper if wrapper_data_attributes.present? attributes.merge! wrapper_data_attributes end @@ -116,7 +97,7 @@ def stacked? return @stacked unless @stacked.nil? # Fetch it from the field - return field.stacked unless field.stacked.nil? + return @field.stacked unless @field.stacked.nil? # Fallback to defaults Avo.configuration.field_wrapper_layout == :stacked diff --git a/app/components/avo/fields/common/badge_viewer_component.rb b/app/components/avo/fields/common/badge_viewer_component.rb index 92115a1873..c8d0380397 100644 --- a/app/components/avo/fields/common/badge_viewer_component.rb +++ b/app/components/avo/fields/common/badge_viewer_component.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true class Avo::Fields::Common::BadgeViewerComponent < Avo::BaseComponent - def initialize(value:, options:) - @value = value - @options = options + prop :value, String + prop :options, Hash + + def after_initialize @backgrounds = { info: "bg-blue-500", success: "bg-green-500", diff --git a/app/components/avo/fields/common/boolean_check_component.rb b/app/components/avo/fields/common/boolean_check_component.rb index 860f197952..6bc34bd599 100644 --- a/app/components/avo/fields/common/boolean_check_component.rb +++ b/app/components/avo/fields/common/boolean_check_component.rb @@ -1,8 +1,11 @@ # frozen_string_literal: true class Avo::Fields::Common::BooleanCheckComponent < Avo::BaseComponent - def initialize(checked: false) - @icon = checked ? "heroicons/outline/check-circle" : "heroicons/outline/x-circle" - @classes = "h-6 #{checked ? "text-green-600" : "text-red-500"}" + prop :checked, _Boolean, default: false + prop :icon, _Nilable(String) do |value| + @checked ? "heroicons/outline/check-circle" : "heroicons/outline/x-circle" + end + prop :classes, _Nilable(String) do |value| + "h-6 #{@checked ? "text-green-600" : "text-red-500"}" end end diff --git a/app/components/avo/fields/common/boolean_group_component.rb b/app/components/avo/fields/common/boolean_group_component.rb index d3e221bf73..44a2ff7e4e 100644 --- a/app/components/avo/fields/common/boolean_group_component.rb +++ b/app/components/avo/fields/common/boolean_group_component.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true class Avo::Fields::Common::BooleanGroupComponent < Avo::BaseComponent - def initialize(options: {}, value: nil) - @options = options - @value = value - end + prop :options, Hash, default: {}.freeze + prop :value, _Nilable(Hash) end diff --git a/app/components/avo/fields/common/files/controls_component.html.erb b/app/components/avo/fields/common/files/controls_component.html.erb index ec53d0648e..6e210dbc74 100644 --- a/app/components/avo/fields/common/files/controls_component.html.erb +++ b/app/components/avo/fields/common/files/controls_component.html.erb @@ -1,6 +1,6 @@
<% if can_download_file? %> - <%= a_link helpers.main_app.rails_blob_path(file, only_path: true, disposition: :attachment), + <%= a_link helpers.main_app.rails_blob_path(@file, only_path: true, disposition: :attachment), icon: "heroicons/outline/download", color: :primary, download: true, @@ -19,7 +19,7 @@ compact: true, size: :xs, class: 'text-center', - title: t('avo.delete_file', item: file.filename), + title: t('avo.delete_file', item: @file.filename), data: { turbo_method: :delete, turbo_confirm: t('avo.are_you_sure'), diff --git a/app/components/avo/fields/common/files/controls_component.rb b/app/components/avo/fields/common/files/controls_component.rb index 9fada6fc7f..2b9550d598 100644 --- a/app/components/avo/fields/common/files/controls_component.rb +++ b/app/components/avo/fields/common/files/controls_component.rb @@ -4,16 +4,13 @@ class Avo::Fields::Common::Files::ControlsComponent < Avo::BaseComponent include Avo::ApplicationHelper include Avo::Fields::Concerns::FileAuthorization - attr_reader :file, :field, :resource - delegate :id, to: :field + delegate :id, to: :@field - def initialize(field:, file:, resource:) - @field = field - @file = file - @resource = resource - end + prop :field, Avo::Fields::BaseField + prop :file, ActiveStorage::Attachment + prop :resource, Avo::BaseResource def destroy_path - Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, file.id).to_s + Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, @file.id).to_s end end diff --git a/app/components/avo/fields/common/files/list_viewer_component.rb b/app/components/avo/fields/common/files/list_viewer_component.rb index 745f24e9d1..ffd7c1f1d3 100644 --- a/app/components/avo/fields/common/files/list_viewer_component.rb +++ b/app/components/avo/fields/common/files/list_viewer_component.rb @@ -3,12 +3,8 @@ class Avo::Fields::Common::Files::ListViewerComponent < Avo::BaseComponent include Turbo::FramesHelper - attr_reader :field, :resource - - def initialize(field:, resource:) - @field = field - @resource = resource - end + prop :field, Avo::Fields::BaseField + prop :resource, Avo::BaseResource def classes base_classes = "py-4 rounded-2xl max-w-full" @@ -23,7 +19,7 @@ def classes end def wrapper_classes - (field.stacked && !field.hide_view_type_switcher) ? "-mt-9" : "" + (@field.stacked && !@field.hide_view_type_switcher) ? "-mt-9" : "" end def available_view_types @@ -32,10 +28,10 @@ def available_view_types def view_type_component(file) component = "Avo::Fields::Common::Files::ViewType::#{view_type.to_s.capitalize}ItemComponent".constantize - component.new(field: field, resource: resource, file: file, extra_classes: "aspect-video") + component.new(field: @field, resource: @resource, file: file, extra_classes: "aspect-video") end def view_type - @view_type ||= (resource.params.dig(:view_type) || field.view_type).to_sym + @view_type ||= (@resource.params.dig(:view_type) || @field.view_type).to_sym end end diff --git a/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb b/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb index 9644a7dcd2..cb5910355d 100644 --- a/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb +++ b/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb @@ -13,11 +13,11 @@
<% end %> - <% if field.display_filename %> + <% if @field.display_filename %> <%= file.filename %> <% end %>
- <%= render Avo::Fields::Common::Files::ControlsComponent.new(field: field, file: file, resource: resource) %> + <%= render Avo::Fields::Common::Files::ControlsComponent.new(field: @field, file: file, resource: @resource) %>
diff --git a/app/components/avo/fields/common/files/view_type/grid_item_component.rb b/app/components/avo/fields/common/files/view_type/grid_item_component.rb index 6c99395d42..8a840952c3 100644 --- a/app/components/avo/fields/common/files/view_type/grid_item_component.rb +++ b/app/components/avo/fields/common/files/view_type/grid_item_component.rb @@ -1,39 +1,35 @@ # frozen_string_literal: true class Avo::Fields::Common::Files::ViewType::GridItemComponent < Avo::BaseComponent - attr_reader :field, :resource - - def initialize(field:, resource:, file: nil, extra_classes: nil) - @file = file - @field = field - @resource = resource - @extra_classes = extra_classes - end + prop :field, Avo::Fields::BaseField + prop :resource, Avo::BaseResource + prop :file, _Nilable(ActiveStorage::Attachment) + prop :extra_classes, _Nilable(String) def id - field.id + @field.id end def file - @file || field.value.attachment + @file || @field.value.attachment rescue nil end def is_image? - file.image? || field.is_image + file.image? || @field.is_image rescue false end def is_audio? - file.audio? || field.is_audio + file.audio? || @field.is_audio rescue false end def is_video? - file.video? || field.is_video + file.video? || @field.is_video rescue false end diff --git a/app/components/avo/fields/common/files/view_type/list_item_component.html.erb b/app/components/avo/fields/common/files/view_type/list_item_component.html.erb index ac2e7ced1b..a704d691fd 100644 --- a/app/components/avo/fields/common/files/view_type/list_item_component.html.erb +++ b/app/components/avo/fields/common/files/view_type/list_item_component.html.erb @@ -13,7 +13,7 @@ <%= helpers.number_to_human_size(file.byte_size) %>
- <%= render Avo::Fields::Common::Files::ControlsComponent.new(field: field, file: file, resource: resource) %> + <%= render Avo::Fields::Common::Files::ControlsComponent.new(field: @field, file: file, resource: @resource) %>
<% else %> diff --git a/app/components/avo/fields/common/gravatar_viewer_component.rb b/app/components/avo/fields/common/gravatar_viewer_component.rb index 273d139db1..159a9b4eff 100644 --- a/app/components/avo/fields/common/gravatar_viewer_component.rb +++ b/app/components/avo/fields/common/gravatar_viewer_component.rb @@ -1,13 +1,11 @@ # frozen_string_literal: true class Avo::Fields::Common::GravatarViewerComponent < Avo::BaseComponent - def initialize(md5: nil, link: nil, default: nil, size: nil, rounded: false, link_to_record: false, title: nil) - @md5 = md5 - @link = link - @default = default - @size = size - @rounded = rounded - @link_to_record = link_to_record - @title = title - end + prop :md5, _Nilable(String) + prop :link, _Nilable(String) + prop :default, _Nilable(String) + prop :size, _Nilable(Integer) + prop :rounded, _Boolean, default: false + prop :link_to_record, _Boolean, default: false + prop :title, _Nilable(String) end diff --git a/app/components/avo/fields/common/heading_component.rb b/app/components/avo/fields/common/heading_component.rb index 7968941b74..552af9be90 100644 --- a/app/components/avo/fields/common/heading_component.rb +++ b/app/components/avo/fields/common/heading_component.rb @@ -3,12 +3,12 @@ class Avo::Fields::Common::HeadingComponent < Avo::BaseComponent include Avo::Concerns::HasResourceStimulusControllers - def initialize(field:) - @field = field - @view = field.resource.view - @classes = "flex items-start py-1 leading-tight bg-gray-100 text-gray-500 text-xs #{@field.get_html(:classes, view: @view, element: :wrapper)}" + prop :field, Avo::Fields::BaseField + def after_initialize + @view = @field.resource.view + @classes = "flex items-start py-1 leading-tight bg-gray-100 text-gray-500 text-xs #{@field.get_html(:classes, view: @view, element: :wrapper)}" @data = stimulus_data_attributes - add_stimulus_attributes_for(field.resource, @data) + add_stimulus_attributes_for(@field.resource, @data) end end diff --git a/app/components/avo/fields/common/key_value_component.html.erb b/app/components/avo/fields/common/key_value_component.html.erb index 7bac693f0d..1ba7262502 100644 --- a/app/components/avo/fields/common/key_value_component.html.erb +++ b/app/components/avo/fields/common/key_value_component.html.erb @@ -41,7 +41,7 @@ data: { "key-value-target": 'input', view: @view, - **@field.get_html(:data, view: view, element: :input) + **@field.get_html(:data, view: @view, element: :input) } %> <% else %> @@ -52,7 +52,7 @@ data: { "key-value-target": 'input', view: @view, - **@field.get_html(:data, view: view, element: :input) + **@field.get_html(:data, view: @view, element: :input) } %> <% end %> diff --git a/app/components/avo/fields/common/key_value_component.rb b/app/components/avo/fields/common/key_value_component.rb index 1df79b6534..a3e8a6f8a8 100644 --- a/app/components/avo/fields/common/key_value_component.rb +++ b/app/components/avo/fields/common/key_value_component.rb @@ -3,11 +3,7 @@ class Avo::Fields::Common::KeyValueComponent < Avo::BaseComponent include Avo::ApplicationHelper - attr_reader :view - - def initialize(field:, form: nil, view: "show") - @field = field - @form = form - @view = Avo::ViewInquirer.new(view) - end + prop :field, Avo::Fields::BaseField + prop :form, _Nilable(ActionView::Helpers::FormBuilder) + prop :view, Avo::ViewInquirer, default: Avo::ViewInquirer.new(:show).freeze end diff --git a/app/components/avo/fields/common/progress_bar_component.html.erb b/app/components/avo/fields/common/progress_bar_component.html.erb index ef667cccd5..024692afb5 100644 --- a/app/components/avo/fields/common/progress_bar_component.html.erb +++ b/app/components/avo/fields/common/progress_bar_component.html.erb @@ -1,8 +1,8 @@
- <% if display_value %> + <% if @display_value %>
- <%= value %><%= value_suffix if value_suffix.present? %> + <%= @value %><%= @value_suffix if @value_suffix.present? %>
<% end %> - <%= tag :progress, min: 0, max: max, value: value, class: "block min-w-[6rem] #{"w-full" if show?} #{"w-auto" if index?}" %> + <%= tag :progress, min: 0, max: @max, value: @value, class: "block min-w-[6rem] #{"w-full" if show?} #{"w-auto" if index?}" %>
diff --git a/app/components/avo/fields/common/progress_bar_component.rb b/app/components/avo/fields/common/progress_bar_component.rb index 9e14de152b..41b6496e6b 100644 --- a/app/components/avo/fields/common/progress_bar_component.rb +++ b/app/components/avo/fields/common/progress_bar_component.rb @@ -1,19 +1,11 @@ # frozen_string_literal: true class Avo::Fields::Common::ProgressBarComponent < Avo::BaseComponent - attr_reader :value - attr_reader :display_value - attr_reader :value_suffix - attr_reader :max - attr_reader :view - - def initialize(value:, display_value: false, value_suffix: nil, max: 100, view: "index") - @value = value - @display_value = display_value - @value_suffix = value_suffix - @max = max - @view = Avo::ViewInquirer.new(view) - end + prop :value, Integer + prop :display_value, _Boolean, default: false + prop :value_suffix, _Nilable(String) + prop :max, Integer, default: 100 + prop :view, Avo::ViewInquirer, reader: :public, default: Avo::ViewInquirer.new(:index).freeze delegate :show?, :index?, to: :view end diff --git a/app/components/avo/fields/common/status_viewer_component.rb b/app/components/avo/fields/common/status_viewer_component.rb index e1aaaa18e1..08516677d2 100644 --- a/app/components/avo/fields/common/status_viewer_component.rb +++ b/app/components/avo/fields/common/status_viewer_component.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true class Avo::Fields::Common::StatusViewerComponent < Avo::BaseComponent - def initialize(status:, label:) - @status = status - @label = label - end + prop :status, String + prop :label, String end diff --git a/app/components/avo/fields/key_value_field/show_component.html.erb b/app/components/avo/fields/key_value_field/show_component.html.erb index 7fb6455d3f..cf3354b561 100644 --- a/app/components/avo/fields/key_value_field/show_component.html.erb +++ b/app/components/avo/fields/key_value_field/show_component.html.erb @@ -1,3 +1,7 @@ <%= field_wrapper **field_wrapper_args, full_width: true do %> - <%= render Avo::Fields::Common::KeyValueComponent.new field: @field, view: :show %> + <%= render Avo::Fields::Common::KeyValueComponent.new( + field: @field, + view: Avo::ViewInquirer.new(:show) + ) + %> <% end %> diff --git a/app/components/avo/fields/tags_field/tag_component.html.erb b/app/components/avo/fields/tags_field/tag_component.html.erb index b25874d2fc..49afb24380 100644 --- a/app/components/avo/fields/tags_field/tag_component.html.erb +++ b/app/components/avo/fields/tags_field/tag_component.html.erb @@ -1,9 +1,9 @@
+ <% if @title.present? %> data-tippy="tooltip" - title="<%= title %>" + title="<%= @title %>" <% end %> data-target="tag-component" > - <%= label %> + <%= @label %>
diff --git a/app/components/avo/fields/tags_field/tag_component.rb b/app/components/avo/fields/tags_field/tag_component.rb index 7952bc0546..b0abde8f9e 100644 --- a/app/components/avo/fields/tags_field/tag_component.rb +++ b/app/components/avo/fields/tags_field/tag_component.rb @@ -1,11 +1,6 @@ # frozen_string_literal: true class Avo::Fields::TagsField::TagComponent < Avo::BaseComponent - attr_reader :label - attr_reader :title - - def initialize(label: nil, title: nil) - @label = label - @title = title - end + prop :label, _Nilable(String) + prop :title, _Nilable(String) end diff --git a/app/components/avo/filters_component.rb b/app/components/avo/filters_component.rb index d90ea535ff..16b5643495 100644 --- a/app/components/avo/filters_component.rb +++ b/app/components/avo/filters_component.rb @@ -3,12 +3,10 @@ class Avo::FiltersComponent < Avo::BaseComponent include Avo::ApplicationHelper - def initialize(filters: [], resource: nil, applied_filters: [], parent_record: nil) - @filters = filters - @resource = resource - @applied_filters = applied_filters - @parent_record = parent_record - end + prop :filters, _Array(Avo::Filters::BaseFilter), default: [].freeze + prop :resource, _Nilable(Avo::BaseResource) + prop :applied_filters, Hash, default: {}.freeze + prop :parent_record, _Nilable(ActiveRecord::Base) def render? @filters.present? diff --git a/app/components/avo/flash_alerts_component.rb b/app/components/avo/flash_alerts_component.rb index f0dadeb911..72c015c721 100644 --- a/app/components/avo/flash_alerts_component.rb +++ b/app/components/avo/flash_alerts_component.rb @@ -3,7 +3,5 @@ class Avo::FlashAlertsComponent < Avo::BaseComponent include Avo::ApplicationHelper - def initialize(flashes: []) - @flashes = flashes - end + prop :flashes, ActionDispatch::Flash::FlashHash, default: [].freeze end diff --git a/app/components/avo/index/field_wrapper_component.rb b/app/components/avo/index/field_wrapper_component.rb index 360d64fc48..14ef3de84d 100644 --- a/app/components/avo/index/field_wrapper_component.rb +++ b/app/components/avo/index/field_wrapper_component.rb @@ -1,16 +1,17 @@ # frozen_string_literal: true class Avo::Index::FieldWrapperComponent < Avo::BaseComponent - attr_reader :view - - def initialize(field: nil, resource: nil, dash_if_blank: true, center_content: false, flush: false, **args) - @field = field - @resource = resource - @dash_if_blank = dash_if_blank - @center_content = center_content - @classes = args[:class].present? ? args[:class] : "" - @args = args - @flush = flush + prop :field, _Nilable(Avo::Fields::BaseField) + prop :resource, _Nilable(Avo::BaseResource) + prop :dash_if_blank, _Boolean, default: true + prop :center_content, _Boolean, default: false + prop :flush, _Boolean, default: false + prop :args, Hash, :**, default: {}.freeze + prop :classes, _Nilable(String) do |value| + @args&.dig(:class) || "" + end + + def after_initialize @view = Avo::ViewInquirer.new("index") end @@ -21,13 +22,13 @@ def classes result += " py-3" end - result += " #{@field.get_html(:classes, view: view, element: :wrapper)}" + result += " #{@field.get_html(:classes, view: @view, element: :wrapper)}" result end def style - @field.get_html(:style, view: view, element: :wrapper) + @field.get_html(:style, view: @view, element: :wrapper) end def stimulus_attributes @@ -37,7 +38,7 @@ def stimulus_attributes attributes["#{controller}-target"] = "#{@field.id.to_s.underscore}_#{@field.type.to_s.underscore}_wrapper".camelize(:lower) end - wrapper_data_attributes = @field.get_html :data, view: view, element: :wrapper + wrapper_data_attributes = @field.get_html :data, view: @view, element: :wrapper if wrapper_data_attributes.present? attributes.merge! wrapper_data_attributes end diff --git a/app/components/avo/index/grid_item_component.html.erb b/app/components/avo/index/grid_item_component.html.erb index 472010aaa3..f75b60ceba 100644 --- a/app/components/avo/index/grid_item_component.html.erb +++ b/app/components/avo/index/grid_item_component.html.erb @@ -19,7 +19,7 @@ <%= render_body %>
- <%= render(Avo::Index::ResourceControlsComponent.new(resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, view_type: :grid, actions: actions)) %> + <%= render(Avo::Index::ResourceControlsComponent.new(resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, view_type: :grid, actions: @actions)) %>
<% end %> diff --git a/app/components/avo/index/grid_item_component.rb b/app/components/avo/index/grid_item_component.rb index 202b980ad5..58abb8bd7f 100644 --- a/app/components/avo/index/grid_item_component.rb +++ b/app/components/avo/index/grid_item_component.rb @@ -4,16 +4,15 @@ class Avo::Index::GridItemComponent < Avo::BaseComponent include Avo::ResourcesHelper include Avo::Fields::Concerns::HasHTMLAttributes - attr_reader :parent_resource, :actions - - def initialize(resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, actions: nil) - @resource = resource - @reflection = reflection - @parent_record = parent_record - @parent_resource = parent_resource - @actions = actions - @card = Avo::ExecutionContext.new(target: resource.grid_view[:card], resource: resource, record: resource.record).handle - @whole_html = Avo::ExecutionContext.new(target: resource.grid_view[:html], resource: resource, record: resource.record).handle + prop :resource, _Nilable(Avo::BaseResource) + prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) + prop :parent_record, _Nilable(ActiveRecord::Base) + prop :parent_resource, _Nilable(Avo::BaseResource) + prop :actions, _Nilable(_Array(Avo::BaseAction)) + + def after_initialize + @card = Avo::ExecutionContext.new(target: @resource.grid_view[:card], resource: @resource, record: @resource.record).handle + @whole_html = Avo::ExecutionContext.new(target: @resource.grid_view[:html], resource: @resource, record: @resource.record).handle end private @@ -29,7 +28,7 @@ def resource_view_path if @parent_record.present? args = { - via_resource_class: parent_resource.class.to_s, + via_resource_class: @parent_resource.class.to_s, via_record_id: @parent_record.to_param } end diff --git a/app/components/avo/index/resource_controls_component.rb b/app/components/avo/index/resource_controls_component.rb index 561e773f72..ceec5d9a9c 100644 --- a/app/components/avo/index/resource_controls_component.rb +++ b/app/components/avo/index/resource_controls_component.rb @@ -3,14 +3,12 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent include Avo::ApplicationHelper - def initialize(resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, view_type: :table, actions: nil) - @resource = resource - @reflection = reflection - @parent_record = parent_record - @parent_resource = parent_resource - @view_type = view_type - @actions = actions - end + prop :resource, _Nilable(Avo::BaseResource) + prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) + prop :parent_record, _Nilable(ActiveRecord::Base) + prop :parent_resource, _Nilable(Avo::BaseResource) + prop :view_type, Symbol, default: :table + prop :actions, _Nilable(_Array(Avo::BaseAction)) def can_detach? is_has_many_association? ? super : false diff --git a/app/components/avo/index/resource_grid_component.rb b/app/components/avo/index/resource_grid_component.rb index 601c77066b..00da185e7f 100644 --- a/app/components/avo/index/resource_grid_component.rb +++ b/app/components/avo/index/resource_grid_component.rb @@ -1,14 +1,10 @@ # frozen_string_literal: true class Avo::Index::ResourceGridComponent < Avo::BaseComponent - attr_reader :actions - - def initialize(resources: nil, resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, actions: nil) - @resources = resources - @resource = resource - @reflection = reflection - @parent_record = parent_record - @parent_resource = parent_resource - @actions = actions - end + prop :resources, _Array(_Nilable(Avo::BaseResource)) + prop :resource, _Nilable(Avo::BaseResource) + prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) + prop :parent_record, _Nilable(ActiveRecord::Base) + prop :parent_resource, _Nilable(Avo::BaseResource) + prop :actions, _Nilable(_Array(Avo::BaseAction)), reader: :public end diff --git a/app/components/avo/index/resource_table_component.html.erb b/app/components/avo/index/resource_table_component.html.erb index 663a5853ce..ff97ebfe8f 100644 --- a/app/components/avo/index/resource_table_component.html.erb +++ b/app/components/avo/index/resource_table_component.html.erb @@ -5,11 +5,11 @@ data-resource-name="<%= @resource.model_key %>" data-item-select-all-selected-all-value="false" data-item-select-all-selected-all-query-value="<%= encrypted_query %>" - data-item-select-all-page-count-value="<%= pagy.pages %>" + data-item-select-all-page-count-value="<%= @pagy.pages %>" data-selected-resources-name="<%= @resource.model_key %>" data-selected-resources="[]" > - <% if pagy.pages > 1 %> + <% if @pagy.pages > 1 %>