it-logica-application-backbone 1.1.8 → 1.2.0

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.
Files changed (26) hide show
  1. data/VERSION +1 -1
  2. data/app/assets/javascripts/backbone_js/bootstrap_modal.js +234 -0
  3. data/app/assets/javascripts/backbone_js/ladas_breadcrumb.js.coffee +15 -2
  4. data/app/assets/javascripts/backbone_js/ladas_editable_table_aligner.js.coffee +243 -0
  5. data/app/assets/javascripts/backbone_js/ladas_editable_table_builder.js.coffee +341 -0
  6. data/app/assets/javascripts/backbone_js/ladas_editable_table_modal_dialog.js.coffee +93 -0
  7. data/app/assets/javascripts/backbone_js/ladas_functions.js +8 -0
  8. data/app/assets/javascripts/backbone_js/ladas_saving.js +6 -0
  9. data/app/assets/javascripts/backbone_js/ladas_table_builder.js.coffee +1 -1
  10. data/app/assets/stylesheets/backbone_css/bootstrap_modal.css +139 -0
  11. data/app/assets/stylesheets/backbone_css/design.css +1 -1
  12. data/app/assets/stylesheets/backbone_css/editable_tables.css.scss +108 -0
  13. data/app/views/helpers/editable_table/_build_ajax_callback_code.html.erb +3 -0
  14. data/app/views/helpers/editable_table/_build_table.html.erb +128 -0
  15. data/app/views/helpers/editable_table/_build_table_data.html.erb +14 -0
  16. data/app/views/helpers/editable_table/_build_table_filter.html.erb +70 -0
  17. data/app/views/helpers/editable_table/_build_table_header.html.erb +136 -0
  18. data/app/views/helpers/editable_table/_build_table_pager.html.erb +31 -0
  19. data/app/views/helpers/editable_table/_build_table_text_description.html.erb +66 -0
  20. data/app/views/helpers/editable_table/_build_table_wrapper.html.erb +106 -0
  21. data/it-logica-application-backbone.gemspec +16 -2
  22. data/lib/model_mixins/table_builder_class_methods.rb +49 -0
  23. data/lib/table_settings/table_action.rb +5 -0
  24. data/lib/table_settings/table_column.rb +11 -0
  25. data/lib/view_mixins/table.rb +5 -0
  26. metadata +29 -15
@@ -45,7 +45,7 @@ class TableBuilder
45
45
  summarize_page += if col.summarize_page_label? then col.summarize_page_label else ''
46
46
  summarize_page += '<span class="value">'
47
47
  summarize_page += if col.summarize_page_value? then col.summarize_page_value else 0
48
- summarize_pagel += '</span>'
48
+ summarize_page += '</span>'
49
49
  summarize_page += '</div>'
50
50
 
51
51
  summarize_page += '</td>'
@@ -0,0 +1,139 @@
1
+ /*!
2
+ * Bootstrap v2.2.1
3
+ *
4
+ * Copyright 2012 Twitter, Inc
5
+ * Licensed under the Apache License v2.0
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ *
8
+ * Designed and built with all the love in the world @twitter by @mdo and @fat.
9
+ */
10
+ .clearfix {
11
+ *zoom: 1;
12
+ }
13
+ .clearfix:before,
14
+ .clearfix:after {
15
+ display: table;
16
+ content: "";
17
+ line-height: 0;
18
+ }
19
+ .clearfix:after {
20
+ clear: both;
21
+ }
22
+ .hide-text {
23
+ font: 0/0 a;
24
+ color: transparent;
25
+ text-shadow: none;
26
+ background-color: transparent;
27
+ border: 0;
28
+ }
29
+ .input-block-level {
30
+ display: block;
31
+ width: 100%;
32
+ min-height: 30px;
33
+ -webkit-box-sizing: border-box;
34
+ -moz-box-sizing: border-box;
35
+ box-sizing: border-box;
36
+ }
37
+ .modal-backdrop {
38
+ position: fixed;
39
+ top: 0;
40
+ right: 0;
41
+ bottom: 0;
42
+ left: 0;
43
+ z-index: 1040;
44
+ background-color: #000000;
45
+ }
46
+ .modal-backdrop.fade {
47
+ opacity: 0;
48
+ }
49
+ .modal-backdrop,
50
+ .modal-backdrop.fade.in {
51
+ opacity: 0.8;
52
+ filter: alpha(opacity=80);
53
+ }
54
+ .modal {
55
+ position: fixed;
56
+ top: 50%;
57
+ left: 50%;
58
+ z-index: 1050;
59
+ width: 560px;
60
+ margin: -250px 0 0 -280px;
61
+ background-color: #ffffff;
62
+ border: 1px solid #999;
63
+ border: 1px solid rgba(0, 0, 0, 0.3);
64
+ *border: 1px solid #999;
65
+ /* IE6-7 */
66
+
67
+ -webkit-border-radius: 6px;
68
+ -moz-border-radius: 6px;
69
+ border-radius: 6px;
70
+ -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
71
+ -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
72
+ box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
73
+ -webkit-background-clip: padding-box;
74
+ -moz-background-clip: padding-box;
75
+ background-clip: padding-box;
76
+ outline: none;
77
+ }
78
+ .modal.fade {
79
+ -webkit-transition: opacity .3s linear, top .3s ease-out;
80
+ -moz-transition: opacity .3s linear, top .3s ease-out;
81
+ -o-transition: opacity .3s linear, top .3s ease-out;
82
+ transition: opacity .3s linear, top .3s ease-out;
83
+ top: -25%;
84
+ }
85
+ .modal.fade.in {
86
+ top: 50%;
87
+ }
88
+ .modal-header {
89
+ padding: 9px 15px;
90
+ border-bottom: 1px solid #eee;
91
+ }
92
+ .modal-header .close {
93
+ margin-top: 2px;
94
+ }
95
+ .modal-header h3 {
96
+ margin: 0;
97
+ line-height: 30px;
98
+ }
99
+ .modal-body {
100
+ overflow-y: auto;
101
+ max-height: 400px;
102
+ padding: 15px;
103
+ }
104
+ .modal-form {
105
+ margin-bottom: 0;
106
+ }
107
+ .modal-footer {
108
+ padding: 14px 15px 15px;
109
+ margin-bottom: 0;
110
+ text-align: right;
111
+ background-color: #f5f5f5;
112
+ border-top: 1px solid #ddd;
113
+ -webkit-border-radius: 0 0 6px 6px;
114
+ -moz-border-radius: 0 0 6px 6px;
115
+ border-radius: 0 0 6px 6px;
116
+ -webkit-box-shadow: inset 0 1px 0 #ffffff;
117
+ -moz-box-shadow: inset 0 1px 0 #ffffff;
118
+ box-shadow: inset 0 1px 0 #ffffff;
119
+ *zoom: 1;
120
+ }
121
+ .modal-footer:before,
122
+ .modal-footer:after {
123
+ display: table;
124
+ content: "";
125
+ line-height: 0;
126
+ }
127
+ .modal-footer:after {
128
+ clear: both;
129
+ }
130
+ .modal-footer .btn + .btn {
131
+ margin-left: 5px;
132
+ margin-bottom: 0;
133
+ }
134
+ .modal-footer .btn-group .btn + .btn {
135
+ margin-left: -1px;
136
+ }
137
+ .modal-footer .btn-block + .btn-block {
138
+ margin-left: 0;
139
+ }
@@ -35,7 +35,7 @@
35
35
  .dataGrid table tr td:first-child, .dataGrid table tr th:first-child {border-left: 0;}
36
36
  .dataGrid table tr td:last-child, .dataGrid table tr th:last-child {border-right: 0;}
37
37
  .dataGrid table thead th, .dataGrid table tfoot td {background: #f5f3ef;}
38
- .dataGrid table tbody tr:hover td {background: #f1fadf !important;}
38
+ /*.dataGrid table tbody tr:hover td {background: #f1fadf !important;}*/
39
39
  .dataGrid table tbody tr.checked td {background: #faf9f8;}
40
40
  .dataGrid table tbody tr td .btn {margin: 0 !important;}
41
41
  .dataGrid table thead th {text-align: left;width: 115px;}
@@ -0,0 +1,108 @@
1
+
2
+ .detachedTableContainer th, .detachedTableContainer td, .scrollTargetContainter th, .scrollTargetContainter td {
3
+ padding: 2px !important;
4
+ border: 1px solid #CCC !important;
5
+ margin: 0px;;
6
+ }
7
+
8
+ .centerContainer .detachedTableContainer {
9
+ width: 1016px;
10
+ }
11
+
12
+ .centerContainer .scrollTargetContainter {
13
+ width: 1000px;
14
+ overflow: hidden;
15
+ }
16
+
17
+ .centerContainer .detachedTableContainer, {
18
+ overflow: auto;
19
+ height: 616px;
20
+ }
21
+
22
+ .detachedTableContainer, .fixed_left_column .scrollTargetContainter {
23
+ overflow: hidden;
24
+ overflow-y: hidden;
25
+ height: 600px;
26
+
27
+ }
28
+
29
+ .fixedLeftColumn table {
30
+ border-right: 5px solid #CCC !important;
31
+ width: 100px;
32
+ }
33
+
34
+ /* table cells must have same properties */
35
+
36
+ //.scrollTargetContainter .headcol, .detachedTableContainer .headcol {
37
+ // position: absolute;
38
+ // //width: 5em;
39
+ // left: 0;
40
+ // top: auto;
41
+ // border-right: 0px none black;
42
+ // border-top-width: 3px;
43
+ // margin-top: -3px;
44
+ //}
45
+
46
+ .editable_cell {
47
+ cursor: pointer;
48
+ }
49
+
50
+ .no_hover .table tbody tr:hover td,
51
+ .no_hover .table tbody tr:hover th {
52
+ //background-color: transparent !important;
53
+ background-color: inherit;
54
+ }
55
+
56
+ label.mini_color_box {
57
+ width: 15px;
58
+ height: 15px;
59
+ display: inline-block;
60
+ cursor: pointer;
61
+ }
62
+
63
+ span.mini_color_box {
64
+ //width: 25px;
65
+ //height: 25px;
66
+ display: inline-block;
67
+ margin: 1px;
68
+ }
69
+
70
+ label.mini_color_box_blank {
71
+ width: 100px;
72
+ border: 2px solid #CCC;
73
+ vertical-align: center;
74
+ text-align: center;
75
+ padding-top: 5px;
76
+ }
77
+
78
+ label.mini_color_box.active {
79
+ border: 6px solid #05e876;
80
+ width: 13px;
81
+ height: 13px;
82
+ }
83
+ label.mini_color_box_blank.active {
84
+ width: 100px;
85
+ height: 20px;
86
+ }
87
+
88
+ span.mini_color_cell {
89
+ display: inline-block;
90
+ width: 20px;
91
+ height: 20px;
92
+ }
93
+
94
+
95
+
96
+ /* tabbulka bude mit fixni vysku radku, prepocinani s 500 polozkama trva moc doulho */
97
+ /* !!!!! proste se do ni nesmi rvat nic vetsiho */
98
+ .editable_table tbody tr {
99
+ height: 25px;
100
+ max-height: 25px;
101
+ min-height: 25px;
102
+ }
103
+
104
+ .editable_table table .btn {
105
+ padding: 0px;
106
+ margin: 0px;
107
+ margin-right: 2px;
108
+ }
@@ -0,0 +1,3 @@
1
+ <script type="text/javascript">
2
+ connect_callback_to_form('<%= caller_id %>');
3
+ </script>
@@ -0,0 +1,128 @@
1
+ <div class="page">
2
+ <%= render :partial => "/helpers/editable_table/build_table_text_description", :locals => {:settings => settings} %>
3
+ </div>
4
+ <% if settings[:display_method]=="print_by_checkboxes" %>
5
+ <div class="print-window-buttons" style="float:right">
6
+ <a class="print_page_functionality print-window-print-dialog-button" href="" onclick="window.print()">
7
+ <i class="icon-print"></i>Tisknout</a>
8
+ <a class="print_page_functionality print-window-close-button" href="" onclick="window.close();">
9
+ <i class="icon-remove"></i>Zavřít</a>
10
+ </div>
11
+ <div style="clear:both"></div>
12
+
13
+ <% end %>
14
+
15
+ <% if settings[:display_method].blank? %>
16
+ <div class="tabs">
17
+ <%= yield :table_form_tabs %>
18
+
19
+ <div class="info">
20
+
21
+
22
+ <% if settings[:checkboxes] %>
23
+ <span>Vybráno: <strong>
24
+ <span title="Počet označených řádků na všech stránkách" id="<%= settings[:form_id]+ "_active_checkboxes_count" %>">
25
+ <%= !settings[:params]["checkbox_pool"].blank? ? settings[:params]["checkbox_pool"].split(",").count : 0 %>
26
+ </span>
27
+ </strong>
28
+ </span>
29
+
30
+
31
+ <% end %>
32
+
33
+ <% if settings[:display_method].blank? %>
34
+ <% if settings[:checkboxes] %>
35
+ <script type="text/javascript">
36
+ function submit_in_new_window(form_id) {
37
+ var form_original = $("#" + form_id);
38
+
39
+ // create new form by cloning without events
40
+ var form = form_original.clone(false)
41
+
42
+ // disabling ajax
43
+ form.removeAttr("data-remote");
44
+
45
+ form.attr("target", "_blank");
46
+ form.attr("action", form_original.attr("action"));
47
+ form.attr("style", "display: none;");
48
+
49
+ // need to append it to browser html, otherwise it wont send in many browsers (with clone it works only with chrome)
50
+ form_original.after(form);
51
+
52
+ //Create an input type dynamically.
53
+ var element = document.createElement("input");
54
+
55
+ //Assign different attributes to the element.
56
+ element.setAttribute("type", "hidden");
57
+ element.setAttribute("value", "print_by_checkboxes");
58
+ element.setAttribute("name", "___display_method___");
59
+
60
+ //Append the element in form
61
+ form.append(element);
62
+
63
+ form.submit();
64
+ form.remove();
65
+ }
66
+
67
+ </script>
68
+ <a href="#" class="btn" onclick="submit_in_new_window('<%= settings[:form_id] %>'); return false;"><i class="icon-print"></i>&nbsp;
69
+ Tisknout výběr</a>
70
+ <% end %>
71
+ <% end %>
72
+ </div>
73
+ </div>
74
+ <% end %>
75
+ <%= form_tag settings[:filter_path], :html => {:'data-type' => 'html'}, :method => 'POST', :class => 'well dataGrid no_hover editable_table', :remote => true, :id => settings[:form_id] do |f| %>
76
+ <% if settings[:display_method].blank? %>
77
+ <% if content_for?(:table_form) %>
78
+ <%= yield :table_form %>
79
+ <% end %>
80
+ <% end %>
81
+
82
+ <fieldset>
83
+ <%= render :partial => "/helpers/editable_table/build_table_filter", :locals => {:settings => settings} %>
84
+
85
+ <% if settings[:display_method].blank? %>
86
+ <% unless settings[:per_page].blank? %>
87
+ <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),
88
+ :onchange => "form_submit_watcher('#{settings[:form_id]}')",
89
+ :class => "") %></span>
90
+ <% end %>
91
+
92
+ <div class="<%= settings[:form_id] + '_ajax_pager' %>">
93
+ <%= render :partial => 'helpers/editable_table/build_table_pager', :locals => {:settings => settings, :placement => "placement-up"} %>
94
+ </div>
95
+
96
+ <% end %>
97
+
98
+ <%= render :partial => "/helpers/editable_table/build_table_wrapper", :locals => {:settings => settings} %>
99
+
100
+ <% if settings[:display_method].blank? %>
101
+ <div class="<%= settings[:form_id] + '_ajax_pager' %>">
102
+ <%= render :partial => 'helpers/editable_table/build_table_pager', :locals => {:settings => settings, :placement => "placement-down"} %>
103
+ </div>
104
+ <% end %>
105
+ </fieldset>
106
+ <% end %>
107
+
108
+
109
+
110
+ <div id="modal_cell_editing" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
111
+ <!--<div class="modal-header">-->
112
+ <!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>-->
113
+ <!--<h3 id="myModalLabel">Modal header</h3>-->
114
+ <!--</div>-->
115
+ <!--<div class="modal-body">-->
116
+ <!--<p>One fine body…</p>-->
117
+ <!--</div>-->
118
+ <!--<div class="modal-footer">-->
119
+ <!--<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>-->
120
+ <!--<button class="btn btn-primary">Save changes</button>-->
121
+ <!--</div>-->
122
+ </div>
123
+ <script type="text/javascript">
124
+ EditableTableModalDialog.init('modal_cell_editing')
125
+ </script>
126
+
127
+
128
+
@@ -0,0 +1,14 @@
1
+ <% settings[:data].each do |row| %>
2
+ <tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
3
+ <td class="sortdiv_td">
4
+ <%#= link_to t('edit'), {:controller => :users_rights, :action => :edit, :id => item.id}, :class => "icon modify" %>
5
+ <%#= link_to(t('delete'), {:controller => :users_rights, :action => :delete, :id => item.id}, :confirm => 'Are you sure you want to delete this user?', :title => 'Delete', :method => :delete) -%>
6
+ </td>
7
+ <% settings[:columns].each do |col| %>
8
+ <td class="sortdiv_td">
9
+ <%= row.send(col[:name]) %>
10
+ </td>
11
+ <% end %>
12
+ </tr>
13
+ <% end %>
14
+
@@ -0,0 +1,70 @@
1
+ <%#= form_tag settings[:filter_path], :html => {:'data-type' => 'html'}, :method => 'POST', :class => 'forms', :remote => true,:id => settings[:form_id] do |f| %>
2
+ <fieldset>
3
+ <%#= label_tag :find, "Hledat" %>
4
+ <%#= text_field_tag :find, settings[:default][:find], {:class => 'text', :id => settings[:form_id] + "_live_search"} %>
5
+ <%#= submit_tag "Filter",{:class => 'button'} %>
6
+ </fieldset>
7
+
8
+ <%= hidden_field_tag :checkbox_pool, (settings[:params].blank? || settings[:params][:checkbox_pool].blank?)? "" : settings[:params][:checkbox_pool], :id => settings[:form_id] + '_checkbox_pool' %>
9
+
10
+ <%= hidden_field_tag :default_order_by, settings[:default][:order].blank? ? settings[:default][:order_by] + " " + settings[:default][:order_by_direction] : settings[:default][:order], :id => settings[:form_id] + '_default_order_by' %>
11
+ <%= hidden_field_tag :order_by, settings[:params][:order_by], :id => settings[:form_id] + '_order_by' %>
12
+ <%#= hidden_field_tag :order_by_direction, settings[:default][:order_by_direction], :id => settings[:form_id] + '_order_by_direction' %>
13
+ <%= hidden_field_tag :page, settings[:default][:page], :id => settings[:form_id] + '_page' %>
14
+
15
+ <%# end %>
16
+
17
+ <%#= javascript_include_tag '/assets/backbone_js/tmpl.min.js' %>
18
+ <script type="text/javascript">
19
+ $(document).ready(function () {
20
+ <% if settings[:template].blank? %>
21
+ ladas_loading_show();
22
+ var initial_parsed_data = jQuery.parseJSON('<%= j settings.to_json.html_safe %>');
23
+ var html_from_json = EditableTableBuilder.render_tbody(initial_parsed_data);
24
+ TableSummaries.refresh(initial_parsed_data);
25
+
26
+ $("#<%= settings[:form_id] %>_ajax_content").html(html_from_json);
27
+ apply_modifiers_of_the_table($("#<%= settings[:form_id] %>_ajax_content"));
28
+ EditableTableAligner.align_table(initial_parsed_data, false);
29
+ ladas_loading_hide();
30
+ <% end %>
31
+ formatLinkForPaginationURL('<%= settings[:form_id] %>');
32
+ FilterChangeMarker.mark_active_filters('<%= settings[:form_id] %>');
33
+
34
+
35
+ $("#<%= settings[:form_id] %>")
36
+ .live("ajax:beforeSend", function (evt, xhr, settings) {
37
+ ladas_loading_show();
38
+ })
39
+ .live("ajax:complete", function (evt, xhr, status) {
40
+ var parsed_response = jQuery.parseJSON(xhr.responseText);
41
+
42
+ //console.log(xhr.responseText)
43
+ //console.log(parsed_response);
44
+ //console.log(parsed_response['settings']);
45
+ $(".<%= settings[:form_id] %>_ajax_pager").html(parsed_response['paginate']);
46
+
47
+ //console.log(ladas_build_table('template-ajax-table', parsed_response));
48
+ <% if settings[:template].blank? %>
49
+ var parsed_settings = jQuery.parseJSON(parsed_response['settings'])
50
+ var html_from_json = EditableTableBuilder.render_tbody(parsed_settings);
51
+ console.log("created")
52
+ TableSummaries.refresh(parsed_settings);
53
+ console.log("summaries")
54
+
55
+ $("#<%= settings[:form_id] %>_ajax_content").html(html_from_json);
56
+ apply_modifiers_of_the_table($("#<%= settings[:form_id] %>_ajax_content"));
57
+ EditableTableAligner.align_table(parsed_settings, true);
58
+ console.log("aligned")
59
+
60
+ <% else %>
61
+ var raw_html = parsed_response['settings']
62
+ $("#<%= settings[:form_id] %>_ajax_content").html(raw_html);
63
+ <% end %>
64
+
65
+ ladas_loading_hide();
66
+ formatLinkForPaginationURL('<%= settings[:form_id] %>');
67
+ })
68
+ });
69
+ </script>
70
+