active_scaffold 3.4.33 → 3.4.34

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: 60cdf903df7b52febfb72af4ada25aa1dde35832
4
- data.tar.gz: f91b93961a06dc90b8f637a377e0e1c766086b8b
3
+ metadata.gz: 5831aedbc0ccb79952a771522d0a768fdf0162cd
4
+ data.tar.gz: 49eae4e8f8fa5aaf500b3217fbc9581379904131
5
5
  SHA512:
6
- metadata.gz: 3fbd34b94bbf32f7bce0acf7473eebe3a95969a184eb6a5144c0962edc13dd36466f7de6ef10a089b9bc12e7b57314b059eea4eb28e5c88994109f0ffa60626c
7
- data.tar.gz: 0f831be90516eb337de6f593dd8ae7fa0bebdbdf9ae525ca10afd2c7d2b3a190f5d1f7fdb4b2cf758c75a936f3710ec2e684e9b22fe3b6e975465c2955c2246c
6
+ metadata.gz: d4a7f15f906733e041f3fdc3fe19f02bd425476735a7513048b425ee830d7617f5ac4ef958a4df30ea9413f85a3d4f72f06a93b4fa8834fc11e04bd39c12921c
7
+ data.tar.gz: 8d4b52569bad66e17e3f7230d48592175d35ca20e8855e8ec8e29c9a27327c886128ff848e9ba1917f8300389b6661a5364ab523097ea3f7faf8def0cb1c65c9
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ = 3.4.34
2
+ - Fix past, future and range on field search with rails 4, local time was used instead of UTC
3
+ - Ignore search params when params[:id] is set
4
+ - Eager load HABTM with scope using left join
5
+ - Add active_scaffold/indicator.gif to precompile so rails 4.2 precompiles it
6
+ - Add support for ActiveRecord::Enum so :select form_ui is used by default
7
+ - Fix nested link on self-association belongs_to for rails >= 4.1
8
+ - Fix update_column for boolean columns with default true on rails 4.2
9
+ - Fix columns lost on tableless models on rails 4.2
10
+
1
11
  = 3.4.33
2
12
  - Fix _base_form when used with actions, so :multipart and :persistent can set to false instead of getting them from action config
3
13
  - Copy update.columns from create.columns, if not defined
@@ -199,7 +199,7 @@ jQuery(document).ready(function($) {
199
199
  });
200
200
  jQuery(document).on('ajax:complete', '.action_group.dyn > ul a', function(event) {
201
201
  var action_link = ActiveScaffold.find_action_link(event.target);
202
- if (action_link.loading_indicator) action_link.loading_indicator.css('visibility','hidden');
202
+ if (action_link && action_link.loading_indicator) action_link.loading_indicator.css('visibility','hidden');
203
203
  jQuery(event.target).closest('.action_group.dyn > ul').remove();
204
204
  });
205
205
 
@@ -984,7 +984,7 @@ var ActiveScaffold = {
984
984
  complete: function(xhr, status) {
985
985
  element = as_form.find('#'+element.attr('id'));
986
986
  element.nextAll('img.loading-indicator').css('visibility','hidden');
987
- var complete_element = element.length ? element : as_form;
987
+ var complete_element = element.length ? element : as_form;
988
988
  complete_element.trigger('ajax:complete', [xhr, status]);
989
989
  if (ActiveScaffold.last_focus) {
990
990
  var item = jQuery(ActiveScaffold.last_focus);
@@ -38,7 +38,7 @@ module ActiveScaffold::Actions
38
38
  end
39
39
 
40
40
  def search_params
41
- @search_params || active_scaffold_session_storage['search']
41
+ @search_params || active_scaffold_session_storage['search'] unless params[:id]
42
42
  end
43
43
 
44
44
  # The default security delegates to ActiveRecordPermissions.
@@ -73,7 +73,9 @@ module ActiveScaffold::Actions
73
73
  active_scaffold_config.send(action).columns.collect_visible(:flatten => true)
74
74
  end
75
75
  sorting = active_scaffold_config.list.user.sorting
76
- columns_for_joins, columns_for_includes = columns.select { |c| c.includes.present? }.partition { |c| sorting.sorts_on? c }
76
+ columns_for_joins, columns_for_includes = columns.select { |c| c.includes.present? }.partition do |c|
77
+ sorting.sorts_on?(c) || (c.plural_association? && c.association.macro == :has_and_belongs_to_many && c.association.scope)
78
+ end
77
79
  active_scaffold_preload.concat columns_for_includes.map(&:includes).flatten.uniq
78
80
  active_scaffold_references.concat columns_for_joins.map(&:includes).flatten.uniq
79
81
  end
@@ -91,7 +91,8 @@ module ActiveScaffold::Actions
91
91
  table_name =
92
92
  if active_scaffold_config.model == nested.association.active_record
93
93
  dependency = ActiveRecord::Associations::JoinDependency.new(chain.klass, chain.joins_values, [])
94
- dependency.join_associations.find { |join| join.try(:reflection).try(:name) == nested.child_association.name }.try(:table).try(:right)
94
+ join_associations = Rails.version >= '4.1.0' ? dependency.join_root.children : dependency.join_associations
95
+ join_associations.find {|join| join.try(:reflection).try(:name) == nested.child_association.name}.try(:table).try(:right)
95
96
  end
96
97
  table_name ||= nested.association.active_record.table_name
97
98
  chain.where(table_name => {nested.association.active_record.primary_key => nested_parent_record}).readonly(false)
@@ -144,7 +144,9 @@ module ActiveScaffold::Actions
144
144
 
145
145
  value ||=
146
146
  unless @column.column.nil? || @column.column.null
147
- @column.column.default == true ? false : @column.column.default
147
+ default_val = @column.column.default
148
+ default_val = @column.column.cast_type.type_cast_from_user default_val if Rails.version >= '4.2.0'
149
+ default_val == true ? false : default_val
148
150
  end
149
151
  unless @column.nil?
150
152
  value = column_value_from_param_value(@record, @column, value)
@@ -76,18 +76,18 @@ module ActiveScaffold
76
76
 
77
77
  module HumanConditionHelpers
78
78
  def active_scaffold_human_condition_date_bridge(column, value)
79
- case value[:opt]
79
+ case value['opt']
80
80
  when 'RANGE'
81
- range_type, range = value[:range].downcase.split('_')
81
+ range_type, range = value['range'].downcase.split('_')
82
82
  format = active_scaffold_human_condition_date_bridge_range_format(range_type, range)
83
83
  from, to = controller.class.date_bridge_from_to(column, value)
84
- "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value[:range].downcase).downcase} (#{I18n.l(from, :format => format)})"
84
+ "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value['range'].downcase).downcase} (#{I18n.l(from, :format => format)})"
85
85
  when 'PAST', 'FUTURE'
86
86
  from, to = controller.class.date_bridge_from_to(column, value)
87
87
  "#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}"
88
88
  else
89
89
  from, to = controller.class.date_bridge_from_to(column, value)
90
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{I18n.l(from)} #{value[:opt] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
90
+ "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value['opt'].downcase).downcase} #{I18n.l(from)} #{value['opt'] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
91
91
  end
92
92
  end
93
93
 
@@ -113,7 +113,7 @@ module ActiveScaffold
113
113
  module Finder
114
114
  module ClassMethods
115
115
  def condition_for_date_bridge_type(column, value, like_pattern)
116
- operator = ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(value[:opt]) && value[:opt] != 'BETWEEN' ? value[:opt] : nil
116
+ operator = ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(value['opt']) && value['opt'] != 'BETWEEN' ? value['opt'] : nil
117
117
  from_value, to_value = date_bridge_from_to(column, value)
118
118
 
119
119
  if column.search_sql.is_a? Proc
@@ -122,18 +122,24 @@ module ActiveScaffold
122
122
  if operator.nil?
123
123
  ['%{search_sql} BETWEEN ? AND ?', from_value.to_s(:db), to_value.to_s(:db)] unless from_value.nil? || to_value.nil?
124
124
  else
125
- ["%{search_sql} #{value[:opt]} ?", from_value.to_s(:db)] unless from_value.nil?
125
+ ["%{search_sql} #{value['opt']} ?", from_value.to_s(:db)] unless from_value.nil?
126
126
  end
127
127
  end
128
128
  end
129
129
 
130
130
  def date_bridge_from_to(column, value)
131
131
  conversion = datetime_conversion_for_condition(column)
132
- case value[:opt]
132
+ case value['opt']
133
133
  when 'RANGE'
134
- date_bridge_from_to_for_range(column, value).collect(&conversion)
134
+ values = date_bridge_from_to_for_range(column, value)
135
+ # Avoid calling to_time, not needed and broken on rails >= 4, because return local time instead of UTC
136
+ values.collect!(&conversion) if conversion != :to_time
137
+ values
135
138
  when 'PAST', 'FUTURE'
136
- date_bridge_from_to_for_trend(column, value).collect(&conversion)
139
+ values = date_bridge_from_to_for_trend(column, value)
140
+ # Avoid calling to_time, not needed and broken on rails >= 4, because return local time instead of UTC
141
+ values.collect!(&conversion) if conversion != :to_time
142
+ values
137
143
  else
138
144
  %w(from to).collect { |field| condition_value_for_datetime(column, value[field], conversion) }
139
145
  end
@@ -171,7 +177,7 @@ module ActiveScaffold
171
177
  end
172
178
 
173
179
  def date_bridge_from_to_for_range(column, value)
174
- case value[:range]
180
+ case value['range']
175
181
  when 'TODAY'
176
182
  return date_bridge_now.beginning_of_day, date_bridge_now.end_of_day
177
183
  when 'YESTERDAY'
@@ -179,7 +185,7 @@ module ActiveScaffold
179
185
  when 'TOMORROW'
180
186
  return date_bridge_now.in(1.day).beginning_of_day, date_bridge_now.in(1.day).end_of_day
181
187
  else
182
- range_type, range = value[:range].downcase.split('_')
188
+ range_type, range = value['range'].downcase.split('_')
183
189
  raise ArgumentError unless %w(week month year).include?(range)
184
190
  case range_type
185
191
  when 'this'
@@ -14,6 +14,8 @@ module ActiveScaffold::DataStructures
14
14
  @inplace_edit = value
15
15
  end
16
16
 
17
+ # :table to refresh list
18
+ # true or :row to refresh row
17
19
  attr_accessor :inplace_edit_update
18
20
 
19
21
  # Whether this column set is collapsed by default in contexts where collapsing is supported
@@ -335,14 +337,18 @@ module ActiveScaffold::DataStructures
335
337
 
336
338
  @text = @column.nil? || [:string, :text].include?(@column.type)
337
339
  if @column
338
- @form_ui = case @column.type
339
- when :boolean then :checkbox
340
- when :text then :textarea
341
- end
342
- if @column.number?
340
+ if active_record_class.respond_to?(:defined_enums) && active_record_class.defined_enums[name.to_s]
341
+ @form_ui = :select
342
+ @options = {:options => active_record_class.send(name.to_s.pluralize).keys}
343
+ elsif @column.number?
343
344
  @number = true
344
345
  @form_ui = :number
345
346
  @options = {:format => :i18n_number}
347
+ else
348
+ @form_ui = case @column.type
349
+ when :boolean then :checkbox
350
+ when :text then :textarea
351
+ end
346
352
  end
347
353
  end
348
354
  @allow_add_existing = true
@@ -25,5 +25,7 @@ module ActiveScaffold
25
25
  ActiveRecord::Associations::SingularAssociation.send :include, ActiveScaffold::Tableless::SingularAssociation
26
26
  end
27
27
  end
28
+
29
+ config.assets.precompile << 'active_scaffold/indicator.gif' if Rails::VERSION::MAJOR >= 4
28
30
  end
29
31
  end
@@ -3,7 +3,7 @@ module ActiveScaffold
3
3
  # Helpers that assist with rendering of a human readable search statement
4
4
  module HumanConditionHelpers
5
5
  def active_scaffold_human_condition_for(column)
6
- return if (value = field_search_params[column.name]).nil?
6
+ return if (value = field_search_params[column.name.to_s]).nil?
7
7
  search_ui = column.search_ui
8
8
  search_ui ||= column.column.type if column.column
9
9
  if override_human_condition_column?(column)
@@ -54,7 +54,7 @@ module ActiveScaffold
54
54
 
55
55
  # the standard active scaffold options used for class, name and scope
56
56
  def active_scaffold_search_options(column)
57
- {:name => "search[#{column.name}]", :class => "#{column.name}-input", :id => "search_#{column.name}", :value => field_search_params[column.name]}
57
+ {:name => "search[#{column.name}]", :class => "#{column.name}-input", :id => "search_#{column.name}", :value => field_search_params[column.name.to_s]}
58
58
  end
59
59
 
60
60
  def search_attribute(column, record)
@@ -161,7 +161,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base
161
161
  end
162
162
 
163
163
  def self.columns
164
- @columns ||= []
164
+ @tableless_columns ||= []
165
165
  end
166
166
  def self.table_name
167
167
  @table_name ||= ActiveModel::Naming.plural(self)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 33
5
+ PATCH = 34
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
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.33
4
+ version: 3.4.34
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-01-18 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.2.18
33
+ version: 3.2.22.2
34
34
  - - <
35
35
  - !ruby/object:Gem::Version
36
36
  version: '5'
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 3.2.18
43
+ version: 3.2.22.2
44
44
  - - <
45
45
  - !ruby/object:Gem::Version
46
46
  version: '5'