manage 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +7 -0
- data/app/controllers/manage/resource_controller.rb +13 -3
- data/app/views/manage/resource/index.html.slim +1 -0
- data/lib/manage/fields/searcher.rb +8 -5
- data/lib/manage/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5ab1fbdedaa13d1098b8c84cc87c9c3a9dbb78d
|
4
|
+
data.tar.gz: ca562946b45a85ff71d560363361b027c13b9ea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45ff6240a3c8028274e298e94e3fd51e0155d45834515071911cba37806646133ae48030c021d88339b7958b7cef97b5f05b0fe1aaa8c3a5eb934120cc10263e
|
7
|
+
data.tar.gz: 02fdbd38fe10568abad6beecdb557f9993320de020602959f508bc79bf27ab8f2cfd091cfa022a826d673873844163430d29aea81f0b23148b40fde0254941b2
|
data/README.rdoc
CHANGED
@@ -17,6 +17,13 @@ to routes.rb yourapp/config/routes.rb:
|
|
17
17
|
|
18
18
|
mount Manage::Engine, at: "/manage"
|
19
19
|
|
20
|
+
|
21
|
+
if you want to have custom design in your app for the manage engine add in application.rb:
|
22
|
+
|
23
|
+
config.assets.precompile += [
|
24
|
+
'manage/custom.css'
|
25
|
+
]
|
26
|
+
|
20
27
|
== Defining resource for administration
|
21
28
|
|
22
29
|
|
@@ -20,12 +20,22 @@ class Manage::ResourceController < Manage::ApplicationController
|
|
20
20
|
end
|
21
21
|
|
22
22
|
config = self.resources_configuration[:self]
|
23
|
-
@search = config[:search].new(params[:f])
|
23
|
+
@search = config[:search].new(clean_search_params(params[:f]))
|
24
24
|
|
25
|
-
@search.results
|
25
|
+
@search.results
|
26
26
|
end
|
27
27
|
|
28
28
|
protected
|
29
|
+
|
30
|
+
def clean_search_params(search_params)
|
31
|
+
return {} unless search_params.is_a?(Hash)
|
32
|
+
search_params = search_params.dup
|
33
|
+
search_params.delete_if do |key, value|
|
34
|
+
value == ''
|
35
|
+
end
|
36
|
+
search_params
|
37
|
+
end
|
38
|
+
|
29
39
|
def collection
|
30
40
|
assocation = end_of_association_chain.page(params[:page] || 1)
|
31
41
|
per_page ? assocation.per(per_page) : assocation
|
@@ -82,7 +92,7 @@ class Manage::ResourceController < Manage::ApplicationController
|
|
82
92
|
options[:except] ||= []
|
83
93
|
options[:include] ||= []
|
84
94
|
|
85
|
-
self.resources_configuration[:self][key] = (resource_class.attribute_names + Array(options[:include])) - Array(options[:except]).map(&:to_s)
|
95
|
+
self.resources_configuration[:self][key] = (resource_class.attribute_names + Array(options[:include])) - Array(options[:except]).map(&:to_s)
|
86
96
|
else
|
87
97
|
self.resources_configuration[:self][key] = fields
|
88
98
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
nav
|
2
2
|
= link_to t('manage.actions.new', model: resource_class.model_name.human), [:new, resource_class.name.tableize.singularize], class: 'button small secondary'
|
3
|
+
= yield(:index_navigation) if content_for? :index_navigation
|
3
4
|
|
4
5
|
= render "manage/resource/index/scopes"
|
5
6
|
|
@@ -21,20 +21,23 @@ module Manage
|
|
21
21
|
|
22
22
|
search_fields.select {|f| not f.to_s.include?('.')}.each do |field|
|
23
23
|
field_type = resource_class.columns_hash[field.to_s].type
|
24
|
-
|
24
|
+
case field_type
|
25
|
+
when *[:text, :string]
|
25
26
|
search_class.option field.to_sym do |scope, value|
|
26
|
-
scope.where
|
27
|
+
value.blank? ? scope : scope.where("lower(#{field.to_s}) LIKE lower(?)", escape_search_term(value))
|
27
28
|
end
|
28
|
-
|
29
|
+
when :datetime
|
29
30
|
search_class.option field.to_sym do |scope, value|
|
30
31
|
date = parse_date value
|
31
32
|
scope.where("DATE(#{field.to_s}) >= ?", date) if date.present?
|
32
33
|
end
|
33
|
-
|
34
|
+
when :integer
|
35
|
+
search_class.option field.to_sym
|
36
|
+
when :boolean
|
34
37
|
search_class.option field.to_sym
|
35
38
|
else
|
36
39
|
search_class.option field.to_sym do |scope, value|
|
37
|
-
scope.where "
|
40
|
+
scope.where "#{field.to_s} = '?'", escape_search_term(value)
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
data/lib/manage/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Empower United
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|