filter tab bugfix/refactoring
This commit is contained in:
@@ -25,6 +25,7 @@ end
|
|||||||
function OPEN()
|
function OPEN()
|
||||||
frame:Show()
|
frame:Show()
|
||||||
update_search_listings()
|
update_search_listings()
|
||||||
|
update_filter_display()
|
||||||
end
|
end
|
||||||
|
|
||||||
function CLOSE()
|
function CLOSE()
|
||||||
|
|||||||
+21
-25
@@ -5,6 +5,9 @@ local money = require 'aux.util.money'
|
|||||||
local cache = require 'aux.core.cache'
|
local cache = require 'aux.core.cache'
|
||||||
local filter_util = require 'aux.util.filter'
|
local filter_util = require 'aux.util.filter'
|
||||||
|
|
||||||
|
local post_filter = T
|
||||||
|
local post_filter_index = 0
|
||||||
|
|
||||||
function valid_level(str)
|
function valid_level(str)
|
||||||
local level = tonumber(str)
|
local level = tonumber(str)
|
||||||
return level and bounded(1, 60, level)
|
return level and bounded(1, 60, level)
|
||||||
@@ -177,8 +180,7 @@ function clear_form()
|
|||||||
UIDropDownMenu_ClearAll(quality_dropdown)
|
UIDropDownMenu_ClearAll(quality_dropdown)
|
||||||
filter_parameter_input:ClearFocus()
|
filter_parameter_input:ClearFocus()
|
||||||
wipe(post_filter)
|
wipe(post_filter)
|
||||||
wipe(filter_builder_state)
|
post_filter_index = 0
|
||||||
filter_builder_state.selected = 0
|
|
||||||
update_filter_display()
|
update_filter_display()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -202,15 +204,14 @@ function formatted_post_filter(components)
|
|||||||
for i, component in ipairs(components) do
|
for i, component in ipairs(components) do
|
||||||
if no_line_break then
|
if no_line_break then
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
elseif i > 1 then
|
end
|
||||||
str = str .. '</p><p>'
|
str = str .. '</p><p>'
|
||||||
for _ = 1, getn(stack) do
|
for _ = 1, getn(stack) + 1 do
|
||||||
str = str .. color.content.background('----')
|
str = str .. color.content.background('----')
|
||||||
end
|
|
||||||
end
|
end
|
||||||
no_line_break = component[1] == 'operator' and component[2] == 'not'
|
no_line_break = component[1] == 'operator' and component[2] == 'not'
|
||||||
|
|
||||||
local filter_color = (filter_builder_state.selected == i and color.gold or color.orange)
|
local filter_color = (post_filter_index == i and color.gold or color.orange)
|
||||||
local component_text = filter_color(component[2])
|
local component_text = filter_color(component[2])
|
||||||
if component[1] == 'operator' and component[2] ~= 'not' then
|
if component[1] == 'operator' and component[2] ~= 'not' then
|
||||||
component_text = component_text .. filter_color(tonumber(component[3]) or '')
|
component_text = component_text .. filter_color(tonumber(component[3]) or '')
|
||||||
@@ -236,42 +237,37 @@ function formatted_post_filter(components)
|
|||||||
str = str .. data_link(i, component_text)
|
str = str .. data_link(i, component_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
return '<html><body><p>' .. str .. '</p></body></html>'
|
return '<html><body><p>' .. data_link(0, 'Post Filter:') .. '</p><p>' .. str .. '</p></body></html>'
|
||||||
end
|
end
|
||||||
|
|
||||||
function data_link(id, str)
|
function data_link(id, str)
|
||||||
return '|H' .. id .. '|h' .. str .. '|h'
|
return format('<a href="%s">%s</a>', id, str)
|
||||||
end
|
end
|
||||||
|
|
||||||
post_filter = T
|
|
||||||
filter_builder_state = O('selected', 0)
|
|
||||||
|
|
||||||
function data_link_click()
|
function data_link_click()
|
||||||
local button = arg3
|
local button = arg3
|
||||||
local index = tonumber(arg1)
|
local index = tonumber(arg1)
|
||||||
if button == 'LeftButton' then
|
if button == 'LeftButton' then
|
||||||
filter_builder_state.selected = index
|
post_filter_index = index
|
||||||
elseif button == 'RightButton' then
|
elseif button == 'RightButton' and index > 0 then
|
||||||
remove_component(index)
|
remove_component(index)
|
||||||
end
|
end
|
||||||
update_filter_display()
|
update_filter_display()
|
||||||
end
|
end
|
||||||
|
|
||||||
function remove_component(index)
|
function remove_component(index)
|
||||||
index = index or filter_builder_state.selected
|
|
||||||
if filter_builder_state.selected >= index then
|
|
||||||
filter_builder_state.selected = max(filter_builder_state.selected - 1, min(1, getn(post_filter)))
|
|
||||||
end
|
|
||||||
filter_builder_state[post_filter[index]] = nil
|
|
||||||
tremove(post_filter, index)
|
tremove(post_filter, index)
|
||||||
|
if post_filter_index >= index then
|
||||||
|
post_filter_index = max(post_filter_index - 1, min(1, getn(post_filter)))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function add_component(component)
|
function add_component(component)
|
||||||
filter_builder_state.selected = filter_builder_state.selected + 1
|
post_filter_index = post_filter_index + 1
|
||||||
tinsert(post_filter, filter_builder_state.selected, component)
|
tinsert(post_filter, post_filter_index, component)
|
||||||
end
|
end
|
||||||
|
|
||||||
function add_post_filter()
|
function add_form_component()
|
||||||
local str = filter_input:GetText()
|
local str = filter_input:GetText()
|
||||||
if str then
|
if str then
|
||||||
local filter = filter_util.filters[str]
|
local filter = filter_util.filters[str]
|
||||||
@@ -280,7 +276,7 @@ function add_post_filter()
|
|||||||
str = str .. '/' .. filter_parameter_input:GetText()
|
str = str .. '/' .. filter_parameter_input:GetText()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local components, error, suggestions = filter_util.parse_filter_string(str)
|
local components, error = filter_util.parse_filter_string(str)
|
||||||
if components and getn(components.blizzard) == 0 and getn(components.post) == 1 then
|
if components and getn(components.blizzard) == 0 and getn(components.post) == 1 then
|
||||||
add_component(components.post[1])
|
add_component(components.post[1])
|
||||||
update_filter_display()
|
update_filter_display()
|
||||||
@@ -335,7 +331,7 @@ function initialize_filter_dropdown()
|
|||||||
'func', function()
|
'func', function()
|
||||||
filter_input:SetText(this.value)
|
filter_input:SetText(this.value)
|
||||||
if index(filter_util.filters[this.value], 'input_type') == '' or this.value == 'not' then
|
if index(filter_util.filters[this.value], 'input_type') == '' or this.value == 'not' then
|
||||||
add_post_filter()
|
add_form_component()
|
||||||
elseif filter_util.filters[this.value] then
|
elseif filter_util.filters[this.value] then
|
||||||
filter_parameter_input:Show()
|
filter_parameter_input:Show()
|
||||||
filter_parameter_input:SetFocus()
|
filter_parameter_input:SetFocus()
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ do
|
|||||||
_G[dropdown:GetName() .. 'Text']:Hide()
|
_G[dropdown:GetName() .. 'Text']:Hide()
|
||||||
local label = gui.label(dropdown, gui.font_size.medium)
|
local label = gui.label(dropdown, gui.font_size.medium)
|
||||||
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
|
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
|
||||||
label:SetText('Post Filter')
|
label:SetText('Component')
|
||||||
filter_dropdown = dropdown
|
filter_dropdown = dropdown
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
@@ -459,7 +459,7 @@ do
|
|||||||
if filter_parameter_input:IsVisible() then
|
if filter_parameter_input:IsVisible() then
|
||||||
filter_parameter_input:SetFocus()
|
filter_parameter_input:SetFocus()
|
||||||
else
|
else
|
||||||
add_post_filter()
|
add_form_component()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
filter_input = input
|
filter_input = input
|
||||||
@@ -472,7 +472,7 @@ do
|
|||||||
filter_input:SetFocus()
|
filter_input:SetFocus()
|
||||||
end)
|
end)
|
||||||
input.char = function() this:complete() end
|
input.char = function() this:complete() end
|
||||||
input.enter = add_post_filter
|
input.enter = add_form_component
|
||||||
input:Hide()
|
input:Hide()
|
||||||
filter_parameter_input = input
|
filter_parameter_input = input
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user