tabulatr2 0.9.30 → 0.9.31

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: af8e5204add46d949b53ab203ff3eb544217d60f
4
- data.tar.gz: 79455bf0881803cf94f77fb50f553c5ac0a4ea60
3
+ metadata.gz: 21719e71fe7654c3881b1abf925168d7ee09bb5f
4
+ data.tar.gz: df5a0301ac3c3e608a96dd62ccf87eb350f884b6
5
5
  SHA512:
6
- metadata.gz: 5db3fe6c8d03c691e552128fc04300fc95aec3438e3718d298d1794e49661d4bb6dfb5463d8d4d874555ea99951e9b235175af513e841fe991f3b806faf054c8
7
- data.tar.gz: 60d58e2003677d4f4949432c3a2b5c4283ca4ce306fac7fcfd4a2a61490e3c74364558f07e8c62ea84c031a632fab9604f4192e3b165342b4eece68cefa152b1
6
+ metadata.gz: 81785a96b3deb0249269a0b2487ed70b231f0fc810e14383e9bd088aeb97f80e47b0116c916436fefb372985fe829bc9462d49cf8dfc04de199593322617ecdd
7
+ data.tar.gz: ef55f54530aa2906db178edca61b1ff56ffdd97ec5ca60c88f502baafdcd85ca9d4ac8f6c94f52e0622acf07e740881280f846b749d0b034cd7533375d0558c7
data/.travis.yml CHANGED
@@ -1,10 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.0
5
- - jruby
6
- matrix:
7
- allow_failures:
8
- - rvm: jruby
3
+ # - 2.1.10
4
+ - 2.2.6
5
+ - 2.3.3
6
+ # - 2.4.0 # wait for json > 1.8.3
7
+ - jruby-9.1.5.0
9
8
  script: "bundle exec rspec spec"
10
9
 
data/Gemfile CHANGED
@@ -15,7 +15,12 @@ end
15
15
 
16
16
 
17
17
  group :development, :test do
18
- gem 'sqlite3', :require => 'sqlite3'
18
+ if defined?(JRUBY_VERSION)
19
+ gem 'activerecord-jdbc-adapter'
20
+ gem 'jdbc-sqlite3'
21
+ else
22
+ gem 'sqlite3'
23
+ end
19
24
  gem 'minitest'
20
25
  gem 'launchy'
21
26
  gem 'database_cleaner', '< 1.1.0'
@@ -75,6 +75,13 @@ Tabulatr.prototype = {
75
75
  },
76
76
 
77
77
  loadDataFromServer: function(hash){
78
+ var data = this.getDataForAjax(hash)
79
+ // deparse existing params http://stackoverflow.com/a/8649003/673826
80
+ var search = location.search.substring(1);
81
+ if (search.length){
82
+ var query = JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
83
+ data = $.extend(query, data);
84
+ }
78
85
  $.ajax({
79
86
  context: this,
80
87
  type: 'GET',
@@ -82,7 +89,7 @@ Tabulatr.prototype = {
82
89
  accepts: {
83
90
  json: 'application/json'
84
91
  },
85
- data: this.getDataForAjax(hash),
92
+ data: data,
86
93
  success: this.handleResponse,
87
94
  complete: this.hideLoadingSpinner,
88
95
  error: this.handleError
@@ -77,17 +77,17 @@
77
77
  option value="last_7_days"= I18n.t("tabulatr.date_filter.last_7_days")
78
78
  option value="this_month"= I18n.t("tabulatr.date_filter.this_month")
79
79
  option value="last_30_days"= I18n.t("tabulatr.date_filter.last_30_days")
80
- option value="from_to"= I18n.t("tabulatr.date_filter.from_to")
80
+ option value="from_to"= "#{I18n.t('tabulatr.date_filter.from')} - #{I18n.t('tabulatr.date_filter.to')}"
81
81
  .row.from_to.hidden
82
82
  .col-xs-6
83
83
  .control-group
84
84
  label.control-label for="#{formatted_name}_#{name}_filter_from"
85
- = "Von"
85
+ = I18n.t("tabulatr.date_filter.from")
86
86
  input.tabulatr_filter.form-control.date-picker.hidden.from_to type="text" id="#{formatted_name}_#{name}_filter_from" name="#{iname}[date][from]"
87
87
  .col-xs-6
88
88
  .control-group
89
89
  label.control-label for="#{formatted_name}_#{name}_filter_from"
90
- = "Bis"
90
+ = I18n.t("tabulatr.date_filter.to")
91
91
  input.tabulatr_filter.form-control.date-picker.from_to.hidden type="text" id="#{formatted_name}_#{name}_filter_to" name="#{iname}[date][to]"
92
92
  - elsif column.filter == :enum
93
93
  select.form-control name=iname data-tabulatr-attribute=name
@@ -43,7 +43,7 @@ class Tabulatr::Data
43
43
  def data_for_table(params, locals: {}, controller: nil, &block)
44
44
 
45
45
  @batch_actions = block if block_given?
46
-
46
+ @controller = controller
47
47
 
48
48
  # count
49
49
  total = @relation.count
@@ -106,7 +106,7 @@ module Tabulatr::Data::Filtering
106
106
  end
107
107
 
108
108
  def apply_custom_filter(filter, value)
109
- filter_result = filter.block.(@relation, value)
109
+ filter_result = self.instance_exec @relation, value, &filter.block
110
110
  handle_search_result(filter_result)
111
111
  end
112
112
 
@@ -14,7 +14,8 @@ en:
14
14
  last_7_days: Last 7 Days
15
15
  this_month: This Month
16
16
  last_30_days: Last 30 Days
17
- from_to: From - To
17
+ from: From
18
+ to: To
18
19
  boolean_filter:
19
20
  both: All
20
21
  'yes': Yes
@@ -39,7 +40,8 @@ de:
39
40
  last_7_days: Letzte 7 Tage
40
41
  this_month: Dieser Monat
41
42
  last_30_days: Letzte 30 Tage
42
- from_to: Von - Bis
43
+ from: Von
44
+ to: Bis
43
45
  boolean_filter:
44
46
  both: Alle
45
47
  'yes': Ja
@@ -85,7 +85,8 @@ class Tabulatr::Renderer
85
85
  end
86
86
 
87
87
  def generate_id
88
- "#{Tabulatr::Utility.formatted_name(@klass.name)}_table_#{@view.controller.controller_name}_#{@view.controller.action_name}_#{@view.instance_variable_get(:@_tabulatr_table_index)}"
88
+ controller_path = @view.controller.class.name.underscore.gsub('/', '-')
89
+ "#{Tabulatr::Utility.formatted_name(@klass.name)}_table_#{controller_path}_#{@view.controller.action_name}_#{@view.instance_variable_get(:@_tabulatr_table_index)}"
89
90
  end
90
91
 
91
92
  def self.build_static_table(records, view, toptions={}, &block)
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Tabulatr
25
- VERSION = "0.9.30"
25
+ VERSION = "0.9.31"
26
26
  end
@@ -1,5 +1,8 @@
1
1
  class VendorsController < ApplicationController
2
+ attr_reader :split
3
+
2
4
  def index
5
+ @split = params[:split] && params[:split].to_f || 100
3
6
  tabulatr_for Vendor
4
7
  end
5
8
  end
@@ -7,9 +7,9 @@ class VendorTabulatrData < Tabulatr::Data
7
7
  filter :product_price_range do |relation, value|
8
8
  relation = relation.joins(:products)
9
9
  if value == 'low'
10
- relation.group("vendors.id").having('AVG(products.price) <= 100')
10
+ relation.group("vendors.id").having('AVG(products.price) <= ?', @controller.split)
11
11
  elsif value == 'high'
12
- relation.group("vendors.id").having('AVG(products.price) > 100')
12
+ relation.group("vendors.id").having('AVG(products.price) > ?', @controller.split)
13
13
  end
14
14
  end
15
15
  end
@@ -4,6 +4,6 @@
4
4
  select.form-control.no-chosen id=input_id name=input_name
5
5
  option= I18n.t("tabulatr.date_filter.none")
6
6
  option value="low"
7
- | <= 100 Euro
7
+ | Cheap
8
8
  option value="high"
9
- | > 100 Euro
9
+ | Expensive
@@ -14,7 +14,8 @@ en:
14
14
  last_7_days: Last 7 Days
15
15
  this_month: This Month
16
16
  last_30_days: Last 30 Days
17
- from_to: From - To
17
+ from: From
18
+ to: To
18
19
  boolean_filter:
19
20
  both: All
20
21
  'yes': Yes
@@ -38,7 +39,8 @@ de:
38
39
  last_7_days: Letzte 7 Tage
39
40
  this_month: Dieser Monat
40
41
  last_30_days: Letzte 30 Tage
41
- from_to: Von - Bis
42
+ from: Von
43
+ to: Bis
42
44
  boolean_filter:
43
45
  both: Alle
44
46
  'yes': Ja
@@ -228,16 +228,35 @@ feature "Tabulatr" do
228
228
  expect(page).to have_css(".tabulatr_table tbody tr", count: 2)
229
229
  click_link 'Filter'
230
230
  within(".tabulatr_filter_form") do
231
- select("> 100 Euro", from: "vendor_filter[product_price_range]")
231
+ select("Expensive", from: "vendor_filter[product_price_range]")
232
232
  end
233
233
  expect(page).to have_css(".tabulatr_table tbody tr", count: 1)
234
234
  expect(page).to have_css('.tabulatr_table tbody td', text: @vendor2.name)
235
235
  within(".tabulatr_filter_form") do
236
- select("<= 100 Euro", from: "vendor_filter[product_price_range]")
236
+ select("Cheap", from: "vendor_filter[product_price_range]")
237
237
  end
238
238
  expect(page).to have_css(".tabulatr_table tbody tr", count: 1)
239
239
  expect(page).to have_css('.tabulatr_table tbody td', text: @vendor1.name)
240
240
  end
241
+
242
+ scenario 'custom split filters', js: true do
243
+ Product.create!([{title: 'foo', price: 7.5, vendor: @vendor1}, {title: 'bar', price: 90, vendor: @vendor1}])
244
+ Product.create!([{title: 'baz', price: 125, vendor: @vendor2}, {title: 'fubar', price: 133.3, vendor: @vendor2}, {title: 'fiz', price: 97, vendor: @vendor2}])
245
+ visit vendors_path + '?split=5'
246
+ expect(page).to have_css(".tabulatr_table tbody tr", count: 2)
247
+ click_link 'Filter'
248
+ within(".tabulatr_filter_form") do
249
+ select("Expensive", from: "vendor_filter[product_price_range]")
250
+ end
251
+ expect(page).to have_css(".tabulatr_table tbody tr", count: 2)
252
+ expect(page).to have_css('.tabulatr_table tbody td', text: @vendor1.name)
253
+ expect(page).to have_css('.tabulatr_table tbody td', text: @vendor2.name)
254
+ within(".tabulatr_filter_form") do
255
+ select("Cheap", from: "vendor_filter[product_price_range]")
256
+ end
257
+ # wait_for_ajax
258
+ expect(page).to have_css(".tabulatr_table tbody tr", count: 0, wait: 10)
259
+ end
241
260
  end
242
261
 
243
262
  feature "Sorting" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulatr2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.30
4
+ version: 0.9.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Horn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-02-06 00:00:00.000000000 Z
13
+ date: 2017-04-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  version: '0'
282
282
  requirements: []
283
283
  rubyforge_project:
284
- rubygems_version: 2.5.1
284
+ rubygems_version: 2.6.10
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: A tight DSL to build tables of ActiveRecord models with sorting, pagination,