list_controls 0.1.2 → 0.1.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/README +1 -5
- data/lib/list_controls/action_controller.rb +12 -5
- metadata +3 -3
data/README
CHANGED
@@ -13,11 +13,7 @@ Controller:
|
|
13
13
|
|
14
14
|
class ProductsController < ApplicationController
|
15
15
|
|
16
|
-
enable_list_controls
|
17
|
-
|
18
|
-
def default_filters
|
19
|
-
{ 'state' => 'new' }
|
20
|
-
end
|
16
|
+
enable_list_controls :default_filters => { 'state' => 'new' }
|
21
17
|
|
22
18
|
def index
|
23
19
|
@products = Product.all :conditions => { :state => @filters.state }
|
@@ -13,7 +13,13 @@ module ListControls
|
|
13
13
|
|
14
14
|
attr_reader :filters
|
15
15
|
|
16
|
-
before_filter :
|
16
|
+
before_filter :list_controls_assign_filters
|
17
|
+
|
18
|
+
@list_controls_default_filters = options[:default_filters] || {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def list_controls_default_filters
|
22
|
+
@list_controls_default_filters
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
@@ -21,15 +27,16 @@ module ListControls
|
|
21
27
|
|
22
28
|
protected
|
23
29
|
|
24
|
-
def
|
25
|
-
|
30
|
+
def list_controls_default_filters
|
31
|
+
f = self.class.list_controls_default_filters
|
32
|
+
f.is_a?(Proc) ? f.call(self) : f
|
26
33
|
end
|
27
34
|
|
28
|
-
def
|
35
|
+
def list_controls_assign_filters
|
29
36
|
session[:list_controls]||= {}
|
30
37
|
|
31
38
|
session_store = session[:list_controls][self.class.to_s]||= {}
|
32
|
-
session_store[:filters] ||=
|
39
|
+
session_store[:filters] ||= list_controls_default_filters
|
33
40
|
session_store[:filters].merge!(params[:filters] || {})
|
34
41
|
|
35
42
|
tmp_filters = session_store[:filters]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: list_controls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Laurynas Butkus
|