avo 3.0.0.pre11 → 3.0.0.pre12
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.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/components/avo/views/resource_edit_component.html.erb +1 -1
- data/app/components/avo/views/resource_index_component.rb +1 -1
- data/app/components/avo/views/resource_show_component.html.erb +1 -1
- data/app/controllers/avo/actions_controller.rb +1 -7
- data/app/controllers/avo/base_controller.rb +1 -1
- data/lib/avo/app.rb +1 -1
- data/lib/avo/base_resource.rb +10 -12
- data/lib/avo/concerns/breadcrumbs.rb +2 -2
- data/lib/avo/concerns/filters_session_handler.rb +5 -3
- data/lib/avo/concerns/has_description.rb +23 -0
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 76b9e80370d7cd7011b456fe12affdd877ac7ea71d44ae1774ff661a2a0a5452
         | 
| 4 | 
            +
              data.tar.gz: 1ce30818dee6f87d249f1e23e5d0c7ee73c9b8e67862c77f393a7598e5d712b4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c90992abccb5192dec1ce3414f4c14bf51dc7e665a08320df9c4a154c7539b55d4bdfa4c6d23322ffc5a550b27f9eb15815298ad07b23a2e7f7fc8ed8be4f16e
         | 
| 7 | 
            +
              data.tar.gz: 390a9b9988437466ced356326a811d6cabdfa360d0982e8dfc464254cf3025bd6660d5ef1656fc44cee2d0fffcffd8f2907488379eb3d817cf6ea2493c976a72
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -18,7 +18,7 @@ | |
| 18 18 | 
             
                multipart: true do |form| %>
         | 
| 19 19 | 
             
                <%= render Avo::ReferrerParamsComponent.new back_path: back_path %>
         | 
| 20 20 | 
             
                <%= content_tag :div, class: 'space-y-12' do %>
         | 
| 21 | 
            -
                  <%= render Avo::PanelComponent.new(name: title, description: @resource. | 
| 21 | 
            +
                  <%= render Avo::PanelComponent.new(name: title, description: @resource.description, display_breadcrumbs: @reflection.blank?, index: 0, data: { panel_id: "main" }) do |c| %>
         | 
| 22 22 | 
             
                    <% c.with_tools do %>
         | 
| 23 23 | 
             
                      <% @resource.render_edit_controls.each do |control| %>
         | 
| 24 24 | 
             
                        <%= render_control control %>
         | 
| @@ -7,7 +7,7 @@ | |
| 7 7 | 
             
                selected_resources: [@resource.record.id],
         | 
| 8 8 | 
             
                **@resource.stimulus_data_attributes
         | 
| 9 9 | 
             
              } do %>
         | 
| 10 | 
            -
              <%= render Avo::PanelComponent.new(name: title, description: @resource. | 
| 10 | 
            +
              <%= render Avo::PanelComponent.new(name: title, description: @resource.description, display_breadcrumbs: @reflection.blank?, index: 0, data: { panel_id: "main" }) do |c| %>
         | 
| 11 11 | 
             
                <% c.with_tools do %>
         | 
| 12 12 | 
             
                  <% @resource.render_show_controls.each do |control| %>
         | 
| 13 13 | 
             
                    <%= render_control control %>
         | 
| @@ -82,13 +82,7 @@ module Avo | |
| 82 82 | 
             
                      flash_messages messages
         | 
| 83 83 |  | 
| 84 84 | 
             
                      if response[:type] == :redirect
         | 
| 85 | 
            -
                         | 
| 86 | 
            -
             | 
| 87 | 
            -
                        if path.respond_to? :call
         | 
| 88 | 
            -
                          path = instance_eval(&path)
         | 
| 89 | 
            -
                        end
         | 
| 90 | 
            -
             | 
| 91 | 
            -
                        redirect_to path
         | 
| 85 | 
            +
                        redirect_to Avo::ExecutionContext.new(target: response[:path]).handle
         | 
| 92 86 | 
             
                      elsif response[:type] == :reload
         | 
| 93 87 | 
             
                        redirect_back fallback_location: resources_path(resource: @resource)
         | 
| 94 88 | 
             
                      end
         | 
| @@ -47,7 +47,7 @@ module Avo | |
| 47 47 | 
             
                    field_id = @index_params[:sort_by].to_sym
         | 
| 48 48 | 
             
                    field = @resource.get_field_definitions.find { |field| field.id == field_id }
         | 
| 49 49 | 
             
                    @query = if field&.sortable.is_a?(Proc)
         | 
| 50 | 
            -
                      field.sortable | 
| 50 | 
            +
                      Avo::ExecutionContext.new(target: field.sortable, query: @query, direction: @index_params[:sort_direction]).handle
         | 
| 51 51 | 
             
                    else
         | 
| 52 52 | 
             
                      @query.order("#{@resource.model_class.table_name}.#{@index_params[:sort_by]} #{@index_params[:sort_direction]}")
         | 
| 53 53 | 
             
                    end
         | 
    
        data/lib/avo/app.rb
    CHANGED
    
    | @@ -38,7 +38,7 @@ module Avo | |
| 38 38 | 
             
                      when "ActiveSupport::Cache::MemCacheStore", "ActiveSupport::Cache::RedisCacheStore"
         | 
| 39 39 | 
             
                        Rails.cache
         | 
| 40 40 | 
             
                      else
         | 
| 41 | 
            -
                        ActiveSupport::Cache.lookup_store(:file_store, " | 
| 41 | 
            +
                        ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp", "cache"))
         | 
| 42 42 | 
             
                      end
         | 
| 43 43 | 
             
                    elsif Rails.env.test?
         | 
| 44 44 | 
             
                      Rails.cache
         | 
    
        data/lib/avo/base_resource.rb
    CHANGED
    
    | @@ -8,6 +8,7 @@ module Avo | |
| 8 8 | 
             
                include Avo::Concerns::HasControls
         | 
| 9 9 | 
             
                include Avo::Concerns::HasStimulusControllers
         | 
| 10 10 | 
             
                include Avo::Concerns::ModelClassConstantized
         | 
| 11 | 
            +
                include Avo::Concerns::HasDescription
         | 
| 11 12 |  | 
| 12 13 | 
             
                # Avo::Current methods
         | 
| 13 14 | 
             
                delegate :context, to: Avo::Current
         | 
| @@ -38,7 +39,6 @@ module Avo | |
| 38 39 |  | 
| 39 40 | 
             
                class_attribute :id, default: :id
         | 
| 40 41 | 
             
                class_attribute :title, default: :id
         | 
| 41 | 
            -
                class_attribute :description, default: :id
         | 
| 42 42 | 
             
                class_attribute :search_query, default: nil
         | 
| 43 43 | 
             
                class_attribute :search_query_help, default: ""
         | 
| 44 44 | 
             
                class_attribute :search_result_path
         | 
| @@ -280,16 +280,6 @@ module Avo | |
| 280 280 | 
             
                  name
         | 
| 281 281 | 
             
                end
         | 
| 282 282 |  | 
| 283 | 
            -
                def resource_description
         | 
| 284 | 
            -
                  return instance_exec(&self.class.description) if self.class.description.respond_to? :call
         | 
| 285 | 
            -
             | 
| 286 | 
            -
                  # Show the description only on the resource index view.
         | 
| 287 | 
            -
                  # If the user wants to conditionally it on all pages, they should use a block.
         | 
| 288 | 
            -
                  if view == :index
         | 
| 289 | 
            -
                    return self.class.description if self.class.description.is_a? String
         | 
| 290 | 
            -
                  end
         | 
| 291 | 
            -
                end
         | 
| 292 | 
            -
             | 
| 293 283 | 
             
                def translation_key
         | 
| 294 284 | 
             
                  self.class.translation_key || "avo.resource_translations.#{class_name.underscore}"
         | 
| 295 285 | 
             
                end
         | 
| @@ -515,7 +505,7 @@ module Avo | |
| 515 505 | 
             
                  nil
         | 
| 516 506 | 
             
                end
         | 
| 517 507 |  | 
| 518 | 
            -
                def  | 
| 508 | 
            +
                def search_description
         | 
| 519 509 | 
             
                  description_field&.value
         | 
| 520 510 | 
             
                end
         | 
| 521 511 |  | 
| @@ -543,5 +533,13 @@ module Avo | |
| 543 533 | 
             
                def record_id
         | 
| 544 534 | 
             
                  record.send(id_attribute)
         | 
| 545 535 | 
             
                end
         | 
| 536 | 
            +
             | 
| 537 | 
            +
                def description_attributes
         | 
| 538 | 
            +
                  {
         | 
| 539 | 
            +
                    view: view,
         | 
| 540 | 
            +
                    resource: self,
         | 
| 541 | 
            +
                    record: record
         | 
| 542 | 
            +
                  }
         | 
| 543 | 
            +
                end
         | 
| 546 544 | 
             
              end
         | 
| 547 545 | 
             
            end
         | 
| @@ -50,7 +50,7 @@ module Avo | |
| 50 50 | 
             
                      when Symbol
         | 
| 51 51 | 
             
                        context.send(name)
         | 
| 52 52 | 
             
                      when Proc
         | 
| 53 | 
            -
                         | 
| 53 | 
            +
                        Avo::ExecutionContext.new(target: name, context: context).handle
         | 
| 54 54 | 
             
                      else
         | 
| 55 55 | 
             
                        name.to_s
         | 
| 56 56 | 
             
                      end
         | 
| @@ -61,7 +61,7 @@ module Avo | |
| 61 61 | 
             
                      when Symbol
         | 
| 62 62 | 
             
                        context.send(path)
         | 
| 63 63 | 
             
                      when Proc
         | 
| 64 | 
            -
                         | 
| 64 | 
            +
                        Avo::ExecutionContext.new(target: path, context: context).handle
         | 
| 65 65 | 
             
                      else
         | 
| 66 66 | 
             
                        context.url_for(path)
         | 
| 67 67 | 
             
                      end
         | 
| @@ -34,9 +34,11 @@ module Avo | |
| 34 34 | 
             
                  end
         | 
| 35 35 |  | 
| 36 36 | 
             
                  def cache_resource_filters?
         | 
| 37 | 
            -
                     | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 37 | 
            +
                    Avo::ExecutionContext.new(
         | 
| 38 | 
            +
                      target: Avo.configuration.cache_resource_filters,
         | 
| 39 | 
            +
                      current_user: current_user,
         | 
| 40 | 
            +
                      resource: @resource
         | 
| 41 | 
            +
                    ).handle
         | 
| 40 42 | 
             
                  end
         | 
| 41 43 | 
             
                end
         | 
| 42 44 | 
             
              end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # Adds the ability to set the visibility of an item in the execution context.
         | 
| 2 | 
            +
            module Avo
         | 
| 3 | 
            +
              module Concerns
         | 
| 4 | 
            +
                module HasDescription
         | 
| 5 | 
            +
                  extend ActiveSupport::Concern
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  class_methods do
         | 
| 8 | 
            +
                    attr_accessor :description
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def description
         | 
| 12 | 
            +
                    Avo::ExecutionContext.new(target: @description || self.class.description, **description_attributes).handle
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  private
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  # Override this method to add custom attributes to the description execution context.
         | 
| 18 | 
            +
                  def description_attributes
         | 
| 19 | 
            +
                    {}
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
    
        data/lib/avo/version.rb
    CHANGED
    
    
| @@ -51,7 +51,7 @@ Avo.configure do |config| | |
| 51 51 | 
             
              ## permanent enable or disable cache_resource_filters, default value is false
         | 
| 52 52 | 
             
              # config.cache_resource_filters = false
         | 
| 53 53 | 
             
              ## provide a lambda to enable or disable cache_resource_filters per user/resource.
         | 
| 54 | 
            -
              # config.cache_resource_filters = -> | 
| 54 | 
            +
              # config.cache_resource_filters = -> { current_user.cache_resource_filters? }
         | 
| 55 55 |  | 
| 56 56 | 
             
              ## == Customization ==
         | 
| 57 57 | 
             
              # config.app_name = 'Avocadelicious'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: avo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3.0.0. | 
| 4 | 
            +
              version: 3.0.0.pre12
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Adrian Marin
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2023-05- | 
| 12 | 
            +
            date: 2023-05-21 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: activerecord
         | 
| @@ -1710,6 +1710,7 @@ files: | |
| 1710 1710 | 
             
            - lib/avo/concerns/can_replace_items.rb
         | 
| 1711 1711 | 
             
            - lib/avo/concerns/filters_session_handler.rb
         | 
| 1712 1712 | 
             
            - lib/avo/concerns/has_controls.rb
         | 
| 1713 | 
            +
            - lib/avo/concerns/has_description.rb
         | 
| 1713 1714 | 
             
            - lib/avo/concerns/has_item_type.rb
         | 
| 1714 1715 | 
             
            - lib/avo/concerns/has_items.rb
         | 
| 1715 1716 | 
             
            - lib/avo/concerns/has_stimulus_controllers.rb
         |