datagrid 1.3.1 → 1.3.2

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: 6ddccc0241fe7be8d5b6cce9fc48cdf20a5d9d29
4
- data.tar.gz: d6f33446081c20970effc047a14a1b147dd17e55
3
+ metadata.gz: bd9359f7f58b34ec6625249fc8d7d13cbb405316
4
+ data.tar.gz: 6dbf5745b7f3135743ef3ed1b23fe630dc100b5b
5
5
  SHA512:
6
- metadata.gz: 5120028296554128bae6a4614a1ac7a021a6c14cb4c107f55d01efb2b11493fe96db1cf9db1e589a6e9318e966ca7ba09aa628d7ba2467594d08d1a6daa333da
7
- data.tar.gz: 4b23c861a07ded0fb42a89a6a5142e6e17372d55581e8f3b527a95060f8c397eeb5b17266c5a527341c3f070db7a4c359869fb1eb04f4202fc26969eafea5551
6
+ metadata.gz: 77117b5608b994d9d67eace4a2b0e05ae9b1c02fa4786f7d21ca7ad748c1c0048a2ae98867570e7cabb2e2b32071b7b07cfb3d4948e7d13d5a5eb931e78c2f90
7
+ data.tar.gz: a3cd49749291d88682cb943e738a30ff525f700d49a15cd8364c3dcadf8325043b2f94b44c61dc612bb3daddaaa344dd2f84c29119d45a76e62127162d50a042
data/Gemfile CHANGED
@@ -18,7 +18,7 @@ group :development do
18
18
  gem "sqlite3"
19
19
 
20
20
  group :mongo do
21
- gem "mongoid", "2.2.2"
21
+ gem "mongoid", "3.1.6"
22
22
  gem "mongo_mapper", ">=0.11.0"
23
23
  gem "bson", "1.4.0"
24
24
  gem "bson_ext", "1.4.0"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
@@ -2,7 +2,7 @@
2
2
  <% grid.html_columns(*options[:columns]).each do |column| %>
3
3
  <th class="<%= datagrid_column_classes(grid, column) %>">
4
4
  <%= column.header %>
5
- <%= datagrid_order_for(grid, column, options) if column.order && options[:order]%>
5
+ <%= datagrid_order_for(grid, column, options) if column.supports_order? && options[:order]%>
6
6
  </th>
7
7
  <% end %>
8
8
  </tr>
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: datagrid 1.3.1 ruby lib
5
+ # stub: datagrid 1.3.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "datagrid"
9
- s.version = "1.3.1"
9
+ s.version = "1.3.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Bogdan Gusiev"]
14
- s.date = "2014-08-21"
14
+ s.date = "2014-10-27"
15
15
  s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
16
16
  s.email = "agresso@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -135,7 +135,7 @@ Gem::Specification.new do |s|
135
135
  s.add_development_dependency(%q<rspec>, [">= 3"])
136
136
  s.add_development_dependency(%q<nokogiri>, [">= 0"])
137
137
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
138
- s.add_development_dependency(%q<mongoid>, ["= 2.2.2"])
138
+ s.add_development_dependency(%q<mongoid>, ["= 3.1.6"])
139
139
  s.add_development_dependency(%q<mongo_mapper>, [">= 0.11.0"])
140
140
  s.add_development_dependency(%q<bson>, ["= 1.4.0"])
141
141
  s.add_development_dependency(%q<bson_ext>, ["= 1.4.0"])
@@ -150,7 +150,7 @@ Gem::Specification.new do |s|
150
150
  s.add_dependency(%q<rspec>, [">= 3"])
151
151
  s.add_dependency(%q<nokogiri>, [">= 0"])
152
152
  s.add_dependency(%q<sqlite3>, [">= 0"])
153
- s.add_dependency(%q<mongoid>, ["= 2.2.2"])
153
+ s.add_dependency(%q<mongoid>, ["= 3.1.6"])
154
154
  s.add_dependency(%q<mongo_mapper>, [">= 0.11.0"])
155
155
  s.add_dependency(%q<bson>, ["= 1.4.0"])
156
156
  s.add_dependency(%q<bson_ext>, ["= 1.4.0"])
@@ -166,7 +166,7 @@ Gem::Specification.new do |s|
166
166
  s.add_dependency(%q<rspec>, [">= 3"])
167
167
  s.add_dependency(%q<nokogiri>, [">= 0"])
168
168
  s.add_dependency(%q<sqlite3>, [">= 0"])
169
- s.add_dependency(%q<mongoid>, ["= 2.2.2"])
169
+ s.add_dependency(%q<mongoid>, ["= 3.1.6"])
170
170
  s.add_dependency(%q<mongo_mapper>, [">= 0.11.0"])
171
171
  s.add_dependency(%q<bson>, ["= 1.4.0"])
172
172
  s.add_dependency(%q<bson_ext>, ["= 1.4.0"])
@@ -106,7 +106,7 @@ class Datagrid::Columns::Column
106
106
  end
107
107
 
108
108
  def inspect
109
- "#<Datagird::Columns::Column #{grid_class}##{name} #{options.inspect}>"
109
+ "#<Datagrid::Columns::Column #{grid_class}##{name} #{options.inspect}>"
110
110
  end
111
111
 
112
112
  def to_s
@@ -24,7 +24,7 @@ module Datagrid
24
24
  end
25
25
 
26
26
  def desc(scope, order)
27
- scope.sort(order.desc)
27
+ scope.sort("#{order} desc")
28
28
  end
29
29
 
30
30
  def default_order(scope, column_name)
@@ -1,4 +1,7 @@
1
1
  class Datagrid::Filters::FloatFilter < Datagrid::Filters::BaseFilter
2
+
3
+ include RangedFilter
4
+
2
5
  def parse(value)
3
6
  return nil if value.blank?
4
7
  value.to_f
@@ -4,10 +4,10 @@ module Datagrid
4
4
  module FormBuilder
5
5
 
6
6
  # Returns a form input html for the corresponding filter name
7
- def datagrid_filter(filter_or_attribute, options = {})
7
+ def datagrid_filter(filter_or_attribute, options = {}, &block)
8
8
  filter = datagrid_get_filter(filter_or_attribute)
9
9
  options = add_html_classes(options, filter.name, datagrid_filter_html_class(filter))
10
- self.send(filter.form_builder_helper_name, filter, options)
10
+ self.send(filter.form_builder_helper_name, filter, options, &block)
11
11
  end
12
12
 
13
13
  # Returns a form label html for the corresponding filter name
@@ -43,7 +43,7 @@ module Datagrid
43
43
  text_field filter.name, options.reverse_merge(:value => object.filter_value_as_string(filter))
44
44
  end
45
45
 
46
- def datagrid_enum_filter(attribute_or_filter, options = {})
46
+ def datagrid_enum_filter(attribute_or_filter, options = {}, &block)
47
47
  filter = datagrid_get_filter(attribute_or_filter)
48
48
  if filter.checkboxes?
49
49
  options = add_html_classes(options, 'checkboxes')
@@ -60,7 +60,14 @@ module Datagrid
60
60
  if !options.has_key?(:multiple) && filter.multiple?
61
61
  options[:multiple] = true
62
62
  end
63
- select filter.name, filter.select(object) || [], {:include_blank => filter.include_blank, :prompt => filter.prompt, :include_hidden => false}, options
63
+ select(
64
+ filter.name,
65
+ filter.select(object) || [],
66
+ {:include_blank => filter.include_blank,
67
+ :prompt => filter.prompt,
68
+ :include_hidden => false},
69
+ options, &block
70
+ )
64
71
  end
65
72
  end
66
73
 
@@ -155,7 +162,7 @@ module Datagrid
155
162
  end
156
163
 
157
164
  def datagrid_float_filter(attribute_or_filter, options = {})
158
- datagrid_default_filter(attribute_or_filter, options)
165
+ datagrid_range_filter(:float, attribute_or_filter, options)
159
166
  end
160
167
 
161
168
  def datagrid_get_attribute(attribute_or_filter)
@@ -19,6 +19,9 @@ en:
19
19
  datetime:
20
20
  range_format:
21
21
  "%{from_input}<span class=\"separator datetime\"> - </span>%{to_input}"
22
+ float:
23
+ range_format:
24
+ "%{from_input}<span class=\"separator float\"> - </span>%{to_input}"
22
25
 
23
26
  eboolean:
24
27
  "yes": "Yes"
@@ -8,6 +8,9 @@ class Datagrid::Scaffold < Rails::Generators::NamedBase
8
8
  template "controller.rb.erb", "app/controllers/#{grid_controller_name.underscore}.rb"
9
9
  template "index.html.erb", "app/views/#{grid_controller_short_name}/index.html.erb"
10
10
  route("resources :#{grid_controller_short_name}")
11
+ unless defined?(::Kaminari) || defined?(::WillPaginate)
12
+ gem 'kaminari'
13
+ end
11
14
  in_root do
12
15
  {
13
16
  "css" => " *= require datagrid",
@@ -43,20 +46,15 @@ class Datagrid::Scaffold < Rails::Generators::NamedBase
43
46
  end
44
47
 
45
48
  def paginate_code
46
- if defined?(::Kaminari) || defined?(::WillPaginate)
47
- "page(params[:page])"
48
- else
49
- "paginate_somehow"
50
- end
49
+ "page(params[:page])"
51
50
  end
52
51
 
53
52
  def pagination_helper_code
54
- if defined?(::Kaminari)
55
- "paginate(@grid.assets)"
56
- elsif defined?(::WillPaginate)
53
+ if defined?(::WillPaginate)
57
54
  "will_paginate(@grid.assets)"
58
55
  else
59
- "some_pagination_helper(@grid.assets)"
56
+ # Kaminari is default
57
+ "paginate(@grid.assets)"
60
58
  end
61
59
 
62
60
  end
@@ -1,3 +1,5 @@
1
+ require "spec_helper"
2
+
1
3
  describe Datagrid::Drivers::MongoMapper, :mongomapper do
2
4
 
3
5
  describe ".match?" do
@@ -27,7 +27,7 @@ describe Datagrid::Filters::DateTimeFilter do
27
27
  let(:_created_at) { [DateTime.now.beginning_of_day, DateTime.now.end_of_day] }
28
28
  it { should include(entry_dated(1.second.ago))}
29
29
  it { should include(entry_dated(Date.today.to_datetime))}
30
- it { should include(entry_dated(Date.today.end_of_day.to_datetime))}
30
+ it { should include(entry_dated(DateTime.now.end_of_day.to_datetime))}
31
31
  it { should_not include(entry_dated(Date.yesterday.end_of_day))}
32
32
  it { should_not include(entry_dated(Date.tomorrow.beginning_of_day))}
33
33
  end
@@ -25,10 +25,11 @@ describe Datagrid::FormBuilder do
25
25
  end
26
26
 
27
27
  subject do
28
- view.datagrid_filter(_filter, _filter_options)
28
+ view.datagrid_filter(_filter, _filter_options, &_filter_block)
29
29
  end
30
30
 
31
31
  let(:_filter_options) { {} }
32
+ let(:_filter_block) { nil }
32
33
  context "with default filter type" do
33
34
  let(:_grid) {
34
35
  test_report do
@@ -152,6 +153,21 @@ describe Datagrid::FormBuilder do
152
153
  )}
153
154
  end
154
155
  end
156
+ context "with float filter type and range option" do
157
+ let(:_filter) { :rating }
158
+ let(:_grid) {
159
+ test_report(:rating => _range) do
160
+ scope {Group}
161
+ filter(:rating, :float, :range => true)
162
+ end
163
+ }
164
+ let(:_range) { [1.5,2.5]}
165
+ it { should equal_to_dom(
166
+ '<input class="rating float_filter from" multiple name="report[rating][]" size="30" type="text" value="1.5"/>' +
167
+ '<span class="separator float"> - </span>' +
168
+ '<input class="rating float_filter to" multiple name="report[rating][]" size="30" type="text" value="2.5"/>'
169
+ )}
170
+ end
155
171
 
156
172
 
157
173
  context "with date filter type and range option" do
@@ -233,6 +249,16 @@ describe Datagrid::FormBuilder do
233
249
  <option value="first">first</option>
234
250
  <option value="second">second</option></select>'
235
251
  )}
252
+
253
+ context "when block is given" do
254
+ before(:each) do
255
+ pending("not supported by rails < 4.1") if Rails.version < '4.1'
256
+ end
257
+ let(:_filter_block ) { proc { template.content_tag(:option, 'block option', :value => 'block_value') }}
258
+ it { should equal_to_dom(
259
+ '<select class="category enum_filter" id="report_category" name="report[category]"><option value=\"block_value\">block option</option></select>'
260
+ )}
261
+ end
236
262
  context "when first option is selected" do
237
263
  before(:each) do
238
264
  _grid.category = "first"
@@ -382,6 +382,7 @@ describe Datagrid::Helper do
382
382
  </div>
383
383
  HTML
384
384
  end
385
+
385
386
  end
386
387
  describe ".datagrid_form_for" do
387
388
  it 'returns namespaced partial if partials options is passed' do
@@ -517,5 +518,28 @@ describe Datagrid::Helper do
517
518
  expect(data_row.random2).to_not eq(html_row.random2)
518
519
  expect(data_row.random2).to_not eq(html_row.random1)
519
520
  end
521
+
522
+ end
523
+
524
+ describe ".datagrid_header" do
525
+
526
+ it "should support order_by_value colums" do
527
+ grid = test_report(:order => "category") do
528
+ scope { Entry }
529
+ column(:category, :order => false, :order_by_value => true)
530
+
531
+ def param_name
532
+ 'grid'
533
+ end
534
+ end
535
+ expect(subject.datagrid_header(grid)).to equal_to_dom(<<HTML)
536
+ <tr><th class="category ordered asc">Category<div class="order">
537
+ <a href="/location?grid%5Bdescending%5D=false&amp;grid%5Border%5D=category" class="asc">&uarr;</a><a href="/location?grid%5Bdescending%5D=true&amp;grid%5Border%5D=category" class="desc">&darr;</a>
538
+ </div>
539
+ </th></tr>
540
+ HTML
541
+ end
520
542
  end
543
+
521
544
  end
545
+
@@ -5,13 +5,13 @@ describe Datagrid::Scaffold do
5
5
 
6
6
  describe '.paginate_code' do
7
7
  it 'should fall through options successfully' do
8
- expect(subject.paginate_code).to eql('paginate_somehow')
8
+ expect(subject.paginate_code).to eql('page(params[:page])')
9
9
  end
10
10
  end
11
11
 
12
12
  describe '.pagination_helper_code' do
13
13
  it 'should fall through options successfully' do
14
- expect(subject.pagination_helper_code).to eql('some_pagination_helper(@grid.assets)')
14
+ expect(subject.pagination_helper_code).to eql('paginate(@grid.assets)')
15
15
  end
16
16
 
17
17
  context "when Kaminari exists" do
@@ -42,11 +42,17 @@ TEST_LOGGER = Logger.new('spec.log')
42
42
  NO_MONGO = ENV['NO_MONGO']
43
43
 
44
44
  begin
45
- Mongoid.from_hash({
46
- "host" => "localhost",
47
- "database" =>"datagrid_mongoid",
48
- "autocreate_indexes" => true,
49
- "logger" => nil,
45
+ Mongoid.load_configuration({
46
+ "sessions" =>
47
+ {
48
+ "default" =>
49
+ {
50
+ "hosts" => ["localhost:27017"],
51
+ "database" =>"datagrid_mongoid",
52
+ "autocreate_indexes" => true,
53
+ "logger" => nil,
54
+ }
55
+ }
50
56
  })
51
57
  MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
52
58
  MongoMapper.database = "datagrid_mongo_mapper"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datagrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-21 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 2.2.2
145
+ version: 3.1.6
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 2.2.2
152
+ version: 3.1.6
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: mongo_mapper
155
155
  requirement: !ruby/object:Gem::Requirement