wice_grid 3.4.8 → 3.4.9
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.
- checksums.yaml +4 -4
- data/README.rdoc +3 -5
- data/Rakefile +1 -1
- data/lib/generators/wice_grid/templates/wice_grid.css.scss +11 -11
- data/lib/wice/active_record_column_wrapper.rb +2 -2
- data/lib/wice/columns/column_action.rb +5 -6
- data/lib/wice/columns/column_custom_dropdown.rb +9 -11
- data/lib/wice/columns/column_date.rb +2 -2
- data/lib/wice/columns/column_datetime.rb +18 -18
- data/lib/wice/columns/column_integer.rb +4 -4
- data/lib/wice/columns/column_range.rb +7 -7
- data/lib/wice/columns/column_string.rb +11 -11
- data/lib/wice/columns.rb +4 -4
- data/lib/wice/grid_renderer.rb +39 -32
- data/lib/wice/wice_grid_controller.rb +17 -15
- data/lib/wice/wice_grid_core_ext.rb +2 -2
- data/lib/wice/wice_grid_misc.rb +1 -1
- data/lib/wice/wice_grid_serialized_queries_controller.rb +11 -11
- data/lib/wice/wice_grid_serialized_query.rb +3 -4
- data/lib/wice/wice_grid_spreadsheet.rb +7 -21
- data/lib/wice_grid.rb +38 -27
- data/wice_grid.gemspec +5 -2
- metadata +16 -3
- data/lib/wice/memory_adapter.rb +0 -172
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c4ac301670447bdd79518dfa9a759e2907862e99
|
|
4
|
+
data.tar.gz: 3ce402160cbecb319f1a323b20f8165a5b1abc32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 22cb097711ef784200fc1a5d3c168c6468f85550af82c920d65b3a9ff2d9e88e27f4b9c26f72fa60ea4f72ec7aba54dad8912bf4ea8d76e3f5b4c353568109f3
|
|
7
|
+
data.tar.gz: a46bdb7761ffd3c52b67039d2b0eeadedc5ade9ddb341f8ead7b7fd75b2898fd323436822af1ec58124faea50848f4367e2f65d346d9e12b4f66d8cc49c872df
|
data/README.rdoc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
= WiceGrid
|
|
2
2
|
|
|
3
|
-
Version:: 3.4.
|
|
3
|
+
Version:: 3.4.9
|
|
4
4
|
Author:: Yuri Leikind
|
|
5
5
|
Sources:: https://github.com/leikind/wice_grid/
|
|
6
6
|
Examples online:: http://wicegrid.herokuapp.com
|
|
@@ -8,12 +8,10 @@ News:: http://leikind.org/tag/wicegrid/
|
|
|
8
8
|
Email:: "Yuri Leikind" <yuri.leikind at gmail dot com>
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
The main supported branch is +rails3+.
|
|
11
|
+
The main supported branch is +rails3+. Rails 3 and Rails 4 are supported.
|
|
12
12
|
|
|
13
13
|
For rails 2 use the +master+ branch: https://github.com/leikind/wice_grid/tree/master
|
|
14
14
|
|
|
15
|
-
Rails 4 is supported beginning with version 3.4.x.
|
|
16
|
-
|
|
17
15
|
|
|
18
16
|
== Intro
|
|
19
17
|
|
|
@@ -709,7 +707,7 @@ jQuery +datepicker+ uses a different format flavor, therefore there is an additi
|
|
|
709
707
|
for presenting initial date values in filters, so make sure that +DATE_FORMAT_JQUERY+ and +DATE_FORMAT+
|
|
710
708
|
result in an identical date representation.
|
|
711
709
|
|
|
712
|
-
Constant +DATEPICKER_YEAR_RANGE+
|
|
710
|
+
Constant +DATEPICKER_YEAR_RANGE+ defines the range of years in the Datepicker year dropdown. Alternatively,
|
|
713
711
|
you can always change this range dynamically with the following javascript:
|
|
714
712
|
|
|
715
713
|
$( ".hasDatepicker" ).datepicker( "option", "yearRange", "2000:2042" );
|
data/Rakefile
CHANGED
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
.collapse-multi-select-icon{
|
|
40
|
-
background: transparent url(
|
|
40
|
+
background: transparent image-url("icons/grid/collapse.gif") no-repeat;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
.expand-multi-select-icon{
|
|
44
|
-
background: transparent url(
|
|
44
|
+
background: transparent image-url("icons/grid/expand.gif") no-repeat;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
}
|
|
@@ -56,43 +56,43 @@
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
.desc {
|
|
59
|
-
background: transparent url(
|
|
59
|
+
background: transparent image-url("icons/grid/arrow_down.gif") right no-repeat
|
|
60
60
|
}
|
|
61
61
|
.asc {
|
|
62
|
-
background: transparent url(
|
|
62
|
+
background: transparent image-url("icons/grid/arrow_up.gif") right no-repeat
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
.submit.clickable{
|
|
66
|
-
background: transparent url(
|
|
66
|
+
background: transparent image-url("icons/grid/table_refresh.png") no-repeat;
|
|
67
67
|
@include icon-dimensions;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
.reset.clickable{
|
|
71
|
-
background: transparent url(
|
|
71
|
+
background: transparent image-url("icons/grid/table.png") no-repeat;
|
|
72
72
|
@include icon-dimensions;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
.wg-show-filter.clickable,
|
|
77
77
|
.wg-hide-filter.clickable{
|
|
78
|
-
background: transparent url(
|
|
78
|
+
background: transparent image-url("icons/grid/page_white_find.png") no-repeat;
|
|
79
79
|
@include icon-dimensions;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
.export-to-csv-button.clickable{
|
|
84
|
-
background: transparent url(
|
|
84
|
+
background: transparent image-url("icons/grid/page_white_excel.png") no-repeat;
|
|
85
85
|
@include icon-dimensions;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
.clickable.select-all{
|
|
89
|
-
background: transparent url(
|
|
89
|
+
background: transparent image-url("icons/grid/tick_all.png") no-repeat;
|
|
90
90
|
@include icon-dimensions;
|
|
91
91
|
float:left;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
.clickable.deselect-all{
|
|
95
|
-
background: transparent url(
|
|
95
|
+
background: transparent image-url("icons/grid/untick_all.png") no-repeat;
|
|
96
96
|
@include icon-dimensions;
|
|
97
97
|
float:left;
|
|
98
98
|
}
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
ul {margin-left: 0 }
|
|
127
127
|
|
|
128
128
|
a.wice-grid-delete-query .delete-icon{
|
|
129
|
-
background: transparent url(
|
|
129
|
+
background: transparent image-url("icons/grid/delete.png") no-repeat;
|
|
130
130
|
float: left;
|
|
131
131
|
@include icon-dimensions;
|
|
132
132
|
}
|
|
@@ -30,7 +30,7 @@ module Wice
|
|
|
30
30
|
|
|
31
31
|
# Preprocess incoming parameters for datetime, if what's coming in is
|
|
32
32
|
# a datetime (with custom_filter it can be anything else, and not
|
|
33
|
-
# the datetime hash {:
|
|
33
|
+
# the datetime hash {fr: ..., to: ...})
|
|
34
34
|
if @request_params
|
|
35
35
|
if (@column.type == :datetime || @column.type == :timestamp) && @request_params.is_a?(Hash)
|
|
36
36
|
[:fr, :to].each do |sym|
|
|
@@ -47,7 +47,7 @@ module Wice
|
|
|
47
47
|
|
|
48
48
|
# Preprocess incoming parameters for date, if what's coming in is
|
|
49
49
|
# a date (with custom_filter it can be anything else, and not
|
|
50
|
-
# the date hash {:
|
|
50
|
+
# the date hash {fr: ..., to: ...})
|
|
51
51
|
if @column.type == :date && @request_params.is_a?(Hash)
|
|
52
52
|
[:fr, :to].each do |sym|
|
|
53
53
|
if @request_params[sym]
|
|
@@ -18,7 +18,7 @@ module Wice
|
|
|
18
18
|
''
|
|
19
19
|
else
|
|
20
20
|
selected = params[grid_name] && params[grid_name][param_name] && params[grid_name][param_name].index(object.send(object_property).to_s)
|
|
21
|
-
check_box_tag("#{grid_name}[#{param_name}][]", object.send(object_property), selected, :
|
|
21
|
+
check_box_tag("#{grid_name}[#{param_name}][]", object.send(object_property), selected, id: nil)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -35,12 +35,11 @@ module Wice
|
|
|
35
35
|
return '' unless @select_all_buttons
|
|
36
36
|
|
|
37
37
|
content_tag(:div, '',
|
|
38
|
-
:
|
|
39
|
-
:
|
|
38
|
+
class: 'clickable select-all',
|
|
39
|
+
title: NlMessage['select_all']) + ' ' +
|
|
40
40
|
content_tag(:div, '',
|
|
41
|
-
:
|
|
42
|
-
:
|
|
43
|
-
|
|
41
|
+
class: 'clickable deselect-all',
|
|
42
|
+
title: NlMessage['deselect_all'])
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
end
|
|
@@ -16,14 +16,12 @@ module Wice
|
|
|
16
16
|
@custom_filter = @custom_filter.call if @custom_filter.kind_of? Proc
|
|
17
17
|
|
|
18
18
|
if @custom_filter.kind_of? Array
|
|
19
|
-
|
|
20
19
|
@custom_filter = [[@filter_all_label, nil]] + @custom_filter.map{|label, value|
|
|
21
20
|
[label.to_s, value.to_s]
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
end
|
|
25
23
|
|
|
26
|
-
select_options = {:
|
|
24
|
+
select_options = {name: @parameter_name + '[]', id: @dom_id, class: 'custom-dropdown form-control'}
|
|
27
25
|
|
|
28
26
|
if @turn_off_select_toggling
|
|
29
27
|
select_toggle = ''
|
|
@@ -35,14 +33,14 @@ module Wice
|
|
|
35
33
|
expand_icon_style, collapse_icon_style = collapse_icon_style, expand_icon_style if select_options[:multiple]
|
|
36
34
|
|
|
37
35
|
select_toggle = content_tag(:span, '',
|
|
38
|
-
:
|
|
39
|
-
:
|
|
40
|
-
:
|
|
36
|
+
title: NlMessage['expand'],
|
|
37
|
+
class: 'expand-multi-select-icon clickable',
|
|
38
|
+
style: expand_icon_style
|
|
41
39
|
) +
|
|
42
40
|
content_tag(:span, '',
|
|
43
|
-
:
|
|
44
|
-
:
|
|
45
|
-
:
|
|
41
|
+
title: NlMessage['collapse'],
|
|
42
|
+
class: 'collapse-multi-select-icon clickable',
|
|
43
|
+
style: collapse_icon_style
|
|
46
44
|
)
|
|
47
45
|
else
|
|
48
46
|
select_options[:multiple] = false
|
|
@@ -65,8 +63,8 @@ module Wice
|
|
|
65
63
|
|
|
66
64
|
def yield_declaration_of_column_filter #:nodoc:
|
|
67
65
|
{
|
|
68
|
-
:
|
|
69
|
-
:
|
|
66
|
+
templates: [@query_without_equals_sign],
|
|
67
|
+
ids: [@dom_id]
|
|
70
68
|
}
|
|
71
69
|
end
|
|
72
70
|
|
|
@@ -9,8 +9,8 @@ module Wice
|
|
|
9
9
|
|
|
10
10
|
def render_standard_filter_internal(params) #:nodoc:
|
|
11
11
|
'<div class="date-filter">' +
|
|
12
|
-
select_date(params[:fr], {:
|
|
13
|
-
select_date(params[:to], {:
|
|
12
|
+
select_date(params[:fr], {include_blank: true, prefix: @name1, id: @dom_id}) + '<br/>' +
|
|
13
|
+
select_date(params[:to], {include_blank: true, prefix: @name2, id: @dom_id2}) +
|
|
14
14
|
'</div>'
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -27,14 +27,14 @@ module Wice
|
|
|
27
27
|
|
|
28
28
|
@queris_ids = x.call(:fr) + x.call(:to)
|
|
29
29
|
|
|
30
|
-
_, _, @name1, _ = form_parameter_name_id_and_query({:
|
|
31
|
-
_, _, @name2, _ = form_parameter_name_id_and_query({:
|
|
30
|
+
_, _, @name1, _ = form_parameter_name_id_and_query({fr: ''})
|
|
31
|
+
_, _, @name2, _ = form_parameter_name_id_and_query({to: ''})
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
def prepare_for_calendar_filter #:nodoc:
|
|
36
|
-
query, _, @name1, @dom_id = form_parameter_name_id_and_query(:
|
|
37
|
-
query2, _, @name2, @dom_id2 = form_parameter_name_id_and_query(:
|
|
36
|
+
query, _, @name1, @dom_id = form_parameter_name_id_and_query(fr: '')
|
|
37
|
+
query2, _, @name2, @dom_id2 = form_parameter_name_id_and_query(to: '')
|
|
38
38
|
|
|
39
39
|
@queris_ids = [[query, @dom_id], [query2, @dom_id2] ]
|
|
40
40
|
end
|
|
@@ -42,27 +42,27 @@ module Wice
|
|
|
42
42
|
|
|
43
43
|
def render_standard_filter_internal(params) #:nodoc:
|
|
44
44
|
'<div class="date-filter">' +
|
|
45
|
-
select_datetime(params[:fr], {:
|
|
46
|
-
select_datetime(params[:to], {:
|
|
45
|
+
select_datetime(params[:fr], {include_blank: true, prefix: @name1}) + '<br/>' +
|
|
46
|
+
select_datetime(params[:to], {include_blank: true, prefix: @name2}) +
|
|
47
47
|
'</div>'
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def render_calendar_filter_internal(params) #:nodoc:
|
|
51
51
|
|
|
52
52
|
calendar_data_from = prepare_data_for_calendar(
|
|
53
|
-
:
|
|
54
|
-
:
|
|
55
|
-
:
|
|
56
|
-
:
|
|
57
|
-
:
|
|
53
|
+
initial_date: params[:fr],
|
|
54
|
+
title: NlMessage['date_selector_tooltip_from'],
|
|
55
|
+
name: @name1,
|
|
56
|
+
fire_event: auto_reload,
|
|
57
|
+
grid_name: self.grid.name
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
calendar_data_to = prepare_data_for_calendar(
|
|
61
|
-
:
|
|
62
|
-
:
|
|
63
|
-
:
|
|
64
|
-
:
|
|
65
|
-
:
|
|
61
|
+
initial_date: params[:to],
|
|
62
|
+
title: NlMessage['date_selector_tooltip_to'],
|
|
63
|
+
name: @name2,
|
|
64
|
+
fire_event: auto_reload,
|
|
65
|
+
grid_name: self.grid.name
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
calendar_data_from.the_other_datepicker_id_to = calendar_data_to.dom_id
|
|
@@ -89,8 +89,8 @@ module Wice
|
|
|
89
89
|
|
|
90
90
|
def yield_declaration_of_column_filter #:nodoc:
|
|
91
91
|
{
|
|
92
|
-
:
|
|
93
|
-
:
|
|
92
|
+
templates: @queris_ids.collect{|tuple| tuple[0] },
|
|
93
|
+
ids: @queris_ids.collect{|tuple| tuple[1] }
|
|
94
94
|
}
|
|
95
95
|
end
|
|
96
96
|
|
|
@@ -8,9 +8,9 @@ module Wice
|
|
|
8
8
|
def render_filter_internal(params) #:nodoc:
|
|
9
9
|
@contains_a_text_input = true
|
|
10
10
|
|
|
11
|
-
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(:
|
|
11
|
+
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(eq: '')
|
|
12
12
|
|
|
13
|
-
opts = {:
|
|
13
|
+
opts = {size: 3, id: @dom_id, class: 'range-start'}
|
|
14
14
|
|
|
15
15
|
opts[:class] += ' form-control input-sm'
|
|
16
16
|
|
|
@@ -23,8 +23,8 @@ module Wice
|
|
|
23
23
|
|
|
24
24
|
def yield_declaration_of_column_filter #:nodoc:
|
|
25
25
|
{
|
|
26
|
-
:
|
|
27
|
-
:
|
|
26
|
+
templates: [@query],
|
|
27
|
+
ids: [@dom_id]
|
|
28
28
|
}
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -8,11 +8,11 @@ module Wice
|
|
|
8
8
|
def render_filter_internal(params) #:nodoc:
|
|
9
9
|
@contains_a_text_input = true
|
|
10
10
|
|
|
11
|
-
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(:
|
|
12
|
-
@query2, _, parameter_name2, @dom_id2 = form_parameter_name_id_and_query(:
|
|
11
|
+
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(fr: '')
|
|
12
|
+
@query2, _, parameter_name2, @dom_id2 = form_parameter_name_id_and_query(to: '')
|
|
13
13
|
|
|
14
|
-
opts1 = {:
|
|
15
|
-
opts2 = {:
|
|
14
|
+
opts1 = {size: 2, id: @dom_id, class: 'form-control input-sm range-start'}
|
|
15
|
+
opts2 = {size: 2, id: @dom_id2, class: 'form-control input-sm range-end'}
|
|
16
16
|
|
|
17
17
|
if auto_reload
|
|
18
18
|
opts1[:class] += ' auto-reload'
|
|
@@ -22,13 +22,13 @@ module Wice
|
|
|
22
22
|
content_tag(
|
|
23
23
|
:div,
|
|
24
24
|
text_field_tag(parameter_name, params[:fr], opts1) + text_field_tag(parameter_name2, params[:to], opts2),
|
|
25
|
-
:
|
|
25
|
+
class: 'form-inline')
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def yield_declaration_of_column_filter #:nodoc:
|
|
29
29
|
{
|
|
30
|
-
:
|
|
31
|
-
:
|
|
30
|
+
templates: [@query, @query2],
|
|
31
|
+
ids: [@dom_id, @dom_id2]
|
|
32
32
|
}
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -14,24 +14,24 @@ module Wice
|
|
|
14
14
|
if negation
|
|
15
15
|
self.auto_reloading_input_with_negation_checkbox = true if auto_reload
|
|
16
16
|
|
|
17
|
-
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(:
|
|
18
|
-
@query2, _, parameter_name2, @dom_id2 = form_parameter_name_id_and_query(:
|
|
17
|
+
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(v: '')
|
|
18
|
+
@query2, _, parameter_name2, @dom_id2 = form_parameter_name_id_and_query(n: '')
|
|
19
19
|
|
|
20
20
|
'<div class="text-filter-container">' +
|
|
21
|
-
text_field_tag(parameter_name, params[:v], :
|
|
21
|
+
text_field_tag(parameter_name, params[:v], size: 8, id: @dom_id, class: css_class) +
|
|
22
22
|
if defined?(Wice::Defaults::NEGATION_CHECKBOX_LABEL) && ! Wice::ConfigurationProvider.value_for(:NEGATION_CHECKBOX_LABEL).blank?
|
|
23
23
|
Wice::ConfigurationProvider.value_for(:NEGATION_CHECKBOX_LABEL)
|
|
24
24
|
else
|
|
25
25
|
''
|
|
26
26
|
end +
|
|
27
27
|
check_box_tag(parameter_name2, '1', (params[:n] == '1'),
|
|
28
|
-
:
|
|
29
|
-
:
|
|
30
|
-
:
|
|
28
|
+
id: @dom_id2,
|
|
29
|
+
title: NlMessage['negation_checkbox_title'],
|
|
30
|
+
class: "negation-checkbox #{css_class}") +
|
|
31
31
|
'</div>'
|
|
32
32
|
else
|
|
33
33
|
@query, _, parameter_name, @dom_id = form_parameter_name_id_and_query('')
|
|
34
|
-
text_field_tag(parameter_name, (params.blank? ? '' : params), :
|
|
34
|
+
text_field_tag(parameter_name, (params.blank? ? '' : params), size: 8, id: @dom_id, class: css_class)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -39,13 +39,13 @@ module Wice
|
|
|
39
39
|
def yield_declaration_of_column_filter #:nodoc:
|
|
40
40
|
if negation
|
|
41
41
|
{
|
|
42
|
-
:
|
|
43
|
-
:
|
|
42
|
+
templates: [@query, @query2],
|
|
43
|
+
ids: [@dom_id, @dom_id2]
|
|
44
44
|
}
|
|
45
45
|
else
|
|
46
46
|
{
|
|
47
|
-
:
|
|
48
|
-
:
|
|
47
|
+
templates: [@query],
|
|
48
|
+
ids: [@dom_id]
|
|
49
49
|
}
|
|
50
50
|
end
|
|
51
51
|
end
|
data/lib/wice/columns.rb
CHANGED
|
@@ -165,9 +165,9 @@ module Wice #:nodoc:
|
|
|
165
165
|
declaration = yield_declaration_of_column_filter
|
|
166
166
|
if declaration
|
|
167
167
|
{
|
|
168
|
-
:
|
|
169
|
-
:
|
|
170
|
-
:
|
|
168
|
+
filterName: self.name,
|
|
169
|
+
detached: detachness,
|
|
170
|
+
declaration: declaration
|
|
171
171
|
}
|
|
172
172
|
end
|
|
173
173
|
end
|
|
@@ -245,7 +245,7 @@ module Wice #:nodoc:
|
|
|
245
245
|
protected
|
|
246
246
|
|
|
247
247
|
def form_parameter_template(v) #:nodoc:
|
|
248
|
-
{@grid.name => {:
|
|
248
|
+
{@grid.name => {f: {self.attribute_name_fully_qualified_for_all_but_main_table_columns => v}}}.to_query
|
|
249
249
|
end
|
|
250
250
|
|
|
251
251
|
def form_parameter_name(v) #:nodoc:
|
data/lib/wice/grid_renderer.rb
CHANGED
|
@@ -92,8 +92,8 @@ module Wice
|
|
|
92
92
|
|
|
93
93
|
def csv_export_icon #:nodoc:
|
|
94
94
|
content_tag(:div, '',
|
|
95
|
-
:
|
|
96
|
-
:
|
|
95
|
+
title: NlMessage['csv_export_tooltip'],
|
|
96
|
+
class: 'clickable export-to-csv-button'
|
|
97
97
|
)
|
|
98
98
|
end
|
|
99
99
|
|
|
@@ -146,10 +146,10 @@ module Wice
|
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
options = {
|
|
149
|
-
|
|
150
|
-
:
|
|
151
|
-
:
|
|
152
|
-
|
|
149
|
+
param_name: :selected,
|
|
150
|
+
html: {},
|
|
151
|
+
select_all_buttons: true,
|
|
152
|
+
object_property: :id
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
opts.assert_valid_keys(options.keys)
|
|
@@ -157,8 +157,15 @@ module Wice
|
|
|
157
157
|
@action_column_present = true
|
|
158
158
|
column_processor_klass = Columns.get_view_column_processor(:action)
|
|
159
159
|
|
|
160
|
-
@columns << column_processor_klass.new(
|
|
161
|
-
|
|
160
|
+
@columns << column_processor_klass.new(
|
|
161
|
+
@grid,
|
|
162
|
+
options[:html],
|
|
163
|
+
options[:param_name],
|
|
164
|
+
options[:select_all_buttons],
|
|
165
|
+
options[:object_property],
|
|
166
|
+
@view,
|
|
167
|
+
block
|
|
168
|
+
)
|
|
162
169
|
end
|
|
163
170
|
|
|
164
171
|
# Defines everything related to a column in a grid - column name, filtering, rendering cells, etc.
|
|
@@ -170,7 +177,7 @@ module Wice
|
|
|
170
177
|
#
|
|
171
178
|
# * <tt>:name</tt> - Name of the column.
|
|
172
179
|
# * <tt>:html</tt> - a hash of HTML attributes to be included into the <tt>td</tt> tag.
|
|
173
|
-
# * <tt>:class</tt> - a shortcut for <tt
|
|
180
|
+
# * <tt>:class</tt> - a shortcut for <tt>html: {class: 'css_class'}</tt>
|
|
174
181
|
# * <tt>:attribute</tt> - name of a database column (which normally correspond to a model attribute with the
|
|
175
182
|
# same name). By default the field is assumed to belong to the default table (see documentation for the
|
|
176
183
|
# +initialize_grid+ method). Parameter <tt>:model</tt> allows to specify another table. Presence of
|
|
@@ -273,26 +280,26 @@ module Wice
|
|
|
273
280
|
|
|
274
281
|
def column(opts = {}, &block)
|
|
275
282
|
options = {
|
|
276
|
-
:
|
|
277
|
-
:
|
|
278
|
-
:
|
|
279
|
-
:
|
|
280
|
-
:
|
|
281
|
-
:
|
|
282
|
-
:
|
|
283
|
-
:
|
|
284
|
-
:
|
|
285
|
-
:
|
|
286
|
-
:
|
|
287
|
-
:
|
|
288
|
-
:
|
|
289
|
-
:
|
|
290
|
-
:
|
|
291
|
-
:
|
|
292
|
-
:
|
|
293
|
-
:
|
|
294
|
-
:
|
|
295
|
-
:
|
|
283
|
+
allow_multiple_selection: Defaults::ALLOW_MULTIPLE_SELECTION,
|
|
284
|
+
ordering: true,
|
|
285
|
+
attribute: nil,
|
|
286
|
+
auto_reload: Defaults::AUTO_RELOAD,
|
|
287
|
+
boolean_filter_false_label: NlMessage['boolean_filter_false_label'],
|
|
288
|
+
boolean_filter_true_label: NlMessage['boolean_filter_true_label'],
|
|
289
|
+
class: nil,
|
|
290
|
+
name: '',
|
|
291
|
+
custom_filter: nil,
|
|
292
|
+
detach_with_id: nil,
|
|
293
|
+
filter_all_label: Defaults::CUSTOM_FILTER_ALL_LABEL,
|
|
294
|
+
helper_style: Defaults::HELPER_STYLE,
|
|
295
|
+
in_csv: true,
|
|
296
|
+
in_html: true,
|
|
297
|
+
model: nil,
|
|
298
|
+
negation: Defaults::NEGATION_IN_STRING_FILTERS,
|
|
299
|
+
filter: true,
|
|
300
|
+
filter_type: nil,
|
|
301
|
+
table_alias: nil,
|
|
302
|
+
html: {}
|
|
296
303
|
}
|
|
297
304
|
|
|
298
305
|
opts.assert_valid_keys(options.keys)
|
|
@@ -426,14 +433,14 @@ module Wice
|
|
|
426
433
|
# and there are no records to render.
|
|
427
434
|
# In addition to the block style two other variants are accepted:
|
|
428
435
|
# * <tt>g.blank_slate "some text to be rendered"</tt>
|
|
429
|
-
# * <tt>g.blank_slate :
|
|
436
|
+
# * <tt>g.blank_slate partial: "partial_name"</tt>
|
|
430
437
|
def blank_slate(opts = nil, &block)
|
|
431
438
|
if (opts.is_a?(Hash) && opts.has_key?(:partial) && block.nil?) || (opts.is_a?(String) && block.nil?)
|
|
432
439
|
@blank_slate_handler = opts
|
|
433
440
|
elsif opts.nil? && block
|
|
434
441
|
@blank_slate_handler = block
|
|
435
442
|
else
|
|
436
|
-
raise WiceGridArgumentError.new("blank_slate accepts only a string, a block, or :
|
|
443
|
+
raise WiceGridArgumentError.new("blank_slate accepts only a string, a block, or template: 'path_to_template' ")
|
|
437
444
|
end
|
|
438
445
|
end
|
|
439
446
|
|
|
@@ -501,7 +508,7 @@ module Wice
|
|
|
501
508
|
end
|
|
502
509
|
|
|
503
510
|
query_params = {@grid.name => {
|
|
504
|
-
@@order_parameter_name
|
|
511
|
+
@@order_parameter_name => column_attribute_name,
|
|
505
512
|
@@order_direction_parameter_name => direction
|
|
506
513
|
}}
|
|
507
514
|
|
|
@@ -90,7 +90,7 @@ module Wice
|
|
|
90
90
|
# This convention can be easily overridden by supplying a hash parameter to +export_grid_if_requested+ where each key is the name of
|
|
91
91
|
# a grid, and the value is the name of the template (like it is specified for +render+, i.e. without '_' and extensions):
|
|
92
92
|
#
|
|
93
|
-
# export_grid_if_requested(:
|
|
93
|
+
# export_grid_if_requested(grid: => 'orders', 'grid2' => 'invoices')
|
|
94
94
|
#
|
|
95
95
|
# If the request is not a CSV export request, the method does nothing and returns +false+, if it is a CSV export request,
|
|
96
96
|
# the method returns +true+.
|
|
@@ -98,12 +98,12 @@ module Wice
|
|
|
98
98
|
# If the action has no explicit +render+ call, it's OK to just place +export_grid_if_requested+ as the last line of the action. Otherwise,
|
|
99
99
|
# to avoid double rendering, use the return value of the method to conditionally call your +render+ :
|
|
100
100
|
#
|
|
101
|
-
# export_grid_if_requested || render(:
|
|
101
|
+
# export_grid_if_requested || render(action: 'index')
|
|
102
102
|
#
|
|
103
103
|
# It's also possible to supply a block which will be called if no CSV export is requested:
|
|
104
104
|
#
|
|
105
105
|
# export_grid_if_requested do
|
|
106
|
-
# render(:
|
|
106
|
+
# render(action: 'index')
|
|
107
107
|
# end
|
|
108
108
|
|
|
109
109
|
def export_grid_if_requested(opts = {})
|
|
@@ -112,11 +112,11 @@ module Wice
|
|
|
112
112
|
if grid
|
|
113
113
|
template_name = opts[grid.name] || opts[grid.name.intern]
|
|
114
114
|
template_name ||= grid.name + '_grid'
|
|
115
|
-
temp_filename = render_to_string(:
|
|
115
|
+
temp_filename = render_to_string(partial: template_name)
|
|
116
116
|
temp_filename = temp_filename.strip
|
|
117
117
|
filename = (grid.csv_file_name || grid.name ) + '.csv'
|
|
118
118
|
grid.csv_tempfile.close
|
|
119
|
-
send_file_rails2 temp_filename, :
|
|
119
|
+
send_file_rails2 temp_filename, filename: filename, type: 'text/csv; charset=utf-8'
|
|
120
120
|
grid.csv_tempfile = nil
|
|
121
121
|
true
|
|
122
122
|
else
|
|
@@ -137,10 +137,12 @@ module Wice
|
|
|
137
137
|
# <tt>:model</tt> of the column declaration with the target custom filter.
|
|
138
138
|
# * <tt>:value</tt> - the value of the column filter.
|
|
139
139
|
def wice_grid_custom_filter_params(opts = {})
|
|
140
|
-
options = {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
options = {
|
|
141
|
+
:grid_name => 'grid',
|
|
142
|
+
:attribute => nil,
|
|
143
|
+
:model => nil,
|
|
144
|
+
:value => nil
|
|
145
|
+
}
|
|
144
146
|
options.merge!(opts)
|
|
145
147
|
|
|
146
148
|
[:attribute, :value].each do |key|
|
|
@@ -173,16 +175,16 @@ module Wice
|
|
|
173
175
|
@performed_render = false
|
|
174
176
|
|
|
175
177
|
logger.info "Sending file #{path}" unless logger.nil?
|
|
176
|
-
File.open(path, 'rb') { |file| render :
|
|
178
|
+
File.open(path, 'rb') { |file| render status: options[:status], text: file.read }
|
|
177
179
|
end
|
|
178
180
|
|
|
179
181
|
|
|
180
182
|
DEFAULT_SEND_FILE_OPTIONS_RAILS2 = { #:nodoc:
|
|
181
|
-
:
|
|
182
|
-
:
|
|
183
|
-
:
|
|
184
|
-
:
|
|
185
|
-
:
|
|
183
|
+
type: 'application/octet-stream'.freeze,
|
|
184
|
+
disposition: 'attachment'.freeze,
|
|
185
|
+
stream: true,
|
|
186
|
+
buffer_size: 4096,
|
|
187
|
+
x_sendfile: false
|
|
186
188
|
}.freeze
|
|
187
189
|
|
|
188
190
|
def send_file_headers_rails2!(options) #:nodoc:
|
|
@@ -66,9 +66,9 @@ module Wice
|
|
|
66
66
|
# Used to transform a traditional params hash
|
|
67
67
|
# into an array of two element arrays where element zero is a parameter name as it appears in HTTP requests,
|
|
68
68
|
# and the first element is the value:
|
|
69
|
-
# { :
|
|
69
|
+
# { a: { b: 3, c: 4, d: { e: 5 }} }.parameter_names_and_values #=> [["a[d][e]", 5], ["a[b]", 3], ["a[c]", 4]]
|
|
70
70
|
# The parameter is an optional array of parameter names to prepend:
|
|
71
|
-
# { :
|
|
71
|
+
# { a: { b: 3, c: 4, d: { e: 5 }} }.parameter_names_and_values(['foo', 'baz']) #=>
|
|
72
72
|
# [["foo[baz][a][d][e]", 5], ["foo[baz][a][b]", 3], ["foo[baz][a][c]", 4]]
|
|
73
73
|
def parameter_names_and_values(hash, initial = []) #:nodoc:
|
|
74
74
|
res = []
|
data/lib/wice/wice_grid_misc.rb
CHANGED
|
@@ -11,22 +11,22 @@ module Wice
|
|
|
11
11
|
# if Rails.version[0..1] == '3.'
|
|
12
12
|
|
|
13
13
|
# map.match '/wice_grid_serialized_queries/:grid_name',
|
|
14
|
-
# :
|
|
15
|
-
# :
|
|
14
|
+
# to: "#{controller}#create",
|
|
15
|
+
# as: 'create_serialized_query'
|
|
16
16
|
|
|
17
17
|
# map.match '/wice_grid_serialized_queries/:grid_name/:id',
|
|
18
|
-
# :
|
|
19
|
-
# :
|
|
18
|
+
# to: "#{controller}#delete",
|
|
19
|
+
# as: 'delete_serialized_query'
|
|
20
20
|
|
|
21
21
|
# else
|
|
22
22
|
|
|
23
23
|
map.post '/wice_grid_serialized_queries/:grid_name',
|
|
24
|
-
:
|
|
25
|
-
:
|
|
24
|
+
to: "#{controller}#create_saved_query",
|
|
25
|
+
as: 'create_serialized_query'
|
|
26
26
|
|
|
27
27
|
map.post '/wice_grid_serialized_queries/:grid_name/:id',
|
|
28
|
-
:
|
|
29
|
-
:
|
|
28
|
+
to: "#{controller}#delete_saved_query",
|
|
29
|
+
as: 'delete_serialized_query'
|
|
30
30
|
|
|
31
31
|
# end
|
|
32
32
|
end
|
|
@@ -84,10 +84,10 @@ module Wice
|
|
|
84
84
|
protected
|
|
85
85
|
|
|
86
86
|
def render_asyns_result
|
|
87
|
-
render :
|
|
88
|
-
'error_messages'
|
|
87
|
+
render json: {
|
|
88
|
+
'error_messages' => @error_messages,
|
|
89
89
|
'notification_messages' => @notification_messages,
|
|
90
|
-
'query_list'
|
|
90
|
+
'query_list' => render_to_string(inline: '<%=saved_queries_list(@grid_name, @saved_query, controller.extra, @confirm).html_safe%>')
|
|
91
91
|
}
|
|
92
92
|
end
|
|
93
93
|
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
class WiceGridSerializedQuery < ActiveRecord::Base #:nodoc:
|
|
3
3
|
serialize :query
|
|
4
4
|
|
|
5
|
-
validates_uniqueness_of :name, :
|
|
6
|
-
:message => 'A query with this name already exists'
|
|
5
|
+
validates_uniqueness_of :name, scope: :grid_name, on: :create, message: 'A query with this name already exists'
|
|
7
6
|
|
|
8
|
-
validates_presence_of :name, :
|
|
7
|
+
validates_presence_of :name, message: 'Please submit the name of the custom query'
|
|
9
8
|
|
|
10
9
|
def self.list(name, controller)
|
|
11
|
-
conditions = {:
|
|
10
|
+
conditions = {grid_name: name}
|
|
12
11
|
self.where(conditions).to_a
|
|
13
12
|
end
|
|
14
13
|
|
|
@@ -5,29 +5,15 @@ module Wice
|
|
|
5
5
|
class Spreadsheet #:nodoc:
|
|
6
6
|
|
|
7
7
|
attr_reader :tempfile
|
|
8
|
-
# CSV in 1.9.1 is a version of FasterCSV
|
|
9
|
-
if RUBY_VERSION =~ /^1\.9\./ || RUBY_VERSION =~ /^2\./
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def << (row) #:nodoc:
|
|
17
|
-
@csv << row
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
else
|
|
21
|
-
def initialize(name, field_separator) #:nodoc:
|
|
22
|
-
@tempfile = Tempfile.new(name)
|
|
23
|
-
@field_separator = field_separator
|
|
24
|
-
end
|
|
9
|
+
def initialize(name, field_separator) #:nodoc:
|
|
10
|
+
@tempfile = Tempfile.new(name)
|
|
11
|
+
@csv = CSV.new(@tempfile, col_sep: field_separator)
|
|
12
|
+
end
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
csv << row.map(&:to_s)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
14
|
+
def << (row) #:nodoc:
|
|
15
|
+
@csv << row
|
|
31
16
|
end
|
|
17
|
+
|
|
32
18
|
end
|
|
33
19
|
end
|
data/lib/wice_grid.rb
CHANGED
|
@@ -52,6 +52,10 @@ module Wice
|
|
|
52
52
|
require 'wice/kaminari_monkey_patching.rb'
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
|
+
|
|
56
|
+
initializer "wice_grid_railtie.configure_rails_assets_precompilation" do |app|
|
|
57
|
+
app.config.assets.precompile << 'icons/grid/*'
|
|
58
|
+
end
|
|
55
59
|
end
|
|
56
60
|
|
|
57
61
|
class WiceGrid
|
|
@@ -95,24 +99,24 @@ module Wice
|
|
|
95
99
|
begin
|
|
96
100
|
# options that are understood
|
|
97
101
|
@options = {
|
|
98
|
-
:
|
|
99
|
-
:
|
|
100
|
-
:
|
|
101
|
-
:
|
|
102
|
-
:
|
|
103
|
-
:
|
|
104
|
-
:
|
|
105
|
-
:
|
|
106
|
-
:
|
|
107
|
-
:
|
|
108
|
-
:
|
|
109
|
-
:
|
|
110
|
-
:
|
|
111
|
-
:
|
|
112
|
-
:
|
|
113
|
-
:
|
|
114
|
-
:
|
|
115
|
-
:
|
|
102
|
+
conditions: nil,
|
|
103
|
+
csv_file_name: nil,
|
|
104
|
+
csv_field_separator: Defaults::CSV_FIELD_SEPARATOR,
|
|
105
|
+
custom_order: {},
|
|
106
|
+
enable_export_to_csv: Defaults::ENABLE_EXPORT_TO_CSV,
|
|
107
|
+
group: nil,
|
|
108
|
+
include: nil,
|
|
109
|
+
joins: nil,
|
|
110
|
+
name: Defaults::GRID_NAME,
|
|
111
|
+
order: nil,
|
|
112
|
+
order_direction: Defaults::ORDER_DIRECTION,
|
|
113
|
+
page: 1,
|
|
114
|
+
page_method_name: Defaults::PAGE_METHOD_NAME,
|
|
115
|
+
per_page: Defaults::PER_PAGE,
|
|
116
|
+
saved_query: nil,
|
|
117
|
+
total_entries: nil,
|
|
118
|
+
with_paginated_resultset: nil,
|
|
119
|
+
with_resultset: nil
|
|
116
120
|
}
|
|
117
121
|
rescue NameError
|
|
118
122
|
raise NameError.new('A constant is missing in wice_grid_config.rb: ' + $!.message +
|
|
@@ -258,9 +262,11 @@ module Wice
|
|
|
258
262
|
end
|
|
259
263
|
|
|
260
264
|
# conditions
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
265
|
+
# do not delete for a while
|
|
266
|
+
# https://github.com/leikind/wice_grid/issues/144
|
|
267
|
+
# if @table_column_matrix.generated_conditions.size == 0
|
|
268
|
+
# @status.delete(:f)
|
|
269
|
+
# end
|
|
264
270
|
|
|
265
271
|
@ar_options[:conditions] = klass.send(:merge_conditions, @status[:conditions], * @table_column_matrix.conditions )
|
|
266
272
|
|
|
@@ -407,8 +413,13 @@ module Wice
|
|
|
407
413
|
end
|
|
408
414
|
|
|
409
415
|
def count #:nodoc:
|
|
410
|
-
form_ar_options(:
|
|
411
|
-
@relation.count(
|
|
416
|
+
form_ar_options(skip_ordering: true, forget_generated_options: true)
|
|
417
|
+
@relation.count(
|
|
418
|
+
conditions: @ar_options[:conditions],
|
|
419
|
+
joins: @ar_options[:joins],
|
|
420
|
+
include: @ar_options[:include],
|
|
421
|
+
group: @ar_options[:group]
|
|
422
|
+
)
|
|
412
423
|
end
|
|
413
424
|
|
|
414
425
|
alias_method :size, :count
|
|
@@ -559,10 +570,10 @@ module Wice
|
|
|
559
570
|
# form_ar_options
|
|
560
571
|
# @klass.unscoped do
|
|
561
572
|
# @relation.count(
|
|
562
|
-
# :
|
|
563
|
-
# :
|
|
564
|
-
# :
|
|
565
|
-
# :
|
|
573
|
+
# joins: @ar_options[:joins],
|
|
574
|
+
# include: @ar_options[:include],
|
|
575
|
+
# group: @ar_options[:group],
|
|
576
|
+
# conditions: @options[:conditions]
|
|
566
577
|
# )
|
|
567
578
|
# end
|
|
568
579
|
# end
|
data/wice_grid.gemspec
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'wice_grid'
|
|
3
|
-
s.version = '3.4.
|
|
3
|
+
s.version = '3.4.9'
|
|
4
4
|
s.homepage = 'https://github.com/leikind/wice_grid'
|
|
5
|
-
s.date = '2014-08-
|
|
5
|
+
s.date = '2014-08-03'
|
|
6
6
|
s.summary = 'A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters.'
|
|
7
7
|
s.description = 'A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters.' +
|
|
8
8
|
'One of the goals of this plugin was to allow the programmer to define the contents of the cell by himself, ' +
|
|
@@ -22,11 +22,14 @@ Gem::Specification.new do |s|
|
|
|
22
22
|
|
|
23
23
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
24
24
|
s.add_runtime_dependency(kaminary, [kaminary_version])
|
|
25
|
+
s.add_runtime_dependency('coffee-rails')
|
|
25
26
|
else
|
|
26
27
|
s.add_dependency(kaminari, [kaminary_version])
|
|
28
|
+
s.add_dependency('coffee-rails')
|
|
27
29
|
end
|
|
28
30
|
else
|
|
29
31
|
s.add_dependency(kaminari, [kaminary_version])
|
|
32
|
+
s.add_dependency('coffee-rails')
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wice_grid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.4.
|
|
4
|
+
version: 3.4.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yuri Leikind
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-08-
|
|
11
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: kaminari
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 0.13.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: coffee-rails
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
27
41
|
description: A Rails grid plugin to create grids with sorting, pagination, and (automatically
|
|
28
42
|
generated) filters.One of the goals of this plugin was to allow the programmer to
|
|
29
43
|
define the contents of the cell by himself, just like one does when rendering a
|
|
@@ -72,7 +86,6 @@ files:
|
|
|
72
86
|
- lib/wice/helpers/wice_grid_serialized_queries_view_helpers.rb
|
|
73
87
|
- lib/wice/helpers/wice_grid_view_helpers.rb
|
|
74
88
|
- lib/wice/kaminari_monkey_patching.rb
|
|
75
|
-
- lib/wice/memory_adapter.rb
|
|
76
89
|
- lib/wice/table_column_matrix.rb
|
|
77
90
|
- lib/wice/wice_grid_controller.rb
|
|
78
91
|
- lib/wice/wice_grid_core_ext.rb
|
data/lib/wice/memory_adapter.rb
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
module Wice
|
|
3
|
-
module MemoryAdapter
|
|
4
|
-
class MemoryAdapter
|
|
5
|
-
def initialize(rows, columns, kaminarafy = true)
|
|
6
|
-
@rows = rows
|
|
7
|
-
@klass = MemoryAdapterKlass.new(columns, self)
|
|
8
|
-
@columns = Set.new
|
|
9
|
-
columns.each do |col|
|
|
10
|
-
@columns << col.name.to_sym
|
|
11
|
-
end
|
|
12
|
-
@page_num = 1
|
|
13
|
-
@per_page = 20
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def klass
|
|
17
|
-
@klass
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def total_count
|
|
21
|
-
length
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def length
|
|
25
|
-
@rows.length
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# 1-based page number
|
|
29
|
-
def current_page
|
|
30
|
-
@page_num
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def limit_value
|
|
34
|
-
@per_page
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def total_pages
|
|
38
|
-
total_pages=(length.to_f / @per_page).ceil
|
|
39
|
-
total_pages
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# 0-based index into array
|
|
43
|
-
def offset_value
|
|
44
|
-
@page_num = total_pages if current_page > total_pages
|
|
45
|
-
|
|
46
|
-
offset_value = (current_page-1) * @per_page
|
|
47
|
-
offset_value
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def num_pages
|
|
51
|
-
total_pages
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def last_page?
|
|
55
|
-
last_page = current_page==total_pages
|
|
56
|
-
last_page
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def includes(*opts)
|
|
60
|
-
self
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def joins(*opts)
|
|
64
|
-
self
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def order(*opts)
|
|
68
|
-
self
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def where(*opts)
|
|
72
|
-
self
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def page(num)
|
|
76
|
-
@page_num=num.to_i
|
|
77
|
-
@page_num =1 if @page_num < 1
|
|
78
|
-
self
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def per(num)
|
|
82
|
-
@per_page=num.to_i
|
|
83
|
-
@per_page = 1 if @per_page < 1
|
|
84
|
-
self
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def each
|
|
88
|
-
start_index = offset_value
|
|
89
|
-
end_index = offset_value + @per_page
|
|
90
|
-
slice = @rows[start_index...end_index]
|
|
91
|
-
if slice
|
|
92
|
-
slice.each do |row|
|
|
93
|
-
yield Row.new(row, self)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def has_column?(col)
|
|
99
|
-
@columns.include?(col)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
class MemoryAdapterKlass
|
|
104
|
-
def initialize(columns, memory_adapter)
|
|
105
|
-
@columns = columns
|
|
106
|
-
@memory_adapter = memory_adapter
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def columns
|
|
110
|
-
@columns
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def table_name
|
|
114
|
-
SecureRandom.hex
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def merge_conditions(*conditions)
|
|
118
|
-
""
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def unscoped(&code)
|
|
122
|
-
#@memory_adapter.unscope
|
|
123
|
-
code.call
|
|
124
|
-
self
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def connection
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
class Row
|
|
132
|
-
def initialize(row, memory_adapter)
|
|
133
|
-
@row=row
|
|
134
|
-
@memory_adapter = memory_adapter
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def method_missing(m, *args, &block)
|
|
138
|
-
if @memory_adapter.has_column?(m)
|
|
139
|
-
@row[m]
|
|
140
|
-
else
|
|
141
|
-
super
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
class Column
|
|
147
|
-
def initialize(name)
|
|
148
|
-
@name = name.to_s
|
|
149
|
-
@model = Model.new
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def name
|
|
153
|
-
@name
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def model
|
|
157
|
-
@model
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def model=(model)
|
|
161
|
-
@model=model
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def type
|
|
165
|
-
:string
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
class Model
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end
|