acts_as_extjs 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/acts_as_extjs.gemspec +5 -2
- data/lib/acts_as_extjs.rb +38 -1
- metadata +18 -4
data/Rakefile
CHANGED
@@ -12,6 +12,7 @@ begin
|
|
12
12
|
gem.authors = ["Marco Scholl"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
14
|
gem.add_development_dependency "activerecord", ">= 2.3.8"
|
15
|
+
gem.add_development_dependency "will_paginate"
|
15
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
17
|
end
|
17
18
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/acts_as_extjs.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts_as_extjs}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marco Scholl"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-25}
|
13
13
|
s.description = %q{ActiveRecord Helper for Extjs}
|
14
14
|
s.email = %q{develop@marco-scholl.de}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -45,13 +45,16 @@ Gem::Specification.new do |s|
|
|
45
45
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
46
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
47
47
|
s.add_development_dependency(%q<activerecord>, [">= 2.3.8"])
|
48
|
+
s.add_development_dependency(%q<will_paginate>, [">= 0"])
|
48
49
|
else
|
49
50
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
50
51
|
s.add_dependency(%q<activerecord>, [">= 2.3.8"])
|
52
|
+
s.add_dependency(%q<will_paginate>, [">= 0"])
|
51
53
|
end
|
52
54
|
else
|
53
55
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
54
56
|
s.add_dependency(%q<activerecord>, [">= 2.3.8"])
|
57
|
+
s.add_dependency(%q<will_paginate>, [">= 0"])
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
data/lib/acts_as_extjs.rb
CHANGED
@@ -9,7 +9,17 @@ module Extjs #:nodoc:
|
|
9
9
|
end
|
10
10
|
|
11
11
|
module ClassMethods
|
12
|
+
# activate gem on ar-model with acts_as_extjs
|
13
|
+
#
|
14
|
+
# -----
|
15
|
+
#
|
16
|
+
# === Example:
|
17
|
+
# class User
|
18
|
+
# acts_as_extjs
|
19
|
+
# end
|
20
|
+
#
|
12
21
|
def acts_as_extjs
|
22
|
+
# empty named sop
|
13
23
|
named_scope :extjs
|
14
24
|
include Extjs::ActsAsExtjs::InstanceMethods
|
15
25
|
extend Extjs::ActsAsExtjs::SingletonMethods
|
@@ -17,6 +27,34 @@ module Extjs #:nodoc:
|
|
17
27
|
end
|
18
28
|
|
19
29
|
module SingletonMethods
|
30
|
+
# search on a model. the result is a hash that can use as json for extjs store
|
31
|
+
#
|
32
|
+
# +args+:: all options that you will use on active record finder with following extras
|
33
|
+
#
|
34
|
+
# -----
|
35
|
+
#
|
36
|
+
# === Options:
|
37
|
+
# <tt>:fields</tt>:: List with hashes like extjs store fields.
|
38
|
+
# <tt>:name</tt>:: Name off field. This will be call on row if not use an custom handler
|
39
|
+
# <tt>:custom</tt>:: can use with Proc.new for own field content
|
40
|
+
# <tt>:mapping</tt>:: Client side mapping by extjs store
|
41
|
+
# <tt>:sort_mapping</tt>:: A Hash to map columns
|
42
|
+
# :fieldname => "sqlfiels"
|
43
|
+
# :user_name => "users.name"
|
44
|
+
# <tt>:start</tt>:: start value from extjs paginate toolbar
|
45
|
+
# <tt>:limit</tt>:: limit value from extjs paginate toolbar
|
46
|
+
# <tt>:page</tt>:: page - will overritten if start/limit set
|
47
|
+
# <tt>:per_page</tt>:: per_page - will overritten if start/limit set
|
48
|
+
# <tt>:sort_by</tt>:: sort field. ignore fields that are not in sort_mapping and use this mapping
|
49
|
+
# <tt>:group_by</tt>:: group field. ignore fields that are not in sort_mapping and use this mapping
|
50
|
+
# <tt>:sort_dir</tt>:: direction: asc | desc
|
51
|
+
# <tt>:group_dir</tt>:: direction: asc | desc
|
52
|
+
#
|
53
|
+
# -----
|
54
|
+
#
|
55
|
+
# === Example:
|
56
|
+
# render :json => User.extjs_result :fields = [{:name => :superid, :type => :id, :custom => Proc.new { |row| row.id }}]
|
57
|
+
#
|
20
58
|
def extjs_result(*args)
|
21
59
|
options = args.extract_options!
|
22
60
|
fields = options.delete(:fields)
|
@@ -41,7 +79,6 @@ module Extjs #:nodoc:
|
|
41
79
|
order = 'created_at DESC'
|
42
80
|
end
|
43
81
|
|
44
|
-
|
45
82
|
if not group_by.blank? and sort_mapping.has_key?(group_by.to_sym)
|
46
83
|
if group_dir.to_s.downcase == "desc"
|
47
84
|
group_dir = " DESC"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_extjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marco Scholl
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-25 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
version: 2.3.8
|
51
51
|
type: :development
|
52
52
|
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: will_paginate
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
53
67
|
description: ActiveRecord Helper for Extjs
|
54
68
|
email: develop@marco-scholl.de
|
55
69
|
executables: []
|