active_scaffold 3.6.6 → 3.6.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db4ded41b22bcb1ff0c1f9d2e59499bd37127ffc4600e53fc24856a9ef525897
4
- data.tar.gz: e3b57c93d2250d0ac83f618ee38c04b8514d56817555bace633a2a9efb05d3ed
3
+ metadata.gz: 5450d62d32a21683b6226c4b1a23694e0dac270987c78e5a5a4452271a55fd08
4
+ data.tar.gz: ef18b964d35d5796b193c2ffde31698d33fd083a4d3fa03d3f486cef418aa9ef
5
5
  SHA512:
6
- metadata.gz: c1a48c8654117d2829cdde939ab632b797287312dfe37fe88d73594b70ef2d48b4cac5872158fb56a090808daa6334310ab3ac8efc73de0109850760ed5673ee
7
- data.tar.gz: 58052fce6e32e54e28cc3d77c43f2a952b32be8c6a314a07047537a1d3c62931476d30c787a0cd239329c099e8dbdff6032d31610fb93cd83e79192ec27c192d
6
+ metadata.gz: 84fbaee76d085ccf789bb610e99a652ecabf4c2158a5813a8dba2b493fafd97bf02be6743874942dea47a9b3067b361c534d4faf832e4c007ec854aaddd53b85
7
+ data.tar.gz: c4e5d788ae233d7c853a24d6cadfc2c1e81e963da2abcb763a453e9cb0ef01a7b028de8af45e2943e29784dcbace065b097ca7a396c3d9cc9bf444955e329987
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,20 @@
1
+ = 3.6.10
2
+ - Don't add numerical constraints based on conditional validation
3
+ - Fix typo in cache key for numerical constraints
4
+ - Fix duplicated params in search form, e.g. embedded constraints
5
+
6
+ = 3.6.9
7
+ - Support depend on .rb or .json locale files for date picker bridge
8
+ - Fix search with dates entered with timezone in datepicker
9
+
10
+ = 3.6.8
11
+ - Add depend_on available translations in app to data picker bridge JS
12
+ - Fix live search with rails-ujs
13
+ - Replace delayedObserver with $.debounce
14
+
15
+ = 3.6.7
16
+ - Upgrade jquery ui timepicker addon to 1.6.3
17
+
1
18
  = 3.6.6
2
19
  - Fix format string for timezone in jquery timepicker
3
20
 
@@ -3,6 +3,7 @@
3
3
  when :jquery
4
4
  jquery_ui = true
5
5
  require_asset "getprototypeof"
6
+ require_asset "jquery.ba-throttle-debounce"
6
7
  if Jquery::Rails.const_defined? 'JQUERY_UI_VERSION'
7
8
  require_asset "jquery-ui"
8
9
  elsif Jquery.const_defined? 'Ui'
@@ -354,6 +354,10 @@ jQuery(document).ready(function($) {
354
354
  }
355
355
  });
356
356
 
357
+ jQuery(document).on('input paste', 'form.search.live input[type=search]', $.debounce((ActiveScaffold.config.live_search_delay || 0.5) * 1000, function() {
358
+ jQuery(this).parent().find('[type=submit]').click();
359
+ }));
360
+
357
361
  jQuery(document).on('turbolinks:before-visit', function() {
358
362
  if (history.state.active_scaffold) {
359
363
  history.replaceState({turbolinks: true, url: document.location.href}, '', document.location.href);
@@ -459,44 +463,6 @@ jQuery(document).on('turbolinks:load', function($) {
459
463
  };
460
464
  })();
461
465
 
462
- /*
463
- $ delayed observer
464
- (c) 2007 - Maxime Haineault (max@centdessin.com)
465
-
466
- Special thanks to Stephen Goguen & Tane Piper.
467
-
468
- Slight modifications by Elliot Winkler
469
- */
470
-
471
- if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
472
- (function($){
473
- $.extend($.fn, {
474
- delayedObserver: function(callback, delay, options){
475
- return this.each(function(){
476
- var el = $(this);
477
- var op = options || {};
478
- el.data('oldval', el.val())
479
- .data('delay', delay === 0 ? delay : (delay || 0.5))
480
- .data('condition', op.condition || function() { return ($(this).data('oldval') == $(this).val()); })
481
- .data('callback', callback)
482
- [(op.event||'keyup')](function(){
483
- if (el.data('condition').apply(el)) { return; }
484
- else {
485
- if (el.data('timer')) { clearTimeout(el.data('timer')); }
486
- el.data('timer', setTimeout(function(){
487
- var callback = el.data('callback')
488
- if (callback) callback.apply(el);
489
- }, el.data('delay') * 1000));
490
- el.data('oldval', el.val());
491
- }
492
- });
493
- });
494
- }
495
- });
496
- })(jQuery);
497
- };
498
-
499
-
500
466
  /*
501
467
  * Simple utility methods
502
468
  */
@@ -507,7 +473,6 @@ var ActiveScaffold = {
507
473
  /* setup some elements on page/form load */
508
474
  ActiveScaffold.load_embedded(container);
509
475
  ActiveScaffold.enable_js_form_buttons(container);
510
- ActiveScaffold.live_search(container);
511
476
  ActiveScaffold.auto_paginate(container);
512
477
  ActiveScaffold.draggable_lists('.draggable-lists', container);
513
478
  ActiveScaffold.sliders(container);
@@ -530,11 +495,6 @@ var ActiveScaffold = {
530
495
  }
531
496
  ActiveScaffold.add_to_history(document.location.href, data, true);
532
497
  },
533
- live_search: function(element) {
534
- jQuery('form.search.live input[type=search]', element).delayedObserver(function() {
535
- jQuery(this).parent().trigger("submit");
536
- }, ActiveScaffold.config.live_search_delay || 0.5);
537
- },
538
498
  auto_paginate: function(element) {
539
499
  var paginate_link = jQuery('.active-scaffold-pagination.auto-paginate a:first', element);
540
500
  if (paginate_link.length) {
@@ -1,4 +1,5 @@
1
1
  <%# encoding: utf-8 %>
2
+ <% I18n.available_locales.each { |locale| Dir[Rails.root.join("config/locales/#{locale}.*")].each { |path| depend_on path } } %>
2
3
  <%= ActiveScaffold::Bridges[:date_picker].localization %>
3
4
  Object.getPrototypeOf(jQuery.datepicker)._attachDatepicker_without_inlineSettings = Object.getPrototypeOf(jQuery.datepicker)._attachDatepicker;
4
5
  jQuery.extend(Object.getPrototypeOf(jQuery.datepicker), {
@@ -14,7 +14,7 @@
14
14
  hidden_params = url_options.except(:controller, :action, :id, :search).to_query.split(Rack::Utils::DEFAULT_SEP)
15
15
  -%>
16
16
 
17
- <%= form_tag url_options, options do %>
17
+ <%= form_tag url_options.slice(:controller, :action, :id, :search), options do %>
18
18
  <% hidden_params.each do |pair| -%>
19
19
  <% key, value = pair.split('=', 2).map { |str| Rack::Utils.unescape(str) } -%>
20
20
  <%= hidden_field_tag(key, value) %>
@@ -13,6 +13,10 @@ module ActiveScaffold::Bridges
13
13
  Jquery::Rails.const_defined?('JQUERY_UI_VERSION') || Jquery.const_defined?('Ui') if Object.const_defined?('Jquery')
14
14
  end
15
15
 
16
+ def self.stylesheets
17
+ 'jquery-ui-timepicker-addon'
18
+ end
19
+
16
20
  def self.localization
17
21
  "jQuery(function($){
18
22
  if (typeof($.datepicker) === 'object') {
@@ -122,9 +122,9 @@ module ActiveScaffold
122
122
  if column.search_sql.is_a? Proc
123
123
  column.search_sql.call(from_value, to_value, operator)
124
124
  elsif operator.nil?
125
- ['%<search_sql>s BETWEEN ? AND ?', from_value.to_s(:db), to_value.to_s(:db)] unless from_value.nil? || to_value.nil?
125
+ ['%<search_sql>s BETWEEN ? AND ?', from_value, to_value] unless from_value.nil? || to_value.nil?
126
126
  else
127
- ["%<search_sql>s #{value['opt']} ?", from_value.to_s(:db)] unless from_value.nil?
127
+ ["%<search_sql>s #{value['opt']} ?", from_value] unless from_value.nil?
128
128
  end
129
129
  end
130
130
 
@@ -319,11 +319,11 @@ module ActiveScaffold
319
319
  if from_value.nil? && to_value.nil?
320
320
  nil
321
321
  elsif !from_value
322
- ['%<search_sql>s <= ?', to_value.to_s(:db)]
322
+ ['%<search_sql>s <= ?', to_value]
323
323
  elsif !to_value
324
- ['%<search_sql>s >= ?', from_value.to_s(:db)]
324
+ ['%<search_sql>s >= ?', from_value]
325
325
  else
326
- ['%<search_sql>s BETWEEN ? AND ?', from_value.to_s(:db), to_value.to_s(:db)]
326
+ ['%<search_sql>s BETWEEN ? AND ?', from_value, to_value]
327
327
  end
328
328
  end
329
329
 
@@ -720,7 +720,9 @@ module ActiveScaffold
720
720
  # Try to get numerical constraints from model's validators
721
721
  def column_numerical_constraints(column, options)
722
722
  validators = column.active_record_class.validators.select do |v|
723
- v.is_a?(ActiveModel::Validations::NumericalityValidator) && v.attributes.include?(column.name)
723
+ v.is_a?(ActiveModel::Validations::NumericalityValidator) &&
724
+ v.attributes.include?(column.name) &&
725
+ !v.options[:if] && !v.options[:unless]
724
726
  end
725
727
 
726
728
  equal_validator = validators.find { |v| v.options[:equal_to] }
@@ -770,7 +772,7 @@ module ActiveScaffold
770
772
  end
771
773
 
772
774
  def numerical_constraints_for_column(column, options)
773
- constraints = Rails.cache.fetch("#{column.cache_key}#numerical_constarints") do
775
+ constraints = Rails.cache.fetch("#{column.cache_key}#numerical_constraints") do
774
776
  column_numerical_constraints(column, options)
775
777
  end
776
778
  constraints.merge(options)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 6
5
- PATCH = 6
5
+ PATCH = 10
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end