wice_grid_mongoid 0.5.7 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -1
- data/Gemfile +17 -0
- data/Gemfile.lock +140 -0
- data/README.rdoc +19 -3
- data/Rakefile +1 -3
- data/VERSION +1 -1
- data/lib/filter_conditions_generators.rb +126 -0
- data/{generators/wice_grid_assets_prototype/templates/stylesheets → lib/generators/wice_grid/templates}/calendarview.css +0 -0
- data/{generators/wice_grid_assets_prototype/templates/javascripts → lib/generators/wice_grid/templates}/calendarview.js +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/arrow_down.gif +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/arrow_up.gif +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/calendar_view_month.png +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/delete.png +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/expand.png +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/page_white_excel.png +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/page_white_find.png +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/table.png +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/table_refresh.png +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/tick_all.png +0 -0
- data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/untick_all.png +0 -0
- data/{generators/common_templates/stylesheets → lib/generators/wice_grid/templates}/wice_grid.css +0 -0
- data/{generators/common_templates/locales → lib/generators/wice_grid/templates}/wice_grid.yml +0 -0
- data/{generators/common_templates/initializers → lib/generators/wice_grid/templates}/wice_grid_config.rb +0 -0
- data/{generators/wice_grid_assets_jquery/templates/javascripts → lib/generators/wice_grid/templates}/wice_grid_jquery.js +0 -0
- data/{generators/wice_grid_assets_prototype/templates/javascripts → lib/generators/wice_grid/templates}/wice_grid_prototype.js +0 -0
- data/lib/generators/wice_grid/wice_grid_assets_jquery_generator.rb +32 -0
- data/lib/generators/wice_grid/wice_grid_assets_prototype_generator.rb +34 -0
- data/lib/grid_renderer.rb +36 -20
- data/lib/helpers/js_calendar_helpers.rb +0 -5
- data/lib/helpers/wice_grid_view_helpers.rb +113 -133
- data/lib/mongoid_field.rb +50 -0
- data/{tasks → lib/tasks}/wice_grid_tasks.rake +0 -0
- data/lib/view_columns.rb +23 -29
- data/lib/wice_grid.rb +91 -379
- data/lib/wice_grid_misc.rb +3 -3
- data/mongoid_wice_grid.gemspec +122 -0
- data/test/blueprint.rb +17 -0
- data/test/public/javascripts/jquery-1.4.2.min.js +154 -0
- data/test/public/javascripts/wice_grid.js +163 -0
- data/test/rails_mongoid_test.rb +104 -0
- data/test/rails_test_app.rb +71 -0
- data/test/require_gems.rb +19 -0
- data/test/spec_helper.rb +22 -0
- data/test/wice_grid_initializer.rb +215 -0
- data/wice_grid_mongoid.gemspec +43 -30
- metadata +45 -34
- data/generators/wice_grid_assets_jquery/templates/USAGE +0 -6
- data/generators/wice_grid_assets_jquery/wice_grid_assets_jquery_generator.rb +0 -35
- data/generators/wice_grid_assets_prototype/USAGE +0 -8
- data/generators/wice_grid_assets_prototype/wice_grid_assets_prototype_generator.rb +0 -37
- data/init.rb +0 -1
- data/install.rb +0 -1
- data/lib/table_column_matrix.rb +0 -51
- data/uninstall.rb +0 -1
data/.gitignore
CHANGED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.0.1'
|
4
|
+
gem "bson_ext", "1.0.4"
|
5
|
+
gem "mongo","1.0.7"
|
6
|
+
gem "mongo_ext"
|
7
|
+
gem "mongoid", "2.0.0.beta.17"
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem 'capybara'
|
11
|
+
gem "rspec-rails", "~> 2.0.1"
|
12
|
+
gem 'rspec'
|
13
|
+
gem 'launchy'
|
14
|
+
gem 'machinist_mongo', :require => 'machinist/mongoid'
|
15
|
+
gem 'faker'
|
16
|
+
#gem 'rr'
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.1)
|
6
|
+
actionpack (= 3.0.1)
|
7
|
+
mail (~> 2.2.5)
|
8
|
+
actionpack (3.0.1)
|
9
|
+
activemodel (= 3.0.1)
|
10
|
+
activesupport (= 3.0.1)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4.1)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.12)
|
16
|
+
rack-test (~> 0.5.4)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.1)
|
19
|
+
activesupport (= 3.0.1)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4.1)
|
22
|
+
activerecord (3.0.1)
|
23
|
+
activemodel (= 3.0.1)
|
24
|
+
activesupport (= 3.0.1)
|
25
|
+
arel (~> 1.0.0)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.1)
|
28
|
+
activemodel (= 3.0.1)
|
29
|
+
activesupport (= 3.0.1)
|
30
|
+
activesupport (3.0.1)
|
31
|
+
arel (1.0.1)
|
32
|
+
activesupport (~> 3.0.0)
|
33
|
+
bson (1.0.4)
|
34
|
+
bson_ext (1.0.4)
|
35
|
+
builder (2.1.2)
|
36
|
+
capybara (0.4.0)
|
37
|
+
celerity (>= 0.7.9)
|
38
|
+
culerity (>= 0.2.4)
|
39
|
+
mime-types (>= 1.16)
|
40
|
+
nokogiri (>= 1.3.3)
|
41
|
+
rack (>= 1.0.0)
|
42
|
+
rack-test (>= 0.5.4)
|
43
|
+
selenium-webdriver (>= 0.0.27)
|
44
|
+
xpath (~> 0.1.2)
|
45
|
+
celerity (0.8.4)
|
46
|
+
childprocess (0.1.4)
|
47
|
+
ffi (~> 0.6.3)
|
48
|
+
configuration (1.2.0)
|
49
|
+
culerity (0.2.12)
|
50
|
+
diff-lcs (1.1.2)
|
51
|
+
erubis (2.6.6)
|
52
|
+
abstract (>= 1.0.0)
|
53
|
+
faker (0.3.1)
|
54
|
+
ffi (0.6.3)
|
55
|
+
rake (>= 0.8.7)
|
56
|
+
i18n (0.4.2)
|
57
|
+
json_pure (1.4.6)
|
58
|
+
launchy (0.3.7)
|
59
|
+
configuration (>= 0.0.5)
|
60
|
+
rake (>= 0.8.1)
|
61
|
+
machinist (1.0.6)
|
62
|
+
machinist_mongo (1.1.1)
|
63
|
+
machinist (~> 1.0.4)
|
64
|
+
mail (2.2.10)
|
65
|
+
activesupport (>= 2.3.6)
|
66
|
+
i18n (~> 0.4.1)
|
67
|
+
mime-types (~> 1.16)
|
68
|
+
treetop (~> 1.4.8)
|
69
|
+
mime-types (1.16)
|
70
|
+
mongo (1.0.7)
|
71
|
+
bson (>= 1.0.4)
|
72
|
+
mongo_ext (0.19.3)
|
73
|
+
mongoid (2.0.0.beta.17)
|
74
|
+
activemodel (~> 3.0.0)
|
75
|
+
bson (= 1.0.4)
|
76
|
+
mongo (= 1.0.7)
|
77
|
+
tzinfo (~> 0.3.22)
|
78
|
+
will_paginate (~> 3.0.pre)
|
79
|
+
nokogiri (1.4.4)
|
80
|
+
polyglot (0.3.1)
|
81
|
+
rack (1.2.1)
|
82
|
+
rack-mount (0.6.13)
|
83
|
+
rack (>= 1.0.0)
|
84
|
+
rack-test (0.5.6)
|
85
|
+
rack (>= 1.0)
|
86
|
+
rails (3.0.1)
|
87
|
+
actionmailer (= 3.0.1)
|
88
|
+
actionpack (= 3.0.1)
|
89
|
+
activerecord (= 3.0.1)
|
90
|
+
activeresource (= 3.0.1)
|
91
|
+
activesupport (= 3.0.1)
|
92
|
+
bundler (~> 1.0.0)
|
93
|
+
railties (= 3.0.1)
|
94
|
+
railties (3.0.1)
|
95
|
+
actionpack (= 3.0.1)
|
96
|
+
activesupport (= 3.0.1)
|
97
|
+
rake (>= 0.8.4)
|
98
|
+
thor (~> 0.14.0)
|
99
|
+
rake (0.8.7)
|
100
|
+
rspec (2.0.1)
|
101
|
+
rspec-core (~> 2.0.1)
|
102
|
+
rspec-expectations (~> 2.0.1)
|
103
|
+
rspec-mocks (~> 2.0.1)
|
104
|
+
rspec-core (2.0.1)
|
105
|
+
rspec-expectations (2.0.1)
|
106
|
+
diff-lcs (>= 1.1.2)
|
107
|
+
rspec-mocks (2.0.1)
|
108
|
+
rspec-core (~> 2.0.1)
|
109
|
+
rspec-expectations (~> 2.0.1)
|
110
|
+
rspec-rails (2.0.1)
|
111
|
+
rspec (~> 2.0.0)
|
112
|
+
rubyzip (0.9.4)
|
113
|
+
selenium-webdriver (0.1.0)
|
114
|
+
childprocess (= 0.1.4)
|
115
|
+
ffi (~> 0.6.3)
|
116
|
+
json_pure
|
117
|
+
rubyzip
|
118
|
+
thor (0.14.6)
|
119
|
+
treetop (1.4.9)
|
120
|
+
polyglot (>= 0.3.1)
|
121
|
+
tzinfo (0.3.23)
|
122
|
+
will_paginate (3.0.pre2)
|
123
|
+
xpath (0.1.2)
|
124
|
+
nokogiri (~> 1.3)
|
125
|
+
|
126
|
+
PLATFORMS
|
127
|
+
ruby
|
128
|
+
|
129
|
+
DEPENDENCIES
|
130
|
+
bson_ext (= 1.0.4)
|
131
|
+
capybara
|
132
|
+
faker
|
133
|
+
launchy
|
134
|
+
machinist_mongo
|
135
|
+
mongo (= 1.0.7)
|
136
|
+
mongo_ext
|
137
|
+
mongoid (= 2.0.0.beta.17)
|
138
|
+
rails (= 3.0.1)
|
139
|
+
rspec
|
140
|
+
rspec-rails (~> 2.0.1)
|
data/README.rdoc
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
= WiceGrid
|
1
|
+
= WiceGrid for Mongoid
|
2
2
|
|
3
|
-
Version:: 0.
|
3
|
+
Version:: 6.0.0.pre1
|
4
4
|
Author:: Yuri Leikind
|
5
|
-
Contributor:: Xavier Defrang
|
5
|
+
Contributor:: Xavier Defrang, Aleksandr Furmanov
|
6
6
|
Homepage:: http://leikind.org/pages/wicegrid
|
7
7
|
Examples online:: http://grid.leikind.org
|
8
8
|
News:: http://leikind.org/wicegrid
|
@@ -10,6 +10,22 @@ Email:: "Yuri Leikind" <yuri.leikind at gmail dot com>
|
|
10
10
|
|
11
11
|
== Intro
|
12
12
|
|
13
|
+
afurmanov> The intention of this fork is to make WiseGrid compatible with Mongoid.
|
14
|
+
|
15
|
+
THIS IS AN EARLY ALPHA VERSION OF THE PLUGIN FOR RAILS 3.0.
|
16
|
+
BASIC STUFF WORKS, BUT A LOT OF FUNCTIONALITIES ARE BROKEN.
|
17
|
+
THE DOCUMENTATION BELOW CAN BE OUTDATED.
|
18
|
+
|
19
|
+
FOR RAILS 3.0 IT ONLY WORKS AS A GEM.
|
20
|
+
AT THE SAME TIME NO OFFICIAL GEM IS YET RELEASED, SO IF YOU WANT TO TRY IT, CLONE THE REPOSITORY, PUT IT INTO vendor/wice_grid AND ADD THIS TO YOUR GEMFILE:
|
21
|
+
|
22
|
+
gem "wice_grid", '3.0.0.pre1', :path => 'vendor/wice_grid'
|
23
|
+
|
24
|
+
|
25
|
+
OR BUILD THE GEM.
|
26
|
+
|
27
|
+
=========================
|
28
|
+
|
13
29
|
WiceGrid is a Rails grid plugin.
|
14
30
|
|
15
31
|
One of the goals of this plugin was to allow the programmer to define the contents of the cell by himself, just like one does when rendering a collection via a simple table (and this is what differentiates WiceGrid from various scaffolding solutions), but automate implementation of filters, ordering, paginations, CSV export, and so on. Ruby blocks provide an elegant means for this.
|
data/Rakefile
CHANGED
@@ -29,11 +29,9 @@ begin
|
|
29
29
|
gem.name = "wice_grid_mongoid"
|
30
30
|
gem.summary = %Q{Rails Grid Plugin}
|
31
31
|
gem.description = %Q{A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters }
|
32
|
-
gem.email =
|
32
|
+
gem.email = "aleksandr.furmanov@gmail.com"
|
33
33
|
gem.homepage = "http://github.com/afurmanov/wice_grid"
|
34
34
|
gem.authors = ["Yuri Leikind", "Aleksandr Furmanov"]
|
35
|
-
#gem.add_development_dependency "will_paginate", ">= 2.3.2"
|
36
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
37
35
|
end
|
38
36
|
Jeweler::GemcutterTasks.new
|
39
37
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
6.0.3
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Wice
|
2
|
+
class FilterConditionsGenerator #:nodoc:
|
3
|
+
|
4
|
+
cattr_accessor :handled_type
|
5
|
+
@@handled_type = HashWithIndifferentAccess.new
|
6
|
+
|
7
|
+
def initialize(field, criteria) #:nodoc:
|
8
|
+
@field = field
|
9
|
+
@criteria = criteria
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate_conditions(opts)
|
13
|
+
raise "must be implemented"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# class FilterConditionsGeneratorCustomFilter < FilterConditionsGenerator #:nodoc:
|
18
|
+
|
19
|
+
# def generate_conditions(opts) #:nodoc:
|
20
|
+
# if opts.empty?
|
21
|
+
# Wice.log "empty parameters for the grid custom filter"
|
22
|
+
# return false
|
23
|
+
# end
|
24
|
+
# opts = (opts.kind_of?(Array) && opts.size == 1) ? opts[0] : opts
|
25
|
+
|
26
|
+
# if opts.kind_of?(Array)
|
27
|
+
# opts_with_special_values, normal_opts = opts.partition{|v| ::Wice::GridTools.special_value(v)}
|
28
|
+
|
29
|
+
# conditions_ar = if normal_opts.size > 0
|
30
|
+
# [" #{@field.alias_or_table_name(table_alias)}.#{@field.name} IN ( " + (['?'] * normal_opts.size).join(', ') + ' )'] + normal_opts
|
31
|
+
# else
|
32
|
+
# []
|
33
|
+
# end
|
34
|
+
|
35
|
+
# if opts_with_special_values.size > 0
|
36
|
+
# special_conditions = opts_with_special_values.collect{|v| " #{@field.alias_or_table_name(table_alias)}.#{@field.name} is " + v}.join(' or ')
|
37
|
+
# if conditions_ar.size > 0
|
38
|
+
# conditions_ar[0] = " (#{conditions_ar[0]} or #{special_conditions} ) "
|
39
|
+
# else
|
40
|
+
# conditions_ar = " ( #{special_conditions} ) "
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
# conditions_ar
|
44
|
+
# else
|
45
|
+
# if ::Wice::GridTools.special_value(opts)
|
46
|
+
# " #{@field.alias_or_table_name(table_alias)}.#{@field.name} is " + opts
|
47
|
+
# else
|
48
|
+
# [" #{@field.alias_or_table_name(table_alias)}.#{@field.name} = ?", opts]
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
|
53
|
+
# end
|
54
|
+
|
55
|
+
class FilterConditionsGeneratorBoolean < FilterConditionsGenerator #:nodoc:
|
56
|
+
@@handled_type[Boolean] = self
|
57
|
+
|
58
|
+
def generate_conditions(opts) #:nodoc:
|
59
|
+
unless (opts.kind_of?(Array) && opts.size == 1 && ['f', 't'].include?(opts[0]))
|
60
|
+
Wice.log "invalid parameters for the grid boolean filter - must be an one item array: #{opts.inspect}"
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
@criteria.where(@field.name.to_s => opts[0] == 't' ? true : false)
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class FilterConditionsGeneratorString < FilterConditionsGenerator #:nodoc:
|
69
|
+
@@handled_type[String] = self
|
70
|
+
|
71
|
+
def generate_conditions(opts) #:nodoc:
|
72
|
+
negation = nil
|
73
|
+
if opts.kind_of? String
|
74
|
+
string_fragment = opts
|
75
|
+
elsif (opts.kind_of? Hash) && opts.has_key?(:v)
|
76
|
+
string_fragment = opts[:v]
|
77
|
+
#negation = opts[:n] == '1' ? 'NOT' : ''
|
78
|
+
else
|
79
|
+
Wice.log "invalid parameters for the grid string filter - must be a string: #{opts.inspect} or a Hash with keys :v and :n"
|
80
|
+
return false
|
81
|
+
end
|
82
|
+
if string_fragment.empty?
|
83
|
+
Wice.log "invalid parameters for the grid string filter - empty string"
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
@criteria.where(@field.name.to_s => /#{string_fragment}/)
|
87
|
+
return true
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
class FilterConditionsGeneratorInteger < FilterConditionsGenerator #:nodoc:
|
93
|
+
@@handled_type[Integer] = self
|
94
|
+
@@handled_type[Float] = self
|
95
|
+
# @@handled_type[BigDecimal] = self
|
96
|
+
|
97
|
+
def generate_conditions(opts) #:nodoc:
|
98
|
+
unless opts.kind_of? Hash
|
99
|
+
Wice.log "invalid parameters for the grid integer filter - must be a hash"
|
100
|
+
return false
|
101
|
+
end
|
102
|
+
|
103
|
+
if !opts[:fr] || !(opts[:fr] =~ /\d/) || !opts[:to] || !(opts[:to] =~ /\d/)
|
104
|
+
Wice.log "invalid parameters for the grid integer filter - either range limits are not supplied or they are not numeric"
|
105
|
+
return false
|
106
|
+
end
|
107
|
+
|
108
|
+
@criteria.where(@field.name.to_sym.gt => opts[:fr].to_i)
|
109
|
+
@criteria.where(@field.name.to_sym.lt => opts[:to].to_i)
|
110
|
+
|
111
|
+
return true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class FilterConditionsGeneratorDate < FilterConditionsGenerator #:nodoc:
|
116
|
+
@@handled_type[Date] = self
|
117
|
+
@@handled_type[DateTime] = self
|
118
|
+
@@handled_type[Time] = self
|
119
|
+
|
120
|
+
def generate_conditions(opts) #:nodoc:
|
121
|
+
@criteria.where(@field.name.to_sym.gt => opts[:fr]) if opts[:fr]
|
122
|
+
@criteria.where(@field.name.to_sym.lt => opts[:to]) if opts[:to]
|
123
|
+
opts[:fr] || opts[:to]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
File without changes
|
File without changes
|
data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/arrow_down.gif
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/page_white_excel.png
RENAMED
File without changes
|
data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/page_white_find.png
RENAMED
File without changes
|
File without changes
|
data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/table_refresh.png
RENAMED
File without changes
|
File without changes
|
data/{generators/common_templates → lib/generators/wice_grid/templates}/icons/untick_all.png
RENAMED
File without changes
|
data/{generators/common_templates/stylesheets → lib/generators/wice_grid/templates}/wice_grid.css
RENAMED
File without changes
|
data/{generators/common_templates/locales → lib/generators/wice_grid/templates}/wice_grid.yml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module WiceGrid
|
2
|
+
module Generators
|
3
|
+
class WiceGridAssetsJqueryGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
desc "Copy WiceGrid assets for JQuery based apps"
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def active_js_framework
|
9
|
+
'jquery'
|
10
|
+
end
|
11
|
+
def inactive_js_framework
|
12
|
+
'prototype'
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def copy_stuff
|
17
|
+
template 'wice_grid_config.rb', 'config/initializers/wice_grid_config.rb'
|
18
|
+
|
19
|
+
copy_file 'wice_grid.yml', 'config/locales/wice_grid.yml'
|
20
|
+
|
21
|
+
copy_file 'wice_grid_jquery.js', 'public/javascripts/wice_grid.js'
|
22
|
+
copy_file 'wice_grid.css', 'public/stylesheets/wice_grid.css'
|
23
|
+
|
24
|
+
%w(arrow_down.gif calendar_view_month.png expand.png page_white_find.png table_refresh.png
|
25
|
+
arrow_up.gif delete.png page_white_excel.png table.png tick_all.png untick_all.png ).each do |f|
|
26
|
+
copy_file "icons/#{f}", "public/images/icons/grid/#{f}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module WiceGrid
|
2
|
+
module Generators
|
3
|
+
class WiceGridAssetsPrototypeGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
desc "Copy WiceGrid assets for Prototype based apps"
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
|
9
|
+
def active_js_framework
|
10
|
+
'prototype'
|
11
|
+
end
|
12
|
+
def inactive_js_framework
|
13
|
+
'jquery'
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy_stuff
|
17
|
+
template 'wice_grid_config.rb', 'config/initializers/wice_grid_config.rb'
|
18
|
+
|
19
|
+
copy_file 'wice_grid.yml', 'config/locales/wice_grid.yml'
|
20
|
+
|
21
|
+
copy_file 'wice_grid_prototype.js', 'public/javascripts/wice_grid.js'
|
22
|
+
copy_file 'calendarview.js', 'public/javascripts/calendarview.js'
|
23
|
+
copy_file 'wice_grid.css', 'public/stylesheets/wice_grid.css'
|
24
|
+
copy_file 'calendarview.css', 'public/stylesheets/calendarview.css'
|
25
|
+
|
26
|
+
%w(arrow_down.gif calendar_view_month.png expand.png page_white_find.png table_refresh.png
|
27
|
+
arrow_up.gif delete.png page_white_excel.png table.png tick_all.png untick_all.png ).each do |f|
|
28
|
+
copy_file "icons/#{f}", "public/images/icons/grid/#{f}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/grid_renderer.rb
CHANGED
@@ -7,8 +7,15 @@ module Wice
|
|
7
7
|
include ActionView::Helpers::TextHelper
|
8
8
|
include ActionView::Helpers::AssetTagHelper
|
9
9
|
include ActionView::Helpers::JavaScriptHelper
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
def config
|
12
|
+
ActionController::Base.config
|
13
|
+
end
|
14
|
+
|
15
|
+
def controller
|
16
|
+
@grid.controller
|
17
|
+
end
|
18
|
+
|
12
19
|
attr_reader :page_parameter_name
|
13
20
|
attr_reader :after_row_handler
|
14
21
|
attr_reader :before_row_handler
|
@@ -32,7 +39,7 @@ module Wice
|
|
32
39
|
end
|
33
40
|
|
34
41
|
def add_column(vc) #:nodoc:
|
35
|
-
@columns_table[vc.
|
42
|
+
@columns_table[vc.attribute_name] = vc if vc.attribute_name
|
36
43
|
@columns << vc
|
37
44
|
end
|
38
45
|
|
@@ -40,6 +47,10 @@ module Wice
|
|
40
47
|
@columns_table[k]
|
41
48
|
end
|
42
49
|
|
50
|
+
def output_csv?
|
51
|
+
return grid.output_csv?
|
52
|
+
end
|
53
|
+
|
43
54
|
def number_of_columns(filter = nil) #:nodoc:
|
44
55
|
filter_columns(filter).size
|
45
56
|
end
|
@@ -282,6 +293,7 @@ module Wice
|
|
282
293
|
:detach_with_id => nil,
|
283
294
|
:filter_all_label => Defaults::CUSTOM_FILTER_ALL_LABEL,
|
284
295
|
:helper_style => Defaults::HELPER_STYLE,
|
296
|
+
:icon => nil,
|
285
297
|
:in_csv => true,
|
286
298
|
:in_html => true,
|
287
299
|
:model_class => nil,
|
@@ -323,10 +335,8 @@ module Wice
|
|
323
335
|
|
324
336
|
klass = ViewColumn
|
325
337
|
if options[:attribute_name] &&
|
326
|
-
col_type_and_table_name = @grid.declare_column(options[:attribute_name], options[:
|
327
|
-
|
328
|
-
|
329
|
-
db_column, table_name, main_table = col_type_and_table_name
|
338
|
+
col_type_and_table_name = @grid.declare_column(options[:attribute_name], options[:custom_filter])
|
339
|
+
db_column, table_name, is_main_table = col_type_and_table_name
|
330
340
|
col_type = db_column.type
|
331
341
|
|
332
342
|
if options[:custom_filter]
|
@@ -370,7 +380,7 @@ module Wice
|
|
370
380
|
end # custom_filter
|
371
381
|
end # attribute_name
|
372
382
|
|
373
|
-
vc = klass.new(block, options, @grid, table_name,
|
383
|
+
vc = klass.new(block, options, @grid, table_name, is_main_table, custom_filter, @view)
|
374
384
|
|
375
385
|
vc.negation = options[:negation_in_filter] if vc.respond_to? :negation=
|
376
386
|
|
@@ -447,18 +457,19 @@ module Wice
|
|
447
457
|
|
448
458
|
if new_params[@grid.name]
|
449
459
|
new_params[@grid.name].delete(:page) # we reset paging here
|
460
|
+
new_params[@grid.name].delete(:per_page) # we reset paging here
|
450
461
|
new_params[@grid.name].delete(:f) # no filter for the base url
|
451
462
|
new_params[@grid.name].delete(:foc) # nullify the focus
|
452
463
|
new_params[@grid.name].delete(:q) # and no request for the saved query
|
453
464
|
end
|
454
465
|
|
455
|
-
new_params[:only_path] =
|
456
|
-
base_link_with_pp_info = controller.url_for
|
466
|
+
new_params[:only_path] = true
|
467
|
+
base_link_with_pp_info = controller.send( :url_for, new_params).gsub(/\?+$/,'')
|
457
468
|
|
458
469
|
if new_params[@grid.name]
|
459
470
|
new_params[@grid.name].delete(:pp) # and reset back to pagination if show all mode is on
|
460
471
|
end
|
461
|
-
[base_link_with_pp_info, controller.url_for
|
472
|
+
[base_link_with_pp_info, controller.send(:url_for, new_params).gsub(/\?+$/,'')]
|
462
473
|
end
|
463
474
|
|
464
475
|
|
@@ -470,18 +481,23 @@ module Wice
|
|
470
481
|
new_params[@grid.name] = {} unless new_params[@grid.name]
|
471
482
|
new_params[@grid.name][:export] = format
|
472
483
|
|
473
|
-
new_params[:only_path] =
|
474
|
-
controller.url_for
|
484
|
+
new_params[:only_path] = true
|
485
|
+
controller.send(:url_for, new_params)
|
475
486
|
end
|
476
487
|
|
488
|
+
def more_link(controller, extra_parameters)
|
489
|
+
new_params = controller.params.deep_clone_yl
|
490
|
+
new_params.merge!(extra_parameters)
|
491
|
+
|
492
|
+
new_params[@grid.name] = {} unless new_params[@grid.name]
|
493
|
+
new_params[@grid.name][:per_page] = @grid.status[:per_page].to_i + (@grid.options[:per_page] || Defaults::PER_PAGE)
|
494
|
+
new_params[:only_path] = true
|
477
495
|
|
478
|
-
|
496
|
+
controller.send(:url_for, new_params)
|
497
|
+
end
|
479
498
|
|
480
|
-
|
481
|
-
|
482
|
-
else
|
483
|
-
column.table_alias_or_table_name + '.' + column.attribute_name
|
484
|
-
end
|
499
|
+
def column_link(column, direction, params, extra_parameters = {}) #:nodoc:
|
500
|
+
column_attribute_name = column.attribute_name
|
485
501
|
|
486
502
|
query_params = {@grid.name => {
|
487
503
|
@@order_parameter_name => column_attribute_name,
|
@@ -528,4 +544,4 @@ module Wice
|
|
528
544
|
end
|
529
545
|
|
530
546
|
end
|
531
|
-
end
|
547
|
+
end
|
@@ -1,11 +1,6 @@
|
|
1
1
|
module Wice
|
2
2
|
module JsCalendarHelpers
|
3
3
|
|
4
|
-
include ActionView::Helpers::AssetTagHelper
|
5
|
-
include ActionView::Helpers::TagHelper
|
6
|
-
include ActionView::Helpers::JavaScriptHelper
|
7
|
-
include ActionView::Helpers::FormTagHelper
|
8
|
-
|
9
4
|
# Jquery
|
10
5
|
|
11
6
|
def date_calendar_jquery(initial_date, view, opts = {}, html_opts = {}) #:nodoc:
|