This commit is contained in:
benji 2015-09-11 21:06:22 +02:00
commit eb26d14e40
4 changed files with 33 additions and 15 deletions

View file

@ -4,6 +4,7 @@ ready = function() {
errors = $("#transaction_errors")
panel_ul = $(errors).find(".panel-body ul")
flash_success = $("#transaction_success")
var table = $('#transactions').DataTable({
processing: true,
serverSide: true,
@ -60,6 +61,14 @@ ready = function() {
});
});
// filters
filters = $("#transactions-filters");
filters_body = filters.find(".panel-body");
filters.find(".panel-heading").click( function() {
filters_body.slideToggle();
});
filters_body.hide();
$(form).on("ajax:before", function(xhr, settings) {
$(flash_success).addClass("hidden")
$(submit_button).val("Processing")

View file

@ -30,7 +30,10 @@ table.pure-table-striped {
}
}
.data-table-filters {
#transactions-filters {
.panel-heading {
cursor: pointer;
}
.row {
padding: 10px;
padding-top: 20px;

View file

@ -16,13 +16,11 @@ class DataTable
end
private
def data
run_query(paginated_query.project(Arel.star)).map do |record|
record.reject! {|k,v| k.is_a? Numeric} # Remove unneeded query results
end
run_query(paginated_query.project(Arel.star))
end
def count
run_query(query.project(Arel.star.count)).first[0]
run_query(query.project(Arel.star.count)).first["COUNT(*)"]
end
def paginated_query
@ -64,7 +62,7 @@ class DataTable
end
def run_query query
ActiveRecord::Base.connection.execute(query.to_sql)
ActiveRecord::Base.connection.exec_query(query.to_sql)
end
def sanitize_params(params)

View file

@ -2,36 +2,42 @@
= render 'transactions/new'
.panel.panel-default.data-table-filters
#transactions-filters.panel.panel-default
.panel-heading
%h3.panel-title Filters
.panel-body
.row
.col-md-8.col-md-offset-2
.bound.input-listen{ 'data-input-type': 'date-range', 'data-filter-name': 'Time' }
.bound.input-listen{ 'data-input-type': 'date-range',
'data-filter-name': 'Time' }
.row
.col-md-6
.input-group
%span.input-group-addon
%span.glyphicon.glyphicon-calendar
%input.lower-bound.form-control.filter-align{type: 'date', placeholder: 'After', class: 'pure-group-addon'}
%input.lower-bound.form-control.filter-align{type: 'date',
placeholder: 'After', class: 'pure-group-addon'}
.col-md-6
.input-group
%span.input-group-addon
%span.glyphicon.glyphicon-calendar
%input.upper-bound.form-control.filter-align{type: 'date', placeholder: 'Before', class: 'pure-group-addon'}
.bound.input-listen.pure-u-1{ 'data-input-type': 'number-range', 'data-filter-name': 'Amount' }
%input.upper-bound.form-control.filter-align{type: 'date',
placeholder: 'Before', class: 'pure-group-addon'}
.bound.input-listen.pure-u-1{ 'data-input-type': 'number-range',
'data-filter-name': 'Amount' }
.row
.col-md-6
.input-group
%span.input-group-addon
%span.glyphicon.glyphicon-euro
%input.lower-bound.form-control.filter-align{type: 'number', placeholder: 'Minimum'}
%input.lower-bound.form-control.filter-align{type: 'number',
placeholder: 'Minimum'}
.col-md-6
.input-group
%span.input-group-addon
%span.glyphicon.glyphicon-euro
%input.upper-bound.form-control.filter-align{type: 'number', placeholder: 'Maximum'}
%input.upper-bound.form-control.filter-align{type: 'number',
placeholder: 'Maximum'}
.row
.col-md-4
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Issuer' }
@ -40,10 +46,12 @@
{ data: { placeholder: "Filter on Issuer" }, class: "select2-selector form-control" }
.col-md-4
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Peer' }
%input{type: 'text', placeholder: 'Filter on Peer', class: "form-control" }
%input{type: 'text', placeholder: 'Filter on Peer',
class: "form-control" }
.col-md-4
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Message' }
%input{type: 'text', placeholder: 'Filter on Message', class: "form-control" }
%input{type: 'text', placeholder: 'Filter on Message',
class: "form-control" }
%table#transactions.pure-table.pure-table-striped{data: { source: user_path(@user) }}
%thead