tabulatr2 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +71 -27
- data/app/assets/javascripts/tabulatr/application.js +130 -133
- data/app/assets/stylesheets/tabulatr/application.css.scss +153 -0
- data/app/assets/stylesheets/tabulatr/bootstrap2_fixes.css.scss +24 -0
- data/app/views/tabulatr/_tabulatr_actual_table.html.slim +35 -0
- data/app/views/tabulatr/_tabulatr_batch_actions_menu.html.slim +34 -0
- data/app/views/tabulatr/_tabulatr_filter_dialog.html.slim +84 -0
- data/app/views/tabulatr/_tabulatr_filter_menu.html.slim +30 -0
- data/app/views/tabulatr/_tabulatr_fuzzy_search_field.html.slim +24 -0
- data/app/views/tabulatr/_tabulatr_info_string.html.slim +23 -0
- data/app/views/tabulatr/_tabulatr_paginator.html.slim +24 -0
- data/app/views/tabulatr/_tabulatr_static_table.html.slim +33 -0
- data/app/views/tabulatr/_tabulatr_table.html.slim +45 -0
- data/lib/tabulatr/data/column_name_builder.rb +86 -0
- data/lib/tabulatr/data/data.rb +135 -0
- data/lib/tabulatr/data/dsl.rb +61 -0
- data/lib/tabulatr/data/filtering.rb +101 -0
- data/lib/tabulatr/data/formatting.rb +65 -0
- data/lib/tabulatr/data/invoker.rb +37 -0
- data/lib/tabulatr/data/pagination.rb +48 -0
- data/lib/tabulatr/data/proxy.rb +41 -0
- data/lib/tabulatr/{tabulatr/batch_actions.rb → data/sorting.rb} +20 -23
- data/lib/tabulatr/engine.rb +24 -1
- data/lib/tabulatr/generators/railtie.rb +33 -0
- data/lib/tabulatr/generators/resource_override.rb +35 -0
- data/lib/{generators → tabulatr/generators}/tabulatr/install_generator.rb +21 -3
- data/lib/{generators → tabulatr/generators}/tabulatr/templates/tabulatr.yml +3 -1
- data/lib/tabulatr/generators/tabulatr/templates/tabulatr_data.rb +18 -0
- data/lib/tabulatr/json_builder.rb +94 -0
- data/lib/tabulatr/rails/action_controller.rb +36 -0
- data/lib/{initializers → tabulatr/rails}/action_view.rb +6 -3
- data/lib/{initializers → tabulatr/rails}/active_record.rb +11 -19
- data/lib/tabulatr/renderer/action.rb +32 -0
- data/lib/tabulatr/{tabulatr/formattr.rb → renderer/association.rb} +19 -30
- data/lib/tabulatr/renderer/checkbox.rb +36 -0
- data/lib/tabulatr/renderer/column.rb +113 -0
- data/lib/{initializers/mark_as_localizable.rb → tabulatr/renderer/columns.rb} +13 -15
- data/lib/tabulatr/renderer/columns_from_block.rb +56 -0
- data/lib/tabulatr/renderer/renderer.rb +96 -0
- data/lib/tabulatr/utility/utility.rb +46 -0
- data/lib/tabulatr/version.rb +25 -2
- data/lib/tabulatr.rb +45 -4
- data/lib/tabulatr2.rb +1 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +2 -2
- data/spec/dummy/app/controllers/products_controller.rb +27 -3
- data/spec/dummy/app/models/vendor.rb +1 -0
- data/spec/dummy/app/tabulatr_data/product_tabulatr_data.rb +29 -0
- data/spec/dummy/app/views/products/implicit_columns.html.erb +1 -0
- data/spec/dummy/app/views/products/one_item_per_page.html.erb +1 -1
- data/spec/dummy/app/views/products/simple_index.html.erb +6 -4
- data/spec/dummy/app/views/products/stupid_array.html.erb +1 -1
- data/spec/dummy/app/views/products/with_batch_actions.html.erb +10 -0
- data/spec/dummy/config/locales/tabulatr.yml +22 -1
- data/spec/dummy/config/routes.rb +3 -1
- data/spec/features/tabulatrs_spec.rb +53 -11
- data/tabulatr.gemspec +1 -1
- metadata +50 -42
- data/app/assets/images/tabulatr/buttons_lite_background.png +0 -0
- data/app/assets/images/tabulatr/pager_arrow_left.gif +0 -0
- data/app/assets/images/tabulatr/pager_arrow_left_off.gif +0 -0
- data/app/assets/images/tabulatr/pager_arrow_right.gif +0 -0
- data/app/assets/images/tabulatr/pager_arrow_right_off.gif +0 -0
- data/app/assets/images/tabulatr/sort_arrow_down.gif +0 -0
- data/app/assets/images/tabulatr/sort_arrow_down_off.gif +0 -0
- data/app/assets/images/tabulatr/sort_arrow_up.gif +0 -0
- data/app/assets/images/tabulatr/sort_arrow_up_off.gif +0 -0
- data/app/assets/stylesheets/tabulatr/application.css +0 -40
- data/lib/initializers/action_controller.rb +0 -13
- data/lib/tabulatr/tabulatr/adapter/active_record.rb +0 -84
- data/lib/tabulatr/tabulatr/adapter.rb +0 -55
- data/lib/tabulatr/tabulatr/data_cell.rb +0 -132
- data/lib/tabulatr/tabulatr/dummy_record.rb +0 -40
- data/lib/tabulatr/tabulatr/empty_cell.rb +0 -44
- data/lib/tabulatr/tabulatr/filter_cell.rb +0 -145
- data/lib/tabulatr/tabulatr/filter_icon.rb +0 -6
- data/lib/tabulatr/tabulatr/finder/find_for_table.rb +0 -187
- data/lib/tabulatr/tabulatr/finder.rb +0 -64
- data/lib/tabulatr/tabulatr/header_cell.rb +0 -146
- data/lib/tabulatr/tabulatr/json_builder.rb +0 -57
- data/lib/tabulatr/tabulatr/paginator.rb +0 -76
- data/lib/tabulatr/tabulatr/row_builder.rb +0 -128
- data/lib/tabulatr/tabulatr/security.rb +0 -21
- data/lib/tabulatr/tabulatr/settings.rb +0 -158
- data/lib/tabulatr/tabulatr.rb +0 -343
- data/spec/lib/tabulatr/tabulatr/finder/find_for_table_spec.rb +0 -187
- /data/lib/{generators → tabulatr/generators}/tabulatr/templates/tabulatr.rb +0 -0
@@ -0,0 +1,153 @@
|
|
1
|
+
// Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
//
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
// a copy of this software and associated documentation files (the
|
5
|
+
// "Software"), to deal in the Software without restriction, including
|
6
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
// the following conditions:
|
10
|
+
//
|
11
|
+
// The above copyright notice and this permission notice shall be
|
12
|
+
// included in all copies or substantial portions of the Software.
|
13
|
+
//
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
.tabulatr-sort{
|
23
|
+
opacity: 0.3;
|
24
|
+
}
|
25
|
+
|
26
|
+
.tabulatr-sort:hover{
|
27
|
+
cursor: pointer;
|
28
|
+
}
|
29
|
+
|
30
|
+
.sorted{
|
31
|
+
opacity: 1;
|
32
|
+
}
|
33
|
+
|
34
|
+
i.tabulatr_remove_filter:hover{
|
35
|
+
cursor: pointer;
|
36
|
+
}
|
37
|
+
|
38
|
+
.tabulatr_filtered_column{
|
39
|
+
text-decoration: underline;
|
40
|
+
}
|
41
|
+
|
42
|
+
.tabulatr-per-page {
|
43
|
+
margin: 20px 10px;
|
44
|
+
a.active{
|
45
|
+
background-color: red;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
.table-controls div{
|
50
|
+
margin: 20px 10px;
|
51
|
+
display: inline-block;
|
52
|
+
vertical-align: middle;
|
53
|
+
}
|
54
|
+
|
55
|
+
.table-controls i, .tabulatr_table i{
|
56
|
+
margin-right: 5px;
|
57
|
+
}
|
58
|
+
|
59
|
+
.table-controls .form-inline{
|
60
|
+
display: inline-block;
|
61
|
+
position: relative;
|
62
|
+
vertical-align: top;
|
63
|
+
}
|
64
|
+
|
65
|
+
#tabulatr-wrench{
|
66
|
+
margin-left: 10px;
|
67
|
+
}
|
68
|
+
|
69
|
+
.pagination{
|
70
|
+
margin: 20px;
|
71
|
+
vertical-align: middle;
|
72
|
+
}
|
73
|
+
|
74
|
+
.pagination_trigger{
|
75
|
+
width: 1px;
|
76
|
+
height: 1px;
|
77
|
+
position: relative;
|
78
|
+
float: left;
|
79
|
+
opacity: 1;
|
80
|
+
}
|
81
|
+
|
82
|
+
div[data-filter-column-name] {
|
83
|
+
display:none;
|
84
|
+
}
|
85
|
+
|
86
|
+
th.tabulatr-sortable {
|
87
|
+
cursor: pointer;
|
88
|
+
|
89
|
+
&.sorted {
|
90
|
+
|
91
|
+
&[data-sorted=asc] {
|
92
|
+
&:after {
|
93
|
+
content: " \25B2";
|
94
|
+
margin-left: 5px;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
&[data-sorted=desc] {
|
99
|
+
&:after {
|
100
|
+
content: " \25BC";
|
101
|
+
margin-left: 5px;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
table.tabulatr_table {
|
108
|
+
td, th {
|
109
|
+
&[align=right] {
|
110
|
+
text-align: right;
|
111
|
+
}
|
112
|
+
|
113
|
+
&[align=center] {
|
114
|
+
text-align: center;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
.tabulatr-table-controls-wrapper {
|
120
|
+
display: block;
|
121
|
+
padding-top: 10px;
|
122
|
+
|
123
|
+
.tabulatr-filter-menu-wrapper {
|
124
|
+
display: inline-block;
|
125
|
+
padding: 20px 0 20px 0;
|
126
|
+
}
|
127
|
+
|
128
|
+
.tabulatr-batch-actions-menu-wrapper {
|
129
|
+
display: inline-block;
|
130
|
+
padding: 20px 0 20px 20px;
|
131
|
+
}
|
132
|
+
|
133
|
+
.tabulatr-paginator-wrapper {
|
134
|
+
display: inline-block;
|
135
|
+
padding: 0;
|
136
|
+
}
|
137
|
+
|
138
|
+
.tabulatr-info-string-wrapper {
|
139
|
+
display: inline-block;
|
140
|
+
padding: 20px 20px 20px 0;
|
141
|
+
}
|
142
|
+
|
143
|
+
.tabulatr-fuzzy-search-field-wrapper {
|
144
|
+
display: inline-block;
|
145
|
+
float: right;
|
146
|
+
padding: 20px 0 20px 0;
|
147
|
+
}
|
148
|
+
|
149
|
+
.tabulatr-filter-dialog-wrapper {
|
150
|
+
display: block;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
form.tabulatr_filter_form {
|
2
|
+
|
3
|
+
.controls {
|
4
|
+
margin-left: 180px;
|
5
|
+
|
6
|
+
a, input, select { margin-left: 10px; }
|
7
|
+
|
8
|
+
@for $i from 1 through 12 {
|
9
|
+
.col-md-#{$i} {
|
10
|
+
display: inline-block;
|
11
|
+
.span.from_to {
|
12
|
+
min-height: 1px !important;
|
13
|
+
padding-top: 10px;
|
14
|
+
margin-left: 10px;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
.pagination {
|
22
|
+
margin: 0 10px 0 0;
|
23
|
+
padding: 0;
|
24
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
|
23
|
+
table.table.tabulatr_table id=table_id data-path=table_options[:path] data-pagesize=table_options[:pagesize]
|
24
|
+
thead
|
25
|
+
tr
|
26
|
+
- columns.each do |column|
|
27
|
+
th data-tabulatr-column-name=column.full_name align=column.align width=column.width valign=column.valign class="#{column.sortable ? 'tabulatr-sortable' : ''}"
|
28
|
+
= column.human_name
|
29
|
+
tbody
|
30
|
+
tfoot
|
31
|
+
tr.empty_row
|
32
|
+
- columns.each do |column|
|
33
|
+
td data-tabulatr-column-name=column.full_name data-tabulatr-type=column.coltype align=column.align width=column.width valign=column.valign
|
34
|
+
span.pagination_trigger data-table="#{table_id}"
|
35
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
- if table_options[:batch_actions]
|
23
|
+
- iname = "#{classname}_batch"
|
24
|
+
.dropdown
|
25
|
+
a.btn.btn-default data-toggle="dropdown" href="#"
|
26
|
+
i.icon-cog.glyphicon.glyphicon-cog'
|
27
|
+
i.icon-caret-down.glyphicon.glyphicon-caret-down
|
28
|
+
ul.dropdown-menu role="menu" aria-labelledby="dLabel"
|
29
|
+
- table_options[:batch_actions].each do |key, label|
|
30
|
+
li
|
31
|
+
= link_to label, '#', class: "batch-action-inputs", data: { \
|
32
|
+
"do-batch-action-name" => iname, \
|
33
|
+
"do-batch-action" => key, \
|
34
|
+
"table-id" => table_id }
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
|
23
|
+
form.form.form-horizontal.tabulatr_filter_form data-table=table_id data-remote="true" role='form'
|
24
|
+
input name="#{classname}_sort" type="hidden"
|
25
|
+
- if table_options[:filter] && columns.filtered_columns.present?
|
26
|
+
- columns.filtered_columns.each do |column|
|
27
|
+
- name = column.full_name
|
28
|
+
.control-group.form-group data-filter-column-name=name
|
29
|
+
- iname = "#{classname}_filter[#{name}]"
|
30
|
+
- filter_name = "tabulatr_form_#{name}"
|
31
|
+
|
32
|
+
label.control-label.col-md-3 for=filter_name
|
33
|
+
= column.human_name
|
34
|
+
|
35
|
+
.controls.col-md-9.row
|
36
|
+
- if column.filter.is_a?(Hash) || column.filter.is_a?(Array) || column.filter.is_a?(String)
|
37
|
+
select.form-control id=name name=iname
|
38
|
+
- if column.filter.class.is_a?(String)
|
39
|
+
= column.filter
|
40
|
+
- else
|
41
|
+
option
|
42
|
+
= options_for_select(column.filter)
|
43
|
+
- elsif column.filter == :range
|
44
|
+
.col-md-5
|
45
|
+
input.tabulatr_filter.form-control type="text" id="#{name}_from" data-tabulatr-attribute="#{name}_from" name="#{iname}[from]"
|
46
|
+
span.col-md-1.text-center —
|
47
|
+
.col-md-5
|
48
|
+
input.tabulatr_filter.form-control type="text" id="#{name}_to" data-tabulatr-attribute="#{name}_to" name="#{iname}[to]"
|
49
|
+
- elsif column.filter == :checkbox
|
50
|
+
= check_box_tag(iname, column.checkbox_value, false, {})
|
51
|
+
= column.checkbox_label
|
52
|
+
- elsif column.filter == :exact
|
53
|
+
.col-md-11
|
54
|
+
input.tabulatr_filter.form-control type="text" id="#{name}_from" data-tabulatr-attribute="#{name}" name="#{iname}"
|
55
|
+
- elsif column.filter == :date
|
56
|
+
.col-md-3
|
57
|
+
select.form-control name="#{iname}[date][simple]" data-tabulatr-date-filter="#{classname}_#{name}_filter"
|
58
|
+
option= I18n.t("tabulatr.date_filter.none")
|
59
|
+
option value="today"= I18n.t("tabulatr.date_filter.today")
|
60
|
+
option value="yesterday"= I18n.t("tabulatr.date_filter.yesterday")
|
61
|
+
option value="this_week"= I18n.t("tabulatr.date_filter.this_week")
|
62
|
+
option value="last_7_days"= I18n.t("tabulatr.date_filter.last_7_days")
|
63
|
+
option value="this_month"= I18n.t("tabulatr.date_filter.this_month")
|
64
|
+
option value="last_30_days"= I18n.t("tabulatr.date_filter.last_30_days")
|
65
|
+
option value="from_to"= I18n.t("tabulatr.date_filter.from_to")
|
66
|
+
.col-md-1
|
67
|
+
.col-md-3
|
68
|
+
input.tabulatr_filter.form-control.date-picker.hidden.from_to type="text" id="#{classname}_#{name}_filter_from" name="#{iname}[date][from]"
|
69
|
+
.col-md-1.text-center
|
70
|
+
.span.from_to.hidden
|
71
|
+
|—
|
72
|
+
.col-md-3
|
73
|
+
input.tabulatr_filter.form-control.date-picker.from_to.hidden type="text" id="#{classname}_#{name}_filter_to" name="#{iname}[date][to]"
|
74
|
+
- else
|
75
|
+
.col-md-11
|
76
|
+
input.tabulatr_filter.form-control type="text" id="#{name}_from" data-tabulatr-attribute="#{name}" name="#{iname}[like]"
|
77
|
+
.col-md-1
|
78
|
+
= link_to "✕", '#', 'data-hide-table-filter' => name, class: 'form-control btn btn-danger btn-mini'
|
79
|
+
|
80
|
+
.control-group.form-group data-filter-column-name="_submit"
|
81
|
+
label.control-label.col-md-3 for="_submit"
|
82
|
+
|
|
83
|
+
.controls.col-md-9
|
84
|
+
input.submit-table.btn.btn-primary.btn-mini.btn-sm type='submit' value=I18n.t('tabulatr.apply_filters')
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
- if table_options[:filter] && columns.filtered_columns.present?
|
23
|
+
.dropdown
|
24
|
+
a.btn.btn-default data-toggle="dropdown" href="#"
|
25
|
+
i.icon-filter.glyphicon.glyphicon-filter'
|
26
|
+
i.icon-caret-down.glyphicon.glyphicon-caret-down
|
27
|
+
ul.dropdown-menu role="menu" aria-labelledby="dLabel"
|
28
|
+
- columns.filtered_columns.each do |column|
|
29
|
+
li
|
30
|
+
= link_to column.human_name, '#', "data-show-table-filter" => column.full_name
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
form#product_fuzzy_search.form-inline.tabulatr-fuzzy-search.pull-right data-table=table_id role="form"
|
23
|
+
.form-group
|
24
|
+
input.form-control.search id="#{klass.name.underscore}_fuzzy_search_query" placeholder="Search" type="search"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
div.tabulatr_count data-table="#{klass.to_s.downcase}_table" data-format-string=I18n.t('tabulatr.count')
|
23
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
- if table_options[:paginate] == true || ((table_options[:paginate].is_a?(Fixnum)) && klass.count > table_options[:paginate])
|
23
|
+
.pagination data-table=table_id
|
24
|
+
ul.pagination data-table=table_id
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
table.table.tabulatr_table
|
23
|
+
thead
|
24
|
+
tr
|
25
|
+
- columns.each do |column|
|
26
|
+
th data-tabulatr-column-name=column.full_name align=column.align width=column.width valign=column.valign
|
27
|
+
= column.human_name
|
28
|
+
tbody
|
29
|
+
- records.each do |record|
|
30
|
+
tr
|
31
|
+
- columns.each do |column|
|
32
|
+
td data-tabulatr-column-name=column.full_name data-tabulatr-type=column.coltype align=column.align width=column.width valign=column.valign
|
33
|
+
= column.value_for(record, self)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/ Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
2
|
+
/
|
3
|
+
/ Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
/ a copy of this software and associated documentation files (the
|
5
|
+
/ "Software"), to deal in the Software without restriction, including
|
6
|
+
/ without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
/ distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
/ permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
/ the following conditions:
|
10
|
+
/
|
11
|
+
/ The above copyright notice and this permission notice shall be
|
12
|
+
/ included in all copies or substantial portions of the Software.
|
13
|
+
/
|
14
|
+
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
/ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
/ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
- table_id = "#{klass.to_s.downcase}_table"
|
23
|
+
- opts = { columns: columns, table_options: table_options, \
|
24
|
+
klass: klass, classname: classname, table_id: table_id }
|
25
|
+
|
26
|
+
.tabulatr-table-controls-wrapper data-table-id=table_id
|
27
|
+
.tabulatr-filter-menu-wrapper data-table-id=table_id
|
28
|
+
= render '/tabulatr/tabulatr_filter_menu', opts
|
29
|
+
|
30
|
+
.tabulatr-batch-actions-menu-wrapper data-table-id=table_id
|
31
|
+
= render '/tabulatr/tabulatr_batch_actions_menu', opts
|
32
|
+
|
33
|
+
.tabulatr-paginator-wrapper data-table-id=table_id
|
34
|
+
= render '/tabulatr/tabulatr_paginator', opts
|
35
|
+
|
36
|
+
.tabulatr-info-string-wrapper data-table-id=table_id
|
37
|
+
= render '/tabulatr/tabulatr_info_string', opts
|
38
|
+
|
39
|
+
.tabulatr-fuzzy-search-field-wrapper data-table-id=table_id
|
40
|
+
= render '/tabulatr/tabulatr_fuzzy_search_field', opts
|
41
|
+
|
42
|
+
.tabulatr-filter-dialog-wrapper data-table-id=table_id
|
43
|
+
= render '/tabulatr/tabulatr_filter_dialog', opts
|
44
|
+
|
45
|
+
= render '/tabulatr/tabulatr_actual_table', opts
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2010-2014 Peter Horn & Florian Thomas, Provideal GmbH
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module Tabulatr
|
25
|
+
class Data
|
26
|
+
module ColumnNameBuilder
|
27
|
+
#--
|
28
|
+
# Access the actual data
|
29
|
+
#++
|
30
|
+
def build_column_name(colname, table_name: nil, use_for: nil, assoc_name: nil)
|
31
|
+
if column_with_table? colname
|
32
|
+
t,c = split_column_name_from_table(colname)
|
33
|
+
return build_column_name(c, table_name: t, use_for: use_for)
|
34
|
+
end
|
35
|
+
table_name ||= @table_name
|
36
|
+
if table_name == @table_name
|
37
|
+
mapping = get_mapping(requested_method: @columns[colname.to_sym], usage: use_for)
|
38
|
+
return mapping if mapping.present?
|
39
|
+
else
|
40
|
+
assoc_name = table_name unless assoc_name
|
41
|
+
include_relation! assoc_name
|
42
|
+
mapping = get_mapping(requested_method: @assocs[assoc_name.to_sym][colname.to_sym], usage: use_for)
|
43
|
+
return mapping if mapping.present?
|
44
|
+
end
|
45
|
+
|
46
|
+
complete_column_name table_name, colname
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def split_column_name_from_table column_name
|
52
|
+
if column_with_table?(column_name)
|
53
|
+
column_name.split(/\.|:/)
|
54
|
+
else
|
55
|
+
column_name
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def column_with_table? column_name
|
60
|
+
column_name['.'] || column_name[':']
|
61
|
+
end
|
62
|
+
|
63
|
+
def complete_column_name table, column
|
64
|
+
t = "#{table.tableize}.#{column}"
|
65
|
+
raise "SECURITY violation, field name is '#{t}'" unless /^[\d\w]+(\.[\d\w]+)?$/.match t
|
66
|
+
t
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_mapping requested_method: nil, usage: nil
|
70
|
+
return if requested_method.nil? || usage.nil?
|
71
|
+
case usage.to_sym
|
72
|
+
when :filter
|
73
|
+
requested_method[:filter_sql]
|
74
|
+
when :sort
|
75
|
+
requested_method[:sort_sql]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def include_relation! name_of_relation
|
80
|
+
@includes << name_of_relation.to_sym
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Tabulatr::Data.send :include, Tabulatr::Data::ColumnNameBuilder
|