avo 2.13.5.pre.2 → 2.13.6.pre.1
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/base_component.rb +3 -2
- data/app/components/avo/fields/common/single_file_viewer_component.html.erb +1 -1
- data/app/components/avo/resource_component.rb +2 -3
- data/app/components/avo/views/resource_edit_component.rb +2 -0
- data/app/javascript/js/controllers/fields/date_field_controller.js +5 -1
- data/lib/avo/base_resource.rb +1 -5
- data/lib/avo/concerns/fetches_things.rb +2 -13
- data/lib/avo/configuration.rb +0 -2
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +8 -10
- data/public/avo-assets/avo.js +50 -50
- data/public/avo-assets/avo.js.map +2 -2
- metadata +2 -3
- data/app/controllers/avo/team_users_controller.rb +0 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5c3d594c867fc840c703aff831b7a39e66ca678d525ce66a698014979197fa8d
         | 
| 4 | 
            +
              data.tar.gz: c8d325159aadabb979c15df783595b68ad2c1ea5c150779f85de66255b1ba221
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3abe727bca4823198022bd9e79ccadc9c2b79b1cc8d6ab1070b57e9761e93620ee457dfa45b45a9847258640c551865b9d830bfd73326372a355c7c3fabbaf60
         | 
| 7 | 
            +
              data.tar.gz: f7107a8cb2b0dbc072a50eaa5faa3b92ad565642c835a11ee30bbcde0f601c94bbc56694f39c4c363592194203144a78215e9bade5c478433a2603a8486f1251
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -9,9 +9,10 @@ class Avo::BaseComponent < ViewComponent::Base | |
| 9 9 |  | 
| 10 10 | 
             
              private
         | 
| 11 11 |  | 
| 12 | 
            -
              #  | 
| 12 | 
            +
              # Figure out what is the corresponding field for this @reflection
         | 
| 13 13 | 
             
              def field
         | 
| 14 | 
            -
                 | 
| 14 | 
            +
                fields = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name).get_field_definitions
         | 
| 15 | 
            +
                fields.find { |f| f.id == @reflection.name }
         | 
| 15 16 | 
             
              rescue
         | 
| 16 17 | 
             
                nil
         | 
| 17 18 | 
             
              end
         | 
| @@ -21,7 +21,7 @@ | |
| 21 21 | 
             
                <div class="flex space-x-2">
         | 
| 22 22 | 
             
                  <div class="flex">
         | 
| 23 23 | 
             
                    <% if @resource.authorization.authorize_action(:download_attachments?, raise_exception: false) %>
         | 
| 24 | 
            -
                      <%= a_link  | 
| 24 | 
            +
                      <%= a_link file.url(disposition: :attachment),
         | 
| 25 25 | 
             
                        icon: 'heroicons/outline/download',
         | 
| 26 26 | 
             
                        color: :primary,
         | 
| 27 27 | 
             
                        download: true,
         | 
| @@ -4,7 +4,6 @@ class Avo::ResourceComponent < Avo::BaseComponent | |
| 4 4 | 
             
              attr_reader :has_many_panels
         | 
| 5 5 | 
             
              attr_reader :has_as_belongs_to_many_panels
         | 
| 6 6 | 
             
              attr_reader :resource_tools
         | 
| 7 | 
            -
              attr_reader :resource
         | 
| 8 7 | 
             
              attr_reader :view
         | 
| 9 8 |  | 
| 10 9 | 
             
              def can_create?
         | 
| @@ -20,7 +19,7 @@ class Avo::ResourceComponent < Avo::BaseComponent | |
| 20 19 | 
             
              end
         | 
| 21 20 |  | 
| 22 21 | 
             
              def can_detach?
         | 
| 23 | 
            -
                authorize_association_for( | 
| 22 | 
            +
                authorize_association_for("detach")
         | 
| 24 23 | 
             
              end
         | 
| 25 24 |  | 
| 26 25 | 
             
              def detach_path
         | 
| @@ -54,7 +53,7 @@ class Avo::ResourceComponent < Avo::BaseComponent | |
| 54 53 |  | 
| 55 54 | 
             
                if @reflection.present?
         | 
| 56 55 | 
             
                  # Fetch the appropiate resource
         | 
| 57 | 
            -
                  reflection_resource =  | 
| 56 | 
            +
                  reflection_resource = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name)
         | 
| 58 57 | 
             
                  # Fetch the model
         | 
| 59 58 | 
             
                  # Hydrate the resource with the model if we have one
         | 
| 60 59 | 
             
                  reflection_resource.hydrate(model: @parent_model) if @parent_model.present?
         | 
| @@ -117,7 +117,11 @@ export default class extends Controller { | |
| 117 117 |  | 
| 118 118 | 
             
                flatpickr(this.fakeInputTarget, options)
         | 
| 119 119 |  | 
| 120 | 
            -
                 | 
| 120 | 
            +
                if (this.enableTimeValue) {
         | 
| 121 | 
            +
                  this.updateRealInput(this.parsedValue.setZone(this.displayTimezone).toISO())
         | 
| 122 | 
            +
                } else {
         | 
| 123 | 
            +
                  this.updateRealInput(universalTimestamp(this.initialValue))
         | 
| 124 | 
            +
                }
         | 
| 121 125 | 
             
              }
         | 
| 122 126 |  | 
| 123 127 | 
             
              onChange(selectedDates) {
         | 
    
        data/lib/avo/base_resource.rb
    CHANGED
    
    | @@ -20,6 +20,7 @@ module Avo | |
| 20 20 | 
             
                delegate :context, to: ::Avo::App
         | 
| 21 21 |  | 
| 22 22 | 
             
                attr_accessor :view
         | 
| 23 | 
            +
                attr_accessor :model
         | 
| 23 24 | 
             
                attr_accessor :reflection
         | 
| 24 25 | 
             
                attr_accessor :user
         | 
| 25 26 | 
             
                attr_accessor :params
         | 
| @@ -110,11 +111,6 @@ module Avo | |
| 110 111 | 
             
                  end
         | 
| 111 112 | 
             
                end
         | 
| 112 113 |  | 
| 113 | 
            -
                def record
         | 
| 114 | 
            -
                  @model
         | 
| 115 | 
            -
                end
         | 
| 116 | 
            -
                alias :model :record
         | 
| 117 | 
            -
             | 
| 118 114 | 
             
                def hydrate(model: nil, view: nil, user: nil, params: nil)
         | 
| 119 115 | 
             
                  @view = view if view.present?
         | 
| 120 116 | 
             
                  @user = user if user.present?
         | 
| @@ -51,15 +51,10 @@ module Avo | |
| 51 51 | 
             
                    #
         | 
| 52 52 | 
             
                    # get_resource_by_name('User') => UserResource
         | 
| 53 53 | 
             
                    # get_resource_by_name(User) => UserResource
         | 
| 54 | 
            -
                    def get_resource_by_model_name( | 
| 55 | 
            -
                      # Fetch the mappings imposed by the user.
         | 
| 56 | 
            -
                      # If they are present, use those ones.
         | 
| 57 | 
            -
                      mapping = get_mapping_for_model klass
         | 
| 58 | 
            -
                      return get_resource(mapping) if mapping.present?
         | 
| 59 | 
            -
             | 
| 54 | 
            +
                    def get_resource_by_model_name(name)
         | 
| 60 55 | 
             
                      valid_resources
         | 
| 61 56 | 
             
                        .find do |resource|
         | 
| 62 | 
            -
                          resource.model_class.model_name.name ==  | 
| 57 | 
            +
                          resource.model_class.model_name.name == name.to_s
         | 
| 63 58 | 
             
                        end
         | 
| 64 59 | 
             
                    end
         | 
| 65 60 |  | 
| @@ -133,12 +128,6 @@ module Avo | |
| 133 128 |  | 
| 134 129 | 
             
                      get_sidebar_partials
         | 
| 135 130 | 
             
                    end
         | 
| 136 | 
            -
             | 
| 137 | 
            -
                    private
         | 
| 138 | 
            -
             | 
| 139 | 
            -
                    def get_mapping_for_model(klass)
         | 
| 140 | 
            -
                      (Avo.configuration.model_resource_mapping || {}).stringify_keys.transform_values(&:to_s)[klass.to_s]
         | 
| 141 | 
            -
                    end
         | 
| 142 131 | 
             
                  end
         | 
| 143 132 | 
             
                end
         | 
| 144 133 | 
             
              end
         | 
    
        data/lib/avo/configuration.rb
    CHANGED
    
    | @@ -34,7 +34,6 @@ module Avo | |
| 34 34 | 
             
                attr_accessor :buttons_on_form_footers
         | 
| 35 35 | 
             
                attr_accessor :main_menu
         | 
| 36 36 | 
             
                attr_accessor :profile_menu
         | 
| 37 | 
            -
                attr_accessor :model_resource_mapping
         | 
| 38 37 |  | 
| 39 38 | 
             
                def initialize
         | 
| 40 39 | 
             
                  @root_path = "/avo"
         | 
| @@ -79,7 +78,6 @@ module Avo | |
| 79 78 | 
             
                  @buttons_on_form_footers = false
         | 
| 80 79 | 
             
                  @main_menu = nil
         | 
| 81 80 | 
             
                  @profile_menu = nil
         | 
| 82 | 
            -
                  @model_resource_mapping = {}
         | 
| 83 81 | 
             
                end
         | 
| 84 82 |  | 
| 85 83 | 
             
                def current_user_method(&block)
         | 
    
        data/lib/avo/version.rb
    CHANGED
    
    
| @@ -34,27 +34,25 @@ Avo.configure do |config| | |
| 34 34 | 
             
              ## == Localization ==
         | 
| 35 35 | 
             
              # config.locale = 'en-US'
         | 
| 36 36 |  | 
| 37 | 
            -
              ## == Resource options ==
         | 
| 38 | 
            -
              # config.resource_controls = :right
         | 
| 39 | 
            -
              # config.model_resource_mapping = {}
         | 
| 40 | 
            -
              # config.default_view_type = :table
         | 
| 41 | 
            -
              # config.per_page = 24
         | 
| 42 | 
            -
              # config.per_page_steps = [12, 24, 48, 72]
         | 
| 43 | 
            -
              # config.via_per_page = 8
         | 
| 44 | 
            -
              # config.id_links_to_resource = false
         | 
| 45 | 
            -
              # config.cache_resources_on_index_view = true
         | 
| 46 | 
            -
             | 
| 47 37 | 
             
              ## == Customization ==
         | 
| 48 38 | 
             
              # config.app_name = 'Avocadelicious'
         | 
| 49 39 | 
             
              # config.timezone = 'UTC'
         | 
| 50 40 | 
             
              # config.currency = 'USD'
         | 
| 41 | 
            +
              # config.per_page = 24
         | 
| 42 | 
            +
              # config.per_page_steps = [12, 24, 48, 72]
         | 
| 43 | 
            +
              # config.via_per_page = 8
         | 
| 44 | 
            +
              # config.default_view_type = :table
         | 
| 51 45 | 
             
              # config.hide_layout_when_printing = false
         | 
| 46 | 
            +
              # config.id_links_to_resource = false
         | 
| 52 47 | 
             
              # config.full_width_container = false
         | 
| 53 48 | 
             
              # config.full_width_index_view = false
         | 
| 49 | 
            +
              # config.cache_resources_on_index_view = true
         | 
| 54 50 | 
             
              # config.search_debounce = 300
         | 
| 55 51 | 
             
              # config.view_component_path = "app/components"
         | 
| 56 52 | 
             
              # config.display_license_request_timeout_error = true
         | 
| 57 53 | 
             
              # config.disabled_features = []
         | 
| 54 | 
            +
              # config.resource_controls = :right
         | 
| 55 | 
            +
             | 
| 58 56 |  | 
| 59 57 | 
             
              ## == Breadcrumbs ==
         | 
| 60 58 | 
             
              # config.display_breadcrumbs = true
         |