active_scaffold 3.7.2 → 3.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,8 +21,10 @@
21
21
  jQuery(element).sortable(jQuery.extend(options, {connectWith: '#'+list_selected.attr('id')}));
22
22
  jQuery(list_selected).sortable(jQuery.extend(options, {connectWith: '#'+element.attr('id')}));
23
23
  return element;
24
- };
25
- jQuery.fn.draggableLists = function() {
26
- this.each(function() { enableDraggableLists(jQuery(this)); });
27
- };
24
+ }
25
+ if (typeof(jQuery.fn.sortable) !== 'undefined') {
26
+ jQuery.fn.draggableLists = function() {
27
+ this.each(function() { enableDraggableLists(jQuery(this)); });
28
+ };
29
+ }
28
30
  })();
@@ -11,10 +11,10 @@
11
11
  var global_settings = ActiveScaffold.config.tiny_mce_settings || {};
12
12
  var local_settings = jQuery(this).data('tinymce');
13
13
  var settings = {};
14
- for (key in global_settings) {
14
+ for (let key in global_settings) {
15
15
  settings[key] = global_settings[key];
16
16
  }
17
- for (key in local_settings) {
17
+ for (let key in local_settings) {
18
18
  settings[key] = local_settings[key];
19
19
  }
20
20
  var id = jQuery(this).attr('id');
@@ -1,11 +1,10 @@
1
1
  <% if Jquery::Rails.const_defined? 'JQUERY_UI_VERSION' %>
2
- <% require_asset "jquery-ui" %>
3
- <% require_asset "jquery-ui-theme" %>
2
+ <% require_asset "jquery-ui" %>
4
3
  <% elsif Jquery.const_defined? 'Ui' %>
5
- <% if Jquery::Ui::Rails::VERSION < '5.0.0' %>
6
- <% require_asset "jquery.ui.datepicker" %>
7
- <% else %>
8
- <% require_asset "jquery-ui/datepicker" %>
9
- <% end %>
10
- <% require_asset "jquery-ui-theme" %>
4
+ <% if Jquery::Ui::Rails::VERSION < '5.0.0' %>
5
+ <% require_asset "jquery.ui.datepicker" %>
6
+ <% else %>
7
+ <% require_asset "jquery-ui/datepicker" %>
8
+ <% end %>
11
9
  <% end %>
10
+ <% require_asset "jquery-ui-theme" if ActiveScaffold.jquery_ui_included? %>
@@ -41,8 +41,17 @@
41
41
  <% end -%>
42
42
  </ol>
43
43
  <p class="form-footer">
44
+ <%
45
+ reset_attrs = {class: 'reset'}
46
+ if active_scaffold_config.field_search.reset_form
47
+ reset_attrs[:data] = {reset: true}
48
+ else
49
+ reset_attrs[:class] << ' as_cancel'
50
+ reset_attrs.merge! remote: true, data: {refresh: true}
51
+ end
52
+ %>
44
53
  <%= submit_tag as_(submit_text), :class => "submit" %>
45
- <%= link_to as_(:reset), url_for(url_options.merge(:search => '')), :class => 'as_cancel reset', :remote => true, :data => {:refresh => true} unless local_assigns[:skip_reset] %>
54
+ <%= link_to as_(:reset), url_for(url_options.merge(:search => '')), reset_attrs unless local_assigns[:skip_reset] %>
46
55
  <%= loading_indicator_tag(:action => :search) %>
47
56
  </p>
48
57
  </form>
@@ -21,6 +21,14 @@
21
21
  <% end -%>
22
22
  <%= search_field_tag :search, (search_params if search_params.is_a? String), :class => 'text-input', :id => search_input_id, :size => 50, :autocomplete => :off, :placeholder => as_(live_search ? :live_search : :search_terms) %>
23
23
  <%= submit_tag as_(submit_text), :class => "submit", :style => ('display:none;' if live_search) %>
24
- <%= link_to as_(:reset), url_for(url_options.merge(:search => '')), :class => 'as_cancel reset', :remote => true, :data => {:refresh => true} unless local_assigns[:skip_reset] %>
24
+ <%
25
+ reset_attrs = {class: 'as_cancel reset'}
26
+ if active_scaffold_config.field_search.reset_form
27
+ reset_attrs[:data] = {reset: true}
28
+ else
29
+ reset_attrs.merge! remote: true, data: {refresh: true}
30
+ end
31
+ %>
32
+ <%= link_to as_(:reset), url_for(url_options.merge(:search => '')), reset_attrs unless local_assigns[:skip_reset] %>
25
33
  <%= loading_indicator_tag(:action => :search) %>
26
34
  <% end %>
@@ -10,7 +10,7 @@ module ActiveScaffold::Bridges
10
10
  end
11
11
 
12
12
  def self.jquery_ui_included?
13
- Jquery::Rails.const_defined?('JQUERY_UI_VERSION') || Jquery.const_defined?('Ui') if Object.const_defined?('Jquery')
13
+ ActiveScaffold.jquery_ui_included?
14
14
  end
15
15
  mattr_accessor :default_ui
16
16
  @@default_ui = true
@@ -27,7 +27,7 @@ class ActiveScaffold::Bridges::RecordSelect
27
27
  def active_scaffold_record_select(record, column, options, value, multiple, ui_options: column.options)
28
28
  unless column.association
29
29
  raise ArgumentError, "record_select can only work against associations (and #{column.name} is not). "\
30
- 'A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user).'
30
+ 'A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user).'
31
31
  end
32
32
  klass = column.association.klass(record)
33
33
  return content_tag :span, '', :class => options[:class] unless klass
@@ -68,13 +68,13 @@ class ActiveScaffold::Bridges::RecordSelect
68
68
  module SearchColumnHelpers
69
69
  def active_scaffold_search_record_select(column, options, ui_options: column.options)
70
70
  value = field_search_record_select_value(column, options[:value], ui_options: ui_options)
71
- active_scaffold_record_select(options[:object], column, options, value, ui_options[:multiple], ui_options: ui_options)
71
+ active_scaffold_record_select(options[:object], column, options.except(:value), value, ui_options[:multiple], ui_options: ui_options)
72
72
  end
73
73
 
74
74
  def field_search_record_select_value(column, value, ui_options: column.options)
75
75
  return if value.blank?
76
76
  if ui_options[:multiple]
77
- column.association.klass.find value.collect!(&:to_i)
77
+ column.association.klass.find value.select(&:present?).collect!(&:to_i)
78
78
  else
79
79
  column.association.klass.find(value.to_i)
80
80
  end
@@ -8,6 +8,7 @@ module ActiveScaffold::Config
8
8
  @text_search = self.class.text_search
9
9
  @human_conditions = self.class.human_conditions
10
10
  @floating_footer = self.class.floating_footer
11
+ @reset_form = self.class.reset_form
11
12
  end
12
13
 
13
14
  # global level configuration
@@ -34,6 +35,8 @@ module ActiveScaffold::Config
34
35
  class_attribute :floating_footer, instance_accessor: false
35
36
  @@floating_footer = false
36
37
 
38
+ cattr_accessor :reset_form, instance_accessor: false
39
+
37
40
  # instance-level configuration
38
41
  # ----------------------------
39
42
 
@@ -79,6 +82,8 @@ module ActiveScaffold::Config
79
82
  # whether footer should float when form is too long to fit in the screen, so footer is always available while scrolling
80
83
  attr_accessor :floating_footer
81
84
 
85
+ attr_accessor :reset_form
86
+
82
87
  UserSettings.class_eval do
83
88
  user_attr :optional_columns, :group_options, :grouped_columns, :human_conditions, :floating_footer
84
89
  end
@@ -7,6 +7,7 @@ module ActiveScaffold::Config
7
7
  @text_search = self.class.text_search
8
8
  @live = self.class.live?
9
9
  @split_terms = self.class.split_terms
10
+ @reset_form = self.class.reset_form
10
11
  end
11
12
 
12
13
  # global level configuration
@@ -33,6 +34,8 @@ module ActiveScaffold::Config
33
34
  cattr_accessor :split_terms, instance_accessor: false
34
35
  @@split_terms = ' '
35
36
 
37
+ cattr_accessor :reset_form, instance_accessor: false
38
+
36
39
  # instance-level configuration
37
40
  # ----------------------------
38
41
 
@@ -56,6 +59,8 @@ module ActiveScaffold::Config
56
59
 
57
60
  attr_accessor :split_terms
58
61
 
62
+ attr_accessor :reset_form
63
+
59
64
  # the ActionLink for this action
60
65
  attr_accessor :link
61
66
 
@@ -29,7 +29,12 @@ module ActiveScaffold
29
29
  def type_casted_tokens(tokens, columns, like_pattern)
30
30
  tokens.map do |value|
31
31
  columns.each_with_object({}) do |column, column_tokens|
32
- column_tokens[column.name] = column.text? ? like_pattern.sub('?', value) : ActiveScaffold::Core.column_type_cast(value, column.column)
32
+ column_tokens[column.name] =
33
+ if column.text?
34
+ like_pattern.sub('?', column.active_record? ? column.active_record_class.sanitize_sql_like(value) : value)
35
+ else
36
+ ActiveScaffold::Core.column_type_cast(value, column.column)
37
+ end
33
38
  end
34
39
  end
35
40
  end
@@ -165,6 +170,7 @@ module ActiveScaffold
165
170
  ['%<search_sql>s in (?)', values] if values.present?
166
171
  else
167
172
  if column.text?
173
+ value = column.active_record? ? column.active_record_class.sanitize_sql_like(value) : value
168
174
  ["%<search_sql>s #{ActiveScaffold::Finder.like_operator} ?", like_pattern.sub('?', value)]
169
175
  else
170
176
  ['%<search_sql>s = ?', ActiveScaffold::Core.column_type_cast(value, column.column)]
@@ -189,6 +195,7 @@ module ActiveScaffold
189
195
  def condition_for_range(column, value, like_pattern = nil)
190
196
  if !value.is_a?(Hash)
191
197
  if column.text?
198
+ value = column.active_record? ? column.active_record_class.sanitize_sql_like(value) : value
192
199
  ["%<search_sql>s #{ActiveScaffold::Finder.like_operator} ?", like_pattern.sub('?', value)]
193
200
  else
194
201
  ['%<search_sql>s = ?', ActiveScaffold::Core.column_type_cast(value, column.column)]
@@ -198,9 +205,10 @@ module ActiveScaffold
198
205
  elsif value[:from].blank?
199
206
  nil
200
207
  elsif ActiveScaffold::Finder::STRING_COMPARATORS.values.include?(value[:opt])
208
+ text = column.active_record? ? column.active_record_class.sanitize_sql_like(value[:from]) : value[:from]
201
209
  [
202
210
  "%<search_sql>s #{'NOT ' if value[:opt].start_with?('not_')}#{ActiveScaffold::Finder.like_operator} ?",
203
- value[:opt].sub('not_', '').sub('?', value[:from])
211
+ value[:opt].sub('not_', '').sub('?', text)
204
212
  ]
205
213
  elsif value[:opt] == 'BETWEEN'
206
214
  ['(%<search_sql>s BETWEEN ? AND ?)', value[:from], value[:to]]
@@ -441,7 +449,8 @@ module ActiveScaffold
441
449
 
442
450
  def condition_for_record_select_type(column, value, like_pattern = nil)
443
451
  if value.is_a?(Array)
444
- ['%<search_sql>s IN (?)', value]
452
+ value = value.select(&:present?)
453
+ ['%<search_sql>s IN (?)', value] if value.present?
445
454
  else
446
455
  ['%<search_sql>s = ?', value]
447
456
  end
@@ -609,7 +618,8 @@ module ActiveScaffold
609
618
  options[:page] ||= 1
610
619
 
611
620
  find_options = finder_options(options)
612
- query = beginning_of_chain.where(nil) # where(nil) is needed because we need a relation
621
+ query = beginning_of_chain
622
+ query = query.where(nil) if active_scaffold_config.active_record? # where(nil) is needed because we need a relation
613
623
 
614
624
  # NOTE: we must use :include in the count query, because some conditions may reference other tables
615
625
  if options[:pagination] && options[:pagination] != :infinite
@@ -15,7 +15,7 @@ module ActiveScaffold
15
15
  end
16
16
 
17
17
  def nested_parent_id
18
- nested_parent_record.id
18
+ clean_id nested_parent_record.id.to_s
19
19
  end
20
20
 
21
21
  def nested_id(controller = nil)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 7
5
- PATCH = 2
5
+ PATCH = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -66,6 +66,12 @@ module ActiveScaffold
66
66
  end
67
67
  end
68
68
 
69
+ mattr_writer :jquery_ui_loaded, instance_writer: false
70
+ def self.jquery_ui_included?
71
+ return true if @@jquery_ui_loaded
72
+ Jquery::Rails.const_defined?('JQUERY_UI_VERSION') || Jquery.const_defined?('Ui') if Object.const_defined?('Jquery')
73
+ end
74
+
69
75
  mattr_writer :js_config, instance_writer: false
70
76
  def self.js_config
71
77
  @@js_config ||= {:scroll_on_close => :checkInViewport}
@@ -60,7 +60,8 @@
60
60
  // the `Cowboy` namespace. Usage will be exactly the same, but instead of
61
61
  // $.method() or jQuery.method(), you'll need to use Cowboy.method().
62
62
 
63
- (function(window,undefined){
63
+ (function() {
64
+ var jqueryThrottleDebounceInit = function($, undefined) {
64
65
  '$:nomunge'; // Used by YUI compressor.
65
66
 
66
67
  // Since jQuery really isn't required for this plugin, use `jQuery` as the
@@ -248,5 +249,11 @@
248
249
  ? jq_throttle( delay, at_begin, false )
249
250
  : jq_throttle( delay, callback, at_begin !== false );
250
251
  };
251
-
252
- })(this);
252
+ };
253
+
254
+ if (window.jQuery) {
255
+ jqueryThrottleDebounceInit(jQuery);
256
+ } else if (typeof exports === 'object' && typeof module === 'object') {
257
+ module.exports = jqueryThrottleDebounceInit;
258
+ }
259
+ })();
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.7.2
4
+ version: 3.7.3
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: 2024-04-07 00:00:00.000000000 Z
11
+ date: 2024-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails