acts_as_flexigrid 0.0.2 → 0.0.3
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.
- data/LICENSE +20 -0
- data/README.rdoc +65 -0
- data/lib/acts_as_flexigrid/version.rb +1 -1
- data/lib/acts_as_flexigrid.rb +2 -1
- data/spec/models/acts_as_flexigrid_spec.rb +16 -2
- metadata +17 -15
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Akihiro Matsumura
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
= acts_as_flexigrid
|
2
|
+
|
3
|
+
ActiveRecord plugin to use easily Flexigrid that is jQuery plugin for grid table
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install acts_as_flexigrid
|
8
|
+
|
9
|
+
== How to use
|
10
|
+
|
11
|
+
1. Download Flexigrid from http://flexigrid.info/ and place javascript and css files.
|
12
|
+
|
13
|
+
2. Include to models
|
14
|
+
|
15
|
+
class Site < ActiveRecord::Base
|
16
|
+
include ActsAsFlexigrid
|
17
|
+
end
|
18
|
+
|
19
|
+
3. Get json response for Flexigrid
|
20
|
+
|
21
|
+
class SitesController < ApplicationController
|
22
|
+
|
23
|
+
def index
|
24
|
+
@sites = Site.where({...})
|
25
|
+
respond_to do |format|
|
26
|
+
format.html
|
27
|
+
format.json do
|
28
|
+
if params.delete(:flexigrid).present?
|
29
|
+
@site = @sites.flexigrid(params)
|
30
|
+
end
|
31
|
+
render :json => @sites
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
...
|
36
|
+
|
37
|
+
4. Set javascript and view
|
38
|
+
|
39
|
+
application.js
|
40
|
+
|
41
|
+
$("#sites-grid").flexigrid({
|
42
|
+
method: "GET",
|
43
|
+
url: "/sites.json?flexigrid=true",
|
44
|
+
dataTyep: "json",
|
45
|
+
colModel: [
|
46
|
+
{display: 'Name', name: 'name, sortable: true},
|
47
|
+
...
|
48
|
+
],
|
49
|
+
searchitems: [
|
50
|
+
{display: "Name", name: 'name, isdefault: true},
|
51
|
+
....
|
52
|
+
],
|
53
|
+
sortname: "name",
|
54
|
+
sortorder: "asc",
|
55
|
+
usepager: true,
|
56
|
+
rp: 10
|
57
|
+
})
|
58
|
+
|
59
|
+
view / app/views/sites/index.html.erb
|
60
|
+
|
61
|
+
<div id="sites-grid"></div>
|
62
|
+
|
63
|
+
== Copyright
|
64
|
+
|
65
|
+
Copyright (c) 2011 Akihiro Matsumura. See LICENSE for details.
|
data/lib/acts_as_flexigrid.rb
CHANGED
@@ -17,7 +17,8 @@ module ActsAsFlexigrid
|
|
17
17
|
|
18
18
|
scope :flexigrid_order, lambda { |name, order|
|
19
19
|
if name.present? and order.present?
|
20
|
-
order
|
20
|
+
order = order.downcase == "asc" ? "asc" : "desc"
|
21
|
+
order("#{quoted_table_name}.#{connection.quote_column_name(name.strip)} #{order}")
|
21
22
|
end
|
22
23
|
}
|
23
24
|
end
|
@@ -42,12 +42,26 @@ describe ActsAsFlexigrid do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe ".
|
45
|
+
describe ".flexigrid_where" do
|
46
46
|
it "should return 100" do
|
47
47
|
User.flexigrid_where("name", "001").count.should == 1
|
48
48
|
end
|
49
49
|
it "should return quated sql" do
|
50
|
-
User.
|
50
|
+
User.flexigrid_where("name", "001").to_sql.should == "SELECT \"users\".* FROM \"users\" WHERE (\"users\".\"name\" LIKE '%001%')"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe ".flexigrid_order" do
|
55
|
+
it "should set desc" do
|
56
|
+
User.flexigrid_order('name', "desc").first.name.should == "user100"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return quated sql" do
|
60
|
+
User.flexigrid_order('name', "asc").to_sql.should == "SELECT \"users\".* FROM \"users\" ORDER BY \"users\".\"name\" asc"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should set desc with valid param" do
|
64
|
+
User.flexigrid_order('name', "hoge").to_sql.should include('desc')
|
51
65
|
end
|
52
66
|
end
|
53
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_flexigrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
|
-
requirement: &
|
17
|
+
requirement: &2154174840 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 3.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2154174840
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activerecord
|
28
|
-
requirement: &
|
28
|
+
requirement: &2154174280 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 3.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2154174280
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: kaminari
|
39
|
-
requirement: &
|
39
|
+
requirement: &2154173720 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2154173720
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rake
|
50
|
-
requirement: &
|
50
|
+
requirement: &2154173020 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2154173020
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: sqlite3
|
61
|
-
requirement: &
|
61
|
+
requirement: &2154172140 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2154172140
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: bundler
|
72
|
-
requirement: &
|
72
|
+
requirement: &2154167320 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 1.0.0
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2154167320
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rspec
|
83
|
-
requirement: &
|
83
|
+
requirement: &2154166720 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2154166720
|
92
92
|
description: acts_as_flexigrid is ActiveRecord plugin for Flexigrid
|
93
93
|
email:
|
94
94
|
- matsumura.aki@gmail.com
|
@@ -98,6 +98,8 @@ extra_rdoc_files: []
|
|
98
98
|
files:
|
99
99
|
- .gitignore
|
100
100
|
- Gemfile
|
101
|
+
- LICENSE
|
102
|
+
- README.rdoc
|
101
103
|
- Rakefile
|
102
104
|
- acts_as_flexigrid.gemspec
|
103
105
|
- lib/acts_as_flexigrid.rb
|