mighty_grid 2.0.0.rc1 → 2.0.0

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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.document +2 -0
  3. data/.gitignore +26 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +35 -0
  6. data/Appraisals +17 -0
  7. data/README.md +44 -24
  8. data/config/locales/en.yml +1 -0
  9. data/gemfiles/rails_40.gemfile +27 -0
  10. data/gemfiles/rails_41.gemfile +27 -0
  11. data/gemfiles/rails_42.gemfile +27 -0
  12. data/lib/mighty_grid/base.rb +1 -1
  13. data/lib/mighty_grid/grid_renderer.rb +5 -2
  14. data/lib/mighty_grid/parameters.rb +1 -1
  15. data/lib/mighty_grid/version.rb +1 -1
  16. data/mighty_grid.gemspec +26 -0
  17. data/spec/dummy/app/assets/images/.keep +0 -0
  18. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  19. data/spec/dummy/app/mailers/.keep +0 -0
  20. data/spec/dummy/app/models/.keep +0 -0
  21. data/spec/dummy/app/models/concerns/.keep +0 -0
  22. data/spec/dummy/lib/assets/.keep +0 -0
  23. metadata +37 -137
  24. data/spec/dummy/config/database.yml +0 -29
  25. data/spec/dummy/db/mg_test.sqlite3 +0 -0
  26. data/spec/dummy/log/development.log +0 -119680
  27. data/spec/dummy/log/test.log +0 -101833
  28. data/spec/dummy/tmp/cache/assets/CCA/5E0/sprockets%2F48d34122dd1905305a6e63e3acb7c042 +0 -0
  29. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  30. data/spec/dummy/tmp/cache/assets/CF9/100/sprockets%2F3d8f5e96de4712db63b98083f75739c3 +0 -0
  31. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  32. data/spec/dummy/tmp/cache/assets/D3C/EE0/sprockets%2Fccfd910338b6dcf575467d3009b46a0d +0 -0
  33. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  34. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  35. data/spec/dummy/tmp/cache/assets/D60/BE0/sprockets%2F37b5ab8193eccd1a29a0c61374c6b51e +0 -0
  36. data/spec/dummy/tmp/cache/assets/D82/820/sprockets%2Ff7c8a51f7f95d66a9d5112f898bc1fd0 +0 -0
  37. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  38. data/spec/dummy/tmp/cache/assets/DF2/A80/sprockets%2F14a708b3bb2a924afdebae773e4ba5d8 +0 -0
  39. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  40. data/spec/dummy/tmp/cache/assets/E0C/4E0/sprockets%2Fed4e3dbab857786229b1bdf7bbd289fe +0 -0
  41. data/spec/dummy/tmp/cache/assets/E14/600/sprockets%2F34cd0de2e0cd2c01e1c91b0ece565deb +0 -0
  42. data/spec/dummy/tmp/cache/assets/development/sprockets/0e57c0129c0245eab3972d87efc6a9b9 +0 -0
  43. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  44. data/spec/dummy/tmp/cache/assets/development/sprockets/14a708b3bb2a924afdebae773e4ba5d8 +0 -0
  45. data/spec/dummy/tmp/cache/assets/development/sprockets/1f8135a48e7ccbcb5361bb9e1f993929 +0 -0
  46. data/spec/dummy/tmp/cache/assets/development/sprockets/2479f30262de64213c228dc752440fd1 +0 -0
  47. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  48. data/spec/dummy/tmp/cache/assets/development/sprockets/34cd0de2e0cd2c01e1c91b0ece565deb +0 -0
  49. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  50. data/spec/dummy/tmp/cache/assets/development/sprockets/37b5ab8193eccd1a29a0c61374c6b51e +0 -0
  51. data/spec/dummy/tmp/cache/assets/development/sprockets/3cbb6c28c7bbcc7c9b547346a59b4e7f +0 -0
  52. data/spec/dummy/tmp/cache/assets/development/sprockets/3d8f5e96de4712db63b98083f75739c3 +0 -0
  53. data/spec/dummy/tmp/cache/assets/development/sprockets/422d4d422d090c103e6b198600a90dac +0 -0
  54. data/spec/dummy/tmp/cache/assets/development/sprockets/48d34122dd1905305a6e63e3acb7c042 +0 -0
  55. data/spec/dummy/tmp/cache/assets/development/sprockets/a8c1ee1faf09397765710724fe3ee140 +0 -0
  56. data/spec/dummy/tmp/cache/assets/development/sprockets/bbd98f4797053ba2accbbca7b81cbbaf +0 -0
  57. data/spec/dummy/tmp/cache/assets/development/sprockets/cc03506b8188f839058f41aa8a4e19da +0 -0
  58. data/spec/dummy/tmp/cache/assets/development/sprockets/cccf51971e81f175e527083a6ef4624d +0 -0
  59. data/spec/dummy/tmp/cache/assets/development/sprockets/ccfd910338b6dcf575467d3009b46a0d +0 -0
  60. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  61. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  62. data/spec/dummy/tmp/cache/assets/development/sprockets/d77d41650e5528f12146c728566cbf33 +0 -0
  63. data/spec/dummy/tmp/cache/assets/development/sprockets/ed4e3dbab857786229b1bdf7bbd289fe +0 -0
  64. data/spec/dummy/tmp/cache/assets/development/sprockets/f7c8a51f7f95d66a9d5112f898bc1fd0 +0 -0
  65. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  66. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  67. data/spec/dummy/tmp/cache/assets/test/sprockets/14a708b3bb2a924afdebae773e4ba5d8 +0 -0
  68. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  69. data/spec/dummy/tmp/cache/assets/test/sprockets/34cd0de2e0cd2c01e1c91b0ece565deb +0 -0
  70. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  71. data/spec/dummy/tmp/cache/assets/test/sprockets/37b5ab8193eccd1a29a0c61374c6b51e +0 -0
  72. data/spec/dummy/tmp/cache/assets/test/sprockets/3d8f5e96de4712db63b98083f75739c3 +0 -0
  73. data/spec/dummy/tmp/cache/assets/test/sprockets/422d4d422d090c103e6b198600a90dac +0 -0
  74. data/spec/dummy/tmp/cache/assets/test/sprockets/48d34122dd1905305a6e63e3acb7c042 +0 -0
  75. data/spec/dummy/tmp/cache/assets/test/sprockets/a8c1ee1faf09397765710724fe3ee140 +0 -0
  76. data/spec/dummy/tmp/cache/assets/test/sprockets/cccf51971e81f175e527083a6ef4624d +0 -0
  77. data/spec/dummy/tmp/cache/assets/test/sprockets/ccfd910338b6dcf575467d3009b46a0d +0 -0
  78. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  79. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  80. data/spec/dummy/tmp/cache/assets/test/sprockets/ed4e3dbab857786229b1bdf7bbd289fe +0 -0
  81. data/spec/dummy/tmp/cache/assets/test/sprockets/f7c8a51f7f95d66a9d5112f898bc1fd0 +0 -0
  82. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  83. data/spec/lib/tmp/config/initializers/mighty_grid.rb +0 -15
  84. data/spec/lib/tmp/config/locales/mighty_grid.en.yml +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae66ac068670599398526077c090a43897244668
4
- data.tar.gz: 599f7821d5b8c9c008313738d1b3ccb19e10aa0a
3
+ metadata.gz: 882bea1ae17754a079753be41bbeb7a855b03956
4
+ data.tar.gz: 44283d60dde96275f986160defedf980b3322996
5
5
  SHA512:
6
- metadata.gz: 4a41aaade69e5ad4e51d84c46291288064f997abcd9a5d97a1c30a053bf9c5a8ba1b3e0e767195b3b089022075ce4f457999235b9124c072d26b1be2b972fd57
7
- data.tar.gz: ae204f9bac3fb47080dc7c21a96f325121c44919f1ea86d98bb98c28c21b6b51d9d5058fff02e7e970e0ac348ab1a35fd7518d1ebf61099f7613babaa1a4181d
6
+ metadata.gz: 9d6444d5e8002af7eb9c30c33873e6174f519ee7da1dfea64792563ac8bdf0efcb76d77df08710f46be319f7c803205ad77c3c6b9af421eea63e8cbecd861299
7
+ data.tar.gz: d8faca0136abe01cb09ee4aea111d4a1457553f96c93482624fa3dc9f9fbec1d2f545dd0588a871b88e2bf315d962b8729ad2c127faa78f65122b575411f6b99
data/.document ADDED
@@ -0,0 +1,2 @@
1
+ lib/**/*.rb
2
+ MIT-LICENSE
data/.gitignore ADDED
@@ -0,0 +1,26 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ *emfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ log
20
+ database.yml
21
+
22
+ spec/dummy/db/*.sqlite3
23
+ spec/dummy/db/*.sqlite3-journal
24
+ spec/dummy/log/*.log
25
+ spec/dummy/tmp/
26
+ spec/dummy/.sass-cache
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,35 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.1
5
+ - ruby-head
6
+
7
+ script:
8
+ - bundle exec rake -f spec/dummy/Rakefile db:migrate
9
+ - bundle exec rake spec cucumber
10
+
11
+ before_script:
12
+ - cp spec/dummy/config/database.yml.travis spec/dummy/config/database.yml
13
+ - mysql -e 'create database mg_test'
14
+ - psql -c 'create database mg_test' -U postgres
15
+
16
+ env:
17
+ - DB=sqlite
18
+ - DB=mysql
19
+ - DB=postgresql
20
+
21
+ gemfile:
22
+ - gemfiles/rails_40.gemfile
23
+ - gemfiles/rails_41.gemfile
24
+ - gemfiles/rails_42.gemfile
25
+
26
+ addons:
27
+ code_climate:
28
+ repo_token: 47bc411a11ccfed015bf25395d8204600c899e530c1c4beed1b7197aa61c6fb6
29
+ postgresql: "9.3"
30
+
31
+ matrix:
32
+ allow_failures:
33
+ - rvm: ruby-head
34
+
35
+ sudo: false
data/Appraisals ADDED
@@ -0,0 +1,17 @@
1
+ appraise "rails_40" do
2
+ gem "rails", "~> 4.0.0"
3
+ gem "activerecord", "~> 4.0.0", require: 'active_record'
4
+ gem 'coffee-rails', '~> 4.0.0'
5
+ end
6
+
7
+ appraise "rails_41" do
8
+ gem "rails", "~> 4.1.0"
9
+ gem "activerecord", "~> 4.1.0", require: 'active_record'
10
+ gem 'coffee-rails', '~> 4.0.0'
11
+ end
12
+
13
+ appraise "rails_42" do
14
+ gem "rails", "~> 4.2.0"
15
+ gem "activerecord", "~> 4.2.0", require: 'active_record'
16
+ gem 'coffee-rails', '~> 4.1.0'
17
+ end
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # MightyGrid [![Gem Version](http://img.shields.io/gem/v/mighty_grid.svg)](http://badge.fury.io/rb/mighty_grid) [![Build Status](https://travis-ci.org/jurrick/mighty_grid.svg?branch=master)](https://travis-ci.org/jurrick/mighty_grid) [![Code Climate](https://codeclimate.com/github/jurrick/mighty_grid.png)](https://codeclimate.com/github/jurrick/mighty_grid) [![Inline docs](http://inch-ci.org/github/jurrick/mighty_grid.png)](http://inch-ci.org/github/jurrick/mighty_grid)
2
2
 
3
- MightyGrid is a flexible grid solution for Ruby On Rails.
3
+ MightyGrid is very simple and flexible grid solution for Ruby On Rails.
4
+
5
+ ## Features
6
+
7
+ * Ruby 2.x support
8
+ * Rails 4.x support
9
+ * Easy building grids
10
+ * Flexible filtering
11
+ * Simple sorting
4
12
 
5
13
  ## Installation
6
14
 
@@ -19,38 +27,50 @@ After generation you will see the following files:
19
27
 
20
28
  ## Quick Start
21
29
 
22
- ### Grid
30
+ 1. Creating grid
23
31
 
24
- Any grid can be defined in a folder `app/grids` for example as follows:
32
+ Any grid can be created in a folder `app/grids` for example as follows:
25
33
 
26
- ```
27
- Class ProductsGrid < MightyGrid::Base
28
- scope { Product }
29
- end
30
- ```
31
-
32
- ### Controller
34
+ ```ruby
35
+ class ProductsGrid < MightyGrid::Base
36
+ scope { Product }
37
+ end
38
+ ```
33
39
 
34
- You can initialize grid like this:
40
+ 2. Initialize the grid in a controller
35
41
 
36
- ```
37
- def index
38
- @products_grid = ProductsGrid.new(params)
39
- end
40
- ```
42
+ ```ruby
43
+ def index
44
+ @products_grid = ProductsGrid.new(params)
45
+ end
46
+ ```
41
47
 
42
- ### Show View
48
+ 3. Show created grid
43
49
 
44
- ```
45
- <%= grid @products_grid do |g| %>
46
- <% - g.column :id %>
47
- <% - g.column :name %>
48
- <% - g.column :description %>
49
- <% end %>
50
- ```
50
+ ```ruby
51
+ <%= grid @products_grid do |g| %>
52
+ <% - g.column :id %>
53
+ <% - g.column :name %>
54
+ <% - g.column :description %>
55
+ <% end %>
56
+ ```
51
57
 
52
58
  ## Usage
53
59
 
60
+ ### Filters
61
+
62
+ A simple example of the use of filters:
63
+
64
+ ```ruby
65
+ class ProductsGrid < MightyGrid::Base
66
+ scope { Product }
67
+
68
+ filter :name
69
+ filter :status, :enum, collection: [['active', 'Active'], ['inactive', 'Inactive']]
70
+ filter :author, :string, attribute: :name, model: User
71
+ end
72
+ ```
73
+
54
74
  ### General configuration options
55
75
 
56
76
  You can configure the following default values by overriding these values using <tt>MightyGrid.setup</tt> method.
@@ -1,6 +1,7 @@
1
1
  en:
2
2
  mighty_grid:
3
3
  display_entries: "<strong>%{first} &ndash; %{last} of %{total}</strong>"
4
+ actions: Actions
4
5
  filters:
5
6
  submit: Apply changes
6
7
  reset: Reset changes
@@ -0,0 +1,27 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "uglifier", ">= 1.3.0"
6
+ gem "jquery-rails"
7
+ gem "rails", "~> 4.0.0"
8
+ gem "activerecord", "~> 4.0.0", :require => "active_record"
9
+ gem "coffee-rails", "~> 4.0.0"
10
+
11
+ group :test do
12
+ gem "sqlite3"
13
+ gem "generator_spec"
14
+ gem "capybara", :require => false
15
+ gem "database_cleaner"
16
+ gem "cucumber-rails", :require => false
17
+ gem "spreewald"
18
+ gem "poltergeist"
19
+ gem "launchy"
20
+ gem "coveralls", :require => false
21
+ gem "codeclimate-test-reporter", :require => nil
22
+ gem "pg", :require => false
23
+ gem "mysql2", :require => false
24
+ gem "pry"
25
+ end
26
+
27
+ gemspec :path => "../"
@@ -0,0 +1,27 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "uglifier", ">= 1.3.0"
6
+ gem "jquery-rails"
7
+ gem "rails", "~> 4.1.0"
8
+ gem "activerecord", "~> 4.1.0", :require => "active_record"
9
+ gem "coffee-rails", "~> 4.0.0"
10
+
11
+ group :test do
12
+ gem "sqlite3"
13
+ gem "generator_spec"
14
+ gem "capybara", :require => false
15
+ gem "database_cleaner"
16
+ gem "cucumber-rails", :require => false
17
+ gem "spreewald"
18
+ gem "poltergeist"
19
+ gem "launchy"
20
+ gem "coveralls", :require => false
21
+ gem "codeclimate-test-reporter", :require => nil
22
+ gem "pg", :require => false
23
+ gem "mysql2", :require => false
24
+ gem "pry"
25
+ end
26
+
27
+ gemspec :path => "../"
@@ -0,0 +1,27 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "uglifier", ">= 1.3.0"
6
+ gem "jquery-rails"
7
+ gem "rails", "~> 4.2.0"
8
+ gem "activerecord", "~> 4.2.0", :require => "active_record"
9
+ gem "coffee-rails", "~> 4.1.0"
10
+
11
+ group :test do
12
+ gem "sqlite3"
13
+ gem "generator_spec"
14
+ gem "capybara", :require => false
15
+ gem "database_cleaner"
16
+ gem "cucumber-rails", :require => false
17
+ gem "spreewald"
18
+ gem "poltergeist"
19
+ gem "launchy"
20
+ gem "coveralls", :require => false
21
+ gem "codeclimate-test-reporter", :require => nil
22
+ gem "pg", :require => false
23
+ gem "mysql2", :require => false
24
+ gem "pry"
25
+ end
26
+
27
+ gemspec :path => "../"
@@ -54,7 +54,7 @@ module MightyGrid
54
54
 
55
55
  def read
56
56
  apply_filters
57
- if @mg_params[:order].present? && current_order_direction.present?
57
+ if @mg_params[:order].present? && current_order_direction.present? && !@mg_params[:order].kind_of?(Hash)
58
58
  @relation = @relation.order("#{@mg_params[:order]} #{current_order_direction.to_sym}")
59
59
  else
60
60
  @relation = @relation.order(@mg_params[:order])
@@ -36,13 +36,16 @@ module MightyGrid
36
36
  def actions(opts = {})
37
37
  options = {
38
38
  partial: 'mighty_grid/actions',
39
- only: [:show, :edit, :destroy]
39
+ only: [:show, :edit, :destroy],
40
+ html: {},
41
+ th_html: {},
42
+ title: I18n.t('mighty_grid.actions', default: 'Actions')
40
43
  }
41
44
 
42
45
  opts.assert_valid_keys(options.keys)
43
46
  options.merge!(opts)
44
47
 
45
- @columns << MightyGrid::Column.new(title: 'Actions') { |object| @grid.controller.render_to_string(partial: options[:partial], locals: { actions: options[:only], object: object }) }
48
+ @columns << MightyGrid::Column.new(options) { |object| @grid.controller.render_to_string(partial: options[:partial], locals: { actions: options[:only], object: object }) }
46
49
  end
47
50
 
48
51
  def row_attributes(&block)
@@ -12,7 +12,7 @@ module MightyGrid
12
12
  @mg_params.merge!(@options)
13
13
  if current_grid_params
14
14
  @mg_params.merge!(current_grid_params.symbolize_keys)
15
- if @mg_params[:order].present? && !@mg_params[:order].to_s.include?('.')
15
+ if @mg_params[:order].present? && !@mg_params[:order].to_s.include?('.') && !@mg_params[:order].kind_of?(Hash)
16
16
  @mg_params[:order] = "#{klass.table_name}.#{@mg_params[:order]}"
17
17
  end
18
18
  end
@@ -7,7 +7,7 @@ module MightyGrid
7
7
  MAJOR = 2
8
8
  MINOR = 0
9
9
  TINY = 0
10
- PRE = 'rc1'
10
+ PRE = nil
11
11
 
12
12
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
13
13
  end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'mighty_grid/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'mighty_grid'
7
+ s.version = MightyGrid.gem_version
8
+ s.authors = ['jurrick']
9
+ s.email = ['jurianp@gmail.com']
10
+ s.summary = %q(Simple and flexible grid for Rails)
11
+ s.description = %q(Simple and flexible grid for Rails)
12
+ s.homepage = 'http://github.com/jurrick/mighty_grid'
13
+ s.license = 'MIT'
14
+ s.required_ruby_version = '~> 2.0'
15
+
16
+ s.files = `git ls-files`.split($/)
17
+ s.test_files = s.files.grep(%r{^(spec|features)/})
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_development_dependency 'bundler', '~> 1.5'
21
+ s.add_development_dependency 'rake'
22
+ s.add_development_dependency 'rspec-rails', '~> 2.14.2'
23
+ s.add_development_dependency 'appraisal'
24
+
25
+ s.add_dependency 'kaminari', '~> 0.15'
26
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes