tabulatr2 0.9.12 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +1 -0
- data/app/assets/javascripts/tabulatr/_storage.js +9 -9
- data/app/assets/javascripts/tabulatr/_tabulatr.js +16 -68
- data/app/assets/stylesheets/tabulatr/application.css.scss +133 -112
- data/app/views/tabulatr/_tabulatr_filter_dialog.html.slim +69 -65
- data/app/views/tabulatr/_tabulatr_filter_menu.html.slim +3 -8
- data/app/views/tabulatr/_tabulatr_table.html.slim +24 -23
- data/lib/tabulatr/data/dsl.rb +12 -12
- data/lib/tabulatr/data/filtering.rb +1 -1
- data/lib/tabulatr/renderer/column.rb +4 -1
- data/lib/tabulatr/version.rb +1 -1
- data/spec/lib/tabulatr/data/dsl_spec.rb +31 -0
- data/spec/lib/tabulatr/renderer/renderer_spec.rb +11 -1
- data/tabulatr.gemspec +1 -1
- metadata +6 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c84d124ea6a79ae026aa59ba8a1365a1bc6ae16
|
4
|
+
data.tar.gz: 85d817921b527a2a5ab2f0427080b64d14830a86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8de26639ec20250a03e347ee476320bd9f7eddf964bd5893266828c77350d35ccebe99cc3f8ab4e9de82e04280235c8a932cc7b76a89d7ad5244a45313c97635
|
7
|
+
data.tar.gz: 7a003812abef8c87fbe511f3950c9d9d9d31312190a13720d7c996a3c1a8d4f5f760dd71d5e27a338b9691c9532fd9f080ff0fad68603469524dd3cb5dba50b7
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -344,6 +344,7 @@ the columns in the block of `table_for`.
|
|
344
344
|
wrap: nil,
|
345
345
|
th_html: false,
|
346
346
|
filter_html: false,
|
347
|
+
filter_label: nil,
|
347
348
|
filter: true, # whether this column should be filterable
|
348
349
|
sortable: true, # whethter this column should be sortable
|
349
350
|
format: nil,
|
@@ -2,11 +2,11 @@ $(function(){
|
|
2
2
|
Tabulatr.prototype.retrieveTableFromLocalStorage = function(response){
|
3
3
|
var currentStorage = JSON.parse(localStorage[this.id]);
|
4
4
|
if(currentStorage !== undefined){
|
5
|
-
$('.pagination[data-table='+ this.id +'] a[data-page='+ response.meta.page +']');
|
5
|
+
$('.pagination[data-table='+ this.id +'] a[data-page='+ response.meta.page +']');
|
6
6
|
var $table = $('#' + this.id);
|
7
7
|
var tableName = this.id.split('_')[0];
|
8
|
-
|
9
|
-
|
8
|
+
var sortParam = currentStorage[tableName +'_sort'];
|
9
|
+
if(sortParam && sortParam != ''){
|
10
10
|
var header = $table.find('th.tabulatr-sortable[data-tabulatr-column-name="'+ sortParam.split(' ')[0] +'"]');
|
11
11
|
header.attr('data-sorted', sortParam.split(' ')[1]);
|
12
12
|
header.addClass('sorted');
|
@@ -18,11 +18,11 @@ $(function(){
|
|
18
18
|
for(var i = 0; i < objKeys.length; i++){
|
19
19
|
elem = $('[name="'+ objKeys[i] +'"]');
|
20
20
|
if(elem.length > 0){
|
21
|
-
|
21
|
+
var val = currentStorage[objKeys[i]];
|
22
|
+
elem.val(val);
|
22
23
|
formParent = elem.parents('.form-group[data-filter-column-name]');
|
23
|
-
if(formParent.length > 0){
|
24
|
-
|
25
|
-
formParent.siblings('[data-filter-column-name="_submit"]').show();
|
24
|
+
if(formParent.length > 0 && val && val.length > 0){
|
25
|
+
$('.tabulatr-outer-wrapper[data-table-id="'+this.id+'"]').addClass('filtered')
|
26
26
|
}
|
27
27
|
}
|
28
28
|
}
|
@@ -34,8 +34,8 @@ $(function(){
|
|
34
34
|
localStorage.removeItem(this.id);
|
35
35
|
$('table#'+ this.id).find('th.sorted').removeClass('sorted').removeAttr('data-sorted');
|
36
36
|
$('form[data-table='+ this.id +'] input.search').val('');
|
37
|
-
$('[data-table-id="'+ this.id +'"] [data-filter-column-name]').
|
37
|
+
$('[data-table-id="'+ this.id +'"] [data-filter-column-name]').find('input[type=text], input[type=hidden], select').val('');
|
38
38
|
$('.tabulatr_filter_form[data-table='+ this.id +'] input[name="'+ tableName +'_sort"]').val('');
|
39
39
|
this.updateTable({page: 1}, true);
|
40
40
|
};
|
41
|
-
});
|
41
|
+
});
|
@@ -357,6 +357,10 @@ $(document).on('ready page:load', function(){
|
|
357
357
|
return false;
|
358
358
|
});
|
359
359
|
|
360
|
+
$('form.tabulatr_filter_form input, form.tabulatr_filter_form select').change(function(){
|
361
|
+
$(this).parents('form.tabulatr_filter_form').submit();
|
362
|
+
});
|
363
|
+
|
360
364
|
$('form.tabulatr_filter_form').submit(function(){
|
361
365
|
var tableId = $(this).data('table');
|
362
366
|
var table_obj;
|
@@ -369,32 +373,6 @@ $(document).on('ready page:load', function(){
|
|
369
373
|
return false;
|
370
374
|
});
|
371
375
|
|
372
|
-
$('.tabulatr_table').on('click', 'i.tabulatr_remove_filter', function(){
|
373
|
-
var $th = $(this).closest('th');
|
374
|
-
var name = $th.data('tabulatr-form-name').
|
375
|
-
replace(/\[(like|checkbox|from|to)\]/, '');
|
376
|
-
name = name.replace(/(:|\.|\[|\])/g,'\\$1');
|
377
|
-
$th.removeClass('tabulatr_filtered_column');
|
378
|
-
if($('[name^='+ name +']').is(':checkbox')){
|
379
|
-
$('[name^='+ name +']').prop('checked', false);
|
380
|
-
}else{
|
381
|
-
$('[name^='+ name +']').val('');
|
382
|
-
}
|
383
|
-
var tableId = $(this).closest('.tabulatr_table').attr('id');
|
384
|
-
$(this).remove();
|
385
|
-
var table_obj;
|
386
|
-
for(var i = 0; i < tabulatr_tables.length; i++){
|
387
|
-
if(tabulatr_tables[i].id == tableId){
|
388
|
-
table_obj = tabulatr_tables[i];
|
389
|
-
}
|
390
|
-
}
|
391
|
-
if(table_obj.hasInfiniteScrolling){
|
392
|
-
$('.pagination_trigger[data-table='+ tableId +']').bind('inview', cbfn);
|
393
|
-
}
|
394
|
-
table_obj.updateTable({});
|
395
|
-
return false;
|
396
|
-
});
|
397
|
-
|
398
376
|
$('.tabulatr_mark_all').click(function(){
|
399
377
|
var tableId = $(this).parents('table').prop('id');
|
400
378
|
var table_obj;
|
@@ -472,8 +450,10 @@ $(document).on('ready page:load', function(){
|
|
472
450
|
});
|
473
451
|
|
474
452
|
$(document).on('click', 'a[data-tabulatr-reset]',function(){
|
453
|
+
var a = $(this);
|
475
454
|
var tableObj, tableName;
|
476
|
-
var tableId =
|
455
|
+
var tableId = a.data('tabulatrReset');
|
456
|
+
a.parents('.tabulatr-outer-wrapper').removeClass('filtered')
|
477
457
|
for(var i = 0; i < tabulatr_tables.length; i++){
|
478
458
|
if(tabulatr_tables[i].id == tableId){
|
479
459
|
tableObj = tabulatr_tables[i];
|
@@ -511,6 +491,12 @@ $(document).on('ready page:load', function(){
|
|
511
491
|
tableObj.updateTable({}, false);
|
512
492
|
});
|
513
493
|
}
|
494
|
+
|
495
|
+
$(document).on('click', 'a[data-show-filters-for]', function(){
|
496
|
+
var a = $(this);
|
497
|
+
a.parents('.tabulatr-outer-wrapper').addClass('filtered');
|
498
|
+
});
|
499
|
+
|
514
500
|
});
|
515
501
|
|
516
502
|
$(document).on('click', '.pagination a[data-page]', function(){
|
@@ -533,52 +519,14 @@ $(document).on('click', '.pagination a[data-page]', function(){
|
|
533
519
|
});
|
534
520
|
|
535
521
|
|
536
|
-
// TODO: We absolutely need to clean that up!
|
537
|
-
|
538
|
-
$(document).on('click', 'a[data-show-table-filter]', function(){
|
539
|
-
var a = $(this);
|
540
|
-
var name = a.data('show-table-filter');
|
541
|
-
var tableId = a.parents('.tabulatr-filter-menu-wrapper').data('table-id');
|
542
|
-
var filterForm = $('.tabulatr_filter_form[data-table="'+ tableId +'"]');
|
543
|
-
filterForm.find($('div[data-filter-column-name="'+ name +'"]')).show('blind');
|
544
|
-
filterForm.find($('div[data-filter-column-name="_submit"]')).show('blind');
|
545
|
-
|
546
|
-
a.hide();
|
547
|
-
return false;
|
548
|
-
});
|
549
|
-
|
550
|
-
$(document).on('click', 'a[data-hide-table-filter]', function(){
|
551
|
-
var a = $(this);
|
552
|
-
var nam = a.data('hide-table-filter');
|
553
|
-
var filterForm = a.parents('.tabulatr_filter_form');
|
554
|
-
var t = filterForm.find($('div[data-filter-column-name="'+nam+'"]'));
|
555
|
-
t.hide();
|
556
|
-
t.find('input[type=text]').val("");
|
557
|
-
t.find('select').val('');
|
558
|
-
var filterMenu = $('.tabulatr-filter-menu-wrapper[data-table-id="'+ filterForm.data('table') +'"]');
|
559
|
-
filterMenu.find($('a[data-show-table-filter="'+nam+'"]')).show();
|
560
|
-
if (filterForm.find($('div[data-filter-column-name]:visible')).length <= 2)
|
561
|
-
filterForm.find($('div[data-filter-column-name="_submit"]')).hide('blind');
|
562
|
-
|
563
|
-
var tableId = filterForm.data('table');
|
564
|
-
var table_obj;
|
565
|
-
for(var i = 0; i < tabulatr_tables.length; i++){
|
566
|
-
if(tabulatr_tables[i].id == tableId){
|
567
|
-
table_obj = tabulatr_tables[i];
|
568
|
-
}
|
569
|
-
}
|
570
|
-
table_obj.submitFilterForm();
|
571
|
-
return false;
|
572
|
-
});
|
573
|
-
|
574
522
|
$(document).on('change', 'select[data-tabulatr-date-filter]', function() {
|
575
523
|
var select = $(this);
|
576
524
|
var option = select.find('option:selected');
|
577
525
|
var val = option.val();
|
578
526
|
if (val === 'from_to') {
|
579
|
-
select.parents('.
|
527
|
+
select.parents('.tabulatr-filter-row').find(".from_to").show().removeClass('hidden');
|
580
528
|
} else {
|
581
|
-
select.parents('.
|
529
|
+
select.parents('.tabulatr-filter-row').find(".from_to").hide().val('');
|
582
530
|
}
|
583
531
|
});
|
584
532
|
|
@@ -601,4 +549,4 @@ var cbfn = function(event, isInView, visiblePartX, visiblePartY) {
|
|
601
549
|
table_obj.updateTable({append: true});
|
602
550
|
}
|
603
551
|
}
|
604
|
-
};
|
552
|
+
};
|
@@ -19,156 +19,177 @@
|
|
19
19
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
.tabulatr-
|
23
|
-
opacity: 0.3;
|
24
|
-
}
|
22
|
+
.tabulatr-outer-wrapper {
|
25
23
|
|
26
|
-
.tabulatr-
|
27
|
-
|
28
|
-
}
|
24
|
+
.tabulatr-filter-col {
|
25
|
+
display:none;
|
26
|
+
}
|
27
|
+
.tabulatr-table-col {
|
28
|
+
@extend .col-xs-12;
|
29
|
+
}
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
&.filtered {
|
32
|
+
.tabulatr-filter-col {
|
33
|
+
display:block;
|
34
|
+
@extend .col-xs-4;
|
35
|
+
@extend .col-sm-3;
|
36
|
+
@extend .col-lg-2;
|
37
|
+
}
|
38
|
+
.tabulatr-table-col {
|
39
|
+
@extend .col-xs-8;
|
40
|
+
@extend .col-sm-9;
|
41
|
+
@extend .col-lg-10;
|
42
|
+
}
|
43
|
+
a[data-show-filters-for] {
|
44
|
+
display: none;
|
45
|
+
}
|
46
|
+
}
|
33
47
|
|
34
|
-
|
35
|
-
|
36
|
-
}
|
48
|
+
.tabulatr-sort{
|
49
|
+
opacity: 0.3;
|
50
|
+
}
|
37
51
|
|
38
|
-
.
|
39
|
-
|
40
|
-
}
|
52
|
+
.tabulatr-sort:hover{
|
53
|
+
cursor: pointer;
|
54
|
+
}
|
41
55
|
|
42
|
-
.
|
43
|
-
|
44
|
-
a.active{
|
45
|
-
background-color: red;
|
56
|
+
.sorted{
|
57
|
+
opacity: 1;
|
46
58
|
}
|
47
|
-
}
|
48
59
|
|
49
|
-
.
|
50
|
-
|
51
|
-
|
52
|
-
vertical-align: middle;
|
53
|
-
}
|
60
|
+
.popover .tabulatr_filter_form {
|
61
|
+
width: 400px;
|
62
|
+
}
|
54
63
|
|
55
|
-
.
|
56
|
-
|
57
|
-
}
|
64
|
+
.tabulatr_filtered_column{
|
65
|
+
text-decoration: underline;
|
66
|
+
}
|
58
67
|
|
59
|
-
.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
68
|
+
.tabulatr-per-page {
|
69
|
+
margin: 20px 10px;
|
70
|
+
a.active{
|
71
|
+
background-color: red;
|
72
|
+
}
|
73
|
+
}
|
64
74
|
|
65
|
-
|
66
|
-
|
67
|
-
|
75
|
+
.table-controls div{
|
76
|
+
margin: 20px 10px;
|
77
|
+
display: inline-block;
|
78
|
+
vertical-align: middle;
|
79
|
+
}
|
68
80
|
|
81
|
+
.table-controls i, .tabulatr_table i{
|
82
|
+
margin-right: 5px;
|
83
|
+
}
|
69
84
|
|
85
|
+
.table-controls .form-inline{
|
86
|
+
display: inline-block;
|
87
|
+
position: relative;
|
88
|
+
vertical-align: top;
|
89
|
+
}
|
70
90
|
|
71
|
-
|
72
|
-
|
73
|
-
}
|
91
|
+
#tabulatr-wrench{
|
92
|
+
margin-left: 10px;
|
93
|
+
}
|
74
94
|
|
75
|
-
th.tabulatr-sortable {
|
76
|
-
|
95
|
+
th.tabulatr-sortable {
|
96
|
+
cursor: pointer;
|
77
97
|
|
78
|
-
|
98
|
+
&.sorted {
|
79
99
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
100
|
+
&[data-sorted=asc] {
|
101
|
+
&:after {
|
102
|
+
content: " \25B2";
|
103
|
+
margin-left: 5px;
|
104
|
+
}
|
84
105
|
}
|
85
|
-
}
|
86
106
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
107
|
+
&[data-sorted=desc] {
|
108
|
+
&:after {
|
109
|
+
content: " \25BC";
|
110
|
+
margin-left: 5px;
|
111
|
+
}
|
91
112
|
}
|
92
113
|
}
|
93
114
|
}
|
94
|
-
}
|
95
115
|
|
96
|
-
table.tabulatr_table {
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
116
|
+
table.tabulatr_table {
|
117
|
+
td, th {
|
118
|
+
&[align=right] {
|
119
|
+
text-align: right;
|
120
|
+
}
|
101
121
|
|
102
|
-
|
103
|
-
|
122
|
+
&[align=center] {
|
123
|
+
text-align: center;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
tr.empty_row{
|
127
|
+
display: none;
|
104
128
|
}
|
105
129
|
}
|
106
|
-
tr.empty_row{
|
107
|
-
display: none;
|
108
|
-
}
|
109
|
-
}
|
110
130
|
|
111
|
-
.tabulatr-table-controls-wrapper {
|
112
|
-
|
113
|
-
|
131
|
+
.tabulatr-table-controls-wrapper {
|
132
|
+
display: block;
|
133
|
+
padding-top: 10px;
|
114
134
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
135
|
+
.tabulatr-filter-menu-wrapper {
|
136
|
+
display: inline-block;
|
137
|
+
padding: 20px 0 20px 0;
|
138
|
+
}
|
119
139
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
140
|
+
.tabulatr-batch-actions-menu-wrapper {
|
141
|
+
display: inline-block;
|
142
|
+
padding: 20px 0 20px 20px;
|
143
|
+
}
|
124
144
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
145
|
+
.tabulatr-paginator-wrapper {
|
146
|
+
display: inline-block;
|
147
|
+
padding: 0;
|
148
|
+
text-align: center;
|
129
149
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
150
|
+
.pagination{
|
151
|
+
margin: 10px 0;
|
152
|
+
vertical-align: middle;
|
153
|
+
}
|
134
154
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
155
|
+
.pagination_trigger{
|
156
|
+
width: 1px;
|
157
|
+
height: 1px;
|
158
|
+
position: relative;
|
159
|
+
float: left;
|
160
|
+
opacity: 1;
|
161
|
+
}
|
141
162
|
}
|
142
|
-
}
|
143
163
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
164
|
+
.tabulatr-info-string-wrapper {
|
165
|
+
display: inline-block;
|
166
|
+
padding: 20px 20px 20px 0;
|
167
|
+
}
|
148
168
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
169
|
+
.tabulatr-fuzzy-search-field-wrapper {
|
170
|
+
display: inline-block;
|
171
|
+
float: right;
|
172
|
+
padding: 20px 0 20px 0;
|
173
|
+
}
|
154
174
|
|
155
|
-
|
156
|
-
|
175
|
+
.tabulatr-filter-dialog-wrapper {
|
176
|
+
display: block;
|
157
177
|
|
158
|
-
|
159
|
-
|
178
|
+
.submit-table{
|
179
|
+
z-index: 2;
|
180
|
+
}
|
160
181
|
}
|
161
182
|
}
|
162
|
-
}
|
163
183
|
|
164
|
-
.tabulatr-table-controls-wrapper.row{
|
165
|
-
|
166
|
-
}
|
184
|
+
.tabulatr-table-controls-wrapper.row{
|
185
|
+
margin: 0;
|
186
|
+
}
|
167
187
|
|
168
|
-
.tabulatr-spinner-box{
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
188
|
+
.tabulatr-spinner-box{
|
189
|
+
width: 100%;
|
190
|
+
height: 50px;
|
191
|
+
display: none;
|
192
|
+
position: relative;
|
193
|
+
text-align: center;
|
194
|
+
}
|
174
195
|
}
|
@@ -20,70 +20,74 @@
|
|
20
20
|
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
.tabulatr-filter-popover title="Filter" data-table=table_id
|
24
|
+
form.form.tabulatr_filter_form data-table=table_id data-remote="true" role='form'
|
25
|
+
.panel.panel-default
|
26
|
+
.panel-heading
|
27
|
+
= t('tabulatr.filter')
|
28
|
+
.btn-group.pull-right
|
29
|
+
a.tabulatr-reset-table.btn.btn-danger.btn-xs data-tabulatr-reset=table_id
|
30
|
+
= fa_icon :remove
|
31
|
+
a.tabulatr-submit-table.btn.btn-primary.btn-xs
|
32
|
+
= fa_icon 'arrow-right'
|
33
|
+
.panel-body
|
34
|
+
.wech style='text-indent: -2000px; height: 0px'
|
35
|
+
= submit_tag "Anwenden"
|
36
|
+
input name="#{formatted_name}_sort" type="hidden" value=table_options[:order_by]
|
37
|
+
- if table_options[:filter] && columns.select(&:filter).present?
|
38
|
+
- columns.select(&:filter).each do |column|
|
39
|
+
- name = column.full_name
|
40
|
+
.row.tabulatr-filter-row
|
41
|
+
.col-xs-12
|
42
|
+
.control-group.form-group data-filter-column-name=name
|
43
|
+
- iname = "#{formatted_name}_filter[#{name}]"
|
44
|
+
- filter_name = "tabulatr_form_#{name}"
|
31
45
|
|
32
|
-
|
33
|
-
|
46
|
+
label.control-label for=filter_name
|
47
|
+
= column.filter_label || column.human_name
|
34
48
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
.col-sm-11
|
81
|
-
input.tabulatr_filter.form-control type="text" data-tabulatr-attribute="#{name}" name="#{iname}[like]"
|
82
|
-
.col-sm-1
|
83
|
-
= link_to "✕", '#', 'data-hide-table-filter' => name, class: 'form-control btn btn-danger btn-mini'
|
84
|
-
|
85
|
-
.control-group.form-group data-filter-column-name="_submit"
|
86
|
-
label.control-label.col-md-3 for="_submit"
|
87
|
-
|
|
88
|
-
.controls.col-md-9
|
89
|
-
input.submit-table.btn.btn-primary.btn-mini.btn-sm type='submit' value=I18n.t('tabulatr.apply_filters')
|
49
|
+
- if column.filter.is_a?(Hash) || column.filter.is_a?(Array) || column.filter.is_a?(String)
|
50
|
+
select.form-control.no-chosen id=name name=iname
|
51
|
+
- if column.filter.class.is_a?(String)
|
52
|
+
= column.filter
|
53
|
+
- else
|
54
|
+
option
|
55
|
+
= options_for_select(column.filter)
|
56
|
+
- elsif column.filter == :range
|
57
|
+
.col-sm-5
|
58
|
+
input.tabulatr_filter.form-control type="text" id="#{name}_from" data-tabulatr-attribute="#{name}_from" name="#{iname}[from]"
|
59
|
+
span.col-sm-1.text-center —
|
60
|
+
.col-sm-5
|
61
|
+
input.tabulatr_filter.form-control type="text" id="#{name}_to" data-tabulatr-attribute="#{name}_to" name="#{iname}[to]"
|
62
|
+
- elsif column.filter == :checkbox
|
63
|
+
.col-xs-12
|
64
|
+
= select_tag(iname, options_for_select([ \
|
65
|
+
[t('tabulatr.boolean_filter.both'), ""],
|
66
|
+
[t('tabulatr.boolean_filter.no'), "false"],
|
67
|
+
[t('tabulatr.boolean_filter.yes'), "true"]] \
|
68
|
+
), class: 'form-control no-chosen')
|
69
|
+
- elsif column.filter == :exact
|
70
|
+
input.tabulatr_filter.form-control type="text" id="#{name}_exact" data-tabulatr-attribute="#{name}" name="#{iname}"
|
71
|
+
- elsif column.filter == :date
|
72
|
+
select.form-control.no-chosen name="#{iname}[date][simple]" data-tabulatr-date-filter="#{formatted_name}_#{name}_filter"
|
73
|
+
option= I18n.t("tabulatr.date_filter.none")
|
74
|
+
option value="today"= I18n.t("tabulatr.date_filter.today")
|
75
|
+
option value="yesterday"= I18n.t("tabulatr.date_filter.yesterday")
|
76
|
+
option value="this_week"= I18n.t("tabulatr.date_filter.this_week")
|
77
|
+
option value="last_7_days"= I18n.t("tabulatr.date_filter.last_7_days")
|
78
|
+
option value="this_month"= I18n.t("tabulatr.date_filter.this_month")
|
79
|
+
option value="last_30_days"= I18n.t("tabulatr.date_filter.last_30_days")
|
80
|
+
option value="from_to"= I18n.t("tabulatr.date_filter.from_to")
|
81
|
+
.row.from_to.hidden
|
82
|
+
.col-xs-6
|
83
|
+
.control-group
|
84
|
+
label.control-label for="#{formatted_name}_#{name}_filter_from"
|
85
|
+
= "Von"
|
86
|
+
input.tabulatr_filter.form-control.date-picker.hidden.from_to type="text" id="#{formatted_name}_#{name}_filter_from" name="#{iname}[date][from]"
|
87
|
+
.col-xs-6
|
88
|
+
.control-group
|
89
|
+
label.control-label for="#{formatted_name}_#{name}_filter_from"
|
90
|
+
= "Bis"
|
91
|
+
input.tabulatr_filter.form-control.date-picker.from_to.hidden type="text" id="#{formatted_name}_#{name}_filter_to" name="#{iname}[date][to]"
|
92
|
+
- else
|
93
|
+
input.tabulatr_filter.form-control type="text" data-tabulatr-attribute="#{name}" name="#{iname}[like]"
|
@@ -20,11 +20,6 @@
|
|
20
20
|
/ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
- if table_options[:filter] && columns.select(&:filter).present?
|
23
|
-
|
24
|
-
|
25
|
-
i.icon-
|
26
|
-
i.icon-caret-down.glyphicon.glyphicon-chevron-down.fa.fa-caret-down
|
27
|
-
ul.dropdown-menu role="menu" aria-labelledby="dLabel"
|
28
|
-
- columns.select(&:filter).each do |column|
|
29
|
-
li
|
30
|
-
= link_to column.human_name, '#', "data-show-table-filter" => column.full_name
|
23
|
+
a.btn.btn-default data-show-filters-for=table_id href="#"
|
24
|
+
=> t('tabulatr.filter')
|
25
|
+
i.icon-caret-right.glyphicon.glyphicon-chevron-right.fa.fa-caret-right
|
@@ -23,29 +23,30 @@
|
|
23
23
|
klass: klass, classname: classname, table_id: table_id,
|
24
24
|
formatted_name: formatted_name }
|
25
25
|
|
26
|
-
.tabulatr-
|
27
|
-
.tabulatr-filter-
|
28
|
-
= render '/tabulatr/
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
= render '/tabulatr/
|
26
|
+
.row.tabulatr-outer-wrapper data-table-id=table_id
|
27
|
+
.tabulatr-filter-col data-table-id=table_id
|
28
|
+
= render '/tabulatr/tabulatr_filter_dialog', opts
|
29
|
+
.tabulatr-table-col.col-xs-12 data-table-id=table_id
|
30
|
+
.tabulatr-table-controls-wrapper.row data-table-id=table_id
|
31
|
+
.tabulatr-filter-menu-wrapper.col-xs-3.col-sm-1 data-table-id=table_id
|
32
|
+
= render '/tabulatr/tabulatr_filter_menu', opts
|
33
|
+
|
34
|
+
.tabulatr-batch-actions-menu-wrapper.col-xs-3.col-sm-1 data-table-id=table_id
|
35
|
+
= render '/tabulatr/tabulatr_batch_actions_menu', opts
|
36
|
+
|
37
|
+
- if tabulatr_data.search?
|
38
|
+
.tabulatr-fuzzy-search-field-wrapper.col-xs-6.col-sm-2 data-table-id=table_id
|
39
|
+
= render '/tabulatr/tabulatr_fuzzy_search_field', opts
|
40
|
+
|
41
|
+
- if table_options[:pagination_position].in?([:top, :both])
|
42
|
+
.tabulatr-paginator-wrapper.col-xs-12.col-sm-8 data-table-id=table_id
|
43
|
+
= render '/tabulatr/tabulatr_paginator', opts
|
44
|
+
|
45
|
+
|
46
|
+
- if table_options[:counter_position].in?([:top, :both])
|
47
|
+
.tabulatr-info-string-wrapper data-table-id=table_id
|
48
|
+
= render '/tabulatr/tabulatr_info_string', opts
|
49
|
+
= render '/tabulatr/tabulatr_actual_table', opts
|
49
50
|
|
50
51
|
- if table_options[:counter_position].in?([:bottom, :both])
|
51
52
|
.tabulatr-info-string-wrapper data-table-id=table_id
|
data/lib/tabulatr/data/dsl.rb
CHANGED
@@ -46,12 +46,12 @@ module Tabulatr::Data::DSL
|
|
46
46
|
|
47
47
|
def column(name, header: nil, sort_sql: nil, filter_sql: nil, sql: nil, table_column_options: {},
|
48
48
|
classes: nil, width: false, align: false, valign: false, wrap: nil, th_html: false,
|
49
|
-
filter_html: false, filter: true, sortable: true, format: nil, map: true, cell_style: {},
|
49
|
+
filter_html: false, filter_label: nil, filter: true, sortable: true, format: nil, map: true, cell_style: {},
|
50
50
|
header_style: {},
|
51
51
|
&block)
|
52
52
|
@table_columns ||= []
|
53
53
|
table_column_options = {classes: classes, width: width, align: align, valign: valign, wrap: wrap,
|
54
|
-
th_html: th_html, filter_html: filter_html, filter: filter, sortable: sortable,
|
54
|
+
th_html: th_html, filter_html: filter_html, filter_label: filter_label, filter: filter, sortable: sortable,
|
55
55
|
format: format, map: map, cell_style: cell_style, header_style: header_style,
|
56
56
|
header: header
|
57
57
|
}.merge(table_column_options)
|
@@ -59,8 +59,8 @@ module Tabulatr::Data::DSL
|
|
59
59
|
table_column = Tabulatr::Renderer::Column.from(
|
60
60
|
table_column_options.merge(name: name,
|
61
61
|
klass: @base,
|
62
|
-
sort_sql: sort_sql || sql || "#{
|
63
|
-
filter_sql: filter_sql || sql || "#{
|
62
|
+
sort_sql: sort_sql || sql || "#{main_class.quoted_table_name}.#{ActiveRecord::Base.connection.quote_column_name(name)}",
|
63
|
+
filter_sql: filter_sql || sql || "#{main_class.quoted_table_name}.#{ActiveRecord::Base.connection.quote_column_name(name)}",
|
64
64
|
table_name: table_name.to_sym,
|
65
65
|
output: block_given? ? block : ->(record){record.send(name)}))
|
66
66
|
@table_columns << table_column
|
@@ -68,35 +68,35 @@ module Tabulatr::Data::DSL
|
|
68
68
|
|
69
69
|
def association(assoc, name, header: nil, sort_sql: nil, filter_sql: nil, sql: nil, table_column_options: {},
|
70
70
|
classes: nil, width: false, align: false, valign: false, wrap: nil, th_html: false,
|
71
|
-
filter_html: false, filter: true, sortable: true, format: nil, map: true, cell_style: {},
|
71
|
+
filter_html: false, filter_label: nil, filter: true, sortable: true, format: nil, map: true, cell_style: {},
|
72
72
|
header_style: {},
|
73
73
|
&block)
|
74
74
|
@table_columns ||= []
|
75
75
|
table_column_options = {classes: classes, width: width, align: align, valign: valign, wrap: wrap,
|
76
|
-
th_html: th_html, filter_html: filter_html, filter: filter, sortable: sortable,
|
76
|
+
th_html: th_html, filter_html: filter_html, filter_label: filter_label, filter: filter, sortable: sortable,
|
77
77
|
format: format, map: map, cell_style: cell_style, header_style: header_style,
|
78
78
|
header: header
|
79
79
|
}.merge(table_column_options)
|
80
80
|
assoc_klass = main_class.reflect_on_association(assoc.to_sym)
|
81
|
-
t_name = assoc_klass.try(:
|
81
|
+
t_name = assoc_klass.try(:quoted_table_name)
|
82
82
|
table_column = Tabulatr::Renderer::Association.from(
|
83
83
|
table_column_options.merge(name: name, table_name: assoc,
|
84
84
|
klass: assoc_klass.try(:klass),
|
85
|
-
sort_sql: sort_sql || sql || "#{t_name}.#{name}",
|
86
|
-
filter_sql: filter_sql || sql || "#{t_name}.#{name}",
|
87
|
-
output: block_given? ? block : ->(record){record.send(assoc).try(name)}))
|
85
|
+
sort_sql: sort_sql || sql || "#{t_name}.#{ActiveRecord::Base.connection.quote_column_name(name)}",
|
86
|
+
filter_sql: filter_sql || sql || "#{t_name}.#{ActiveRecord::Base.connection.quote_column_name(name)}",
|
87
|
+
output: block_given? ? block : ->(record){a=record.send(assoc); a.try(:read_attribute, name) || a.try(name)}))
|
88
88
|
@table_columns << table_column
|
89
89
|
end
|
90
90
|
|
91
91
|
def actions(header: nil, name: nil, table_column_options: {},
|
92
92
|
classes: nil, width: false, align: false, valign: false, wrap: nil, th_html: false,
|
93
|
-
filter_html: false, filter: true, sortable: true, format: nil, map: true, cell_style: {},
|
93
|
+
filter_html: false, filter_label: nil, filter: true, sortable: true, format: nil, map: true, cell_style: {},
|
94
94
|
header_style: {},
|
95
95
|
&block)
|
96
96
|
raise 'give a block to action column' unless block_given?
|
97
97
|
@table_columns ||= []
|
98
98
|
table_column_options = {classes: classes, width: width, align: align, valign: valign, wrap: wrap,
|
99
|
-
th_html: th_html, filter_html: filter_html, filter: filter, sortable: sortable,
|
99
|
+
th_html: th_html, filter_html: filter_html, filter_label: filter_label, filter: filter, sortable: sortable,
|
100
100
|
format: format, map: map, cell_style: cell_style, header_style: header_style
|
101
101
|
}.merge(table_column_options)
|
102
102
|
table_column = Tabulatr::Renderer::Action.from(
|
@@ -67,7 +67,7 @@ module Tabulatr::Data::Filtering
|
|
67
67
|
|
68
68
|
def apply_condition(n,v)
|
69
69
|
if ['true', 'false'].include?(v)
|
70
|
-
@relation = @relation.where(
|
70
|
+
@relation = @relation.where("#{n.filter_sql} = ?", Tabulatr::Utility.string_to_boolean(v))
|
71
71
|
elsif v.is_a?(String)
|
72
72
|
apply_string_condition("#{n.filter_sql} = ?", v)
|
73
73
|
elsif v.is_a?(Hash)
|
@@ -25,7 +25,7 @@ class Tabulatr::Renderer::Column
|
|
25
25
|
include ActiveModel::Model
|
26
26
|
|
27
27
|
attr_accessor *%i{name header width align valign wrap type th_html filter_html
|
28
|
-
filter filter_width range_filter_symbol
|
28
|
+
filter_label filter filter_width range_filter_symbol
|
29
29
|
sortable table_name block klass format map classes cell_style header_style
|
30
30
|
sort_sql filter_sql output}
|
31
31
|
|
@@ -40,6 +40,7 @@ class Tabulatr::Renderer::Column
|
|
40
40
|
wrap: nil,
|
41
41
|
th_html: false,
|
42
42
|
filter_html: false,
|
43
|
+
filter_label: nil,
|
43
44
|
filter: true,
|
44
45
|
sortable: true,
|
45
46
|
format: nil,
|
@@ -62,6 +63,7 @@ class Tabulatr::Renderer::Column
|
|
62
63
|
wrap: wrap,
|
63
64
|
th_html: th_html,
|
64
65
|
filter_html: filter_html,
|
66
|
+
filter_label: filter_label,
|
65
67
|
filter: filter,
|
66
68
|
sortable: sortable,
|
67
69
|
format: format,
|
@@ -85,6 +87,7 @@ class Tabulatr::Renderer::Column
|
|
85
87
|
self.wrap = hash[:wrap] || self.wrap
|
86
88
|
self.th_html = hash[:th_html] || self.th_html
|
87
89
|
self.filter_html = hash[:filter_html] || self.filter_html
|
90
|
+
self.filter_label = hash[:filter_label] || self.filter_label
|
88
91
|
self.filter = hash[:filter] || self.filter
|
89
92
|
self.sortable = hash[:sortable] || self.sortable
|
90
93
|
self.format = hash[:format] || self.format
|
data/lib/tabulatr/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tabulatr::Data::DSL do
|
4
|
+
class DummySpecClass
|
5
|
+
extend Tabulatr::Data::DSL
|
6
|
+
end
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
DummySpecClass.instance_variable_set('@table_columns', [])
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#column' do
|
13
|
+
it 'escapes table and column names' do
|
14
|
+
allow(DummySpecClass).to receive(:main_class).and_return(Product)
|
15
|
+
DummySpecClass.column(:active)
|
16
|
+
table_column = DummySpecClass.instance_variable_get('@table_columns').first
|
17
|
+
expect(table_column.filter_sql).to match(/\"products\".\"active\"/)
|
18
|
+
expect(table_column.sort_sql).to match(/\"products\".\"active\"/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#association' do
|
23
|
+
it 'escapes table and column names' do
|
24
|
+
allow(DummySpecClass).to receive(:main_class).and_return(Product)
|
25
|
+
DummySpecClass.association(:vendor, :name)
|
26
|
+
table_column = DummySpecClass.instance_variable_get('@table_columns').first
|
27
|
+
expect(table_column.filter_sql).to match(/\"vendors\".\"name\"/)
|
28
|
+
expect(table_column.sort_sql).to match(/\"vendors\".\"name\"/)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Tabulatr::Renderer do
|
4
4
|
|
5
5
|
def double_view
|
6
|
-
view = double(controller: double(controller_name: 'products', action_name: 'index'))
|
6
|
+
view = double(controller: double(controller_name: 'products', action_name: 'index'), render: '')
|
7
7
|
view.instance_variable_set('@_tabulatr_table_index', 0)
|
8
8
|
view
|
9
9
|
end
|
@@ -24,4 +24,14 @@ describe Tabulatr::Renderer do
|
|
24
24
|
expect(renderer.instance_variable_get('@table_options')[:persistent]).to eq true
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
describe '#build_table' do
|
29
|
+
it 'gets columns by their names' do
|
30
|
+
renderer = Tabulatr::Renderer.new(Product, double_view)
|
31
|
+
renderer.build_table(['_buttons'], 'ProductTabulatrData')
|
32
|
+
columns = renderer.instance_variable_get('@columns')
|
33
|
+
expect(columns.count).to be(1)
|
34
|
+
expect(columns.first).to be_instance_of(Tabulatr::Renderer::Buttons)
|
35
|
+
end
|
36
|
+
end
|
27
37
|
end
|
data/tabulatr.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
|
26
26
|
s.add_runtime_dependency('rails', '~> 4.0')
|
27
|
-
s.add_dependency('slim', '~> 2.0
|
27
|
+
s.add_dependency('slim', '~> 2.0')
|
28
28
|
s.add_dependency('tilt', '~> 1.4', '>= 1.4.1')
|
29
29
|
s.add_dependency('font-awesome-rails', '~> 4.0')
|
30
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabulatr2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Horn
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -32,20 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 2.0
|
36
|
-
- - ">="
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: 2.0.0
|
35
|
+
version: '2.0'
|
39
36
|
type: :runtime
|
40
37
|
prerelease: false
|
41
38
|
version_requirements: !ruby/object:Gem::Requirement
|
42
39
|
requirements:
|
43
40
|
- - "~>"
|
44
41
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.0
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 2.0.0
|
42
|
+
version: '2.0'
|
49
43
|
- !ruby/object:Gem::Dependency
|
50
44
|
name: tilt
|
51
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,6 +207,7 @@ files:
|
|
213
207
|
- spec/dummy/public/favicon.ico
|
214
208
|
- spec/features/tabulatrs_spec.rb
|
215
209
|
- spec/lib/tabulatr/data/data_spec.rb
|
210
|
+
- spec/lib/tabulatr/data/dsl_spec.rb
|
216
211
|
- spec/lib/tabulatr/data/filtering_spec.rb
|
217
212
|
- spec/lib/tabulatr/data/formatting_spec.rb
|
218
213
|
- spec/lib/tabulatr/data/pagination_spec.rb
|
@@ -311,6 +306,7 @@ test_files:
|
|
311
306
|
- spec/dummy/public/favicon.ico
|
312
307
|
- spec/features/tabulatrs_spec.rb
|
313
308
|
- spec/lib/tabulatr/data/data_spec.rb
|
309
|
+
- spec/lib/tabulatr/data/dsl_spec.rb
|
314
310
|
- spec/lib/tabulatr/data/filtering_spec.rb
|
315
311
|
- spec/lib/tabulatr/data/formatting_spec.rb
|
316
312
|
- spec/lib/tabulatr/data/pagination_spec.rb
|