active-list 4.2.1 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/active-list/finder.rb +1 -1
- data/lib/active-list/generator.rb +17 -17
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.2.
|
1
|
+
4.2.2
|
data/lib/active-list/finder.rb
CHANGED
@@ -49,10 +49,10 @@ module ActiveList
|
|
49
49
|
|
50
50
|
def generate_view_method_code
|
51
51
|
code = "# encoding: utf-8\n"
|
52
|
-
code
|
53
|
-
code
|
54
|
-
code
|
55
|
-
code
|
52
|
+
code << "def #{self.view_method_name}(options={}, &block)\n"
|
53
|
+
code << self.session_initialization_code.gsub(/^/, ' ')
|
54
|
+
code << self.renderer.build_table_code(self).gsub(/^/, ' ')
|
55
|
+
code << "end\n"
|
56
56
|
# code.split("\n").each_with_index{|l, x| puts((x+1).to_s.rjust(4)+": "+l)}
|
57
57
|
return code
|
58
58
|
end
|
@@ -60,25 +60,25 @@ module ActiveList
|
|
60
60
|
|
61
61
|
def session_initialization_code
|
62
62
|
code = "options = {} unless options.is_a? Hash\n"
|
63
|
-
code
|
63
|
+
code << "options = (params||{}).merge(options)\n"
|
64
64
|
# Session values
|
65
|
-
code
|
66
|
-
code
|
67
|
-
code
|
68
|
-
code
|
65
|
+
code << "session[:list] = {} unless session[:list].is_a? Hash\n"
|
66
|
+
code << "session[:list][:#{self.view_method_name}] = {} unless session[:list][:#{self.view_method_name}].is_a? Hash\n"
|
67
|
+
code << "list_params = session[:list][:#{self.view_method_name}]\n"
|
68
|
+
code << "list_params[:hidden_columns] = [] unless list_params[:hidden_columns].is_a? Array\n"
|
69
69
|
for parameter, convertor in @parameters.sort{|a,b| a[0].to_s <=> b[0].to_s}
|
70
70
|
expr = "options.delete('#{self.name}_#{parameter}') || options.delete('#{parameter}') || list_params[:#{parameter}]"
|
71
71
|
expr += " || #{@options[parameter]}" unless @options[parameter].blank?
|
72
|
-
code
|
72
|
+
code << "list_params[:#{parameter}] = (#{expr}).#{convertor}\n"
|
73
73
|
end
|
74
74
|
# Order
|
75
|
-
code
|
76
|
-
code
|
77
|
-
code
|
78
|
-
code
|
79
|
-
code
|
80
|
-
code
|
81
|
-
code
|
75
|
+
code << "order = #{self.options[:order] ? self.options[:order].inspect : 'nil'}\n"
|
76
|
+
code << "if (col = {"+self.sortable_columns.collect{|c| "'#{c.id}'=>'#{c.name}'"}.join(', ')+"}[list_params[:sort]])\n"
|
77
|
+
code << " list_params[:dir] ||= 'asc'\n"
|
78
|
+
code << " if list_params[:dir] == 'asc' or list_params[:dir] == 'desc'\n"
|
79
|
+
code << " order = #{@model.name}.connection.quote_column_name(col)+' '+list_params[:dir]\n"
|
80
|
+
code << " end\n"
|
81
|
+
code << "end\n"
|
82
82
|
|
83
83
|
return code
|
84
84
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: active-list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
version: !binary |-
|
5
|
-
|
5
|
+
NC4yLjI=
|
6
6
|
prerelease:
|
7
7
|
platform: ruby
|
8
8
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-02-
|
13
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|