wice_grid 3.2.0 → 3.2.1.pre1
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/CHANGELOG +9 -6
- data/README.rdoc +29 -0
- data/VERSION +1 -1
- data/lib/active_record_column_wrapper.rb +105 -0
- data/lib/columns/column_action.rb +50 -0
- data/lib/columns/column_boolean.rb +43 -0
- data/lib/columns/column_custom_dropdown.rb +119 -0
- data/lib/columns/column_date.rb +23 -0
- data/lib/columns/column_datetime.rb +113 -0
- data/lib/columns/column_float.rb +14 -0
- data/lib/columns/column_integer.rb +63 -0
- data/lib/columns/column_processor_index.rb +19 -0
- data/lib/columns/column_range.rb +74 -0
- data/lib/columns/column_string.rb +89 -0
- data/lib/columns.rb +223 -0
- data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +1 -1
- data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +2 -2
- data/lib/grid_renderer.rb +19 -9
- data/lib/helpers/wice_grid_view_helpers.rb +6 -10
- data/lib/kaminari_monkey_patching.rb +4 -4
- data/lib/wice_grid.rb +15 -245
- data/lib/wice_grid_controller.rb +4 -4
- data/lib/wice_grid_core_ext.rb +3 -3
- data/wice_grid.gemspec +15 -13
- metadata +17 -15
- data/lib/view_columns/action_view_column.rb +0 -45
- data/lib/view_columns/column_processor_index.rb +0 -16
- data/lib/view_columns/view_column_boolean.rb +0 -23
- data/lib/view_columns/view_column_custom_dropdown.rb +0 -80
- data/lib/view_columns/view_column_date.rb +0 -17
- data/lib/view_columns/view_column_datetime.rb +0 -85
- data/lib/view_columns/view_column_float.rb +0 -7
- data/lib/view_columns/view_column_integer.rb +0 -38
- data/lib/view_columns/view_column_string.rb +0 -63
- data/lib/view_columns.rb +0 -177
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module Wice
|
3
|
-
|
4
|
-
class ViewColumnDate < ViewColumnDatetime #:nodoc:
|
5
|
-
|
6
|
-
@@datetime_chunk_names = %w(year month day)
|
7
|
-
|
8
|
-
def render_standard_filter_internal(params) #:nodoc:
|
9
|
-
'<div class="date-filter">' +
|
10
|
-
select_date(params[:fr], {:include_blank => true, :prefix => @name1, :id => @dom_id}) + '<br/>' +
|
11
|
-
select_date(params[:to], {:include_blank => true, :prefix => @name2, :id => @dom_id2}) +
|
12
|
-
'</div>'
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module Wice
|
3
|
-
|
4
|
-
class ViewColumnDatetime < ViewColumn #:nodoc:
|
5
|
-
include ActionView::Helpers::DateHelper
|
6
|
-
include Wice::JsCalendarHelpers
|
7
|
-
|
8
|
-
|
9
|
-
# name_and_id_from_options in Rails Date helper does not substitute '.' with '_'
|
10
|
-
# like all other simpler form helpers do. Thus, overriding it here.
|
11
|
-
def name_and_id_from_options(options, type) #:nodoc:
|
12
|
-
options[:name] = (options[:prefix] || DEFAULT_PREFIX) + (options[:discard_type] ? '' : "[#{type}]")
|
13
|
-
options[:id] = options[:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
|
14
|
-
end
|
15
|
-
|
16
|
-
@@datetime_chunk_names = %w(year month day hour minute)
|
17
|
-
|
18
|
-
def prepare_for_standard_filter #:nodoc:
|
19
|
-
x = lambda{|sym|
|
20
|
-
@@datetime_chunk_names.collect{|datetime_chunk_name|
|
21
|
-
triple = form_parameter_name_id_and_query(sym => {datetime_chunk_name => ''})
|
22
|
-
[triple[0], triple[3]]
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
@queris_ids = x.call(:fr) + x.call(:to)
|
27
|
-
|
28
|
-
_, _, @name1, _ = form_parameter_name_id_and_query({:fr => ''})
|
29
|
-
_, _, @name2, _ = form_parameter_name_id_and_query({:to => ''})
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
def prepare_for_calendar_filter #:nodoc:
|
34
|
-
query, _, @name1, @dom_id = form_parameter_name_id_and_query(:fr => '')
|
35
|
-
query2, _, @name2, @dom_id2 = form_parameter_name_id_and_query(:to => '')
|
36
|
-
|
37
|
-
@queris_ids = [[query, @dom_id], [query2, @dom_id2] ]
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
def render_standard_filter_internal(params) #:nodoc:
|
42
|
-
'<div class="date-filter">' +
|
43
|
-
select_datetime(params[:fr], {:include_blank => true, :prefix => @name1}) + '<br/>' +
|
44
|
-
select_datetime(params[:to], {:include_blank => true, :prefix => @name2}) +
|
45
|
-
'</div>'
|
46
|
-
end
|
47
|
-
|
48
|
-
def render_calendar_filter_internal(params) #:nodoc:
|
49
|
-
|
50
|
-
html1 = date_calendar_jquery(
|
51
|
-
params[:fr], NlMessage['date_selector_tooltip_from'], :prefix => @name1, :fire_event => auto_reload, :grid_name => self.grid.name)
|
52
|
-
|
53
|
-
html2 = date_calendar_jquery(
|
54
|
-
params[:to], NlMessage['date_selector_tooltip_to'], :prefix => @name2, :fire_event => auto_reload, :grid_name => self.grid.name)
|
55
|
-
|
56
|
-
%!<div class="date-filter">#{html1}<br/>#{html2}</div>!
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
def render_filter_internal(params) #:nodoc:
|
61
|
-
if helper_style == :standard
|
62
|
-
prepare_for_standard_filter
|
63
|
-
render_standard_filter_internal(params)
|
64
|
-
else
|
65
|
-
prepare_for_calendar_filter
|
66
|
-
render_calendar_filter_internal(params)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def yield_declaration_of_column_filter #:nodoc:
|
72
|
-
{
|
73
|
-
:templates => @queris_ids.collect{|tuple| tuple[0] },
|
74
|
-
:ids => @queris_ids.collect{|tuple| tuple[1] }
|
75
|
-
}
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
def has_auto_reloading_calendar? #:nodoc:
|
80
|
-
auto_reload && helper_style == :calendar
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module Wice
|
3
|
-
|
4
|
-
class ViewColumnInteger < ViewColumn #:nodoc:
|
5
|
-
|
6
|
-
def render_filter_internal(params) #:nodoc:
|
7
|
-
@contains_a_text_input = true
|
8
|
-
|
9
|
-
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(:fr => '')
|
10
|
-
@query2, _, parameter_name2, @dom_id2 = form_parameter_name_id_and_query(:to => '')
|
11
|
-
|
12
|
-
opts1 = {:size => 3, :id => @dom_id, :class => 'range-start'}
|
13
|
-
opts2 = {:size => 3, :id => @dom_id2, :class => 'range-end'}
|
14
|
-
|
15
|
-
if auto_reload
|
16
|
-
opts1[:class] += ' auto-reload'
|
17
|
-
opts2[:class] += ' auto-reload'
|
18
|
-
end
|
19
|
-
|
20
|
-
text_field_tag(parameter_name, params[:fr], opts1) + text_field_tag(parameter_name2, params[:to], opts2)
|
21
|
-
end
|
22
|
-
|
23
|
-
def yield_declaration_of_column_filter #:nodoc:
|
24
|
-
{
|
25
|
-
:templates => [@query, @query2],
|
26
|
-
:ids => [@dom_id, @dom_id2]
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def has_auto_reloading_input? #:nodoc:
|
32
|
-
auto_reload
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module Wice
|
3
|
-
|
4
|
-
class ViewColumnString < ViewColumn #:nodoc:
|
5
|
-
|
6
|
-
attr_accessor :negation, :auto_reloading_input_with_negation_checkbox
|
7
|
-
|
8
|
-
def render_filter_internal(params) #:nodoc:
|
9
|
-
@contains_a_text_input = true
|
10
|
-
css_class = auto_reload ? 'auto-reload' : nil
|
11
|
-
|
12
|
-
if negation
|
13
|
-
self.auto_reloading_input_with_negation_checkbox = true if auto_reload
|
14
|
-
|
15
|
-
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(:v => '')
|
16
|
-
@query2, _, parameter_name2, @dom_id2 = form_parameter_name_id_and_query(:n => '')
|
17
|
-
|
18
|
-
'<div class="text-filter-container">' +
|
19
|
-
text_field_tag(parameter_name, params[:v], :size => 8, :id => @dom_id, :class => css_class) +
|
20
|
-
if defined?(Wice::Defaults::NEGATION_CHECKBOX_LABEL) && ! Wice::ConfigurationProvider.value_for(:NEGATION_CHECKBOX_LABEL).blank?
|
21
|
-
Wice::ConfigurationProvider.value_for(:NEGATION_CHECKBOX_LABEL)
|
22
|
-
else
|
23
|
-
''
|
24
|
-
end +
|
25
|
-
check_box_tag(parameter_name2, '1', (params[:n] == '1'),
|
26
|
-
:id => @dom_id2,
|
27
|
-
:title => NlMessage['negation_checkbox_title'],
|
28
|
-
:class => "negation-checkbox #{css_class}") +
|
29
|
-
'</div>'
|
30
|
-
else
|
31
|
-
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query('')
|
32
|
-
text_field_tag(parameter_name, (params.blank? ? '' : params), :size => 8, :id => @dom_id, :class => css_class)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def yield_declaration_of_column_filter #:nodoc:
|
38
|
-
if negation
|
39
|
-
{
|
40
|
-
:templates => [@query, @query2],
|
41
|
-
:ids => [@dom_id, @dom_id2]
|
42
|
-
}
|
43
|
-
else
|
44
|
-
{
|
45
|
-
:templates => [@query],
|
46
|
-
:ids => [@dom_id]
|
47
|
-
}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def has_auto_reloading_input? #:nodoc:
|
53
|
-
auto_reload
|
54
|
-
end
|
55
|
-
|
56
|
-
def auto_reloading_input_with_negation_checkbox? #:nodoc:
|
57
|
-
self.auto_reloading_input_with_negation_checkbox
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
end
|
data/lib/view_columns.rb
DELETED
@@ -1,177 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module Wice
|
3
|
-
|
4
|
-
class ViewColumn #:nodoc:
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def load_column_processors
|
8
|
-
|
9
|
-
loaded_column_processors = Hash.new
|
10
|
-
Wice::COLUMN_PROCESSOR_INDEX.each do |column_type, column_source_file|
|
11
|
-
unless loaded_column_processors[column_source_file]
|
12
|
-
require "view_columns/#{column_source_file}.rb"
|
13
|
-
column_class_name = column_source_file.classify
|
14
|
-
|
15
|
-
unless Wice.const_defined?(column_class_name.intern)
|
16
|
-
raise "#{column_source_file}.rb is expected to define #{column_class_name}!"
|
17
|
-
end
|
18
|
-
column_class = eval("Wice::#{column_class_name}")
|
19
|
-
|
20
|
-
loaded_column_processors[column_source_file] = column_class
|
21
|
-
end
|
22
|
-
|
23
|
-
@@handled_type[column_type] = loaded_column_processors[column_source_file]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_column_processor(column_type)
|
28
|
-
@@handled_type[column_type] || ViewColumn
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
include ActionView::Helpers::FormTagHelper
|
33
|
-
include ActionView::Helpers::TagHelper
|
34
|
-
include ActionView::Helpers::JavaScriptHelper
|
35
|
-
include ActionView::Helpers::AssetTagHelper
|
36
|
-
|
37
|
-
# fields defined from the options parameter
|
38
|
-
FIELDS = [:attribute, :name, :html, :filter, :model, :allow_multiple_selection,
|
39
|
-
:in_html, :in_csv, :helper_style, :table_alias, :custom_order, :detach_with_id, :ordering, :auto_reload]
|
40
|
-
|
41
|
-
attr_accessor *FIELDS
|
42
|
-
|
43
|
-
attr_accessor :cell_rendering_block, :grid, :css_class, :table_name, :main_table, :model, :custom_filter
|
44
|
-
|
45
|
-
attr_reader :contains_a_text_input
|
46
|
-
|
47
|
-
def initialize(block, options, grid_obj, tname, mtable, cfilter, view) #:nodoc:
|
48
|
-
self.cell_rendering_block = block
|
49
|
-
self.grid = grid_obj
|
50
|
-
self.table_name = tname
|
51
|
-
self.main_table = mtable
|
52
|
-
self.custom_filter = cfilter
|
53
|
-
@view = view
|
54
|
-
|
55
|
-
FIELDS.each do |field|
|
56
|
-
self.send(field.to_s + '=', options[field])
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
cattr_accessor :handled_type
|
61
|
-
@@handled_type = Hash.new
|
62
|
-
|
63
|
-
def css_class #:nodoc:
|
64
|
-
@css_class || ''
|
65
|
-
end
|
66
|
-
|
67
|
-
def yield_declaration_of_column_filter #:nodoc:
|
68
|
-
nil
|
69
|
-
end
|
70
|
-
|
71
|
-
def detachness #:nodoc:
|
72
|
-
(! detach_with_id.blank?).to_s
|
73
|
-
end
|
74
|
-
|
75
|
-
def yield_declaration #:nodoc:
|
76
|
-
declaration = yield_declaration_of_column_filter
|
77
|
-
if declaration
|
78
|
-
{
|
79
|
-
:filterName => self.name,
|
80
|
-
:detached => detachness,
|
81
|
-
:declaration => declaration
|
82
|
-
}
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
def config #:nodoc:
|
88
|
-
@view.config
|
89
|
-
end
|
90
|
-
|
91
|
-
def controller #:nodoc:
|
92
|
-
@view.controller
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
def render_filter #:nodoc:
|
97
|
-
params = @grid.filter_params(self)
|
98
|
-
render_filter_internal(params)
|
99
|
-
end
|
100
|
-
|
101
|
-
def render_filter_internal(params) #:nodoc:
|
102
|
-
'<!-- implement me! -->'
|
103
|
-
end
|
104
|
-
|
105
|
-
def form_parameter_name_id_and_query(v) #:nodoc:
|
106
|
-
query = form_parameter_template(v)
|
107
|
-
query_without_equals_sign = query.sub(/=$/,'')
|
108
|
-
parameter_name = CGI.unescape(query_without_equals_sign)
|
109
|
-
dom_id = id_out_of_name(parameter_name)
|
110
|
-
return query, query_without_equals_sign, parameter_name, dom_id.tr('.', '_')
|
111
|
-
end
|
112
|
-
|
113
|
-
# bad name, because for the main table the name is not really 'fully_qualified'
|
114
|
-
def attribute_name_fully_qualified_for_all_but_main_table_columns #:nodoc:
|
115
|
-
self.main_table ? attribute : table_alias_or_table_name + '.' + attribute
|
116
|
-
end
|
117
|
-
|
118
|
-
def fully_qualified_attribute_name #:nodoc:
|
119
|
-
table_alias_or_table_name + '.' + attribute
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
|
-
def filter_shown? #:nodoc:
|
124
|
-
self.attribute && self.filter
|
125
|
-
end
|
126
|
-
|
127
|
-
def filter_shown_in_main_table? #:nodoc:
|
128
|
-
filter_shown? && ! self.detach_with_id
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
def table_alias_or_table_name #:nodoc:
|
133
|
-
table_alias || table_name
|
134
|
-
end
|
135
|
-
|
136
|
-
def capable_of_hosting_filter_related_icons? #:nodoc:
|
137
|
-
self.attribute.blank? && self.name.blank? && ! self.filter_shown?
|
138
|
-
end
|
139
|
-
|
140
|
-
def has_auto_reloading_input? #:nodoc:
|
141
|
-
false
|
142
|
-
end
|
143
|
-
|
144
|
-
def auto_reloading_input_with_negation_checkbox? #:nodoc:
|
145
|
-
false
|
146
|
-
end
|
147
|
-
|
148
|
-
def has_auto_reloading_select? #:nodoc:
|
149
|
-
false
|
150
|
-
end
|
151
|
-
|
152
|
-
def has_auto_reloading_calendar? #:nodoc:
|
153
|
-
false
|
154
|
-
end
|
155
|
-
|
156
|
-
protected
|
157
|
-
|
158
|
-
def form_parameter_template(v) #:nodoc:
|
159
|
-
{@grid.name => {:f => {self.attribute_name_fully_qualified_for_all_but_main_table_columns => v}}}.to_query
|
160
|
-
end
|
161
|
-
|
162
|
-
def form_parameter_name(v) #:nodoc:
|
163
|
-
form_parameter_template_hash(v).to_query
|
164
|
-
end
|
165
|
-
|
166
|
-
def name_out_of_template(s) #:nodoc:
|
167
|
-
CGI.unescape(s).sub(/=$/,'')
|
168
|
-
end
|
169
|
-
|
170
|
-
def id_out_of_name(s) #:nodoc:
|
171
|
-
s.gsub(/[\[\]]+/,'_').sub(/_+$/, '')
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
|
177
|
-
end
|