active_scaffold_vho 3.2.14 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c576f0fdb424066e52144dcec305c1c178ca4918
4
- data.tar.gz: 1bc3acea47c7574dd2734fb058743c0778d09987
3
+ metadata.gz: 16c43edc7915430121126d58256c1870f4c004d8
4
+ data.tar.gz: d5d5d3062d893e999c1d5f3a0d1e784a62754969
5
5
  SHA512:
6
- metadata.gz: a8b66e04ad0ee3cbbcb180a25c6f4810233cc52b43868512b390da0354e74bd128bbdaa0159c25c869b6c99c4cd6ae4bd0e20934de72a0ffc15a4ad9b3c92367
7
- data.tar.gz: 8aafbe16e23775702d32c62f2446af94ed9f38fb829ba3e9d043f11d7173ef4ea55fa7f5665dcf902fc4c114564b4440d111b130847ebba5cb7957d8415d287e
6
+ metadata.gz: 6cfcc4ed805ac16c9e7e0f11e8f0595a427d247e86ddad061fd588083a141270596400e80704dd422f977b4f07d9c2d527a1fcba0b1f051ac3a0ca456005ef94
7
+ data.tar.gz: d30b2830c55b320eb4a2c511f335954fddee15b3b62e91f64e034855412af80b6a10dd65cf5844ff562d2b3623a1a39d973ca19709a2cd5d8b4cc480031b61ce
data/Gemfile.lock CHANGED
@@ -1,98 +1,90 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_scaffold_vho (3.2.14)
4
+ active_scaffold_vho (4.0.0)
5
5
  kaminari
6
- rails (>= 3.1.0)
6
+ rails (~> 4.0.0)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionmailer (3.2.22.4)
12
- actionpack (= 3.2.22.4)
13
- mail (~> 2.5.4)
14
- actionpack (3.2.22.4)
15
- activemodel (= 3.2.22.4)
16
- activesupport (= 3.2.22.4)
17
- builder (~> 3.0.0)
11
+ actionmailer (4.0.13)
12
+ actionpack (= 4.0.13)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ actionpack (4.0.13)
15
+ activesupport (= 4.0.13)
16
+ builder (~> 3.1.0)
18
17
  erubis (~> 2.7.0)
19
- journey (~> 1.0.4)
20
- rack (~> 1.4.5)
21
- rack-cache (~> 1.2)
22
- rack-test (~> 0.6.1)
23
- sprockets (~> 2.2.1)
24
- activemodel (3.2.22.4)
25
- activesupport (= 3.2.22.4)
26
- builder (~> 3.0.0)
27
- activerecord (3.2.22.4)
28
- activemodel (= 3.2.22.4)
29
- activesupport (= 3.2.22.4)
30
- arel (~> 3.0.2)
31
- tzinfo (~> 0.3.29)
32
- activeresource (3.2.22.4)
33
- activemodel (= 3.2.22.4)
34
- activesupport (= 3.2.22.4)
35
- activesupport (3.2.22.4)
36
- i18n (~> 0.6, >= 0.6.4)
37
- multi_json (~> 1.0)
38
- arel (3.0.3)
39
- builder (3.0.4)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ activemodel (4.0.13)
21
+ activesupport (= 4.0.13)
22
+ builder (~> 3.1.0)
23
+ activerecord (4.0.13)
24
+ activemodel (= 4.0.13)
25
+ activerecord-deprecated_finders (~> 1.0.2)
26
+ activesupport (= 4.0.13)
27
+ arel (~> 4.0.0)
28
+ activerecord-deprecated_finders (1.0.4)
29
+ activesupport (4.0.13)
30
+ i18n (~> 0.6, >= 0.6.9)
31
+ minitest (~> 4.2)
32
+ multi_json (~> 1.3)
33
+ thread_safe (~> 0.1)
34
+ tzinfo (~> 0.3.37)
35
+ arel (4.0.2)
36
+ builder (3.1.4)
37
+ concurrent-ruby (1.0.2)
40
38
  docile (1.1.5)
41
39
  erubis (2.7.0)
42
- hike (1.2.3)
43
40
  i18n (0.7.0)
44
- journey (1.0.4)
45
- json (1.8.3)
46
41
  kaminari (0.17.0)
47
42
  actionpack (>= 3.0.0)
48
43
  activesupport (>= 3.0.0)
49
- mail (2.5.4)
50
- mime-types (~> 1.16)
51
- treetop (~> 1.4.8)
52
- mime-types (1.25.1)
44
+ mail (2.6.4)
45
+ mime-types (>= 1.16, < 4)
46
+ mime-types (3.1)
47
+ mime-types-data (~> 3.2015)
48
+ mime-types-data (3.2016.0521)
49
+ minitest (4.7.5)
53
50
  multi_json (1.12.1)
54
- polyglot (0.3.5)
55
- rack (1.4.7)
56
- rack-cache (1.6.1)
57
- rack (>= 0.4)
58
- rack-ssl (1.3.4)
59
- rack
51
+ rack (1.5.5)
60
52
  rack-test (0.6.3)
61
53
  rack (>= 1.0)
62
- rails (3.2.22.4)
63
- actionmailer (= 3.2.22.4)
64
- actionpack (= 3.2.22.4)
65
- activerecord (= 3.2.22.4)
66
- activeresource (= 3.2.22.4)
67
- activesupport (= 3.2.22.4)
68
- bundler (~> 1.0)
69
- railties (= 3.2.22.4)
70
- railties (3.2.22.4)
71
- actionpack (= 3.2.22.4)
72
- activesupport (= 3.2.22.4)
73
- rack-ssl (~> 1.3.2)
54
+ rails (4.0.13)
55
+ actionmailer (= 4.0.13)
56
+ actionpack (= 4.0.13)
57
+ activerecord (= 4.0.13)
58
+ activesupport (= 4.0.13)
59
+ bundler (>= 1.3.0, < 2.0)
60
+ railties (= 4.0.13)
61
+ sprockets-rails (~> 2.0)
62
+ railties (4.0.13)
63
+ actionpack (= 4.0.13)
64
+ activesupport (= 4.0.13)
74
65
  rake (>= 0.8.7)
75
- rdoc (~> 3.4)
76
- thor (>= 0.14.6, < 2.0)
66
+ thor (>= 0.18.1, < 2.0)
77
67
  rake (11.2.2)
78
- rdoc (3.12.2)
79
- json (~> 1.4)
80
- shoulda (2.11.3)
68
+ shoulda (3.5.0)
69
+ shoulda-context (~> 1.0, >= 1.0.1)
70
+ shoulda-matchers (>= 1.4.1, < 3.0)
71
+ shoulda-context (1.2.1)
72
+ shoulda-matchers (2.8.0)
73
+ activesupport (>= 3.0.0)
81
74
  simplecov (0.9.2)
82
75
  docile (~> 1.1.0)
83
76
  multi_json (~> 1.0)
84
77
  simplecov-html (~> 0.9.0)
85
78
  simplecov-html (0.9.0)
86
- sprockets (2.2.3)
87
- hike (~> 1.2)
88
- multi_json (~> 1.0)
89
- rack (~> 1.0)
90
- tilt (~> 1.1, != 1.3.0)
79
+ sprockets (3.7.0)
80
+ concurrent-ruby (~> 1.0)
81
+ rack (> 1, < 3)
82
+ sprockets-rails (2.3.3)
83
+ actionpack (>= 3.0)
84
+ activesupport (>= 3.0)
85
+ sprockets (>= 2.8, < 4.0)
91
86
  thor (0.19.1)
92
- tilt (1.4.1)
93
- treetop (1.4.15)
94
- polyglot
95
- polyglot (>= 0.3.1)
87
+ thread_safe (0.3.5)
96
88
  tzinfo (0.3.51)
97
89
 
98
90
  PLATFORMS
@@ -26,6 +26,6 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
27
27
  s.add_development_dependency(%q<simplecov>, ["~> 0.9.0"])
28
28
 
29
- s.add_runtime_dependency(%q<rails>, [">= 3.1.0"])
29
+ s.add_runtime_dependency(%q<rails>, ["~> 4.0.0"])
30
30
  s.add_runtime_dependency(%q<kaminari>)
31
31
  end
@@ -1,6 +1,6 @@
1
1
  <%
2
2
  parent_record = @record
3
- associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).all
3
+ associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).to_a
4
4
  associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order)
5
5
  if column.show_blank_record? associated
6
6
  associated << if column.singular_association?
@@ -1,5 +1,5 @@
1
1
  <%
2
- record = list_record if list_record # compat with render :partial :collection
2
+ record = list_record if local_assigns[:list_record] # compat with render :partial :collection
3
3
  columns ||= list_columns
4
4
  tr_class = cycle("", "even-record")
5
5
  tr_class += " #{list_row_class(record)}" if respond_to? :list_row_class
@@ -1,7 +1,3 @@
1
- unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 0
2
- raise "This version of ActiveScaffold requires Rails 3.0 or higher. Please use an earlier version."
3
- end
4
-
5
1
  begin
6
2
  require 'render_component'
7
3
  rescue LoadError
@@ -189,7 +185,11 @@ module ActiveScaffold
189
185
 
190
186
  # defines the attribute read methods on the model, so record.send() doesn't find protected/private methods instead
191
187
  klass = self.active_scaffold_config.model
192
- klass.define_attribute_methods unless klass.attribute_methods_generated?
188
+
189
+ if !klass.respond_to?(:attribute_methods_generated) || !klass.attribute_methods_generated?
190
+ klass.define_attribute_methods
191
+ end
192
+
193
193
  # include the rest of the code into the controller: the action core and the included actions
194
194
  module_eval do
195
195
  include ActiveScaffold::Finder
@@ -96,13 +96,14 @@ module ActiveScaffold::Actions
96
96
 
97
97
  def each_record_in_scope
98
98
  do_search if respond_to? :do_search, true
99
- finder_options = { :order => "#{active_scaffold_config.model.connection.quote_table_name(active_scaffold_config.model.table_name)}.#{active_scaffold_config.model.primary_key} ASC",
100
- :conditions => all_conditions,
101
- :joins => joins_for_finder}
99
+ finder_options = { :reorder => "#{active_scaffold_config.model.connection.quote_table_name(active_scaffold_config.model.table_name)}.#{active_scaffold_config.model.primary_key} ASC",
100
+ :where => all_conditions,
101
+ :joins => joins_for_finder}
102
102
  finder_options.merge! custom_finder_options
103
- finder_options.merge! :include => (active_scaffold_includes.blank? ? nil : active_scaffold_includes)
103
+ finder_options.merge! :includes => (active_scaffold_includes.blank? ? nil : active_scaffold_includes)
104
104
  klass = beginning_of_chain
105
- klass.all(finder_options).each {|record| yield record}
105
+ append_to_query(klass, finder_options)
106
+ klass.find_each {|record| yield record}
106
107
  end
107
108
 
108
109
  # The default security delegates to ActiveRecordPermissions.
@@ -144,7 +144,7 @@ module ActiveScaffold
144
144
 
145
145
  def column_plural_assocation_value_from_value(column, value)
146
146
  # it's an array of ids
147
- if value and not value.empty?
147
+ if value && !value.empty?
148
148
  ids = value.select {|id| id.respond_to?(:empty?) ? !id.empty? : true}
149
149
  ids.empty? ? [] : column.association.klass.find(ids)
150
150
  end
@@ -1,5 +1,5 @@
1
- include Sprockets::Helpers::RailsHelper
2
- include Sprockets::Helpers::IsolatedHelper
1
+ #include Sprockets::Helpers::RailsHelper
2
+ #include Sprockets::Helpers::IsolatedHelper
3
3
 
4
4
  class File #:nodoc:
5
5
 
@@ -4,7 +4,7 @@ module ActionView
4
4
  # activescaffolds view path do not have a subdir, so just remove the prefix
5
5
  # > rails 3.2.22 uses an additional fifth parameter
6
6
  def find_templates(name, prefix, partial, details, outside_app_allowed = false)
7
- if ::Rails::VERSION::MAJOR >= 4 || (::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR == 2 && ::Rails::VERSION::TINY >= 22)
7
+ if (::Rails::VERSION::MAJOR >= 4 && ::Rails::VERSION::MINOR > 0) || (::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR == 2 && ::Rails::VERSION::TINY >= 22)
8
8
  super(name,'',partial, details, outside_app_allowed)
9
9
  else
10
10
  super(name,'',partial, details)
@@ -1,12 +1,18 @@
1
- module ActionView
2
- module Helpers
3
- class InstanceTag
4
- private
5
- def datetime_selector_with_name(options, html_options)
6
- options.merge!(:prefix => options[:name].gsub(/\[[^\[]*\]$/,'')) if options[:name]
7
- datetime_selector_without_name(options, html_options)
1
+ module ActiveScaffold
2
+ module DateSelectExtension
3
+ def datetime_selector_with_name(options, html_options)
4
+ options.merge!(:prefix => options[:name].gsub(/\[[^\[]*\]$/,'')) if options[:name]
5
+ datetime_selector_without_name(options, html_options)
6
+ end
7
+
8
+ def self.included(base)
9
+ base.class_eval do
10
+ alias_method_chain :datetime_selector, :name
11
+ private :datetime_selector_without_name, :datetime_selector_with_name, :datetime_selector
8
12
  end
9
- alias_method_chain :datetime_selector, :name
10
13
  end
11
14
  end
12
15
  end
16
+ (defined?(ActionView::Helpers::Tags::DateSelect) ? ActionView::Helpers::Tags::DateSelect : ActionView::Helpers::InstanceTag).class_eval do
17
+ include ActiveScaffold::DateSelectExtension
18
+ end
@@ -48,9 +48,9 @@ class ActiveRecord::Base
48
48
  # returns true otherwise, even when none of the associations have been instantiated. build wrapper methods accordingly.
49
49
  def with_unsaved_associated
50
50
  associations_for_update.all? do |association|
51
- association_proxy = send(association.name)
52
- if association_proxy
53
- records = association_proxy
51
+ association_proxy = self.association(association.name)
52
+ if association_proxy.target.present?
53
+ records = association_proxy.target
54
54
  records = [records] unless records.is_a? Array # convert singular associations into collections for ease of use
55
55
  records.select {|r| r.unsaved? and not r.readonly?}.all? {|r| yield r} # must use select instead of find_all, which Rails overrides on association proxies for db access
56
56
  else
@@ -1,5 +1,11 @@
1
1
  module ActiveScaffold
2
2
  module Finder
3
+
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ helper_method :append_to_query
7
+ end
8
+
3
9
  def self.like_operator
4
10
  @@like_operator ||= ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
5
11
  end
@@ -214,12 +220,6 @@ module ActiveScaffold
214
220
  :null,
215
221
  :not_null
216
222
  ]
217
-
218
-
219
-
220
- def self.included(klass)
221
- klass.extend ClassMethods
222
- end
223
223
 
224
224
  protected
225
225
 
@@ -286,7 +286,7 @@ module ActiveScaffold
286
286
 
287
287
  # we build the paginator differently for method- and sql-based sorting
288
288
  records = if options[:sorting] && options[:sorting].sorts_by_method?
289
- Kaminari.paginate_array(sort_collection_by_column(append_to_query(klass, finder_options).all, *options[:sorting].first))
289
+ Kaminari.paginate_array(sort_collection_by_column(append_to_query(klass, finder_options).to_a, *options[:sorting].first))
290
290
  else
291
291
  append_to_query(klass, finder_options)
292
292
  end
@@ -94,7 +94,7 @@ module ActiveScaffold
94
94
  options = active_scaffold_input_text_options(options) if text_types.include?(column.column.type)
95
95
  if column.column.type == :string && options[:maxlength].blank?
96
96
  options[:maxlength] = column.column.limit
97
- options[:size] ||= ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"]
97
+ options[:size] ||= options[:maxlength].to_i > 30 ? 30 : options[:maxlength]
98
98
  end
99
99
  options[:include_blank] = true if column.column.null and [:date, :datetime, :time].include?(column.column.type)
100
100
  options[:value] = format_number_value(@record.send(column.name), column.options) if column.column.number?
@@ -212,7 +212,8 @@ module ActiveScaffold
212
212
  record_select_options = {:controller => remote_controller, :id => options[:id]}
213
213
  record_select_options.merge!(active_scaffold_input_text_options)
214
214
  record_select_options.merge!(column.options)
215
- record_select_options[:size] ||= ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"]
215
+
216
+ record_select_options[:size] ||= ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"] unless defined?(ActionView::Helpers::Tags::DateSelect)
216
217
 
217
218
  unless options['data-update_url'].nil?
218
219
  record_select_options['data-update_url'] = options['data-update_url']
@@ -359,7 +360,7 @@ module ActiveScaffold
359
360
  record_select_field(options[:name], @record, options)
360
361
  else
361
362
  select_options = options_for_select(options_for_association(nested.association)) #unless column.through_association?
362
- select_options ||= options_for_select(active_scaffold_config.model.all.collect {|c| [h(c.to_label), c.id]})
363
+ select_options ||= options_for_select(active_scaffold_config.model.to_a.collect {|c| [h(c.to_label), c.id]})
363
364
  select_tag 'associated_id', ('<option value="">' + as_(:_select_) + '</option>' + select_options).html_safe unless select_options.empty?
364
365
  end
365
366
  end
@@ -16,7 +16,7 @@ module ActiveScaffold
16
16
  when :integer, :decimal, :float
17
17
  "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{format_number_value(controller.class.condition_value_for_numeric(column, value[:from]), column.options)} #{value[:opt] == 'BETWEEN' ? '- ' + format_number_value(controller.class.condition_value_for_numeric(column, value[:to]), column.options).to_s : ''}"
18
18
  when :string
19
- opt = ActiveScaffold::Finder::StringComparators.index(value[:opt]) || value[:opt]
19
+ opt = ActiveScaffold::Finder::StringComparators.key(value[:opt]) || value[:opt]
20
20
  "#{column.active_record_class.human_attribute_name(column.name)} #{as_(opt).downcase} '#{column.stripped_value(value[:from])}' #{opt == 'BETWEEN' ? '- ' + column.stripped_value(value[:to]).to_s : ''}"
21
21
  when :date, :time, :datetime, :timestamp
22
22
  conversion = column.column.type == :date ? :to_date : :to_time
@@ -102,21 +102,21 @@ module ActiveScaffold
102
102
  end
103
103
 
104
104
  # There are two basic ways to clean a column's value: h() and sanitize(). The latter is useful
105
- # when the column contains *valid* html data, and you want to just disable any scripting. People
106
- # can always use field overrides to clean data one way or the other, but having this override
107
- # lets people decide which way it should happen by default.
108
- #
109
- # Why is it not a configuration option? Because it seems like a somewhat rare request. But it
110
- # could eventually be an option in config.list (and config.show, I guess).
111
- def clean_column_value(v)
112
- h(v)
105
+ # when the column contains *valid* html data, and you want to just disable any scripting.
106
+ # if sanitize_value key is passed to this function sanitize will be used
107
+ def clean_column_value(v, options = {})
108
+ if (options[:sanitize_value].present?)
109
+ sanitize(v)
110
+ else
111
+ h(v)
112
+ end
113
113
  end
114
114
 
115
115
  ##
116
116
  ## Overrides
117
117
  ##
118
118
  def active_scaffold_column_text(column, record)
119
- truncate(clean_column_value(record.send(column.name)), :length => column.options[:truncate] || 50)
119
+ truncate(clean_column_value(record.send(column.name), column.options), :length => column.options[:truncate] || 50)
120
120
  end
121
121
 
122
122
  def active_scaffold_column_select(column, record)
@@ -236,7 +236,7 @@ module ActiveScaffold
236
236
  else
237
237
  column_value.to_s
238
238
  end
239
- clean_column_value(value)
239
+ clean_column_value(value, options)
240
240
  end
241
241
 
242
242
  def cache_association(value, column)
@@ -301,8 +301,12 @@ module ActiveScaffold
301
301
  conditions = controller.send(:all_conditions)
302
302
  includes = active_scaffold_config.list.count_includes
303
303
  includes ||= controller.send(:active_scaffold_includes) unless conditions.nil?
304
- calculation = beginning_of_chain.calculate(column.calculate, column.name, :conditions => conditions,
305
- :joins => controller.send(:joins_for_collection), :include => includes)
304
+ calculation_scope = beginning_of_chain
305
+ append_to_query(calculation_scope, {
306
+ :where => conditions,
307
+ :joins => controller.send(:joins_for_collection),
308
+ :includes => includes})
309
+ calculation_scope.calculate(column.calculate, column.name)
306
310
  else
307
311
  column.calculate.call(@records)
308
312
  end
@@ -1,10 +1,10 @@
1
1
  module ActiveScaffold
2
2
  module MarkedModel
3
3
  # This is a module aimed at making the make session_stored marked_records available to ActiveRecord models
4
-
5
- def self.included(base)
6
- base.extend ClassMethods
7
- base.scope :marked, lambda {{:conditions => {:id => base.marked_records.to_a}}}
4
+
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ scope :marked, -> { where(primary_key => marked_records.to_a)}
8
8
  end
9
9
 
10
10
  def marked
@@ -1,8 +1,8 @@
1
1
  module ActiveScaffold
2
2
  module Version
3
- MAJOR = 3
4
- MINOR = 2
5
- PATCH = 14
3
+ MAJOR = 4
4
+ MINOR = 0
5
+ PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_vho
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.14
4
+ version: 4.0.0
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: 2016-08-13 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 3.1.0
61
+ version: 4.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 3.1.0
68
+ version: 4.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: kaminari
71
71
  requirement: !ruby/object:Gem::Requirement