wice_grid 3.0.4 → 3.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/CHANGELOG +24 -2
  2. data/README.rdoc +282 -316
  3. data/RELEASE_NOTES_3.2.pre1.rdoc +82 -0
  4. data/Rakefile +4 -2
  5. data/SAVED_QUERIES_HOWTO.rdoc +18 -31
  6. data/VERSION +1 -1
  7. data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +22 -0
  8. data/lib/generators/wice_grid/install_generator.rb +20 -0
  9. data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +13 -0
  10. data/lib/generators/wice_grid/templates/wice_grid.css.scss +139 -0
  11. data/lib/generators/wice_grid/templates/wice_grid.yml +113 -19
  12. data/lib/generators/wice_grid/templates/wice_grid_config.rb +17 -41
  13. data/lib/grid_output_buffer.rb +3 -2
  14. data/lib/grid_renderer.rb +63 -102
  15. data/lib/helpers/js_calendar_helpers.rb +27 -157
  16. data/lib/helpers/wice_grid_misc_view_helpers.rb +1 -66
  17. data/lib/helpers/wice_grid_serialized_queries_view_helpers.rb +41 -32
  18. data/lib/helpers/wice_grid_view_helpers.rb +138 -274
  19. data/lib/table_column_matrix.rb +11 -11
  20. data/lib/view_columns.rb +41 -350
  21. data/lib/view_columns/action_view_column.rb +45 -0
  22. data/lib/view_columns/column_processor_index.rb +16 -0
  23. data/lib/view_columns/view_column_boolean.rb +23 -0
  24. data/lib/view_columns/view_column_custom_dropdown.rb +81 -0
  25. data/lib/view_columns/view_column_date.rb +17 -0
  26. data/lib/view_columns/view_column_datetime.rb +85 -0
  27. data/lib/view_columns/view_column_float.rb +7 -0
  28. data/lib/view_columns/view_column_integer.rb +38 -0
  29. data/lib/view_columns/view_column_string.rb +63 -0
  30. data/lib/wice_grid.rb +23 -26
  31. data/lib/wice_grid_controller.rb +14 -15
  32. data/lib/wice_grid_misc.rb +3 -3
  33. data/lib/wice_grid_serialized_queries_controller.rb +15 -18
  34. data/lib/wice_grid_spreadsheet.rb +2 -2
  35. data/lib/will_paginate_paginator.rb +31 -0
  36. data/test/readme.txt +1 -0
  37. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/arrow_down.gif +0 -0
  38. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/arrow_up.gif +0 -0
  39. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/calendar_view_month.png +0 -0
  40. data/vendor/assets/images/icons/grid/collapse.gif +0 -0
  41. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/delete.png +0 -0
  42. data/vendor/assets/images/icons/grid/expand.gif +0 -0
  43. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/page_white_excel.png +0 -0
  44. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/page_white_find.png +0 -0
  45. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/table.png +0 -0
  46. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/table_refresh.png +0 -0
  47. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/tick_all.png +0 -0
  48. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/untick_all.png +0 -0
  49. data/vendor/assets/javascripts/wice_grid.js +3 -0
  50. data/vendor/assets/javascripts/wice_grid_init.js.coffee +247 -0
  51. data/vendor/assets/javascripts/wice_grid_processor.js.coffee +128 -0
  52. data/vendor/assets/javascripts/wice_grid_saved_queries_init.js.coffee +103 -0
  53. data/wice_grid.gemspec +44 -50
  54. metadata +68 -94
  55. data/lib/generators/wice_grid/templates/calendarview.css +0 -107
  56. data/lib/generators/wice_grid/templates/calendarview.js +0 -1168
  57. data/lib/generators/wice_grid/templates/icons/expand.png +0 -0
  58. data/lib/generators/wice_grid/templates/wice_grid.css +0 -173
  59. data/lib/generators/wice_grid/templates/wice_grid_jquery.js +0 -162
  60. data/lib/generators/wice_grid/templates/wice_grid_prototype.js +0 -154
  61. data/lib/generators/wice_grid/wice_grid_assets_jquery_generator.rb +0 -32
  62. data/lib/generators/wice_grid/wice_grid_assets_prototype_generator.rb +0 -34
  63. data/lib/js_adaptors/jquery_adaptor.rb +0 -157
  64. data/lib/js_adaptors/js_adaptor.rb +0 -12
  65. data/lib/js_adaptors/prototype_adaptor.rb +0 -179
  66. data/lib/tasks/wice_grid_tasks.rake +0 -28
  67. data/lib/views/create.rjs +0 -13
  68. data/lib/views/create_jq.rjs +0 -31
  69. data/lib/views/delete.rjs +0 -12
  70. data/lib/views/delete_jq.rjs +0 -26
  71. data/test/.gitignore +0 -2
  72. data/test/database.yml +0 -21
  73. data/test/schema.rb +0 -33
  74. data/test/test_helper.rb +0 -89
  75. data/test/views/projects_and_people_grid.html.erb +0 -12
  76. data/test/views/projects_and_people_grid_invalid.html.erb +0 -12
  77. data/test/views/simple_projects_grid.html.erb +0 -9
  78. data/test/wice_grid_core_ext_test.rb +0 -183
  79. data/test/wice_grid_functional_test.rb +0 -68
  80. data/test/wice_grid_misc_test.rb +0 -41
  81. data/test/wice_grid_test.rb +0 -42
  82. data/test/wice_grid_view_helper_test.rb +0 -12
@@ -1,173 +0,0 @@
1
- /* This is just an example, so feel free to re-style it completely */
2
-
3
- .wice_grid {
4
- border: 1px solid #ccc;
5
- border-collapse: collapse;
6
- border-spacing: 0px
7
- }
8
-
9
- .wice_grid .clickable{
10
- cursor: pointer;
11
- }
12
-
13
- .wice_grid th {
14
- background-color: #dfdfdf;
15
- font-weight: bold;
16
- text-shadow: rgb(204, 204, 204) 0px 1px 0px;
17
- height: 2em;
18
- padding: 0 1em;
19
-
20
- }
21
- .wice_grid th a {
22
- color: #000;
23
- }
24
- .wice_grid th a:hover {
25
- color: #333;
26
- }
27
-
28
- .wice_grid tr.wice_grid_title_row th,
29
- .wice_grid tr.wice_grid_filter_row th{
30
- background-color: #dddddd;
31
- vertical-align: top;
32
- }
33
-
34
-
35
-
36
- .wice_grid th.filter_icons, .wice_grid th.hide_show_icon {
37
- text-align: right ;
38
- }
39
-
40
- .wice_grid thead {
41
- border-bottom: 1px solid #666;
42
- }
43
-
44
- .wice_grid tr.odd {
45
- background-color: #fff;
46
- }
47
-
48
- .wice_grid tr.even {
49
- background-color: #eeeeee;
50
- }
51
-
52
- .wice_grid td {
53
- border-bottom: 1px dotted #9999CC;
54
- height: 2.5em;
55
- padding: 0 1em;
56
- }
57
-
58
- .wice_grid .desc, .wice_grid .asc{
59
- padding-right: 18px;
60
- text-decoration:none;
61
- }
62
-
63
- .wice_grid .desc {
64
- background: transparent url(/images/icons/grid/arrow_down.gif) right no-repeat
65
- }
66
- .wice_grid .asc {
67
- background: transparent url(/images/icons/grid/arrow_up.gif) right no-repeat
68
- }
69
-
70
- .wice_grid th div.date-filter {
71
- text-align: left;
72
- }
73
-
74
- .wice_grid tr.even td.active_filter { background-color: #ddddff; }
75
- .wice_grid tr.odd td.active_filter { background-color: #eeeeff; }
76
-
77
- .wice_grid tr.even td.sorted { background-color: #ffffcc; }
78
- .wice_grid tr.odd td.sorted { background-color: #ffffee; }
79
-
80
-
81
- .wice_grid a.date_label {text-decoration: none;}
82
- .wice_grid a.date_label:hover {text-decoration: line-through;}
83
-
84
- .wice_grid td.sel{
85
- text-align: center;
86
- }
87
-
88
- .wice_grid_container .pagination {
89
- float: left;
90
- }
91
-
92
- .wice_grid_container .pagination_status {
93
- font-weight: bold;
94
- float: right;
95
- }
96
-
97
- .wice_grid_container .pagination_status .show_all_link a {
98
- text-decoration: none;
99
- font-size: 80%;
100
- }
101
-
102
- .wice_grid .custom_dropdown_container { position: relative; padding-right: 9px;}
103
- .wice_grid .custom_dropdown_container .toggle_multi_select_icon { position:absolute; top:0; right:0; }
104
-
105
- .wice_grid .text_filter_container { position: relative; padding-right: 13px;}
106
- .wice_grid .text_filter_container .negation_checkbox { position:absolute; top:0; right:0; }
107
-
108
-
109
- /* Saved Queries */
110
-
111
- .wice_grid_container h3 {
112
- font-family: 'Lucida Grande';
113
- font-size: 16px;
114
- font-style: normal;
115
- font-weight: bold;
116
- margin-bottom: 2px;
117
- }
118
-
119
- .wice_grid_query_panel {
120
- width: 400px;
121
- border:1px solid #ddd;
122
- margin-top : 10px;
123
- margin-bottom : 10px;
124
- padding : 5px;
125
- }
126
-
127
-
128
- .wice_grid_query_panel .query_list{
129
- list-style-image: none;
130
- list-style-position: outside;
131
- list-style-type: none;
132
- margin-left : 0px;
133
- }
134
-
135
- .wice_grid_query_panel .query_list li a.query_load_link {
136
- text-decoration: none;
137
- }
138
-
139
-
140
- .wice_grid_query_panel .query_list li a.current {
141
- font-weight: bold;
142
- text-decoration: underline;
143
- }
144
-
145
-
146
- .wice_grid_query_panel .query_list li a.query_load_link:hover {
147
- text-decoration: underline;
148
- }
149
-
150
-
151
- .wice_grid_query_panel .wice_grid_notice {
152
- padding:.4em;
153
- margin-bottom:1em;
154
- border:2px solid #ddd;
155
- background:#FFF6BF;
156
- color:#514721;
157
- border-color:#FFD324;
158
- }
159
-
160
-
161
- .wice_grid_query_panel .errorExplanation {
162
- padding:.4em;
163
- margin-bottom:1em;
164
- border:2px solid #ddd;
165
- background:#FBE3E4;
166
- color:#8a1f11;
167
- border-color:#FBC2C4;
168
- list-style-image: none;
169
- list-style-position: outside;
170
- list-style-type: none;
171
- margin-left : 0px;
172
- }
173
-
@@ -1,162 +0,0 @@
1
- function WiceGridProcessor(name, base_request_for_filter, base_link_for_show_all_records,
2
- link_for_export, parameter_name_for_query_loading, parameter_name_for_focus, environment){
3
-
4
- this.checkIfJsFrameworkIsLoaded = function(){
5
- if (! jQuery){
6
- alert("jQuery not loaded, WiceGrid cannot proceed!")
7
- }
8
- }
9
-
10
- this.checkIfJsFrameworkIsLoaded();
11
- this.name = name;
12
- this.parameter_name_for_query_loading = parameter_name_for_query_loading;
13
- this.parameter_name_for_focus = parameter_name_for_focus;
14
- this.base_request_for_filter = base_request_for_filter;
15
- this.base_link_for_show_all_records = base_link_for_show_all_records;
16
- this.link_for_export = link_for_export;
17
- this.filter_declarations = new Array();
18
- this.environment = environment;
19
-
20
- this.toString = function(){
21
- return "<WiceGridProcessor instance for grid '" + this.name + "'>";
22
- }
23
-
24
-
25
- this.process = function(dom_id_to_focus){
26
- window.location = this.build_url_with_params(dom_id_to_focus);
27
- }
28
-
29
- this.reload_page_for_given_grid_state = function(grid_state){
30
- var request_path = this.grid_state_to_request(grid_state);
31
- window.location = this.append_to_url(this.base_link_for_show_all_records, request_path);
32
- }
33
-
34
- this.load_query = function(query_id){
35
- var request = this.append_to_url(this.build_url_with_params(),
36
- (this.parameter_name_for_query_loading + encodeURIComponent(query_id)));
37
- window.location = request;
38
- }
39
-
40
- this.save_query = function(field_id, query_name, base_path_to_query_controller, grid_state, input_ids){
41
- if (input_ids instanceof Array) {
42
- input_ids.each(function(dom_id){
43
- grid_state.push(['extra[' + dom_id + ']', $('#'+ dom_id)[0].value])
44
- });
45
- }
46
-
47
- var request_path = this.grid_state_to_request(grid_state);
48
-
49
- jQuery.ajax({
50
- url: base_path_to_query_controller,
51
- async: true,
52
- data: request_path + '&query_name=' + encodeURIComponent(query_name),
53
- dataType: 'script',
54
- success: function(){$('#' + field_id).val('')},
55
- type: 'POST'
56
- });
57
- }
58
-
59
- this.grid_state_to_request = function(grid_state){
60
- return jQuery.map(grid_state, function(pair){
61
- return encodeURIComponent(pair[0]) + '=' + encodeURIComponent(pair[1]);
62
- }).join('&');
63
- }
64
-
65
-
66
- this.append_to_url = function(url, str){
67
- var sep;
68
- if (url.indexOf('?') != -1){
69
- if (/[&\?]$/.exec(url)){
70
- sep = '';
71
- }else{
72
- sep = '&';
73
- }
74
- }else{
75
- sep = '?';
76
- }
77
- return url + sep + str;
78
- }
79
-
80
-
81
- this.build_url_with_params = function(dom_id_to_focus){
82
- var results = new Array();
83
- var _this = this;
84
- jQuery.each(this.filter_declarations, function(i, filter_declaration){
85
- param = _this.read_values_and_form_query_string(
86
- filter_declaration.filter_name, filter_declaration.detached,
87
- filter_declaration.templates, filter_declaration.ids);
88
- if (param && param != ''){
89
- results.push(param);
90
- }
91
- });
92
-
93
- var res = this.base_request_for_filter;
94
- if ( results.length != 0){
95
- all_filter_params = results.join('&');
96
- res = this.append_to_url(res, all_filter_params);
97
- }
98
- if (dom_id_to_focus){
99
- res = this.append_to_url(res, this.parameter_name_for_focus + dom_id_to_focus);
100
- }
101
- return res;
102
- }
103
-
104
- this.reset = function(){
105
- window.location = this.base_request_for_filter;
106
- }
107
-
108
- this.export_to_csv = function(){
109
- window.location = this.link_for_export;
110
- }
111
-
112
- this.register = function(func){
113
- this.filter_declarations.push(func);
114
- }
115
-
116
- this.read_values_and_form_query_string = function(filter_name, detached, templates, ids){
117
- var res = new Array();
118
- for(i = 0; i < templates.length; i++){
119
- if($(ids[i]) == null){
120
- if (this.environment == "development"){
121
- message = 'WiceGrid: Error reading state of filter "' + filter_name + '". No DOM element with id "' + ids[i] + '" found.'
122
- if (detached){
123
- message += 'You have declared "' + filter_name +
124
- '" as a detached filter but have not output it anywhere in the template. Read documentation about detached filters.'
125
- }
126
- alert(message);
127
- }
128
- return '';
129
- }
130
- var el = $('#' + ids[i]);
131
- var val;
132
- if (el[0] && el[0].type == 'checkbox'){
133
- if (el[0].checked) val = 1;
134
- } else {
135
- val = el.val();
136
- }
137
- if (val instanceof Array) {
138
- for(j = 0; j < val.length; j++){
139
- if (val[j] && val[j] != "")
140
- res.push(templates[i] + encodeURIComponent(val[j]));
141
- }
142
- } else if (val && val != ''){
143
- res.push(templates[i] + encodeURIComponent(val));
144
- }
145
- }
146
- return res.join('&');
147
- }
148
-
149
- };
150
-
151
- function toggle_multi_select(select_id, link_obj, expand_label, collapse_label) {
152
- var select = $('#' + select_id)[0];
153
- if (select.multiple == true) {
154
- select.multiple = false;
155
- link_obj.title = expand_label;
156
- } else {
157
- select.multiple = true;
158
- link_obj.title = collapse_label;
159
- }
160
- }
161
-
162
- WiceGridProcessor._version = '0.4.3';
@@ -1,154 +0,0 @@
1
- function WiceGridProcessor(name, base_request_for_filter, base_link_for_show_all_records,
2
- link_for_export, parameter_name_for_query_loading, parameter_name_for_focus, environment){
3
-
4
- this.checkIfJsFrameworkIsLoaded = function(){
5
- if (typeof(Prototype) == "undefined"){
6
- alert("Prototype javascript library not loaded, WiceGrid cannot proceed!")
7
- }
8
- }
9
-
10
-
11
- this.checkIfJsFrameworkIsLoaded();
12
- this.name = name;
13
- this.parameter_name_for_query_loading = parameter_name_for_query_loading;
14
- this.parameter_name_for_focus = parameter_name_for_focus;
15
- this.base_request_for_filter = base_request_for_filter;
16
- this.base_link_for_show_all_records = base_link_for_show_all_records;
17
- this.link_for_export = link_for_export;
18
- this.filter_declarations = new Array();
19
- this.environment = environment;
20
-
21
- this.toString = function(){
22
- return "<WiceGridProcessor instance for grid '" + this.name + "'>";
23
- }
24
-
25
-
26
- this.process = function(dom_id_to_focus){
27
- window.location = this.build_url_with_params(dom_id_to_focus);
28
- }
29
-
30
- this.reload_page_for_given_grid_state = function(grid_state){
31
- var request_path = this.grid_state_to_request(grid_state);
32
- window.location = this.append_to_url(this.base_link_for_show_all_records, request_path);
33
- }
34
-
35
- this.load_query = function(query_id){
36
- var request = this.append_to_url(this.build_url_with_params(),
37
- (this.parameter_name_for_query_loading + encodeURIComponent(query_id)));
38
- window.location = request;
39
- }
40
-
41
- this.save_query = function(field_id, query_name, base_path_to_query_controller, grid_state, input_ids){
42
- if (input_ids instanceof Array) {
43
- input_ids.each(function(dom_id){
44
- grid_state.push(['extra[' + dom_id + ']', $F(dom_id)])
45
- });
46
- }
47
-
48
- var request_path = this.grid_state_to_request(grid_state);
49
-
50
- new Ajax.Request(base_path_to_query_controller, {
51
- asynchronous:true,
52
- evalScripts:true,
53
- onSuccess: function(){ $(field_id).value = "" },
54
- parameters: request_path + '&query_name=' + encodeURIComponent(query_name)
55
- })
56
- }
57
-
58
- this.grid_state_to_request = function(grid_state){
59
- return res = grid_state.collect(function(pair){
60
- return encodeURIComponent(pair[0]) + '=' + encodeURIComponent(pair[1]);
61
- }).join('&');
62
- }
63
-
64
-
65
- this.append_to_url = function(url, str){
66
- var sep;
67
- if (url.include('?')){
68
- if (/[&\?]$/.exec(url)){
69
- sep = '';
70
- }else{
71
- sep = '&';
72
- }
73
- }else{
74
- sep = '?';
75
- }
76
- return url + sep + str;
77
- }
78
-
79
-
80
- this.build_url_with_params = function(dom_id_to_focus){
81
- var results = new Array();
82
- this.filter_declarations.each(function(filter_declaration){
83
- param = this.read_values_and_form_query_string(
84
- filter_declaration.filter_name, filter_declaration.detached,
85
- filter_declaration.templates, filter_declaration.ids);
86
- if (param && param != ''){
87
- results.push(param);
88
- }
89
- }.bind(this));
90
- var res = this.base_request_for_filter;
91
- if ( results.length != 0){
92
- all_filter_params = results.join('&');
93
- res = this.append_to_url(res, all_filter_params);
94
- }
95
- if (dom_id_to_focus){
96
- res = this.append_to_url(res, this.parameter_name_for_focus + dom_id_to_focus);
97
- }
98
- return res;
99
- }
100
-
101
- this.reset = function(){
102
- window.location = this.base_request_for_filter;
103
- }
104
-
105
- this.export_to_csv = function(){
106
- window.location = this.link_for_export;
107
- }
108
-
109
-
110
- this.register = function(func){
111
- this.filter_declarations.push(func);
112
- }
113
-
114
- this.read_values_and_form_query_string = function(filter_name, detached, templates, ids){
115
- var res = new Array();
116
- for(i = 0; i < templates.length; i++){
117
- if($(ids[i]) == null){
118
- if (this.environment == "development"){
119
- message = 'WiceGrid: Error reading state of filter "' + filter_name + '". No DOM element with id "' + ids[i] + '" found.'
120
- if (detached){
121
- message += 'You have declared "' + filter_name +
122
- '" as a detached filter but have not output it anywhere in the template. Read documentation about detached filters.'
123
- }
124
- alert(message);
125
- }
126
- return '';
127
- }
128
- var val = $F(ids[i]);
129
- if (val instanceof Array) {
130
- for(j = 0; j < val.length; j++){
131
- if (val[j] && val[j] != "")
132
- res.push(templates[i] + encodeURIComponent(val[j]));
133
- }
134
- } else if (val && ! val.empty()){
135
- res.push(templates[i] + encodeURIComponent(val));
136
- }
137
- }
138
- return res.join('&');
139
- }
140
-
141
- };
142
-
143
- function toggle_multi_select(select_id, link_obj, expand_label, collapse_label) {
144
- var select = $(select_id);
145
- if (select.multiple == true) {
146
- select.multiple = false;
147
- link_obj.title = expand_label;
148
- } else {
149
- select.multiple = true;
150
- link_obj.title = collapse_label;
151
- }
152
- }
153
-
154
- WiceGridProcessor._version = '0.4.3';