tab/app/views/users/show.html.haml

64 lines
1.9 KiB
Plaintext
Raw Normal View History

2015-09-08 17:39:13 +00:00
%h2= @user.name
2015-09-08 18:45:32 +00:00
%table#transactions.display{data: { source: user_path(@user) }}
2015-09-08 17:39:13 +00:00
%thead
%tr
%th Amount
%th Origin
%th Message
2015-09-08 18:45:32 +00:00
%th Peer
2015-09-08 17:39:13 +00:00
%th Time
%tr
%td.bound.input-listen
%input.lower-bound{type: 'number', placeholder: 'lower', class: 'pure-u-1-5'}
= "<= Amount <="
%input.upper-bound{type: 'number', placeholder: 'upper', class: 'pure-u-1-5'}
%td.input-listen
%input{type: 'text', placeholder: 'Filter on Origin'}
%td.input-listen
%input{type: 'text', placeholder: 'Filter on Message'}
%td.input-listen
%input{type: 'text', placeholder: 'Filter on Peer'}
%td.bound.input-listen
%input.lower-bound{type: 'date', placeholder: 'after'}
= "<= Time <="
%input.upper-bound{type: 'date', placeholder: 'before'}
2015-09-08 17:39:13 +00:00
%tbody
2015-09-08 18:45:32 +00:00
:javascript
$(document).ready(function() {
var table = $('#transactions').DataTable({
processing: true,
serverSide: true,
searching: true,
ordering: false,
ajax: $('#transactions').data('source'),
pagingType: 'full_numbers',
columns: [
{ data: 'amount', name: 'Amount' },
{ data: 'origin', name: 'Origin' },
{ data: 'message', name: 'Message' },
{ data: 'peer', name: 'Peer' },
{ data: 'time', name: 'Time' }
]
});
var tds = $('.input-listen');
var i = 0;
table.columns().every(function() {
var column = this
tds.eq(i).find('input').on('keyup change', function() {
var value = null;
var td = $(this).parent();
if(td.hasClass('bound')) {
value = td.find('.lower-bound').val() + '~' + td.find('.upper-bound').val();
} else {
value = $(this).val()
}
if(column.search() !== value) {
column.search(value).draw();
}
});
i = i + 1;
});
2015-09-08 18:45:32 +00:00
});