small filter change

This commit is contained in:
Manuel Simon Hirsig
2016-08-02 21:56:44 +02:00
parent e14279a78b
commit 673835c18b
2 changed files with 8 additions and 26 deletions
+1 -1
View File
@@ -877,7 +877,7 @@ function private.add_post_component()
Aux.log('Invalid operator suffix')
return
end
filter = filter..Aux.filter.operator_suffix(arity)
filter = filter..(arity or '')
end
if Aux.filter.filters[name] and Aux.filter.filters[name].input_type ~= '' then
filter = filter..'/'..m.filter_input:GetText()
+7 -25
View File
@@ -209,19 +209,17 @@ function private.operator(str)
return 'not', 1
end
local _, _, and_op, and_arity = strfind(str, '^(and)(.*)$')
local _, _, or_op, or_arity = strfind(str, '^(or)(.*)$')
local _, _, and_op, and_arity = strfind(str, '^(and)(%d*)$')
local _, _, or_op, or_arity = strfind(str, '^(or)(%d*)$')
local op = and_op or or_op
local arity = and_arity or or_arity
if op then
if arity == '' then
return op, 2
elseif tonumber(arity) and tonumber(arity) > 2 then
return op, tonumber(arity)
elseif arity == '*' then
return op
elseif tonumber(arity) and tonumber(arity) >= 2 then
return op, tonumber(arity)
end
end
end
@@ -518,7 +516,7 @@ function public.query_string(components)
for _, component in components.post do
if component[1] == 'operator' then
prettified.append(component[2]..m.operator_suffix(component[3]))
prettified.append(component[2]..(tonumber(component[3]) or ''))
elseif component[1] == 'filter' then
prettified.append(component[2])
if component[3] then
@@ -547,7 +545,7 @@ function public.indented_post_query_string(components)
if component[1] == 'operator' and component[2] then
no_line_break = component[2] == 'not'
str = str..'|cffffff00'..component[2]..m.operator_suffix(component[3])..'|r'
str = str..'|cffffff00'..component[2]..(tonumber(component[3]) or '')..'|r'
tinsert(stack, component[3] or '*')
elseif component[1] == 'filter' then
str = str..'|cffffff00'..component[2]..'|r'
@@ -590,13 +588,7 @@ function private.prettified_query_string(components)
for _, component in components.post do
if component[1] == 'operator' then
local suffix = ''
if not component[3] then
suffix = '*'
elseif component[3] > 2 then
suffix = component[3]
end
prettified.append('|cffffff00'..component[2]..suffix..'|r')
prettified.append('|cffffff00'..component[2]..(tonumber(component[3]) or '')..'|r')
elseif component[1] == 'filter' then
if component[2] ~= 'tooltip' then
prettified.append('|cffffff00'..component[2]..'|r')
@@ -621,16 +613,6 @@ function public.unquote(name)
return name
end
function public.operator_suffix(arity)
if not arity then
return '*'
elseif arity == 2 then
return ''
else
return arity
end
end
function private.blizzard_query(components)
local filters = {}
for _, filter in components.blizzard do