active_scaffold 3.6.17 → 3.6.20
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.rdoc +12 -1
 - data/lib/active_scaffold/actions/common_search.rb +16 -0
 - data/lib/active_scaffold/actions/core.rb +1 -2
 - data/lib/active_scaffold/actions/field_search.rb +5 -9
 - data/lib/active_scaffold/actions/nested.rb +10 -5
 - data/lib/active_scaffold/actions/search.rb +1 -6
 - data/lib/active_scaffold/data_structures/column.rb +0 -1
 - data/lib/active_scaffold/data_structures/nested_info.rb +9 -1
 - data/lib/active_scaffold/finder.rb +1 -1
 - data/lib/active_scaffold/tableless.rb +3 -2
 - data/lib/active_scaffold/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5a6a07cc017cbfdb8a278a7297ac61d6e6d4f3802240a157a366b2829cf3661e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 00d4f1bcbacca4e2a04f87db162be697ebd82f73aae9b23dbd1ffd3e43614610
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 78f5e7472c1cbb36fd40c6f0a3b06f797e87e2969127d5506eee6f7b25d1f2b794c35684f477b1204e08d9c2c696b78c3c849b481d3b43c169ecf16b7f99c0f6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 98f6fed6e5ac8512b74e27155285c0b81f0cd422e0cfbab3f0a01ba5e4a9e92a32cb8f4a199ef8118e71aceb188f9137e5d8bed48bc9ee0903ad420b92e771b5
         
     | 
    
        data/CHANGELOG.rdoc
    CHANGED
    
    | 
         @@ -1,3 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = 3.6.20
         
     | 
| 
      
 2 
     | 
    
         
            +
            - Fix numeric search on field search for rails >= 5.0
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            = 3.6.19
         
     | 
| 
      
 5 
     | 
    
         
            +
            - Improve create action in has_many through singular association, supporting more cases
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            = 3.6.18
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Add references only for column.search_joins which are in column.includes, and do search_joins for the rest, search_joins default to includes, so won't change behaviour on most cases, but allows to preload some associations without joining in the query
         
     | 
| 
      
 9 
     | 
    
         
            +
            - Don't define default search_joins, as it may return includes, so search_joins will default to includes unless is defined, and the previous change won't change the behaviour if user doesn't define search_joins
         
     | 
| 
      
 10 
     | 
    
         
            +
            - Fix update_columns on through association
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       1 
12 
     | 
    
         
             
            = 3.6.17
         
     | 
| 
       2 
13 
     | 
    
         
             
            - Don't add includes or left joins for constrained columns, as they are ignored on sorting clause
         
     | 
| 
       3 
14 
     | 
    
         
             
            - Fix deprecation on cache counts with rails 5, and fix the queries for rails >= 5.1
         
     | 
| 
         @@ -73,7 +84,7 @@ 
     | 
|
| 
       73 
84 
     | 
    
         
             
            = 3.6.1
         
     | 
| 
       74 
85 
     | 
    
         
             
            - Display group cols vertically when subform layout is vertical
         
     | 
| 
       75 
86 
     | 
    
         
             
            - Fix html attributes for input datetime on field search, when jquery ui is not used
         
     | 
| 
       76 
     | 
    
         
            -
            - Fix constraint columns for nested list on through  
     | 
| 
      
 87 
     | 
    
         
            +
            - Fix constraint columns for nested list on through associations
         
     | 
| 
       77 
88 
     | 
    
         
             
            - Support rails 6.1
         
     | 
| 
       78 
89 
     | 
    
         | 
| 
       79 
90 
     | 
    
         
             
            = 3.6.0
         
     | 
| 
         @@ -31,6 +31,22 @@ module ActiveScaffold::Actions 
     | 
|
| 
       31 
31 
     | 
    
         
             
                    params_hash params[:search]
         
     | 
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
      
 34 
     | 
    
         
            +
                  def set_outer_joins_for_search(columns)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    references = []
         
     | 
| 
      
 36 
     | 
    
         
            +
                    outer_joins = []
         
     | 
| 
      
 37 
     | 
    
         
            +
                    columns.each do |column|
         
     | 
| 
      
 38 
     | 
    
         
            +
                      next unless column.search_joins.present?
         
     | 
| 
      
 39 
     | 
    
         
            +
                      if column.includes.present? && list_columns.include?(column)
         
     | 
| 
      
 40 
     | 
    
         
            +
                        references << (column.search_joins & column.includes)
         
     | 
| 
      
 41 
     | 
    
         
            +
                        outer_joins << (column.search_joins - column.includes)
         
     | 
| 
      
 42 
     | 
    
         
            +
                      else
         
     | 
| 
      
 43 
     | 
    
         
            +
                        outer_joins << column.search_joins
         
     | 
| 
      
 44 
     | 
    
         
            +
                      end
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
                    active_scaffold_references.concat references.flatten.uniq.compact
         
     | 
| 
      
 47 
     | 
    
         
            +
                    active_scaffold_outer_joins.concat outer_joins.flatten.uniq.compact
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       34 
50 
     | 
    
         
             
                  def store_search_params_into_session
         
     | 
| 
       35 
51 
     | 
    
         
             
                    if active_scaffold_config.store_user_settings
         
     | 
| 
       36 
52 
     | 
    
         
             
                      if params[:search].present?
         
     | 
| 
         @@ -100,8 +100,7 @@ module ActiveScaffold::Actions 
     | 
|
| 
       100 
100 
     | 
    
         
             
                  record = params[:id] ? copy_attributes(find_if_allowed(params[:id], :read)) : new_model
         
     | 
| 
       101 
101 
     | 
    
         
             
                  apply_constraints_to_record(record) unless scope || params[:id]
         
     | 
| 
       102 
102 
     | 
    
         
             
                  create_association_with_parent record, true if nested?
         
     | 
| 
       103 
     | 
    
         
            -
                   
     | 
| 
       104 
     | 
    
         
            -
                  record.send "#{column.name}=", value
         
     | 
| 
      
 103 
     | 
    
         
            +
                  update_column_from_params(record, column, value, true)
         
     | 
| 
       105 
104 
     | 
    
         
             
                  record.id = params[:id]
         
     | 
| 
       106 
105 
     | 
    
         
             
                  record
         
     | 
| 
       107 
106 
     | 
    
         
             
                end
         
     | 
| 
         @@ -161,10 +161,14 @@ module ActiveScaffold::Actions 
     | 
|
| 
       161 
161 
     | 
    
         
             
                      search_condition = self.class.condition_for_column(column, value, text_search)
         
     | 
| 
       162 
162 
     | 
    
         
             
                      next if search_condition.blank?
         
     | 
| 
       163 
163 
     | 
    
         | 
| 
       164 
     | 
    
         
            -
                      joins_for_search_on_column(column, count_includes)
         
     | 
| 
       165 
164 
     | 
    
         
             
                      active_scaffold_conditions << search_condition
         
     | 
| 
       166 
165 
     | 
    
         
             
                      filtered_columns << column
         
     | 
| 
       167 
166 
     | 
    
         
             
                    end
         
     | 
| 
      
 167 
     | 
    
         
            +
                    if grouped_search? || active_scaffold_config.list.user.count_includes.present?
         
     | 
| 
      
 168 
     | 
    
         
            +
                      active_scaffold_outer_joins.concat filtered_columns.map(&:search_joins).flatten.uniq.compact
         
     | 
| 
      
 169 
     | 
    
         
            +
                    else
         
     | 
| 
      
 170 
     | 
    
         
            +
                      set_outer_joins_for_search filtered_columns
         
     | 
| 
      
 171 
     | 
    
         
            +
                    end
         
     | 
| 
       168 
172 
     | 
    
         
             
                    if filtered_columns.present? || grouped_search?
         
     | 
| 
       169 
173 
     | 
    
         
             
                      @filtered = active_scaffold_config.field_search.human_conditions ? filtered_columns : true
         
     | 
| 
       170 
174 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -172,14 +176,6 @@ module ActiveScaffold::Actions 
     | 
|
| 
       172 
176 
     | 
    
         
             
                    active_scaffold_config.list.user.page = nil
         
     | 
| 
       173 
177 
     | 
    
         
             
                  end
         
     | 
| 
       174 
178 
     | 
    
         | 
| 
       175 
     | 
    
         
            -
                  def joins_for_search_on_column(column, count_includes)
         
     | 
| 
       176 
     | 
    
         
            -
                    if count_includes.nil? && column.includes.present? && list_columns.include?(column) && !grouped_search?
         
     | 
| 
       177 
     | 
    
         
            -
                      active_scaffold_references << column.includes
         
     | 
| 
       178 
     | 
    
         
            -
                    elsif column.search_joins.present?
         
     | 
| 
       179 
     | 
    
         
            -
                      active_scaffold_outer_joins << column.search_joins
         
     | 
| 
       180 
     | 
    
         
            -
                    end
         
     | 
| 
       181 
     | 
    
         
            -
                  end
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
179 
     | 
    
         
             
                  def field_search_ignore?
         
     | 
| 
       184 
180 
     | 
    
         
             
                    active_scaffold_config.list.always_show_search && active_scaffold_config.list.search_partial == 'field_search'
         
     | 
| 
       185 
181 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -122,16 +122,21 @@ module ActiveScaffold::Actions 
     | 
|
| 
       122 
122 
     | 
    
         
             
                  # has_many is done by beginning_of_chain and rails if direct association, not in through associations
         
     | 
| 
       123 
123 
     | 
    
         
             
                  return false if nested.has_many? && !nested.association.through?
         
     | 
| 
       124 
124 
     | 
    
         
             
                  return false if check_match && !nested.match_model?(active_scaffold_config.model)
         
     | 
| 
       125 
     | 
    
         
            -
                  nested.child_association && nested_parent_record
         
     | 
| 
      
 125 
     | 
    
         
            +
                  (nested.child_association || nested.create_through_singular?) && nested_parent_record
         
     | 
| 
       126 
126 
     | 
    
         
             
                end
         
     | 
| 
       127 
127 
     | 
    
         | 
| 
       128 
128 
     | 
    
         
             
                def create_association_with_parent(record, check_match = false)
         
     | 
| 
       129 
129 
     | 
    
         
             
                  return unless create_association_with_parent?(check_match)
         
     | 
| 
       130 
     | 
    
         
            -
                  if nested.child_association 
     | 
| 
      
 130 
     | 
    
         
            +
                  if nested.child_association&.singular?
         
     | 
| 
       131 
131 
     | 
    
         
             
                    record.send("#{nested.child_association.name}=", nested_parent_record)
         
     | 
| 
       132 
     | 
    
         
            -
                  elsif nested. 
     | 
| 
       133 
     | 
    
         
            -
                    through = nested_parent_record.send(nested.association.through_reflection.name)
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
      
 132 
     | 
    
         
            +
                  elsif nested.create_through_singular?
         
     | 
| 
      
 133 
     | 
    
         
            +
                    through = nested_parent_record.send(nested.association.through_reflection.name) ||
         
     | 
| 
      
 134 
     | 
    
         
            +
                      nested_parent_record.send("build_#{nested.association.through_reflection.name}")
         
     | 
| 
      
 135 
     | 
    
         
            +
                    if nested.source_reflection.reverse_association.collection?
         
     | 
| 
      
 136 
     | 
    
         
            +
                      record.send(nested.source_reflection.reverse) << through
         
     | 
| 
      
 137 
     | 
    
         
            +
                    else
         
     | 
| 
      
 138 
     | 
    
         
            +
                      record.send("#{nested.source_reflection.reverse}=", through)
         
     | 
| 
      
 139 
     | 
    
         
            +
                    end
         
     | 
| 
       135 
140 
     | 
    
         
             
                  else
         
     | 
| 
       136 
141 
     | 
    
         
             
                    record.send(nested.child_association.name) << nested_parent_record
         
     | 
| 
       137 
142 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -26,12 +26,7 @@ module ActiveScaffold::Actions 
     | 
|
| 
       26 
26 
     | 
    
         
             
                      @filtered = search_conditions.present?
         
     | 
| 
       27 
27 
     | 
    
         
             
                      active_scaffold_conditions.concat search_conditions if @filtered
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                       
     | 
| 
       30 
     | 
    
         
            -
                        column.includes.present? && list_columns.include?(column)
         
     | 
| 
       31 
     | 
    
         
            -
                      end
         
     | 
| 
       32 
     | 
    
         
            -
                      active_scaffold_references.concat references.map(&:includes).flatten.uniq.compact
         
     | 
| 
       33 
     | 
    
         
            -
                      active_scaffold_outer_joins.concat outer_joins.map(&:search_joins).flatten.uniq.compact
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
                      set_outer_joins_for_search columns
         
     | 
| 
       35 
30 
     | 
    
         
             
                      active_scaffold_config.list.user.page = nil
         
     | 
| 
       36 
31 
     | 
    
         
             
                    else
         
     | 
| 
       37 
32 
     | 
    
         
             
                      super
         
     | 
| 
         @@ -353,7 +353,6 @@ module ActiveScaffold::DataStructures 
     | 
|
| 
       353 
353 
     | 
    
         
             
                  if delegated_association
         
     | 
| 
       354 
354 
     | 
    
         
             
                    self.includes = includes ? [delegated_association.name => includes] : [delegated_association.name]
         
     | 
| 
       355 
355 
     | 
    
         
             
                  end
         
     | 
| 
       356 
     | 
    
         
            -
                  self.search_joins = includes.clone if includes
         
     | 
| 
       357 
356 
     | 
    
         | 
| 
       358 
357 
     | 
    
         
             
                  # default all the configurable variables
         
     | 
| 
       359 
358 
     | 
    
         
             
                  self.css_class = ''
         
     | 
| 
         @@ -94,12 +94,20 @@ module ActiveScaffold::DataStructures 
     | 
|
| 
       94 
94 
     | 
    
         
             
                  return false unless through_association?
         
     | 
| 
       95 
95 
     | 
    
         
             
                  return true if association.through_reflection.options[:through] # create not possible, too many levels
         
     | 
| 
       96 
96 
     | 
    
         
             
                  return true if association.source_reflection.options[:through] # create not possible, too many levels
         
     | 
| 
       97 
     | 
    
         
            -
                  return false if  
     | 
| 
      
 97 
     | 
    
         
            +
                  return false if create_through_singular? # create allowed, AS has code for this
         
     | 
| 
       98 
98 
     | 
    
         | 
| 
       99 
99 
     | 
    
         
             
                  # create allowed only if through reflection in record to be created is included in create columns
         
     | 
| 
       100 
100 
     | 
    
         
             
                  !child_association || !columns.include?(child_association.through_reflection.name)
         
     | 
| 
       101 
101 
     | 
    
         
             
                end
         
     | 
| 
       102 
102 
     | 
    
         | 
| 
      
 103 
     | 
    
         
            +
                def create_through_singular?
         
     | 
| 
      
 104 
     | 
    
         
            +
                  association.through_singular? && source_reflection.reverse
         
     | 
| 
      
 105 
     | 
    
         
            +
                end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                def source_reflection
         
     | 
| 
      
 108 
     | 
    
         
            +
                  @source_reflection ||= ActiveScaffold::DataStructures::Association::ActiveRecord.new(association.source_reflection)
         
     | 
| 
      
 109 
     | 
    
         
            +
                end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
       103 
111 
     | 
    
         
             
                def through_association?
         
     | 
| 
       104 
112 
     | 
    
         
             
                  association.through?
         
     | 
| 
       105 
113 
     | 
    
         
             
                end
         
     | 
| 
         @@ -297,7 +297,7 @@ module ActiveScaffold 
     | 
|
| 
       297 
297 
     | 
    
         
             
                      end
         
     | 
| 
       298 
298 
     | 
    
         
             
                    when :float     then value.to_f
         
     | 
| 
       299 
299 
     | 
    
         
             
                    when :decimal
         
     | 
| 
       300 
     | 
    
         
            -
                      ::ActiveRecord::Type::Decimal.new.type_cast_from_user 
     | 
| 
      
 300 
     | 
    
         
            +
                      ::ActiveRecord::Type::Decimal.new.send(Rails.version < '5.0' ? :type_cast_from_user : :cast, value)
         
     | 
| 
       301 
301 
     | 
    
         
             
                    else
         
     | 
| 
       302 
302 
     | 
    
         
             
                      value
         
     | 
| 
       303 
303 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -78,7 +78,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App 
     | 
|
| 
       78 
78 
     | 
    
         
             
                      class << scope; include RelationExtension; end
         
     | 
| 
       79 
79 
     | 
    
         
             
                      assoc_conditions = scope.proxy_association&.send(:association_scope)&.conditions
         
     | 
| 
       80 
80 
     | 
    
         
             
                      if assoc_conditions&.present?
         
     | 
| 
       81 
     | 
    
         
            -
                        scope.conditions.concat 
     | 
| 
      
 81 
     | 
    
         
            +
                        scope.conditions.concat(assoc_conditions.map { |c| c.is_a?(Hash) ? c[klass.table_name] || c : c })
         
     | 
| 
       82 
82 
     | 
    
         
             
                      end
         
     | 
| 
       83 
83 
     | 
    
         
             
                    end
         
     | 
| 
       84 
84 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -167,10 +167,11 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App 
     | 
|
| 
       167 
167 
     | 
    
         
             
                end
         
     | 
| 
       168 
168 
     | 
    
         | 
| 
       169 
169 
     | 
    
         
             
                def exists?
         
     | 
| 
       170 
     | 
    
         
            -
                  size 
     | 
| 
      
 170 
     | 
    
         
            +
                  size.positive?
         
     | 
| 
       171 
171 
     | 
    
         
             
                end
         
     | 
| 
       172 
172 
     | 
    
         | 
| 
       173 
173 
     | 
    
         
             
                private
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
       174 
175 
     | 
    
         
             
                def exec_queries
         
     | 
| 
       175 
176 
     | 
    
         
             
                  @records = @klass.find_all(self)
         
     | 
| 
       176 
177 
     | 
    
         
             
                  @loaded = true
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: active_scaffold
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 3.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.6.20
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Many, see README
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-07-05 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -477,7 +477,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       477 
477 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       478 
478 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       479 
479 
     | 
    
         
             
            requirements: []
         
     | 
| 
       480 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 480 
     | 
    
         
            +
            rubygems_version: 3.2.3
         
     | 
| 
       481 
481 
     | 
    
         
             
            signing_key:
         
     | 
| 
       482 
482 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       483 
483 
     | 
    
         
             
            summary: Rails 4.x and 5.x versions of ActiveScaffold supporting prototype and jquery
         
     |