sferik-merb-admin 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +2 -1
- data/Rakefile +3 -3
- data/app/controllers/forms.rb +17 -18
- data/lib/merb-admin.rb +1 -1
- metadata +3 -3
data/README.markdown
CHANGED
@@ -14,7 +14,7 @@ At the command prompt, type:
|
|
14
14
|
|
15
15
|
In your app, add the following dependency to `config/dependencies.rb`:
|
16
16
|
|
17
|
-
dependency "sferik-merb-admin", "0.2.
|
17
|
+
dependency "sferik-merb-admin", "0.2.5", :require_as => "merb-admin"
|
18
18
|
|
19
19
|
Add the following route to `config/router.rb`:
|
20
20
|
|
@@ -30,6 +30,7 @@ You can configuring the merb-admin slice in a before_app_loads block:
|
|
30
30
|
|
31
31
|
Merb::BootLoader.before_app_loads do
|
32
32
|
Merb::Slices::config[:merb_admin][:app_name] = "My App"
|
33
|
+
Merb::Slices::config[:merb_admin][:paginate] = true
|
33
34
|
end
|
34
35
|
|
35
36
|
## Run it
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ AUTHOR = "Erik Michaels-Ober"
|
|
12
12
|
EMAIL = "sferik@gmail.com"
|
13
13
|
HOMEPAGE = "http://twitter.com/sferik"
|
14
14
|
SUMMARY = "MerbAdmin is a merb slice that provides an easy-to-use interface for managing your data."
|
15
|
-
GEM_VERSION = "0.2.
|
15
|
+
GEM_VERSION = "0.2.5"
|
16
16
|
|
17
17
|
spec = Gem::Specification.new do |s|
|
18
18
|
s.rubyforge_project = "merb"
|
@@ -26,8 +26,8 @@ spec = Gem::Specification.new do |s|
|
|
26
26
|
s.author = AUTHOR
|
27
27
|
s.email = EMAIL
|
28
28
|
s.homepage = HOMEPAGE
|
29
|
-
s.add_dependency("merb-slices",
|
30
|
-
s.add_dependency("merb_datamapper",
|
29
|
+
s.add_dependency("merb-slices", ">= 1.0.12")
|
30
|
+
s.add_dependency("merb_datamapper", ">= 1.0.12")
|
31
31
|
s.add_dependency("dm-core", ">= 0.9.11")
|
32
32
|
s.add_dependency("dm-is-paginated", ">= 0.0.1")
|
33
33
|
s.require_path = "lib"
|
data/app/controllers/forms.rb
CHANGED
@@ -13,33 +13,32 @@ class MerbAdmin::Forms < MerbAdmin::Application
|
|
13
13
|
filters = params[:filter] || {}
|
14
14
|
filters.each_pair do |key, value|
|
15
15
|
if @model.properties[key].primitive.to_s == "TrueClass"
|
16
|
-
options.merge!(key.to_sym => (value == "true"
|
16
|
+
options.merge!(key.to_sym => (value == "true"))
|
17
17
|
elsif @model.properties[key].primitive.to_s == "Integer" && @model.properties[key].type.respond_to?(:flag_map)
|
18
18
|
options.merge!(key.to_sym => value.to_sym)
|
19
19
|
end
|
20
20
|
end
|
21
|
-
if params[:
|
21
|
+
if params[:query]
|
22
|
+
condition_statement = []
|
23
|
+
conditions = []
|
24
|
+
@properties.each do |property|
|
25
|
+
next unless property.type.to_s == "String"
|
26
|
+
condition_statement << "#{property.field} LIKE ?"
|
27
|
+
conditions << "%#{params[:query]}%"
|
28
|
+
end
|
29
|
+
conditions.unshift(condition_statement.join(" OR "))
|
30
|
+
options.merge!(:conditions => conditions) unless conditions == [""]
|
31
|
+
end
|
32
|
+
if params[:sort]
|
33
|
+
order = "[:#{params[:sort]}.#{params[:sort_reverse] ? 'desc' : 'asc'}]"
|
34
|
+
options.merge!(:order => eval(order))
|
35
|
+
end
|
36
|
+
if !MerbAdmin[:paginate] || params[:all]
|
22
37
|
options = {
|
23
38
|
:limit => 200,
|
24
39
|
}.merge(options)
|
25
40
|
@instances = @model.all(options).reverse
|
26
41
|
else
|
27
|
-
if params[:query]
|
28
|
-
condition_statement = []
|
29
|
-
conditions = []
|
30
|
-
@properties.each do |property|
|
31
|
-
next unless property.primitive.to_s == "String"
|
32
|
-
condition_statement << "#{property.field} LIKE ?"
|
33
|
-
conditions << "%#{params[:query]}%"
|
34
|
-
end
|
35
|
-
conditions.unshift(condition_statement.join(" OR "))
|
36
|
-
options.merge!(:conditions => conditions) unless conditions == [""]
|
37
|
-
end
|
38
|
-
if params[:sort]
|
39
|
-
order = "[:#{params[:sort]}.#{params[:sort_reverse] ? 'desc' : 'asc'}]"
|
40
|
-
options.merge!(:order => eval(order))
|
41
|
-
end
|
42
|
-
|
43
42
|
# monkey patch pagination
|
44
43
|
@model.class_eval("is_paginated") unless @model.respond_to?(:paginated)
|
45
44
|
@current_page = (params[:page] || 1).to_i
|
data/lib/merb-admin.rb
CHANGED
@@ -22,7 +22,7 @@ if defined?(Merb::Plugins)
|
|
22
22
|
|
23
23
|
# Slice metadata
|
24
24
|
self.description = "MerbAdmin is a merb slice that uses your DataMapper models to provide an easy-to-use, Django-style interface for content managers."
|
25
|
-
self.version = "0.2.
|
25
|
+
self.version = "0.2.5"
|
26
26
|
self.author = "Erik Michaels-Ober"
|
27
27
|
|
28
28
|
# Stub classes loaded hook - runs before LoadClasses BootLoader
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sferik-merb-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Michaels-Ober
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- - "
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.0.12
|
24
24
|
version:
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.0.12
|
34
34
|
version:
|