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 +4 -4
- data/.travis.yml +5 -6
- data/Gemfile +6 -1
- data/app/assets/javascripts/tabulatr/_tabulatr.js +8 -1
- data/app/views/tabulatr/_tabulatr_filter_dialog.html.slim +3 -3
- data/lib/tabulatr/data/data.rb +1 -1
- data/lib/tabulatr/data/filtering.rb +1 -1
- data/lib/tabulatr/generators/tabulatr/templates/tabulatr.yml +4 -2
- data/lib/tabulatr/renderer/renderer.rb +2 -1
- data/lib/tabulatr/version.rb +1 -1
- data/spec/dummy/app/controllers/vendors_controller.rb +3 -0
- data/spec/dummy/app/tabulatr_data/vendor_tabulatr_data.rb +2 -2
- data/spec/dummy/app/views/tabulatr/filter/_product_price_range.html.slim +2 -2
- data/spec/dummy/config/locales/tabulatr.yml +4 -2
- data/spec/features/tabulatrs_spec.rb +21 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21719e71fe7654c3881b1abf925168d7ee09bb5f
|
4
|
+
data.tar.gz: df5a0301ac3c3e608a96dd62ccf87eb350f884b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81785a96b3deb0249269a0b2487ed70b231f0fc810e14383e9bd088aeb97f80e47b0116c916436fefb372985fe829bc9462d49cf8dfc04de199593322617ecdd
|
7
|
+
data.tar.gz: ef55f54530aa2906db178edca61b1ff56ffdd97ec5ca60c88f502baafdcd85ca9d4ac8f6c94f52e0622acf07e740881280f846b749d0b034cd7533375d0558c7
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -15,7 +15,12 @@ end
|
|
15
15
|
|
16
16
|
|
17
17
|
group :development, :test do
|
18
|
-
|
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:
|
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(
|
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
|
-
= "
|
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
|
-
= "
|
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
|
data/lib/tabulatr/data/data.rb
CHANGED
@@ -106,7 +106,7 @@ module Tabulatr::Data::Filtering
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def apply_custom_filter(filter, value)
|
109
|
-
filter_result =
|
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
|
-
|
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
|
-
|
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
|
-
|
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)
|
data/lib/tabulatr/version.rb
CHANGED
@@ -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) <=
|
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) >
|
12
|
+
relation.group("vendors.id").having('AVG(products.price) > ?', @controller.split)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -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
|
-
|
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
|
-
|
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("
|
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("
|
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.
|
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-
|
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.
|
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,
|