tab/app/views/users/show.html.haml
2015-09-09 21:26:26 +02:00

69 lines
2.3 KiB
Text

%h2= @user.name
%table#transactions.pure-table.pure-table-striped{data: { source: user_path(@user) }}
%thead
%tr
%th Time
%th Amount
%th Peer
%th Issuer
%th Message
%tbody
%tfoot
%tr
%td.bound.input-listen{ 'data-input-type': 'date-range' }
%input.lower-bound{type: 'date', placeholder: 'after'}
= "<= Time <="
%input.upper-bound{type: 'date', placeholder: 'before'}
%td.bound.input-listen{ 'data-input-type': 'number-range' }
%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{ 'data-input-type': 'text' }
%input{type: 'text', placeholder: 'Filter on Issuer'}
%td.input-listen{ 'data-input-type': 'text' }
%input{type: 'text', placeholder: 'Filter on Peer'}
%td.input-listen{ 'data-input-type': 'text' }
%input{type: 'text', placeholder: 'Filter on Message'}
:javascript
$(document).ready(function() {
var table = $('#transactions').DataTable({
processing: true,
serverSide: true,
searching: false,
lengthChange: false,
ordering: false,
ajax: $('#transactions').data('source'),
pagingType: 'full_numbers',
autoWidth: false,
responsive: true,
columns: [
{ data: 'time', name: 'Time', className: 'min-tablet-l'},
{ data: 'amount', name: 'Amount', className: 'min-mobile'},
{ data: 'peer', name: 'Peer', className: 'min-mobile'},
{ data: 'issuer', name: 'Issuer', className: 'min-desktop'},
{ data: 'message', name: 'Message', className: 'min-tablet-p'},
]
});
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()
}
value = td.attr('data-input-type') + ':' + value
if(column.search() !== value) {
column.search(value).draw();
}
});
i = i + 1;
});
});