wice_grid 3.0.0.pre2 → 3.0.0.pre3

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.
@@ -1,6 +1,6 @@
1
1
  = WiceGrid
2
2
 
3
- Version:: 3.0.0.pre1
3
+ Version:: 3.0.0.pre3
4
4
  Author:: Yuri Leikind
5
5
  Homepage:: http://leikind.org/pages/wicegrid
6
6
  Examples online:: http://grid.leikind.org
@@ -691,7 +691,7 @@ WiceGrid icons are in directory <tt>public/images/icons/grid/</tt>.
691
691
 
692
692
  === Adding rows to the grid
693
693
 
694
- It is possible to add your own handcrafted HTML after and/or before each grid row. This works similar to +row_attributes+, by adding blocks +after_row+ and +before_row+:
694
+ It is possible to add your own handcrafted HTML after and/or before each grid row. This works similar to +row_attributes+, by adding blocks +after_row+, +before_row+, and +last_row+:
695
695
 
696
696
  <%= grid(@tasks_grid) do |g|
697
697
  g.before_row do |task|
@@ -702,12 +702,21 @@ It is possible to add your own handcrafted HTML after and/or before each grid ro
702
702
  nil
703
703
  end
704
704
  end
705
+
706
+ g.last_row do # This row will always be added to the bottom of the grid
707
+ content_tag(:tr,
708
+ content_tag(:td,
709
+ 'Last row',
710
+ :colspan => 10),
711
+ :class => 'last_row')
712
+ end
713
+
705
714
  .......
706
715
  end %>
707
716
 
708
717
  It is up for the developer to return the correct HTML code, or return +nil+ if no row is needed for this record. Naturally, there is only one +before_row+ definition and one +after_row+ definition for a WiceGrid instance.
709
718
 
710
- A real life example might be some enterprisy tables inside a table.
719
+ A real life example might be some enterprisy tables inside a table.
711
720
 
712
721
  === Rendering a grid without records
713
722
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0.pre2
1
+ 3.0.0.pre3
@@ -274,6 +274,135 @@ pt:
274
274
  validates_presence_error: Queira indicar o nome da query que deseja gravar
275
275
  query_deleted_message: A query foi apagada.
276
276
  query_saved_message: A query foi gravada.
277
- # To do: translate
278
- select_all: Select all
279
- deselect_all: Remove selection
277
+ select_all: Selecionar todos
278
+ deselect_all: Remover seleção
279
+
280
+ pt-BR:
281
+ date:
282
+ order:
283
+ - :year
284
+ - :month
285
+ - :day
286
+ wice_grid:
287
+ show_filter_tooltip: Mostrar o filtro
288
+ hide_filter_tooltip: Esconder o filtro
289
+ csv_export_tooltip: Exportar em CSV
290
+ filter_tooltip: Filtrar
291
+ reset_filter_tooltip: Reinicializar
292
+ boolean_filter_true_label: sim
293
+ boolean_filter_false_label: não
294
+ previous_label: « Anterior
295
+ next_label: Próximo »
296
+ date_selector_tooltip_from: De
297
+ date_selector_tooltip_to: a
298
+ negation_checkbox_title: Excluir
299
+ show_all_records_label: Ver todos
300
+ show_all_records_tooltip: Ver todos os registos
301
+ all_queries_warning: Tem certeza que gostaria de visualizar todos os registos?
302
+ switch_back_to_paginated_mode_label: Voltar à lista paginada
303
+ switch_back_to_paginated_mode_tooltip: Voltar à lista por página
304
+ date_string_tooltip: Clique para apagar
305
+ saved_query_panel_title: Filtros gravados
306
+ save_query_button_label: Gravar o estado dos filtros
307
+ saved_query_deletion_confirmation: Tem certeza?
308
+ saved_query_deletion_link_title: Apagar o filtro
309
+ saved_query_link_title: Carregar o filtro
310
+ validates_uniqueness_error: Já existe um filtro com o mesmo nome
311
+ validates_presence_error: Indique o nome do filtro que deseja gravar
312
+ query_deleted_message: O filtro foi apagado.
313
+ query_saved_message: O filtro foi gravado.
314
+ select_all: Selecionar todos
315
+ deselect_all: Remover seleção
316
+
317
+
318
+ sk:
319
+ date:
320
+ order:
321
+ - :year
322
+ - :month
323
+ - :day
324
+ wice_grid:
325
+ show_filter_tooltip: Zobraziť filter
326
+ hide_filter_tooltip: Skryť filter
327
+ csv_export_tooltip: Exportovať do CSV
328
+ filter_tooltip: Filter
329
+ reset_filter_tooltip: Zrušiť filtre
330
+ boolean_filter_true_label: "áno"
331
+ boolean_filter_false_label: "nie"
332
+ previous_label: « Predchádzajúci
333
+ next_label: Následujúci »
334
+ # Title of the icon clicking on which will show the calendar to set the FROM date.
335
+ date_selector_tooltip_from: Dátum od
336
+ # Title of the icon clicking on which will show the calendar to set the TO date.
337
+ date_selector_tooltip_to: Dátum do
338
+ # The title of the checkox to turn on negation
339
+ negation_checkbox_title: Inverzný výber
340
+ # link to switch to show all records
341
+ show_all_records_label: Zobraziť všetko
342
+ # tooltip for the link to switch to show all records
343
+ show_all_records_tooltip: Zobrazí všetky záznamy v databáze
344
+ # Warning message shown when the user wants to switch to all-records mode
345
+ all_queries_warning: Určite chceš zobraziť všetky záznamy v databáze?
346
+ # link to paginated view
347
+ switch_back_to_paginated_mode_label: späť na stránkové zobrazenie
348
+ # tooltip for the link to paginated view
349
+ switch_back_to_paginated_mode_tooltip: Prepnúť do stránkového zobrazenia
350
+ # Title of the date string.
351
+ date_string_tooltip: Kliknutím zmažeš
352
+ saved_query_panel_title: Uložené filtre/výsledky
353
+ save_query_button_label: Uložiť stav filtrov
354
+ saved_query_deletion_confirmation: Si si istý?
355
+ saved_query_deletion_link_title: Vymazať uložený filter
356
+ saved_query_link_title: Nahrať uložený filter
357
+ validates_uniqueness_error: Filter s uvedeným názvom už existuje.
358
+ validates_presence_error: Prosím zadaj názov uloženého filtra.
359
+ query_deleted_message: Uložený filter bol vymazaný.
360
+ query_saved_message: Filter bol uložený.
361
+ select_all: Vyber všetko
362
+ deselect_all: Zrušiť výber
363
+
364
+ cz:
365
+ date:
366
+ order:
367
+ - :year
368
+ - :month
369
+ - :day
370
+ wice_grid:
371
+ show_filter_tooltip: Zobrazit filtr
372
+ hide_filter_tooltip: Skrýt filtr
373
+ csv_export_tooltip: Exportovat do CSV
374
+ filter_tooltip: Filtr
375
+ reset_filter_tooltip: Zrušit filtr
376
+ boolean_filter_true_label: "áno"
377
+ boolean_filter_false_label: "ne"
378
+ previous_label: « Předešlý
379
+ next_label: Následující »
380
+ # Title of the icon clicking on which will show the calendar to set the FROM date.
381
+ date_selector_tooltip_from: Dátum od
382
+ # Title of the icon clicking on which will show the calendar to set the TO date.
383
+ date_selector_tooltip_to: Dátum do
384
+ # The title of the checkox to turn on negation
385
+ negation_checkbox_title: Inverzní výběr
386
+ # link to switch to show all records
387
+ show_all_records_label: Zobrazit všechno
388
+ # tooltip for the link to switch to show all records
389
+ show_all_records_tooltip: Zobrazí všechny záznamy v databáze
390
+ # Warning message shown when the user wants to switch to all-records mode
391
+ all_queries_warning: Určitě chceš zobrazit všechny záznamy v databáze?
392
+ # link to paginated view
393
+ switch_back_to_paginated_mode_label: zpět na stránkové zobrazení
394
+ # tooltip for the link to paginated view
395
+ switch_back_to_paginated_mode_tooltip: Přepnout do stránkového zobrazení
396
+ # Title of the date string.
397
+ date_string_tooltip: Kliknutím zmažeš
398
+ saved_query_panel_title: Uložené filtry
399
+ save_query_button_label: Uložit aktuálni stav filtrů
400
+ saved_query_deletion_confirmation: Seš si jistej?
401
+ saved_query_deletion_link_title: Smazat uloženej filtr
402
+ saved_query_link_title: Použít uloženej filtr
403
+ validates_uniqueness_error: Filtr už existuje.
404
+ validates_presence_error: Prosím zadej název filtru.
405
+ query_deleted_message: Uložený filtr byl smazán.
406
+ query_saved_message: Filtr byl uložen.
407
+ select_all: Vyber všechno
408
+ deselect_all: Zrušit výběr
@@ -67,6 +67,11 @@ if defined?(Wice::Defaults)
67
67
  # A boolean value specifying if a change in a filter triggers reloading of the grid.
68
68
  Wice::Defaults::AUTO_RELOAD = false
69
69
 
70
+ # If set to an integer (including 0), in integer and float filters the second field will be
71
+ # dynamically updated when the first field is updated
72
+ Wice::Defaults::SECOND_RANGE_VALUE_FOLLOWING_THE_FIRST = false
73
+ # Wice::Defaults::SECOND_RANGE_VALUE_FOLLOWING_THE_FIRST = 1
74
+
70
75
 
71
76
  # SQL operator used for matching strings in string filters.
72
77
  Wice::Defaults::STRING_MATCHING_OPERATOR = 'LIKE'
@@ -12,6 +12,7 @@ module Wice
12
12
  attr_reader :after_row_handler
13
13
  attr_reader :before_row_handler
14
14
  attr_reader :blank_slate_handler
15
+ attr_reader :last_row_handler
15
16
  attr_reader :grid
16
17
  attr_accessor :erb_mode
17
18
 
@@ -407,6 +408,11 @@ module Wice
407
408
  @before_row_handler = block
408
409
  end
409
410
 
411
+ # Can be used to add HTML code (calculation results, for example) after all rows.
412
+ # Nothing is added if the block return +false+ or +nil+.
413
+ def last_row(&block)
414
+ @last_row_handler = block
415
+ end
410
416
  # The output of the block submitted to +blank_slate+ is rendered instead of the whole grid if no filters are active
411
417
  # and there are no records to render.
412
418
  # In addition to the block style two other variants are accepted:
@@ -520,6 +526,10 @@ module Wice
520
526
  contains_auto_reloading_elements(:has_auto_reloading_calendar?)
521
527
  end
522
528
 
529
+ def contains_range_filters
530
+ filter_columns(:in_html).detect{|column| column.filter_shown? && column.is_a?(ViewColumnInteger)}
531
+ end
532
+
523
533
  protected
524
534
 
525
535
  def contains_auto_reloading_elements(what) #:nodoc:
@@ -532,4 +542,4 @@ module Wice
532
542
  end
533
543
 
534
544
  end
535
- end
545
+ end
@@ -4,9 +4,9 @@ module Wice #:nodoc:
4
4
  # Jquery
5
5
 
6
6
  def date_calendar_jquery(initial_date, view, opts = {}, html_opts = {}) #:nodoc:
7
- date_format = Wice::Defaults::DATE_FORMAT
7
+ date_format = Wice::ConfigurationProvider.value_for(:DATE_FORMAT)
8
8
 
9
- options, name, date_string, dom_id, datepicker_placeholder_id, date_span_id =
9
+ options, name, date_string, dom_id, datepicker_placeholder_id, date_span_id, close_calendar_event_name =
10
10
  prepare_data_for_calendar(opts, date_format, initial_date)
11
11
 
12
12
  remove_date_function = %! $('##{date_span_id}').html(''); $('##{dom_id}')[0].value = ''; !
@@ -23,19 +23,19 @@ module Wice #:nodoc:
23
23
 
24
24
  html = "<span id=\"#{datepicker_placeholder_id}\">#{date_picker}</span>"
25
25
 
26
- javascript = calendar_constructor_jquery(dom_id, view, Wice::Defaults::DATE_FORMAT_JQUERY,
27
- date_span_id, opts[:fire_event], html_opts[:title], datepicker_placeholder_id)
26
+ javascript = calendar_constructor_jquery(dom_id, view, Wice::ConfigurationProvider.value_for(:DATE_FORMAT_JQUERY),
27
+ date_span_id, opts[:fire_event], html_opts[:title], datepicker_placeholder_id, close_calendar_event_name)
28
28
 
29
29
  [html, javascript]
30
30
  end
31
31
 
32
32
  # Prototype
33
33
  def date_calendar_prototype(initial_date, view, opts = {}, html_opts = {}) #:nodoc:
34
- select_date_datetime_common_prototype(initial_date, view, opts, html_opts, false, Wice::Defaults::DATE_FORMAT)
34
+ select_date_datetime_common_prototype(initial_date, view, opts, html_opts, false, Wice::ConfigurationProvider.value_for(:DATE_FORMAT))
35
35
  end
36
36
 
37
37
  def datetime_calendar_prototype(initial_date, view, opts = {}, html_opts = {}) #:nodoc:
38
- select_date_datetime_common_prototype(initial_date, view, opts, html_opts, true, Wice::Defaults::DATETIME_FORMAT)
38
+ select_date_datetime_common_prototype(initial_date, view, opts, html_opts, true, Wice::ConfigurationProvider.value_for(:DATETIME_FORMAT))
39
39
  end
40
40
 
41
41
  protected
@@ -50,19 +50,20 @@ module Wice #:nodoc:
50
50
  dom_id = options[:id] || name.gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
51
51
  datepicker_placeholder_id = dom_id + '_date_placeholder'
52
52
  date_span_id = dom_id + '_date_view'
53
-
54
- return options, name, date_string, dom_id, datepicker_placeholder_id, date_span_id
53
+ close_calendar_event_name = "wg:calendarChanged_#{opts[:grid_name]}"
54
+ return options, name, date_string, dom_id, datepicker_placeholder_id, date_span_id, close_calendar_event_name
55
55
  end
56
56
 
57
57
  # jquery
58
58
 
59
- def calendar_constructor_jquery(dom_id, view, date_format, date_span_id, fireEvent, title, datepicker_placeholder_id) #:nodoc:
59
+ def calendar_constructor_jquery(dom_id, view, date_format, date_span_id, fireEvent, title,
60
+ datepicker_placeholder_id, close_calendar_event_name)
60
61
 
61
62
  javascript = %| $( "##{dom_id}" ).datepicker({\n|
62
63
  javascript << %| firstDay: 1,\n|
63
64
  javascript << %| showOn: "button",\n|
64
65
  javascript << %| dateFormat: "#{date_format}",\n|
65
- javascript << %| buttonImage: "#{::Wice::Defaults::CALENDAR_ICON}",\n|
66
+ javascript << %| buttonImage: "#{Wice::ConfigurationProvider.value_for(:CALENDAR_ICON)}",\n|
66
67
  javascript << %| buttonImageOnly: true,\n|
67
68
  javascript << %| buttonText: "#{title}",\n|
68
69
  javascript << %| changeMonth: true,\n|
@@ -70,7 +71,7 @@ module Wice #:nodoc:
70
71
  javascript << %| onSelect: function(dateText, inst) {\n|
71
72
  javascript << %| $("##{date_span_id}").html(dateText);\n|
72
73
  if fireEvent
73
- javascript << %| $("##{dom_id}").trigger('wg:calendarChanged');\n|
74
+ javascript << %| $("##{dom_id}").trigger('#{close_calendar_event_name}');\n|
74
75
  end
75
76
  javascript << %| }\n|
76
77
  javascript << %| });\n|
@@ -116,7 +117,7 @@ module Wice #:nodoc:
116
117
  # prortotype
117
118
 
118
119
  def calendar_constructor_prototype(popup_trigger_icon_id, view, dom_id, date_format,
119
- date_span_id, with_time, fireEvent) #:nodoc:
120
+ date_span_id, with_time, fireEvent, close_calendar_event_name)
120
121
  javascript = ''
121
122
 
122
123
  unless view.respond_to? :wg_calendar_lang_set
@@ -132,11 +133,11 @@ module Wice #:nodoc:
132
133
  javascript << %| popupTriggerElement : "#{popup_trigger_icon_id}",\n |
133
134
  javascript << %| initialDate : $('#{dom_id}').value,\n |
134
135
  if fireEvent
135
- javascript << %| onHideCallback : function(){Event.fire($(#{dom_id}), 'wg:calendarChanged')},\n |
136
+ javascript << %| onHideCallback : function(){Event.fire($(#{dom_id}), '#{close_calendar_event_name}')},\n |
136
137
  end
137
138
  javascript << %| dateFormat : "#{date_format}",\n|
138
- unless Wice::Defaults::POPUP_PLACEMENT_STRATEGY == :trigger
139
- javascript << %| popupPositioningStrategy : "#{Wice::Defaults::POPUP_PLACEMENT_STRATEGY}",\n|
139
+ unless Wice::ConfigurationProvider.value_for(:POPUP_PLACEMENT_STRATEGY) == :trigger
140
+ javascript << %| popupPositioningStrategy : "#{Wice::ConfigurationProvider.value_for(:POPUP_PLACEMENT_STRATEGY)}",\n|
140
141
  end
141
142
  if with_time
142
143
  javascript << %| withTime : true,\n|
@@ -149,14 +150,14 @@ module Wice #:nodoc:
149
150
 
150
151
  def select_date_datetime_common_prototype(initial_date, view, opts, html_opts, with_time, date_format) #:nodoc:
151
152
 
152
- options, name, date_string, dom_id, datepicker_placeholder_id, date_span_id =
153
+ options, name, date_string, dom_id, datepicker_placeholder_id, date_span_id, close_calendar_event_name =
153
154
  prepare_data_for_calendar(opts, date_format, initial_date)
154
155
 
155
156
  popup_trigger_icon_id = dom_id + '_trigger'
156
157
 
157
158
  function = %! $('#{date_span_id}').innerHTML = ''; $('#{dom_id}').value = ''; !
158
159
  if opts[:fire_event]
159
- function += "Event.fire($(#{dom_id}), 'wg:calendarChanged')"
160
+ function += "Event.fire($(#{dom_id}), '#{close_calendar_event_name}')"
160
161
  end
161
162
 
162
163
  date_picker = image_tag(Defaults::CALENDAR_ICON,
@@ -174,7 +175,7 @@ module Wice #:nodoc:
174
175
 
175
176
  html = "<span id=\"#{datepicker_placeholder_id}\">#{date_picker}</span>"
176
177
 
177
- javascript = calendar_constructor_prototype(popup_trigger_icon_id, view, dom_id, date_format, date_span_id, with_time, opts[:fire_event])
178
+ javascript = calendar_constructor_prototype(popup_trigger_icon_id, view, dom_id, date_format, date_span_id, with_time, opts[:fire_event], close_calendar_event_name)
178
179
 
179
180
  [html, javascript]
180
181
  end
@@ -13,7 +13,7 @@ module Wice
13
13
  end
14
14
 
15
15
  grid.get_state_as_parameter_value_pairs(true).collect{|param_name, value|
16
- hidden_field_tag(param_name, value)
16
+ hidden_field_tag(param_name, value, :id => "hidden-#{param_name.gsub(/[\[\]]/, '-')}")
17
17
  }.join("\n").html_safe_if_necessary
18
18
  end
19
19
 
@@ -475,6 +475,14 @@ module Wice
475
475
  content << after_row_output if after_row_output
476
476
  end
477
477
 
478
+ last_row_output = if rendering.last_row_handler
479
+ call_block_as_erb_or_ruby(rendering, rendering.last_row_handler, nil)
480
+ else
481
+ nil
482
+ end
483
+
484
+ content << last_row_output if last_row_output
485
+
478
486
  content << '</tbody></table></div>'
479
487
 
480
488
  base_link_for_filter, base_link_for_show_all_records = rendering.base_link_for_filter(controller, options[:extra_request_parameters])
@@ -538,6 +546,11 @@ module Wice
538
546
  cached_javascript << JsAdaptor.focus_element(rendering.element_to_focus)
539
547
  end
540
548
 
549
+ if Wice::ConfigurationProvider.value_for(:SECOND_RANGE_VALUE_FOLLOWING_THE_FIRST) && rendering.contains_range_filters
550
+ cached_javascript << JsAdaptor.update_ranges(grid.name)
551
+ end
552
+
553
+
541
554
  content << javascript_tag(
542
555
  JsAdaptor.dom_loaded +
543
556
  %/ #{prototype_and_js_version_check}\n/ +
@@ -778,4 +791,4 @@ module Wice
778
791
  end
779
792
 
780
793
  end
781
- end
794
+ end
@@ -42,7 +42,7 @@ module Wice::JsAdaptor #:nodoc:
42
42
  end
43
43
 
44
44
  def enter_key_event_registration(grid_name) #:nodoc:
45
- %! $('div##{grid_name}.wice_grid_container .wice_grid_filter_row input[type=text]').keydown(function(event){\n! +
45
+ %! $('div##{grid_name}.wice_grid_container .wice_grid_filter_row input[type=text], .#{grid_name}_detached_filter input[type=text]').keydown(function(event){\n! +
46
46
  %! if (event.keyCode == 13) {#{grid_name}.process()}\n! +
47
47
  %! });\n!
48
48
  end
@@ -73,7 +73,7 @@ module Wice::JsAdaptor #:nodoc:
73
73
 
74
74
 
75
75
  def auto_reloading_calendar_event_initialization(grid_name) #:nodoc:
76
- %! $(document).bind('wg:calendarChanged', function(event){\n! +
76
+ %! $(document).bind('wg:calendarChanged_#{grid_name}', function(event){\n! +
77
77
  %! #{grid_name}.process()\n! +
78
78
  %! });\n!
79
79
  end
@@ -139,6 +139,18 @@ module Wice::JsAdaptor #:nodoc:
139
139
  %! }\n!
140
140
  end
141
141
 
142
+
143
+ def update_ranges(grid_name)
144
+ %! $('div##{grid_name}.wice_grid_container .range-start, .#{grid_name}_detached_filter .range-start').keyup(function(e, a){\n! +
145
+ %! var endRange = $(e.target).next();\n! +
146
+ %! if (e.target.value){\n! +
147
+ %! endRange.val(#{Wice::ConfigurationProvider.value_for(:SECOND_RANGE_VALUE_FOLLOWING_THE_FIRST)} + parseInt(e.target.value));\n! +
148
+ %! }else{\n! +
149
+ %! endRange.val('');\n! +
150
+ %! }\n! +
151
+ %! });\n!
152
+ end
153
+
142
154
  end
143
155
 
144
156
  end
@@ -3,7 +3,7 @@
3
3
  module Wice::JsAdaptor #:nodoc:
4
4
  mattr_accessor :calendar_module
5
5
  def self.init #:nodoc:
6
- if Wice::Defaults::JS_FRAMEWORK == :prototype
6
+ if Wice::ConfigurationProvider.value_for(:JS_FRAMEWORK) == :prototype
7
7
  include Wice::JsAdaptor::Prototype
8
8
  else
9
9
  include Wice::JsAdaptor::Jquery
@@ -45,7 +45,7 @@ module Wice::JsAdaptor #:nodoc:
45
45
  end
46
46
 
47
47
  def enter_key_event_registration(grid_name) #:nodoc:
48
- %! $$('div##{grid_name}.wice_grid_container .wice_grid_filter_row input[type=text]').each(function(e){\n! +
48
+ %! $$('div##{grid_name}.wice_grid_container .wice_grid_filter_row input[type=text], .#{grid_name}_detached_filter input[type=text]').each(function(e){\n! +
49
49
  %! e.observe('keydown', function(event){\n! +
50
50
  %! if (event.keyCode == 13) {#{grid_name}.process()}\n! +
51
51
  %! })\n! +
@@ -86,7 +86,7 @@ module Wice::JsAdaptor #:nodoc:
86
86
 
87
87
 
88
88
  def auto_reloading_calendar_event_initialization(grid_name) #:nodoc:
89
- %! document.observe('wg:calendarChanged', function(event){\n! +
89
+ %! document.observe('wg:calendarChanged_#{grid_name}', function(event){\n! +
90
90
  %! #{grid_name}.process()\n! +
91
91
  %! });\n!
92
92
  end
@@ -161,8 +161,19 @@ module Wice::JsAdaptor #:nodoc:
161
161
  %! elToFocus.value = elToFocus.value;\n! # this will just place the cursor at the end of the text input
162
162
  end
163
163
 
164
- end
164
+ def update_ranges(grid_name)
165
+ %/ $$('div##{grid_name}.wice_grid_container .range-start, .#{grid_name}_detached_filter .range-start').each(function(e){\n/+
166
+ %/ e.observe('keyup', function(){\n/+
167
+ %! var endRange = e.next();\n! +
168
+ %! if (e.value){\n! +
169
+ %/ endRange.value = #{Wice::ConfigurationProvider.value_for(:SECOND_RANGE_VALUE_FOLLOWING_THE_FIRST)} + parseInt(e.value);\n/ +
170
+ %/ }else{\n/ +
171
+ %/ endRange.value = '';\n/ +
172
+ %/ }\n/ +
173
+ %/ })\n/+
174
+ %/ });\n/
175
+ end
165
176
 
177
+ end
166
178
  end
167
-
168
179
  end
@@ -203,12 +203,12 @@ module Wice
203
203
  @query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(:fr => '')
204
204
  @query2, _, parameter_name2, @dom_id2 = form_parameter_name_id_and_query(:to => '')
205
205
 
206
- opts1 = {:size => 3, :id => @dom_id}
207
- opts2 = {:size => 3, :id => @dom_id2}
206
+ opts1 = {:size => 3, :id => @dom_id, :class => 'range-start'}
207
+ opts2 = {:size => 3, :id => @dom_id2, :class => 'range-end'}
208
208
 
209
209
  if auto_reload
210
- opts1[:class] = ' auto_reload'
211
- opts2[:class] = ' auto_reload'
210
+ opts1[:class] += ' auto_reload'
211
+ opts2[:class] += ' auto_reload'
212
212
  end
213
213
 
214
214
  text_field_tag(parameter_name, params[:fr], opts1) + text_field_tag(parameter_name2, params[:to], opts2)
@@ -356,10 +356,10 @@ module Wice
356
356
 
357
357
  def render_calendar_filter_internal(params) #:nodoc:
358
358
  html1, js1 = datetime_calendar_prototype(params[:fr], @view,
359
- {:include_blank => true, :prefix => @name1, :id => @dom_id, :fire_event => auto_reload},
359
+ {:include_blank => true, :prefix => @name1, :id => @dom_id, :fire_event => auto_reload, :grid_name => self.grid.name},
360
360
  :title => WiceGridNlMessageProvider.get_message(:DATE_SELECTOR_TOOLTIP_FROM))
361
361
  html2, js2 = datetime_calendar_prototype(params[:to], @view,
362
- {:include_blank => true, :prefix => @name2, :id => @dom_id2, :fire_event => auto_reload},
362
+ {:include_blank => true, :prefix => @name2, :id => @dom_id2, :fire_event => auto_reload, :grid_name => self.grid.name},
363
363
  :title => WiceGridNlMessageProvider.get_message(:DATE_SELECTOR_TOOLTIP_TO))
364
364
  [%!<div class="date-filter">#{html1}<br/>#{html2}</div>!, js1 + js2]
365
365
  end
@@ -401,17 +401,17 @@ module Wice
401
401
 
402
402
  def render_calendar_filter_internal(params) #:nodoc:
403
403
 
404
- calendar_helper_method = if Wice::Defaults::JS_FRAMEWORK == :prototype
404
+ calendar_helper_method = if Wice::ConfigurationProvider.value_for(:JS_FRAMEWORK) == :prototype
405
405
  :date_calendar_prototype
406
406
  else
407
407
  :date_calendar_jquery
408
408
  end
409
409
 
410
410
  html1, js1 = send(calendar_helper_method, params[:fr], @view,
411
- {:include_blank => true, :prefix => @name1, :fire_event => auto_reload},
411
+ {:include_blank => true, :prefix => @name1, :fire_event => auto_reload, :grid_name => self.grid.name},
412
412
  :title => WiceGridNlMessageProvider.get_message(:DATE_SELECTOR_TOOLTIP_FROM))
413
413
  html2, js2 = send(calendar_helper_method, params[:to], @view,
414
- {:include_blank => true, :prefix => @name2, :fire_event => auto_reload},
414
+ {:include_blank => true, :prefix => @name2, :fire_event => auto_reload, :grid_name => self.grid.name},
415
415
  :title => WiceGridNlMessageProvider.get_message(:DATE_SELECTOR_TOOLTIP_TO))
416
416
 
417
417
  [%!<div class="date-filter">#{html1}<br/>#{html2}</div>!, js1 + js2]
@@ -447,8 +447,8 @@ module Wice
447
447
 
448
448
  '<div class="text_filter_container">' +
449
449
  text_field_tag(parameter_name, params[:v], :size => 8, :id => @dom_id, :class => css_class) +
450
- if defined?(::Wice::Defaults::NEGATION_CHECKBOX_LABEL) && ! ::Wice::Defaults::NEGATION_CHECKBOX_LABEL.blank?
451
- ::Wice::Defaults::NEGATION_CHECKBOX_LABEL
450
+ if defined?(Wice::Defaults::NEGATION_CHECKBOX_LABEL) && ! Wice::ConfigurationProvider.value_for(:NEGATION_CHECKBOX_LABEL).blank?
451
+ Wice::ConfigurationProvider.value_for(:NEGATION_CHECKBOX_LABEL)
452
452
  else
453
453
  ''
454
454
  end +
@@ -485,7 +485,11 @@ module Wice
485
485
  end
486
486
 
487
487
  if custom_order.blank?
488
- ActiveRecord::Base.connection.quote_table_name(fully_qualified_column_name.strip)
488
+ if ActiveRecord::ConnectionAdapters.const_defined?(:SQLite3Adapter) && ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::SQLite3Adapter)
489
+ fully_qualified_column_name.strip.split('.').map{|chunk| ActiveRecord::Base.connection.quote_table_name(chunk)}.join('.')
490
+ else
491
+ ActiveRecord::Base.connection.quote_table_name(fully_qualified_column_name.strip)
492
+ end
489
493
  else
490
494
  if custom_order.is_a? String
491
495
  custom_order.gsub(/\?/, fully_qualified_column_name)
@@ -619,9 +623,9 @@ module Wice
619
623
  [:fr, :to].each do |sym|
620
624
  if @request_params[sym]
621
625
  if @request_params[sym].is_a?(String)
622
- @request_params[sym] = Wice::Defaults::DATETIME_PARSER.call(@request_params[sym])
626
+ @request_params[sym] = Wice::ConfigurationProvider.value_for(:DATETIME_PARSER).call(@request_params[sym])
623
627
  elsif @request_params[sym].is_a?(Hash)
624
- @request_params[sym] = ::Wice::GridTools.params_2_datetime(@request_params[sym])
628
+ @request_params[sym] = Wice::GridTools.params_2_datetime(@request_params[sym])
625
629
  end
626
630
  end
627
631
  end
@@ -635,7 +639,7 @@ module Wice
635
639
  [:fr, :to].each do |sym|
636
640
  if @request_params[sym]
637
641
  if @request_params[sym].is_a?(String)
638
- @request_params[sym] = Wice::Defaults::DATE_PARSER.call(@request_params[sym])
642
+ @request_params[sym] = Wice::ConfigurationProvider.value_for(:DATE_PARSER).call(@request_params[sym])
639
643
  elsif @request_params[sym].is_a?(Hash)
640
644
  @request_params[sym] = ::Wice::GridTools.params_2_date(@request_params[sym])
641
645
  end
@@ -20,7 +20,7 @@ module Wice
20
20
  # Retrieves and constantizes (if needed ) the Query Store model
21
21
  def get_query_store_model #:nodoc:
22
22
 
23
- query_store_model = ::Wice::Defaults::QUERY_STORE_MODEL
23
+ query_store_model = Wice::ConfigurationProvider.value_for(:QUERY_STORE_MODEL)
24
24
  query_store_model = query_store_model.constantize if query_store_model.is_a? String
25
25
  raise ::Wice::WiceGridArgumentError.new("Defaults::QUERY_STORE_MODEL must be an ActiveRecord class or a string which can be constantized to an ActiveRecord class") unless query_store_model.kind_of? Class
26
26
  validate_query_model(query_store_model) unless @@model_validated
@@ -28,11 +28,11 @@ module Wice
28
28
  end
29
29
 
30
30
  def get_string_matching_operators(model) #:nodoc:
31
- if defined?(Wice::Defaults::STRING_MATCHING_OPERATORS) && Wice::Defaults::STRING_MATCHING_OPERATORS.is_a?(Hash) &&
32
- str_matching_operator = Wice::Defaults::STRING_MATCHING_OPERATORS[model.connection.class.to_s]
31
+ if defined?(Wice::Defaults::STRING_MATCHING_OPERATORS) && Wice::ConfigurationProvider.value_for(:STRING_MATCHING_OPERATORS).is_a?(Hash) &&
32
+ str_matching_operator = Wice::ConfigurationProvider.value_for(:STRING_MATCHING_OPERATORS)[model.connection.class.to_s]
33
33
  str_matching_operator
34
34
  else
35
- Wice::Defaults::STRING_MATCHING_OPERATOR
35
+ Wice::ConfigurationProvider.value_for(:STRING_MATCHING_OPERATOR)
36
36
  end
37
37
  end
38
38
 
@@ -81,6 +81,20 @@ module Wice
81
81
  end
82
82
  end
83
83
 
84
+ module ConfigurationProvider #:nodoc:
85
+ class << self
86
+
87
+ def value_for(key) #:nodoc:
88
+ if Wice::Defaults.const_defined?(key)
89
+ Wice::Defaults.const_get(key)
90
+ else
91
+ raise WiceGridException.new("Could not find constant #{key} in the configuration file! Please run the generator command to update the configuration file:\n rails g wice_grid:wice_grid_assets_jquery\nor rails g wice_grid:wice_grid_assets_prototype\ndepending on your JS framework")
92
+ end
93
+ end
94
+
95
+ end
96
+ end
97
+
84
98
  module Defaults #:nodoc:
85
99
  end
86
100
 
@@ -33,7 +33,7 @@ module Wice
33
33
  @error_messages = sq.errors.full_raw_messages.join(' ')
34
34
  end
35
35
  end
36
- template_name = if Wice::Defaults::JS_FRAMEWORK == :prototype
36
+ template_name = if Wice::ConfigurationProvider.value_for(:JS_FRAMEWORK) == :prototype
37
37
  'delete'
38
38
  else
39
39
  'delete_jq'
@@ -60,7 +60,7 @@ module Wice
60
60
  else
61
61
  @error_messages = @saved_query.errors.map{ |_, msg| msg }.join(' ')
62
62
  end
63
- template_name = if Wice::Defaults::JS_FRAMEWORK == :prototype
63
+ template_name = if Wice::ConfigurationProvider.value_for(:JS_FRAMEWORK) == :prototype
64
64
  'create'
65
65
  else
66
66
  'create_jq'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wice_grid}
8
- s.version = "3.0.0.pre2"
8
+ s.version = "3.0.0.pre3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yuri Leikind"]
12
- s.date = %q{2010-12-28}
12
+ s.date = %q{2011-02-18}
13
13
  s.description = %q{A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters }
14
14
  s.email = %q{yuri.leikind@gmail.com}
15
15
  s.extra_rdoc_files = [
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
- hash: -1876988207
4
+ hash: -1876988210
5
5
  prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
- - pre2
11
- version: 3.0.0.pre2
10
+ - pre3
11
+ version: 3.0.0.pre3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Yuri Leikind
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-28 00:00:00 +01:00
19
+ date: 2011-02-18 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency