wice_grid 3.5.0 → 3.6.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.inch.yml +3 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +181 -0
  5. data/.travis.yml +22 -0
  6. data/{CHANGELOG → CHANGELOG.md} +95 -31
  7. data/Gemfile +4 -1
  8. data/README.md +1517 -0
  9. data/Rakefile +51 -7
  10. data/{SAVED_QUERIES_HOWTO.rdoc → SAVED_QUERIES_HOWTO.md} +34 -31
  11. data/TODO.md +16 -0
  12. data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +4 -6
  13. data/lib/generators/wice_grid/install_generator.rb +2 -5
  14. data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +1 -0
  15. data/lib/generators/wice_grid/templates/wice_grid_config.rb +29 -34
  16. data/lib/wice/active_record_column_wrapper.rb +36 -17
  17. data/lib/wice/columns.rb +53 -52
  18. data/lib/wice/columns/column_action.rb +11 -13
  19. data/lib/wice/columns/column_boolean.rb +9 -11
  20. data/lib/wice/columns/column_bootstrap_datepicker.rb +48 -0
  21. data/lib/wice/columns/column_custom_dropdown.rb +22 -23
  22. data/lib/wice/columns/column_float.rb +2 -6
  23. data/lib/wice/columns/column_html5_datepicker.rb +31 -0
  24. data/lib/wice/columns/column_integer.rb +9 -13
  25. data/lib/wice/columns/column_jquery_datepicker.rb +49 -0
  26. data/lib/wice/columns/column_processor_index.rb +18 -13
  27. data/lib/wice/columns/column_rails_date_helper.rb +41 -0
  28. data/lib/wice/columns/column_rails_datetime_helper.rb +40 -0
  29. data/lib/wice/columns/column_range.rb +7 -11
  30. data/lib/wice/columns/column_string.rb +24 -20
  31. data/lib/wice/columns/common_date_datetime_mixin.rb +20 -0
  32. data/lib/wice/columns/common_js_date_datetime_conditions_generator_mixin.rb +39 -0
  33. data/lib/wice/columns/common_js_date_datetime_mixin.rb +15 -0
  34. data/lib/wice/columns/{column_date.rb → common_rails_date_datetime_conditions_generator_mixin.rb} +4 -22
  35. data/lib/wice/columns/common_standard_helper_date_datetime_mixin.rb +22 -0
  36. data/lib/wice/grid_output_buffer.rb +19 -10
  37. data/lib/wice/grid_renderer.rb +146 -85
  38. data/lib/wice/helpers/bs_calendar_helpers.rb +6 -7
  39. data/lib/wice/helpers/js_calendar_helpers.rb +19 -17
  40. data/lib/wice/helpers/wice_grid_misc_view_helpers.rb +18 -18
  41. data/lib/wice/helpers/wice_grid_serialized_queries_view_helpers.rb +44 -49
  42. data/lib/wice/helpers/wice_grid_view_helpers.rb +131 -134
  43. data/lib/wice/kaminari_monkey_patching.rb +3 -1
  44. data/lib/wice/table_column_matrix.rb +23 -8
  45. data/lib/wice/wice_grid_controller.rb +12 -16
  46. data/lib/wice/wice_grid_core_ext.rb +12 -20
  47. data/lib/wice/wice_grid_misc.rb +131 -53
  48. data/lib/wice/wice_grid_serialized_queries_controller.rb +10 -11
  49. data/lib/wice/wice_grid_serialized_query.rb +4 -3
  50. data/lib/wice/wice_grid_spreadsheet.rb +19 -18
  51. data/lib/wice_grid.rb +144 -135
  52. data/spec/schema.rb +9 -0
  53. data/spec/spec_helper.rb +75 -0
  54. data/spec/support/active_record.rb +11 -0
  55. data/spec/support/wice_grid_test_config.rb +172 -0
  56. data/spec/wice/grid_output_buffer_spec.rb +41 -0
  57. data/spec/wice/table_column_matrix_spec.rb +38 -0
  58. data/spec/wice/wice_grid_misc_spec.rb +159 -0
  59. data/spec/wice/wice_grid_spreadsheet_spec.rb +14 -0
  60. data/test/readme.txt +1 -1
  61. data/vendor/assets/javascripts/wice_grid_init.js.coffee +14 -8
  62. data/vendor/assets/stylesheets/wice_grid.scss +84 -0
  63. data/wice_grid.gemspec +32 -16
  64. metadata +217 -25
  65. data/README.rdoc +0 -1325
  66. data/lib/generators/wice_grid/templates/wice_grid.scss +0 -140
  67. data/lib/wice/columns/column_datetime.rb +0 -171
  68. data/vendor/assets/images/icons/grid/arrow_down.gif +0 -0
  69. data/vendor/assets/images/icons/grid/arrow_up.gif +0 -0
  70. data/vendor/assets/images/icons/grid/calendar_view_month.png +0 -0
  71. data/vendor/assets/images/icons/grid/collapse.gif +0 -0
  72. data/vendor/assets/images/icons/grid/delete.png +0 -0
  73. data/vendor/assets/images/icons/grid/expand.gif +0 -0
  74. data/vendor/assets/images/icons/grid/page_white_excel.png +0 -0
  75. data/vendor/assets/images/icons/grid/page_white_find.png +0 -0
  76. data/vendor/assets/images/icons/grid/table.png +0 -0
  77. data/vendor/assets/images/icons/grid/table_refresh.png +0 -0
  78. data/vendor/assets/images/icons/grid/tick_all.png +0 -0
  79. data/vendor/assets/images/icons/grid/untick_all.png +0 -0
@@ -1,140 +0,0 @@
1
- @mixin icon-dimensions {
2
- width: 16px;
3
- height: 16px;
4
- }
5
-
6
- .wg-detached-filter, .wice-grid{
7
-
8
- .text-filter-container {
9
- input{
10
- width:auto;
11
- margin-right: 10px;
12
- display: inline;
13
- }
14
- }
15
-
16
- a.date-label {text-decoration: none;}
17
- a.date-label:hover {text-decoration: line-through;}
18
-
19
- .clickable{
20
- cursor: pointer;
21
- margin-bottom: 2px;
22
- margin-right: 2px;
23
- }
24
-
25
- .ui-datepicker-trigger, .wg-detached-filter .ui-datepicker-trigger{
26
- cursor: pointer;
27
- }
28
-
29
- .custom-dropdown-container {
30
-
31
- .expand-multi-select-icon, .collapse-multi-select-icon{
32
- width: 10px;
33
- height: 10px;
34
- display: inline-block;
35
- margin-left: 5px;
36
- vertical-align: top;
37
- }
38
-
39
- .collapse-multi-select-icon{
40
- background: transparent image-url("icons/grid/collapse.gif") no-repeat;
41
- }
42
-
43
- .expand-multi-select-icon{
44
- background: transparent image-url("icons/grid/expand.gif") no-repeat;
45
- }
46
-
47
- }
48
- }
49
-
50
- .wice-grid{
51
-
52
-
53
- .desc, .asc{
54
- padding-right: 18px;
55
- text-decoration:none;
56
- }
57
-
58
- .desc {
59
- background: transparent image-url("icons/grid/arrow_down.gif") right no-repeat
60
- }
61
- .asc {
62
- background: transparent image-url("icons/grid/arrow_up.gif") right no-repeat
63
- }
64
-
65
- .submit.clickable{
66
- background: transparent image-url("icons/grid/table_refresh.png") no-repeat;
67
- @include icon-dimensions;
68
- }
69
-
70
- .reset.clickable{
71
- background: transparent image-url("icons/grid/table.png") no-repeat;
72
- @include icon-dimensions;
73
- }
74
-
75
-
76
- .wg-show-filter.clickable,
77
- .wg-hide-filter.clickable{
78
- background: transparent image-url("icons/grid/page_white_find.png") no-repeat;
79
- @include icon-dimensions;
80
- }
81
-
82
-
83
- .export-to-csv-button.clickable{
84
- background: transparent image-url("icons/grid/page_white_excel.png") no-repeat;
85
- @include icon-dimensions;
86
- }
87
-
88
- .clickable.select-all{
89
- background: transparent image-url("icons/grid/tick_all.png") no-repeat;
90
- @include icon-dimensions;
91
- float:left;
92
- }
93
-
94
- .clickable.deselect-all{
95
- background: transparent image-url("icons/grid/untick_all.png") no-repeat;
96
- @include icon-dimensions;
97
- float:left;
98
- }
99
-
100
-
101
- /* in case of twitter bootstrap :) */
102
- thead th select{
103
- width: auto;
104
- }
105
-
106
- .pagination{
107
- margin: 0px;
108
- float: left;
109
- }
110
-
111
-
112
- tr.wg-filter-row input[type=text] {
113
- width: 100px;
114
- }
115
-
116
- .pagination_status {
117
- font-weight: bold;
118
- float: right;
119
- }
120
-
121
- }
122
-
123
- .wice-grid-query-panel{
124
- li {list-style-type: none; }
125
-
126
- ul {margin-left: 0 }
127
-
128
- a.wice-grid-delete-query .delete-icon{
129
- background: transparent image-url("icons/grid/delete.png") no-repeat;
130
- float: left;
131
- @include icon-dimensions;
132
- }
133
- }
134
-
135
- input.wice-grid-save-query-field{
136
- width: auto;
137
- display: inline-block;
138
- margin-right: 10px;
139
- }
140
-
@@ -1,171 +0,0 @@
1
- module Wice
2
-
3
- module Columns #:nodoc:
4
-
5
- class ViewColumnDatetime < ViewColumn #:nodoc:
6
- include ActionView::Helpers::DateHelper
7
- include Wice::BsCalendarHelpers
8
- include Wice::JsCalendarHelpers
9
-
10
-
11
- # name_and_id_from_options in Rails Date helper does not substitute '.' with '_'
12
- # like all other simpler form helpers do. Thus, overriding it here.
13
- def name_and_id_from_options(options, type) #:nodoc:
14
- options[:name] = (options[:prefix] || DEFAULT_PREFIX) + (options[:discard_type] ? '' : "[#{type}]")
15
- options[:id] = options[:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
16
- end
17
-
18
- def chunk_names
19
- %w(year month day hour minute)
20
- end
21
-
22
- def prepare_for_standard_filter #:nodoc:
23
- x = lambda{|sym|
24
- chunk_names.map{|datetime_chunk_name|
25
- triple = form_parameter_name_id_and_query(sym => {datetime_chunk_name => ''})
26
- [triple[0], triple[3]]
27
- }
28
- }
29
-
30
- @queris_ids = x.call(:fr) + x.call(:to)
31
-
32
- _, _, @name1, _ = form_parameter_name_id_and_query({fr: ''})
33
- _, _, @name2, _ = form_parameter_name_id_and_query({to: ''})
34
- end
35
-
36
-
37
- def prepare_for_calendar_filter #:nodoc:
38
- query, _, @name1, @dom_id = form_parameter_name_id_and_query(fr: '')
39
- query2, _, @name2, @dom_id2 = form_parameter_name_id_and_query(to: '')
40
-
41
- @queris_ids = [[query, @dom_id], [query2, @dom_id2] ]
42
- end
43
-
44
-
45
- def render_standard_filter_internal(params) #:nodoc:
46
- '<div class="date-filter">' +
47
- select_datetime(params[:fr], {include_blank: true, prefix: @name1}) + '<br/>' +
48
- select_datetime(params[:to], {include_blank: true, prefix: @name2}) +
49
- '</div>'
50
- end
51
-
52
-
53
- def render_html5_filter_internal(params) #:nodoc:
54
- css_class = 'form-control input-sm native-datepicker ' + (auto_reload ? 'auto-reload' : '')
55
- date_format = Wice::ConfigurationProvider.value_for(:DATE_FORMAT)
56
- '<div class="date-filter wg-html5-datepicker">' +
57
- date_field_tag(@name1, params[:fr].try(:strftime, date_format), {class: css_class, id: @dom_id}) + '<br/>' +
58
- date_field_tag(@name2, params[:to].try(:strftime, date_format), {class: css_class, id: @dom_id2}) +
59
- '</div>'
60
- end
61
-
62
- def render_bs_filter_internal(params) #:nodoc:
63
- calendar_data_from = prepare_data_for_bscalendar(
64
- initial_date: params[:fr],
65
- name: @name1,
66
- fire_event: auto_reload,
67
- grid_name: self.grid.name
68
- )
69
-
70
- calendar_data_to = prepare_data_for_bscalendar(
71
- initial_date: params[:to],
72
- name: @name2,
73
- fire_event: auto_reload,
74
- grid_name: self.grid.name
75
- )
76
-
77
- calendar_data_from.the_other_datepicker_id_to = calendar_data_to.dom_id
78
- calendar_data_to.the_other_datepicker_id_from = calendar_data_from.dom_id
79
-
80
- html1 = date_calendar_bs calendar_data_from
81
-
82
- html2 = date_calendar_bs calendar_data_to
83
-
84
- %!<div class="date-filter wg-bootstrap-datepicker">#{html1}#{html2}</div>!
85
- end
86
-
87
- def render_calendar_filter_internal(params) #:nodoc:
88
-
89
- calendar_data_from = prepare_data_for_calendar(
90
- initial_date: params[:fr],
91
- title: NlMessage['date_selector_tooltip_from'],
92
- name: @name1,
93
- fire_event: auto_reload,
94
- grid_name: self.grid.name
95
- )
96
-
97
- calendar_data_to = prepare_data_for_calendar(
98
- initial_date: params[:to],
99
- title: NlMessage['date_selector_tooltip_to'],
100
- name: @name2,
101
- fire_event: auto_reload,
102
- grid_name: self.grid.name
103
- )
104
-
105
- calendar_data_from.the_other_datepicker_id_to = calendar_data_to.dom_id
106
- calendar_data_to.the_other_datepicker_id_from = calendar_data_from.dom_id
107
-
108
- html1 = date_calendar_jquery calendar_data_from
109
-
110
- html2 = date_calendar_jquery calendar_data_to
111
-
112
- %!<div class="date-filter wg-jquery-datepicker">#{html1}<br/>#{html2}</div>!
113
- end
114
-
115
-
116
- def render_filter_internal(params) #:nodoc:
117
- if helper_style == :standard
118
- prepare_for_standard_filter
119
- render_standard_filter_internal(params)
120
- elsif helper_style == :html5
121
- prepare_for_calendar_filter
122
- render_html5_filter_internal(params)
123
- elsif helper_style == :bootstrap
124
- prepare_for_calendar_filter
125
- render_bs_filter_internal(params)
126
- else # :calendar
127
- prepare_for_calendar_filter
128
- render_calendar_filter_internal(params)
129
- end
130
- end
131
-
132
-
133
- def yield_declaration_of_column_filter #:nodoc:
134
- {
135
- templates: @queris_ids.collect{|tuple| tuple[0] },
136
- ids: @queris_ids.collect{|tuple| tuple[1] }
137
- }
138
- end
139
-
140
-
141
- def has_auto_reloading_calendar? #:nodoc:
142
- auto_reload && [:bootstrap, :calendar].include?(helper_style)
143
- end
144
-
145
- end
146
-
147
- class ConditionsGeneratorColumnDatetime < ConditionsGeneratorColumn #:nodoc:
148
-
149
- def generate_conditions(table_alias, opts) #:nodoc:
150
- conditions = [[]]
151
- if opts[:fr]
152
- conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} >= ? "
153
- conditions << opts[:fr]
154
- end
155
-
156
- if opts[:to]
157
- conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} <= ? "
158
- conditions << (opts[:to])
159
- end
160
-
161
- return false if conditions.size == 1
162
-
163
- conditions[0] = conditions[0].join(' and ')
164
- conditions
165
- end
166
- end
167
-
168
- end
169
-
170
-
171
- end