it-logica-application-backbone 1.0.26 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.26
1
+ 1.0.27
@@ -16,13 +16,13 @@ class JstreeMethods
16
16
  ############### private ##########3
17
17
 
18
18
  @show: (element) ->
19
- element.show()
19
+ element.show("fast")
20
20
  element.parent("li").removeClass("jstree-closed")
21
21
  element.parent("li").addClass("jstree-open")
22
22
  element.parent("li").children("button").html("-")
23
23
 
24
24
  @hide: (element) ->
25
- element.hide()
25
+ element.hide("fast")
26
26
  element.parent("li").removeClass("jstree-open")
27
27
  element.parent("li").addClass("jstree-closed")
28
28
  element.parent("li").children("button").html("+")
@@ -26,36 +26,47 @@ class TableBuilder
26
26
  functions_present = TableBuilder.obj.row? && TableBuilder.obj.row.functions?
27
27
 
28
28
  # code for sumarizes of the page (paginated)
29
- TableBuilder.html += '<tr class="summarize_page">'
29
+ summarize_page_present = false
30
+ summarize_page = ""
31
+ summarize_page += '<tr class="summarize_page">'
30
32
  # todo make sure functions collumn got skipped when placement is different, eg. on the end
31
- TableBuilder.html += '<td class="summarize"></td>' if functions_present
32
- TableBuilder.html += '<td class="summarize"></td>' if TableBuilder.obj.checkboxes?
33
+ summarize_page += '<td class="summarize"></td>' if functions_present
34
+ summarize_page += '<td class="summarize"></td>' if TableBuilder.obj.checkboxes?
33
35
  for col in TableBuilder.obj.columns
34
36
  do (col) ->
35
- TableBuilder.html += '<td class="summarize">'
37
+ summarize_page += '<td class="summarize">'
36
38
  if col.summarize_page? || col.summarize_page_value?
37
- TableBuilder.html += '<div class="summarize_page">'
38
- TableBuilder.html += if col.summarize_page_label? then col.summarize_page_label else '<span class="label">Celkem na stránce: </span>'
39
- TableBuilder.html += if col.summarize_page_value? then col.summarize_page_value else 0
40
- TableBuilder.html += '</div>'
39
+ summarize_page_present = true
40
+ summarize_page += '<div class="summarize_page">'
41
+ summarize_page += if col.summarize_page_label? then col.summarize_page_label else '<span class="label">Celkem na stránce: </span>'
42
+ summarize_page += if col.summarize_page_value? then col.summarize_page_value else 0
43
+ summarize_page += '</div>'
44
+
45
+ summarize_page += '</td>'
46
+ summarize_page += '</tr>'
41
47
 
42
- TableBuilder.html += '</td>'
43
- TableBuilder.html += '</tr>'
48
+
49
+ TableBuilder.html += summarize_page if summarize_page_present
44
50
 
45
51
  # code for sumarizes of the all filtered data (paginated is not used)
46
- TableBuilder.html += '<tr class="summarize_all">'
47
- TableBuilder.html += '<td class="summarize"></td>' if functions_present
48
- TableBuilder.html += '<td class="summarize"></td>' if TableBuilder.obj.checkboxes?
52
+ summarize_all_present = false
53
+ summarize_all = ""
54
+ summarize_all += '<tr class="summarize_all">'
55
+ summarize_all += '<td class="summarize"></td>' if functions_present
56
+ summarize_all += '<td class="summarize"></td>' if TableBuilder.obj.checkboxes?
49
57
  for col in TableBuilder.obj.columns
50
58
  do (col) ->
51
- TableBuilder.html += '<td class="summarize">'
59
+ summarize_all += '<td class="summarize">'
52
60
  if col.summarize_all? || col.summarize_all_value?
53
- TableBuilder.html += '<div class="summarize_all">'
54
- TableBuilder.html += if col.summarize_all_label? then col.summarize_all_label else '<span class="label">Celkem: </span>'
55
- TableBuilder.html += if col.summarize_all_value? then col.summarize_all_value else 0
56
- TableBuilder.html += '</div>'
57
- TableBuilder.html += '</td>'
58
- TableBuilder.html += '</tr>'
61
+ summarize_all_present = true
62
+ summarize_all += '<div class="summarize_all">'
63
+ summarize_all += if col.summarize_all_label? then col.summarize_all_label else '<span class="label">Celkem: </span>'
64
+ summarize_all += if col.summarize_all_value? then col.summarize_all_value else 0
65
+ summarize_all += '</div>'
66
+ summarize_all += '</td>'
67
+ summarize_all += '</tr>'
68
+
69
+ TableBuilder.html += summarize_all if summarize_all_present
59
70
 
60
71
  @add_row_checkboxes: (row) ->
61
72
  if TableBuilder.obj.checkboxes?
@@ -1,24 +1,64 @@
1
1
  <%= yield :above_table_form %>
2
2
 
3
3
  <%= render :partial => "/helpers/build_table_text_description", :locals => {:settings => settings} %>
4
+ <% if settings[:display_method].blank? %>
5
+ <% if settings[:checkboxes] %>
6
+ <script type="text/javascript">
7
+ function submit_in_new_window(form_id) {
8
+ var form_original = $("#" + form_id);
9
+ var form = form_original.clone(true, true);
10
+ form.attr("data-remote", "false");
11
+ form.attr("target", "_blank");
12
+
13
+ //Create an input type dynamically.
14
+ var element = document.createElement("input");
15
+
16
+ //Assign different attributes to the element.
17
+ element.setAttribute("type", "hidden");
18
+ element.setAttribute("value", "print_by_checkboxes");
19
+ element.setAttribute("name", "___display_method___");
20
+
21
+
22
+ //Append the element in form
23
+ form.append(element);
24
+ form.submit();
25
+ }
26
+
27
+ </script>
28
+ <a href="#" class="btn" onclick="submit_in_new_window('<%= settings[:form_id] %>'); return false;">Tisk</a>
29
+ <% end %>
30
+ <% end %>
4
31
 
5
32
  <%= form_tag settings[:filter_path], :html => {:'data-type' => 'html'}, :method => 'POST', :class => 'well dataGrid', :remote => true, :id => settings[:form_id] do |f| %>
6
- <% if content_for?(:table_form) %>
7
- <%= yield :table_form %>
33
+ <% if settings[:display_method].blank? %>
34
+ <% if content_for?(:table_form) %>
35
+ <%= yield :table_form %>
36
+ <% end %>
8
37
  <% end %>
38
+
9
39
  <fieldset>
10
40
  <%= render :partial => "/helpers/build_table_filter", :locals => {:settings => settings} %>
11
- <% unless settings[:per_page].blank? %>
41
+
42
+ <% if settings[:display_method].blank? %>
43
+ <% unless settings[:per_page].blank? %>
12
44
  <span class="select_for_per_page" style="float: right">Zobrazit na stránku: <%= select_tag("per_page_chosen", options_for_select(settings[:per_page], settings[:params]['per_page'].to_i),
13
- :onchange => "form_submit_watcher('#{settings[:form_id]}')",
14
- :class => "") %></span>
45
+ :onchange => "form_submit_watcher('#{settings[:form_id]}')",
46
+ :class => "") %></span>
47
+ <% end %>
48
+
49
+
50
+
51
+ <div class="<%= settings[:form_id] + '_ajax_pager' %>">
52
+ <%= render :partial => 'helpers/build_table_pager', :locals => {:settings => settings} %>
53
+ </div>
15
54
  <% end %>
16
- <div class="<%= settings[:form_id] + '_ajax_pager' %>">
17
- <%= render :partial => 'helpers/build_table_pager', :locals => {:settings => settings} %>
18
- </div>
55
+
19
56
  <%= render :partial => "/helpers/build_table_wrapper", :locals => {:settings => settings} %>
20
- <div class="<%= settings[:form_id] + '_ajax_pager' %>">
21
- <%= render :partial => 'helpers/build_table_pager', :locals => {:settings => settings} %>
22
- </div>
57
+
58
+ <% if settings[:display_method].blank? %>
59
+ <div class="<%= settings[:form_id] + '_ajax_pager' %>">
60
+ <%= render :partial => 'helpers/build_table_pager', :locals => {:settings => settings} %>
61
+ </div>
62
+ <% end %>
23
63
  </fieldset>
24
64
  <% end %>
@@ -12,7 +12,9 @@
12
12
  onkeypress="paginate_by_enter('<%= settings[:form_id] %>', this, event);">
13
13
  <button class="btn" onclick='$("#" + "<%= settings[:form_id] %>" + "_page").val($(this).prev("input").val()); $("#" + "<%= settings[:form_id] %>").submit(); return false;'>Přejít</button>
14
14
  <%= will_paginate settings[:data_paginate], {:container => false, :inner_window => 1, :outer_window => 1} %>
15
+ <%= page_entries_info settings[:data_paginate] %>
15
16
  </div>
17
+
16
18
  <% end %>
17
19
  </div>
18
20
 
@@ -50,10 +50,13 @@
50
50
 
51
51
  %>
52
52
 
53
- <% if !edit_description_path.blank? && !edit_right.blank? && edit_right %>
54
- <div class="table_text_description_edit_button">
55
- <a href="#" onclick="load_page(<%= edit_description_path.to_json %>); return false;" class="btn primary">Editovat popisek</a>
56
- </div>
53
+ <% if settings[:display_method].blank? %>
54
+ <% if !edit_description_path.blank? && !edit_right.blank? && edit_right %>
55
+ <div class="table_text_description_edit_button">
56
+ <a href="#" onclick="load_page(<%= edit_description_path.to_json %>); return false;" class="btn primary">Editovat
57
+ popisek</a>
58
+ </div>
59
+ <% end %>
57
60
  <% end %>
58
61
 
59
62
  <% unless text.blank? %>
@@ -1,7 +1,7 @@
1
1
  <table class="table table-bordered table-condensed table_special">
2
2
  <thead>
3
3
  <!--<tr>-->
4
- <!--<th colspan="100" class="<%= settings[:form_id] + '_ajax_pager' %>">-->
4
+ <!--<th colspan="100" class="<%#= settings[:form_id] + '_ajax_pager' %>">-->
5
5
  <!--<%#= render :partial => 'helpers/build_table_pager', :locals => {:settings => settings} %>-->
6
6
  <!--</th>-->
7
7
  <!--</tr>-->
@@ -45,80 +45,82 @@
45
45
  </strong>
46
46
  </div>
47
47
 
48
- <div class="sortable clearfix">
49
- <% if col[:column_method].blank? && col[:row_method].blank? && !col[:name].blank? %>
50
- <a href="#"
51
- onclick="TableSorting.change_sorting('<%= settings[:form_id] %>','<%= col[:table] + "." +col[:name] %>', 'asc', this); return false;"
52
- ondblclick="TableSorting.force_change_sorting('<%= settings[:form_id] %>','<%= col[:table] + "." +col[:name] %>', 'asc', this); return false;"
53
- title="Seřadit od nejnižší hodnoty"
54
- class="btn first sort_button <%= (order_by_arr.include?(col[:table] + "." + col[:name] + " asc")) ? "btn-success" : "" %>"
55
- id="<%= order_asc_id %>">
56
- <i class="icon-arrow-up"></i>
57
- </a>
58
-
59
- <a href="#"
60
- onclick="TableSorting.change_sorting('<%= settings[:form_id] %>','<%= col[:table] + "." +col[:name] %>', 'desc', this); return false;"
61
- ondblclick="TableSorting.force_change_sorting('<%= settings[:form_id] %>','<%= col[:table] + "." +col[:name] %>', 'desc', this); return false;"
62
- title="Seřadit od nejvyšší hodnoty"
63
- class="btn sort_button <%= (order_by_arr.include?(col[:table] + "." + col[:name] + " desc")) ? "btn-success" : "" %>"
64
- id="<%= order_desc_id %>">
65
- <i class="icon-arrow-down"></i>
66
- </a>
67
- <% end %>
68
- </div>
48
+ <% if settings[:display_method].blank? %>
49
+ <div class="sortable clearfix">
50
+ <% if col[:column_method].blank? && col[:row_method].blank? && !col[:name].blank? %>
51
+ <a href="#"
52
+ onclick="TableSorting.change_sorting('<%= settings[:form_id] %>','<%= col[:table] + "." +col[:name] %>', 'asc', this); return false;"
53
+ ondblclick="TableSorting.force_change_sorting('<%= settings[:form_id] %>','<%= col[:table] + "." +col[:name] %>', 'asc', this); return false;"
54
+ title="Seřadit od nejnižší hodnoty"
55
+ class="btn first sort_button <%= (order_by_arr.include?(col[:table] + "." + col[:name] + " asc")) ? "btn-success" : "" %>"
56
+ id="<%= order_asc_id %>">
57
+ <i class="icon-arrow-up"></i>
58
+ </a>
59
+
60
+ <a href="#"
61
+ onclick="TableSorting.change_sorting('<%= settings[:form_id] %>','<%= col[:table] + "." +col[:name] %>', 'desc', this); return false;"
62
+ ondblclick="TableSorting.force_change_sorting('<%= settings[:form_id] %>','<%= col[:table] + "." +col[:name] %>', 'desc', this); return false;"
63
+ title="Seřadit od nejvyšší hodnoty"
64
+ class="btn sort_button <%= (order_by_arr.include?(col[:table] + "." + col[:name] + " desc")) ? "btn-success" : "" %>"
65
+ id="<%= order_desc_id %>">
66
+ <i class="icon-arrow-down"></i>
67
+ </a>
68
+ <% end %>
69
+ </div>
69
70
 
70
71
 
71
72
 
72
- <% case col[:filter] %>
73
- <% when :find %>
74
- <div class="inputs clearfix">
75
- <% saved_param = (!settings[:params].blank? && !settings[:params]['find'].blank? && !settings[:params]['find']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['find']["#{col[:table]}.#{col[:name]}"] : "" %>
76
- <%= text_field_tag "find[#{col[:table]}.#{col[:name]}]", saved_param,
77
- {:class => "text first #{settings[:form_id] + '_column_find'}"} %>
78
- </div>
79
- <% when :multichoice %>
80
- <div class="inputs clearfix">
81
- <% saved_param = (!settings[:params].blank? && !settings[:params]['multichoice'].blank? && !settings[:params]['multichoice']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['multichoice']["#{col[:table]}.#{col[:name]}"] : [] %>
82
- <%= select_tag("multichoice[#{col[:table]}.#{col[:name]}]", options_for_select(col[:filter_data], saved_param),
83
- :onchange => "form_submit_watcher('#{settings[:form_id]}')",
84
- :multiple => true,
85
- :class => "multiselect_class") %>
86
- </div>
87
- <% when :number %>
88
- <div class="inputs range clearfix">
89
- <% saved_param = (!settings[:params].blank? && !settings[:params]['date_from'].blank? && !settings[:params]['date_from']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['date_from']["#{col[:table]}.#{col[:name]}"] : "" %>
90
-
91
- <%= text_field_tag "number_from[#{col[:table]}.#{col[:name]}]", saved_param, {:class => "text first #{settings[:form_id] + '_column_find'}",
73
+ <% case col[:filter] %>
74
+ <% when :find %>
75
+ <div class="inputs clearfix">
76
+ <% saved_param = (!settings[:params].blank? && !settings[:params]['find'].blank? && !settings[:params]['find']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['find']["#{col[:table]}.#{col[:name]}"] : "" %>
77
+ <%= text_field_tag "find[#{col[:table]}.#{col[:name]}]", saved_param,
78
+ {:class => "text first #{settings[:form_id] + '_column_find'}"} %>
79
+ </div>
80
+ <% when :multichoice %>
81
+ <div class="inputs clearfix">
82
+ <% saved_param = (!settings[:params].blank? && !settings[:params]['multichoice'].blank? && !settings[:params]['multichoice']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['multichoice']["#{col[:table]}.#{col[:name]}"] : [] %>
83
+ <%= select_tag("multichoice[#{col[:table]}.#{col[:name]}]", options_for_select(col[:filter_data], saved_param),
84
+ :onchange => "form_submit_watcher('#{settings[:form_id]}')",
85
+ :multiple => true,
86
+ :class => "multiselect_class") %>
87
+ </div>
88
+ <% when :number %>
89
+ <div class="inputs range clearfix">
90
+ <% saved_param = (!settings[:params].blank? && !settings[:params]['date_from'].blank? && !settings[:params]['date_from']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['date_from']["#{col[:table]}.#{col[:name]}"] : "" %>
91
+
92
+ <%= text_field_tag "number_from[#{col[:table]}.#{col[:name]}]", saved_param, {:class => "text first #{settings[:form_id] + '_column_find'}",
93
+ :onchange => "form_submit_watcher('#{settings[:form_id]}')",
94
+ :placeholder => "min.",
95
+ :title => "Hodnota musí být vetší nebo rovna zadané hodnotě"} %>
96
+ <% saved_param = (!settings[:params].blank? && !settings[:params]['date_to'].blank? && !settings[:params]['date_to']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['date_to']["#{col[:table]}.#{col[:name]}"] : "" %>
97
+ <%#= label_tag "date_to[#{col[:table]}.#{col[:name]}]", "Do", :class => "datetime_class_label" %>
98
+ <%= text_field_tag "number_to[#{col[:table]}.#{col[:name]}]", saved_param, {:class => "text #{settings[:form_id] + '_column_find'}",
99
+ :onchange => "form_submit_watcher('#{settings[:form_id]}')",
100
+ :placeholder => "max.",
101
+ :title => "Hodnota musí být menší nebo rovna zadané hodnotě"} %>
102
+ </div>
103
+ <% when :date %>
104
+ <div class="inputs range clearfix">
105
+ <% saved_param = (!settings[:params].blank? && !settings[:params]['date_from'].blank? && !settings[:params]['date_from']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['date_from']["#{col[:table]}.#{col[:name]}"] : "" %>
106
+ <%#= label_tag "date_from[#{col[:table]}.#{col[:name]}]", "Od", :class => "datetime_class_label" %>
107
+ <%= text_field_tag "date_from[#{col[:table]}.#{col[:name]}]", saved_param, {:class => "text datetime_class first",
108
+ :onchange => "form_submit_watcher('#{settings[:form_id]}')",
109
+ :placeholder => "od",
110
+ :title => "Datum od"} %>
111
+ <% saved_param = (!settings[:params].blank? && !settings[:params]['date_to'].blank? && !settings[:params]['date_to']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['date_to']["#{col[:table]}.#{col[:name]}"] : "" %>
112
+ <%#= label_tag "date_to[#{col[:table]}.#{col[:name]}]", "Do", :class => "datetime_class_label" %>
113
+ <%= text_field_tag "date_to[#{col[:table]}.#{col[:name]}]", saved_param, {:class => "text datetime_class",
92
114
  :onchange => "form_submit_watcher('#{settings[:form_id]}')",
93
- :placeholder => "min.",
94
- :title => "Hodnota musí být vetší nebo rovna zadané hodnotě"} %>
95
- <% saved_param = (!settings[:params].blank? && !settings[:params]['date_to'].blank? && !settings[:params]['date_to']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['date_to']["#{col[:table]}.#{col[:name]}"] : "" %>
96
- <%#= label_tag "date_to[#{col[:table]}.#{col[:name]}]", "Do", :class => "datetime_class_label" %>
97
- <%= text_field_tag "number_to[#{col[:table]}.#{col[:name]}]", saved_param, {:class => "text #{settings[:form_id] + '_column_find'}",
98
- :onchange => "form_submit_watcher('#{settings[:form_id]}')",
99
- :placeholder => "max.",
100
- :title => "Hodnota musí být menší nebo rovna zadané hodnotě"} %>
101
- </div>
102
- <% when :date %>
103
- <div class="inputs range clearfix">
104
- <% saved_param = (!settings[:params].blank? && !settings[:params]['date_from'].blank? && !settings[:params]['date_from']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['date_from']["#{col[:table]}.#{col[:name]}"] : "" %>
105
- <%#= label_tag "date_from[#{col[:table]}.#{col[:name]}]", "Od", :class => "datetime_class_label" %>
106
- <%= text_field_tag "date_from[#{col[:table]}.#{col[:name]}]", saved_param, {:class => "text datetime_class first",
107
- :onchange => "form_submit_watcher('#{settings[:form_id]}')",
108
- :placeholder => "od",
109
- :title => "Datum od"} %>
110
- <% saved_param = (!settings[:params].blank? && !settings[:params]['date_to'].blank? && !settings[:params]['date_to']["#{col[:table]}.#{col[:name]}"].blank?) ? settings[:params]['date_to']["#{col[:table]}.#{col[:name]}"] : "" %>
111
- <%#= label_tag "date_to[#{col[:table]}.#{col[:name]}]", "Do", :class => "datetime_class_label" %>
112
- <%= text_field_tag "date_to[#{col[:table]}.#{col[:name]}]", saved_param, {:class => "text datetime_class",
113
- :onchange => "form_submit_watcher('#{settings[:form_id]}')",
114
- :placeholder => "do",
115
- :title => "Datum do"} %>
116
- </div>
117
- <% else %>
118
- <% end %>
119
-
115
+ :placeholder => "do",
116
+ :title => "Datum do"} %>
117
+ </div>
118
+ <% else %>
119
+ <% end %>
120
120
 
121
+ <% end %>
121
122
  </th>
123
+
122
124
  <% end %>
123
125
  </tr>
124
126
 
@@ -130,7 +132,7 @@
130
132
  </tbody>
131
133
  <tfoot>
132
134
  <!--<tr>-->
133
- <!--<th colspan="100" class="<%= settings[:form_id] + '_ajax_pager' %>">-->
135
+ <!--<th colspan="100" class="<%#= settings[:form_id] + '_ajax_pager' %>">-->
134
136
  <!--<%#= render :partial => 'helpers/build_table_pager', :locals => {:settings => settings} %>-->
135
137
  <!--</th>-->
136
138
  <!--</tr>-->
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "it-logica-application-backbone"
8
- s.version = "1.0.26"
8
+ s.version = "1.0.27"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ladas"]
12
- s.date = "2012-09-11"
12
+ s.date = "2012-09-12"
13
13
  s.description = "longer description of your gem"
14
14
  s.email = "ladislav.smola@it-logica.cz"
15
15
  s.extra_rdoc_files = [
@@ -5,30 +5,41 @@ module ControllerMixins
5
5
  data = yield
6
6
  class_obj = data.respond_to?(:klass) ? data.klass : data
7
7
  if action_name == "filter"
8
- default_params = params
9
- if !params.blank? && params["clear"]
10
- default_params = @settings[:default].dup
11
- default_params[:order_by] = @settings[:default][:order_by] + " " + @settings[:default][:order_by_direction] if !@settings[:default][:order_by].blank? && !@settings[:default][:order_by_direction].blank?
12
- default_params[:order_by] = @settings[:default][:order] if !@settings[:default][:order].blank?
13
- end
8
+ case params["___display_method___"]
9
+ when "print_by_checkboxes"
10
+ # printing page, it should be opened in new window
11
+ @settings = class_obj.prepare_settings(logged_user, data, @settings, default_params)
14
12
 
15
- @settings = class_obj.prepare_settings(logged_user, data, @settings, default_params)
16
- if !params.blank? && params["clear"]
17
- session["#{@settings[:form_id]}_params"] = ""
18
- render :layout => false, :action => :index
19
- else
20
- @paginate = render_to_string(:partial => "/helpers/build_table_pager", :locals => {:settings => @settings})
21
- session["#{@settings[:form_id]}_params"] = params
22
- if @settings[:template].blank?
23
- # if there is no template a will return json and tbody renders in javascript template
24
- returned_t_body = @settings.to_json
25
- else
26
- # or there is template so i will return template rendered here in ruby
27
- returned_t_body = render_to_string(:partial => @settings[:template], :locals => {:settings => @settings})
28
- end
29
13
 
30
- render :layout => false, :json => {:settings => returned_t_body, :paginate => @paginate}.to_json
14
+ render :layout => "print", :action => :index
15
+ else
16
+ # default print of table
17
+ default_params = params
18
+ if !params.blank? && params["clear"]
19
+ default_params = @settings[:default].dup
20
+ default_params[:order_by] = @settings[:default][:order_by] + " " + @settings[:default][:order_by_direction] if !@settings[:default][:order_by].blank? && !@settings[:default][:order_by_direction].blank?
21
+ default_params[:order_by] = @settings[:default][:order] if !@settings[:default][:order].blank?
22
+ end
23
+
24
+ @settings = class_obj.prepare_settings(logged_user, data, @settings, default_params)
25
+ if !params.blank? && params["clear"]
26
+ session["#{@settings[:form_id]}_params"] = ""
27
+ render :layout => false, :action => :index
28
+ else
29
+ @paginate = render_to_string(:partial => "/helpers/build_table_pager", :locals => {:settings => @settings})
30
+ session["#{@settings[:form_id]}_params"] = params
31
+ if @settings[:template].blank?
32
+ # if there is no template a will return json and tbody renders in javascript template
33
+ returned_t_body = @settings.to_json
34
+ else
35
+ # or there is template so i will return template rendered here in ruby
36
+ returned_t_body = render_to_string(:partial => @settings[:template], :locals => {:settings => @settings})
37
+ end
38
+
39
+ render :layout => false, :json => {:settings => returned_t_body, :paginate => @paginate}.to_json
40
+ end
31
41
  end
42
+
32
43
  elsif action_name == "index"
33
44
  default_params = @settings[:default].dup
34
45
  default_params[:order_by] = @settings[:default][:order_by] + " " + @settings[:default][:order_by_direction] if !@settings[:default][:order_by].blank? && !@settings[:default][:order_by_direction].blank?
@@ -52,34 +63,49 @@ module ControllerMixins
52
63
  data = yield
53
64
  class_obj = data.respond_to?(:klass) ? data.klass : data
54
65
 
55
- filter_method = settings[:filter_method]
66
+ filter_method = settings[:filter_method]
56
67
  show_table_method = settings[:show_table_method]
57
68
 
58
69
  default_params = set_default_params(filter_method, show_table_method, settings)
59
70
 
60
- settings = class_obj.prepare_settings(logged_user, data, settings, default_params)
71
+ case display_method
72
+ when "print_by_checkboxes"
73
+ # vyjímka pro tisk tabulek
74
+ # printing page, it should be opened in new window
75
+ settings[:filter_method] = "only_by_checkboxes"
76
+ settings[:display_method] = display_method
77
+ settings = class_obj.prepare_settings(logged_user, data, settings, default_params)
61
78
 
62
- # Filtrovani se renderuje zde
63
- if is_filtering?(filter_method)
79
+ render_table_for_printing(settings, show_table_method)
80
+ else
81
+ settings = class_obj.prepare_settings(logged_user, data, settings, default_params)
64
82
 
65
- if clear_filter? # Tlacitko Smazat filtr
66
- render_table_on_clear_filter(settings, show_table_method)
67
- else # Ostatni filtry
68
- render_tbody_on_filter(settings)
69
- end
83
+ # Filtrovani se renderuje zde
84
+ if is_filtering?(filter_method)
85
+
86
+ if clear_filter? # Tlacitko Smazat filtr
87
+ render_table_on_clear_filter(settings, show_table_method)
88
+ else # Ostatni filtry
89
+ render_tbody_on_filter(settings)
90
+ end
70
91
 
92
+ end
71
93
  end
72
94
 
73
95
  # Cele vykresleni stranky normalne z metody, ktera toto zavolala
74
96
  end
75
97
 
76
- def set_default_params(filter_method, show_table_method, settings )
98
+ def set_default_params(filter_method, show_table_method, settings)
77
99
  default_params = params
78
100
  default_params = default_params_for_clear_filter(settings) if is_filtering?(filter_method) && clear_filter?
79
101
  default_params = default_params_for_show_table(settings) if is_showing_table?(show_table_method)
80
102
  default_params
81
103
  end
82
104
 
105
+ def render_table_for_printing(settings, show_table_method)
106
+ render :layout => "print", :action => (show_table_method.blank? ? :index : show_table_method)
107
+ end
108
+
83
109
  def render_table_on_clear_filter(settings, show_table_method)
84
110
  session["#{settings[:form_id]}_params"] = ""
85
111
  render :layout => false, :action => (show_table_method.blank? ? :index : show_table_method)
@@ -103,6 +129,10 @@ module ControllerMixins
103
129
  !params.blank? && params["clear"]
104
130
  end
105
131
 
132
+ def display_method
133
+ params["___display_method___"]
134
+ end
135
+
106
136
  def default_params_for_clear_filter(settings)
107
137
  default_params = settings[:default].dup
108
138
  default_params[:order_by] = settings[:default][:order_by] + " " + settings[:default][:order_by_direction] if !settings[:default][:order_by].blank? && !settings[:default][:order_by_direction].blank?
@@ -30,7 +30,7 @@ module ModelMixins
30
30
 
31
31
  not_selected_items = object.filter(object, settings, params, per_page)
32
32
  items = not_selected_items.selection(settings)
33
- if params[:page].to_i > items.total_pages && items.total_pages > 0
33
+ if items.respond_to?(:total_pages) && params[:page].to_i > items.total_pages && items.total_pages > 0
34
34
  params[:page] = 1
35
35
  not_selected_items = object.filter(object, settings, params, per_page)
36
36
  items = not_selected_items.selection(settings)
@@ -271,124 +271,132 @@ module ModelMixins
271
271
  having_cond_str = ""
272
272
  having_cond_hash = {}
273
273
 
274
-
275
- if !params.blank? && params['find']
276
- params['find'].each_pair do |i, v|
277
- i = i.gsub(/___unknown___\./, "") #some cleaning job
278
- unless v.blank?
279
- if i.match(/^.*?non_existing_column___.*$/i)
280
- identifier = i.split("non_existing_column___").second
281
- settings[:columns].each do |col|
282
- if !col[:select_as].blank? && !col[:format_method].blank? && col[:format_method] == identifier
283
- cond_str += " AND " unless cond_str.blank?
284
- cond_str += "( "
285
- sub_cond = ""
286
- col[:select].split(",").each do |sub_cond_col|
287
- sub_cond += " OR " unless sub_cond.blank?
288
- non_existing_column_i = col[:select_as] + "." + sub_cond_col.gsub(" ", "")
289
- cond_id = "find_#{non_existing_column_i.gsub(/\./, '_')}"
290
- sub_cond += "#{non_existing_column_i} LIKE :#{cond_id}" #OR guest_email LIKE :find"
291
- cond_hash.merge!({cond_id.to_sym => "%#{v}%"})
274
+ case settings[:filter_method]
275
+ when "only_by_checkboxes"
276
+ # filtering only by checkboxes
277
+ cond_str = "(#{settings[:row][:id]} IN (:checkboxes))"
278
+ cond_hash = {:checkboxes => params["checkbox_pool"].split(",")}
279
+ per_page = nil # no paginate for checkbox filter
280
+ else
281
+ # filtering by table filters
282
+ if !params.blank? && params['find']
283
+ params['find'].each_pair do |i, v|
284
+ i = i.gsub(/___unknown___\./, "") #some cleaning job
285
+ unless v.blank?
286
+ if i.match(/^.*?non_existing_column___.*$/i)
287
+ identifier = i.split("non_existing_column___").second
288
+ settings[:columns].each do |col|
289
+ if !col[:select_as].blank? && !col[:format_method].blank? && col[:format_method] == identifier
290
+ cond_str += " AND " unless cond_str.blank?
291
+ cond_str += "( "
292
+ sub_cond = ""
293
+ col[:select].split(",").each do |sub_cond_col|
294
+ sub_cond += " OR " unless sub_cond.blank?
295
+ non_existing_column_i = col[:select_as] + "." + sub_cond_col.gsub(" ", "")
296
+ cond_id = "find_#{non_existing_column_i.gsub(/\./, '_')}"
297
+ sub_cond += "#{non_existing_column_i} LIKE :#{cond_id}" #OR guest_email LIKE :find"
298
+ cond_hash.merge!({cond_id.to_sym => "%#{v}%"})
299
+ end
300
+ cond_str += sub_cond + " )"
301
+ else
302
+ ""
303
+ end
292
304
  end
293
- cond_str += sub_cond + " )"
294
305
  else
295
- ""
306
+ if i.match(/^.*?___sql_expression___.*$/i)
307
+ i = i.gsub(/___sql_expression___\./, "") #some cleaning job
308
+
309
+ having_cond_str += " AND " unless having_cond_str.blank?
310
+ cond_id = "find_#{i.gsub(/\./, '_')}"
311
+ having_cond_str += "#{i} LIKE :#{cond_id}" #OR guest_email LIKE :find"
312
+ having_cond_hash.merge!({cond_id.to_sym => "%#{v}%"})
313
+ else
314
+ cond_str += " AND " unless cond_str.blank?
315
+ cond_id = "find_#{i.gsub(/\./, '_')}"
316
+ cond_str += "#{i} LIKE :#{cond_id}" #OR guest_email LIKE :find"
317
+ cond_hash.merge!({cond_id.to_sym => "%#{v}%"})
318
+ end
296
319
  end
297
320
  end
298
- else
299
- if i.match(/^.*?___sql_expression___.*$/i)
300
- i = i.gsub(/___sql_expression___\./, "") #some cleaning job
301
-
302
- having_cond_str += " AND " unless having_cond_str.blank?
303
- cond_id = "find_#{i.gsub(/\./, '_')}"
304
- having_cond_str += "#{i} LIKE :#{cond_id}" #OR guest_email LIKE :find"
305
- having_cond_hash.merge!({cond_id.to_sym => "%#{v}%"})
306
- else
307
- cond_str += " AND " unless cond_str.blank?
308
- cond_id = "find_#{i.gsub(/\./, '_')}"
309
- cond_str += "#{i} LIKE :#{cond_id}" #OR guest_email LIKE :find"
310
- cond_hash.merge!({cond_id.to_sym => "%#{v}%"})
311
- end
312
321
  end
313
322
  end
314
- end
315
- end
316
323
 
317
324
 
318
- # ToDo ladas add having condition to others
319
- if !params.blank? && params['multichoice']
320
- params['multichoice'].each_pair do |i, v|
321
- i = i.gsub(/___unknown___\./, "") #some cleaning job
322
- unless v.blank?
323
- cond_str += " AND " unless cond_str.blank?
324
- cond_id = "multichoice_#{i.gsub(/\./, '_')}"
325
+ # ToDo ladas add having condition to others
326
+ if !params.blank? && params['multichoice']
327
+ params['multichoice'].each_pair do |i, v|
328
+ i = i.gsub(/___unknown___\./, "") #some cleaning job
329
+ unless v.blank?
330
+ cond_str += " AND " unless cond_str.blank?
331
+ cond_id = "multichoice_#{i.gsub(/\./, '_')}"
325
332
 
326
- cond_str += "#{i} IN (:#{cond_id})" #OR guest_email LIKE :find"
327
- cond_hash.merge!({cond_id.to_sym => v})
333
+ cond_str += "#{i} IN (:#{cond_id})" #OR guest_email LIKE :find"
334
+ cond_hash.merge!({cond_id.to_sym => v})
335
+ end
336
+ end
328
337
  end
329
- end
330
- end
331
338
 
332
- if !params.blank? && (params['date_from'] || params['number_from'])
333
- from_hash = params['date_from']
334
- if from_hash.blank?
335
- from_hash = params['number_from']
336
- else
337
- from_hash.merge!(params['number_from']) unless params['number_from'].blank?
338
- end
339
- from_hash.each_pair do |i, v|
340
- i = i.gsub(/___unknown___\./, "") #some cleaning job
341
- unless v.blank?
342
- if i.match(/^.*?___sql_expression___.*$/i)
343
- i = i.gsub(/___sql_expression___\./, "") #some cleaning job
344
- having_cond_str += " AND " unless having_cond_str.blank?
345
- cond_id = "date_from_#{i.gsub(/\./, '_')}"
346
- having_cond_str += "#{i} >= :#{cond_id}" #OR guest_email LIKE :find"
347
- having_cond_hash.merge!({cond_id.to_sym => "#{v}"})
339
+ if !params.blank? && (params['date_from'] || params['number_from'])
340
+ from_hash = params['date_from']
341
+ if from_hash.blank?
342
+ from_hash = params['number_from']
348
343
  else
349
- cond_str += " AND " unless cond_str.blank?
350
- cond_id = "date_from_#{i.gsub(/\./, '_')}"
351
- cond_str += "#{i} >= :#{cond_id}" #OR guest_email LIKE :find"
352
- cond_hash.merge!({cond_id.to_sym => "#{v}"})
344
+ from_hash.merge!(params['number_from']) unless params['number_from'].blank?
345
+ end
346
+ from_hash.each_pair do |i, v|
347
+ i = i.gsub(/___unknown___\./, "") #some cleaning job
348
+ unless v.blank?
349
+ if i.match(/^.*?___sql_expression___.*$/i)
350
+ i = i.gsub(/___sql_expression___\./, "") #some cleaning job
351
+ having_cond_str += " AND " unless having_cond_str.blank?
352
+ cond_id = "date_from_#{i.gsub(/\./, '_')}"
353
+ having_cond_str += "#{i} >= :#{cond_id}" #OR guest_email LIKE :find"
354
+ having_cond_hash.merge!({cond_id.to_sym => "#{v}"})
355
+ else
356
+ cond_str += " AND " unless cond_str.blank?
357
+ cond_id = "date_from_#{i.gsub(/\./, '_')}"
358
+ cond_str += "#{i} >= :#{cond_id}" #OR guest_email LIKE :find"
359
+ cond_hash.merge!({cond_id.to_sym => "#{v}"})
360
+ end
361
+ end
353
362
  end
354
363
  end
355
- end
356
- end
357
364
 
358
- if !params.blank? && (params['date_to'] || params['number_to'])
359
- to_hash = params['date_to']
360
- if to_hash.blank?
361
- to_hash = params['number_to']
362
- else
363
- to_hash.merge!(params['number_to']) unless params['number_to'].blank?
364
- end
365
- to_hash.each_pair do |i, v|
366
- i = i.gsub(/___unknown___\./, "") #some cleaning job
367
- unless v.blank?
368
- if i.match(/^.*?___sql_expression___.*$/i)
369
- i = i.gsub(/___sql_expression___\./, "") #some cleaning job
370
- having_cond_str += " AND " unless having_cond_str.blank?
371
- cond_id = "date_to_#{i.gsub(/\./, '_')}"
372
- having_cond_str += "#{i} <= :#{cond_id}" #OR guest_email LIKE :find"
373
- having_cond_hash.merge!({cond_id.to_sym => "#{v}"})
365
+ if !params.blank? && (params['date_to'] || params['number_to'])
366
+ to_hash = params['date_to']
367
+ if to_hash.blank?
368
+ to_hash = params['number_to']
374
369
  else
375
- cond_str += " AND " unless cond_str.blank?
376
- cond_id = "date_to_#{i.gsub(/\./, '_')}"
377
- cond_str += "#{i} <= :#{cond_id}" #OR guest_email LIKE :find"
378
- cond_hash.merge!({cond_id.to_sym => "#{v}"})
370
+ to_hash.merge!(params['number_to']) unless params['number_to'].blank?
371
+ end
372
+ to_hash.each_pair do |i, v|
373
+ i = i.gsub(/___unknown___\./, "") #some cleaning job
374
+ unless v.blank?
375
+ if i.match(/^.*?___sql_expression___.*$/i)
376
+ i = i.gsub(/___sql_expression___\./, "") #some cleaning job
377
+ having_cond_str += " AND " unless having_cond_str.blank?
378
+ cond_id = "date_to_#{i.gsub(/\./, '_')}"
379
+ having_cond_str += "#{i} <= :#{cond_id}" #OR guest_email LIKE :find"
380
+ having_cond_hash.merge!({cond_id.to_sym => "#{v}"})
381
+ else
382
+ cond_str += " AND " unless cond_str.blank?
383
+ cond_id = "date_to_#{i.gsub(/\./, '_')}"
384
+ cond_str += "#{i} <= :#{cond_id}" #OR guest_email LIKE :find"
385
+ cond_hash.merge!({cond_id.to_sym => "#{v}"})
386
+ end
387
+ end
379
388
  end
380
389
  end
381
- end
382
- end
383
390
 
391
+ #items = self.joins("LEFT OUTER JOIN intranet_text_pages ON resource_id = intranet_text_pages.id").where(cond_str, cond_hash).paginate(:page => params[:page], :per_page => per_page).order(order_by).selection(settings)
392
+ #if params[:page].to_i > items.total_pages && items.total_pages > 0
393
+ # params[:page] = 1
394
+ # items = self.where(cond_str, cond_hash).paginate(:page => params[:page], :per_page => per_page).order(order_by).selection(settings)
395
+ #end
396
+ #items
397
+ end
384
398
  ret = where(cond_str, cond_hash).order(order_by)
385
399
  ret = ret.having(having_cond_str, having_cond_hash) unless having_cond_str.blank?
386
- #items = self.joins("LEFT OUTER JOIN intranet_text_pages ON resource_id = intranet_text_pages.id").where(cond_str, cond_hash).paginate(:page => params[:page], :per_page => per_page).order(order_by).selection(settings)
387
- #if params[:page].to_i > items.total_pages && items.total_pages > 0
388
- # params[:page] = 1
389
- # items = self.where(cond_str, cond_hash).paginate(:page => params[:page], :per_page => per_page).order(order_by).selection(settings)
390
- #end
391
- #items
392
400
 
393
401
  # if there are additional joins i will add them
394
402
  settings[:columns].each do |col|
@@ -419,7 +427,7 @@ module ModelMixins
419
427
  # I am caching total count
420
428
  # todo find out how to cache this when everything can change, maybe I can cache only not filtered version
421
429
  # !!!!!!1 dont turn this on till then
422
-
430
+
423
431
  total_count = Rails.cache.fetch(settings[:form_id] + "__cached_total_count", :expires_in => settings[:total_count_cache]) do
424
432
  if object.respond_to?(:klass)
425
433
  mysql_count = object.klass.find_by_sql("SELECT COUNT(*) AS count_all FROM (" + ret.selection(settings).to_sql + ") count")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: it-logica-application-backbone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.26
4
+ version: 1.0.27
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-11 00:00:00.000000000 Z
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: htmlentities
16
- requirement: &82385980 !ruby/object:Gem::Requirement
16
+ requirement: &81265360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *82385980
24
+ version_requirements: *81265360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shoulda
27
- requirement: &82385710 !ruby/object:Gem::Requirement
27
+ requirement: &81265080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *82385710
35
+ version_requirements: *81265080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdoc
38
- requirement: &82385360 !ruby/object:Gem::Requirement
38
+ requirement: &81264650 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.12'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *82385360
46
+ version_requirements: *81264650
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &82384740 !ruby/object:Gem::Requirement
49
+ requirement: &81264110 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.1.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *82384740
57
+ version_requirements: *81264110
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &82384340 !ruby/object:Gem::Requirement
60
+ requirement: &81263730 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.8.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *82384340
68
+ version_requirements: *81263730
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &82383920 !ruby/object:Gem::Requirement
71
+ requirement: &81263290 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *82383920
79
+ version_requirements: *81263290
80
80
  description: longer description of your gem
81
81
  email: ladislav.smola@it-logica.cz
82
82
  executables: []
@@ -577,7 +577,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
577
577
  version: '0'
578
578
  segments:
579
579
  - 0
580
- hash: 659796033
580
+ hash: 457958481
581
581
  required_rubygems_version: !ruby/object:Gem::Requirement
582
582
  none: false
583
583
  requirements: