improve (and fix) parsing
This commit is contained in:
parent
dd7fc618b6
commit
d336e778f7
1 changed files with 8 additions and 3 deletions
|
@ -60,7 +60,8 @@ class DataTable
|
||||||
columns: Hash.new
|
columns: Hash.new
|
||||||
}
|
}
|
||||||
params.require(:columns).each do |i, column|
|
params.require(:columns).each do |i, column|
|
||||||
type, value = column.require(:search)[:value].split(':')
|
type, *values = column.require(:search)[:value].split(':')
|
||||||
|
value = values.join(':') unless values.empty?
|
||||||
h = clean[:columns][column.require(:data).to_sym] = {
|
h = clean[:columns][column.require(:data).to_sym] = {
|
||||||
name: column[:name],
|
name: column[:name],
|
||||||
searchable: column[:searchable] == 'true',
|
searchable: column[:searchable] == 'true',
|
||||||
|
@ -68,9 +69,13 @@ class DataTable
|
||||||
type: type
|
type: type
|
||||||
}
|
}
|
||||||
if type == 'number-range'
|
if type == 'number-range'
|
||||||
h[:lower], h[:upper] = value.split('~').map &:to_i
|
h[:lower], h[:upper] = value.split('~').map do |euros|
|
||||||
|
(euros.to_f * 100).to_i rescue nil
|
||||||
|
end
|
||||||
elsif type == 'date-range'
|
elsif type == 'date-range'
|
||||||
h[:lower], h[:upper] = value.split('~').map &:to_datetime
|
h[:lower], h[:upper] = value.split('~').map do |string|
|
||||||
|
string.to_datetime rescue nil
|
||||||
|
end
|
||||||
else
|
else
|
||||||
h[:value] = value
|
h[:value] = value
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue