Fix search bug.

This commit is contained in:
BoHung Chiu 2021-12-19 18:01:23 +08:00
parent 9e53640351
commit 22ce8d5f1a
1 changed files with 6 additions and 3 deletions

View File

@ -181,10 +181,13 @@ class UniversalTablesController < ApplicationController
if params["column"].present?
keywords = params["q"]
keywords = keywords.strip.nil? ? keywords : keywords.strip
column = table.table_columns.where(:key => params["column"]).first
if column.make_categorizable
regex = Regexp.new(".*"+keywords+".*", "i")
else
regexes = keywords.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/)
regex = Regexp.union(regexes.map{|word| Regexp.new(".*"+word+".*", "i")})
column = table.table_columns.where(:key => params["column"]).first
end
if params["sort"].present?
column_to_sort = table.table_columns.where(:key => params["sortcolumn"]).first
case column_to_sort.type