filter input change, some bugfixes
This commit is contained in:
+26
-45
@@ -192,7 +192,7 @@ function private.clear_form()
|
|||||||
UIDropDownMenu_ClearAll(m.subclass_dropdown)
|
UIDropDownMenu_ClearAll(m.subclass_dropdown)
|
||||||
UIDropDownMenu_ClearAll(m.slot_dropdown)
|
UIDropDownMenu_ClearAll(m.slot_dropdown)
|
||||||
UIDropDownMenu_ClearAll(m.quality_dropdown)
|
UIDropDownMenu_ClearAll(m.quality_dropdown)
|
||||||
m.filter_input:ClearFocus()
|
m.filter_parameter_input:ClearFocus()
|
||||||
m.post_filter = {}
|
m.post_filter = {}
|
||||||
m.filter_builder_state = {selected=0}
|
m.filter_builder_state = {selected=0}
|
||||||
m.update_filter_display()
|
m.update_filter_display()
|
||||||
@@ -209,7 +209,7 @@ end
|
|||||||
|
|
||||||
function private.export_query_string()
|
function private.export_query_string()
|
||||||
m.search_box:SetText(m.get_filter_builder_query())
|
m.search_box:SetText(m.get_filter_builder_query())
|
||||||
m.filter_input:ClearFocus()
|
m.filter_parameter_input:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.formatted_post_filter(components)
|
function public.formatted_post_filter(components)
|
||||||
@@ -223,21 +223,22 @@ function public.formatted_post_filter(components)
|
|||||||
elseif i > 1 then
|
elseif i > 1 then
|
||||||
str = str..'</p><p>'
|
str = str..'</p><p>'
|
||||||
for _=1,getn(stack) do
|
for _=1,getn(stack) do
|
||||||
str = str..aux.gui.inline_color.content.backdrop..'----'..FONT_COLOR_CODE_CLOSE
|
str = str..aux.gui.color.content.backdrop('----')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
no_line_break = component[1] == 'operator' and component[2] == 'not'
|
no_line_break = component[1] == 'operator' and component[2] == 'not'
|
||||||
|
|
||||||
local component_text = component[2]
|
local filter_color = (m.filter_builder_state.selected == i and aux.gui.color.green or aux.gui.color.yellow)
|
||||||
|
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..(tonumber(component[3]) or '')
|
component_text = component_text..filter_color(tonumber(component[3]) or '')
|
||||||
tinsert(stack, component[3])
|
tinsert(stack, component[3])
|
||||||
elseif component[1] == 'filter' then
|
elseif component[1] == 'filter' then
|
||||||
for _, parameter in {component[3]} do
|
for parameter in aux.util.present(component[3]) do
|
||||||
if aux.filter.filters[component[2]].input_type == 'money' then
|
if aux.filter.filters[component[2]].input_type == 'money' then
|
||||||
parameter = aux.money.to_string(aux.money.from_string(parameter), nil, true, nil, nil, true)
|
parameter = aux.money.to_string(aux.money.from_string(parameter), nil, true, nil, nil, true)
|
||||||
end
|
end
|
||||||
component_text = component_text..': '..aux.auction_listing.colors.ORANGE..parameter..FONT_COLOR_CODE_CLOSE or component_text
|
component_text = component_text..filter_color(': ')..aux.gui.color.orange(parameter)
|
||||||
end
|
end
|
||||||
while getn(stack) > 0 and stack[getn(stack)] do
|
while getn(stack) > 0 and stack[getn(stack)] do
|
||||||
local top = tremove(stack)
|
local top = tremove(stack)
|
||||||
@@ -247,11 +248,6 @@ function public.formatted_post_filter(components)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if m.filter_builder_state.selected == i then
|
|
||||||
component_text = aux.auction_listing.colors.GREEN..component_text..FONT_COLOR_CODE_CLOSE
|
|
||||||
else
|
|
||||||
component_text = aux.auction_listing.colors.YELLOW..component_text..FONT_COLOR_CODE_CLOSE
|
|
||||||
end
|
|
||||||
str = str..m.data_link(i, component_text)
|
str = str..m.data_link(i, component_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -290,31 +286,23 @@ function private.add_component(component)
|
|||||||
tinsert(m.post_filter, m.filter_builder_state.selected, component)
|
tinsert(m.post_filter, m.filter_builder_state.selected, component)
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.add_dropdown_component()
|
function private.add_post_filter()
|
||||||
for _, str in {UIDropDownMenu_GetSelectedValue(m.filter_dropdown)} do
|
for str in aux.util.present(m.filter_input:GetText()) do
|
||||||
if not aux.filter.filters[str] and str == 'and' or str == 'or' then
|
for filter in aux.util.present(aux.filter.filters[str]) do
|
||||||
local arity = m.filter_input:GetText()
|
|
||||||
arity = tonumber(arity) and aux.util.round(tonumber(arity))
|
|
||||||
if arity and arity < 2 then
|
|
||||||
aux.log('Invalid operator suffix')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
str = str..(arity or '')
|
|
||||||
end
|
|
||||||
for _, filter in {aux.filter.filters[str]} do
|
|
||||||
if filter.input_type ~= '' then
|
if filter.input_type ~= '' then
|
||||||
str = str..'/'..m.filter_input:GetText()
|
str = str..'/'..m.filter_parameter_input:GetText()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local components, error, suggestions = aux.filter.parse_query_string(str)
|
local components, error, suggestions = aux.filter.parse_query_string(str)
|
||||||
|
|
||||||
if components then
|
if components and getn(components.blizzard) == 0 and getn(components.post) == 1 then
|
||||||
m.add_component(components.post[1])
|
m.add_component(components.post[1])
|
||||||
m.update_filter_display()
|
m.update_filter_display()
|
||||||
m.filter_input:SetText('')
|
m.filter_parameter_input:SetText('')
|
||||||
m.filter_input:ClearFocus()
|
m.filter_input:HighlightText()
|
||||||
else
|
m.filter_input:SetFocus()
|
||||||
|
elseif error then
|
||||||
aux.log(error)
|
aux.log(error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -357,25 +345,18 @@ function private.set_filter_display_offset(x_offset, y_offset)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function private.initialize_filter_dropdown()
|
function private.initialize_filter_dropdown()
|
||||||
local function on_click()
|
for _, filter in {'and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity', 'left', 'utilizable', 'discard'} do
|
||||||
UIDropDownMenu_SetSelectedValue(m.filter_dropdown, this.value)
|
|
||||||
m.filter_button:SetText(this.value)
|
|
||||||
if (not aux.filter.filters[this.value] or aux.filter.filters[this.value].input_type == '') and this.value ~= 'and' and this.value ~= 'or' then
|
|
||||||
m.filter_input:Hide()
|
|
||||||
else
|
|
||||||
local _, _, suggestions = aux.filter.parse_query_string(UIDropDownMenu_GetSelectedValue(m.filter_dropdown)..'/')
|
|
||||||
m.filter_input:SetNumeric(not aux.filter.filters[this.value] or aux.filter.filters[this.value].input_type == 'number')
|
|
||||||
m.filter_input.complete = aux.completion.complete(function() return suggestions or {} end)
|
|
||||||
m.filter_input:Show()
|
|
||||||
m.filter_input:SetFocus()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, filter in {'and', 'or', 'not', 'min-unit-buy', 'max-unit-bid', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity', 'left', 'utilizable', 'discard'} do
|
|
||||||
UIDropDownMenu_AddButton{
|
UIDropDownMenu_AddButton{
|
||||||
text = filter,
|
text = filter,
|
||||||
value = filter,
|
value = filter,
|
||||||
func = on_click,
|
func = function()
|
||||||
|
m.filter_input:SetText(this.value)
|
||||||
|
if aux.filter.filters[this.value] and aux.filter.filters[this.value].input_type ~= '' then
|
||||||
|
m.filter_parameter_input:SetFocus()
|
||||||
|
else
|
||||||
|
m.add_post_filter()
|
||||||
|
end
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+36
-19
@@ -500,7 +500,6 @@ function private.create_frames()
|
|||||||
dropdown:SetScript('OnShow', function()
|
dropdown:SetScript('OnShow', function()
|
||||||
UIDropDownMenu_Initialize(this, m.initialize_slot_dropdown)
|
UIDropDownMenu_Initialize(this, m.initialize_slot_dropdown)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local dropdown = aux.gui.dropdown(m.frame.filter)
|
local dropdown = aux.gui.dropdown(m.frame.filter)
|
||||||
@@ -531,31 +530,49 @@ function private.create_frames()
|
|||||||
private.filter_dropdown = dropdown
|
private.filter_dropdown = dropdown
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local btn = aux.gui.button(m.frame.filter, 16)
|
local input = aux.gui.editbox(m.frame.filter)
|
||||||
btn:SetWidth(150)
|
input:SetPoint('CENTER', m.filter_dropdown, 'CENTER', 0, 0)
|
||||||
btn:SetHeight(25)
|
input:SetWidth(150)
|
||||||
btn:SetPoint('CENTER', m.filter_dropdown, 'CENTER', 0, 0)
|
input:SetScript('OnTabPressed', function()
|
||||||
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
|
m.filter_parameter_input:SetFocus()
|
||||||
btn:SetScript('OnClick', function()
|
end)
|
||||||
if arg1 == 'LeftButton' then
|
input.complete = aux.completion.complete(function() return {'and', 'or', 'not', unpack(aux.util.keys(aux.filter.filters))} end)
|
||||||
m.add_dropdown_component()
|
input:SetScript('OnChar', function()
|
||||||
elseif arg1 == 'RightButton' then
|
this:complete()
|
||||||
m.remove_component()
|
end)
|
||||||
end
|
input:SetScript('OnTextChanged', function()
|
||||||
end)
|
local filter = this:GetText()
|
||||||
private.filter_button = btn
|
if aux.filter.filters[filter] and aux.filter.filters[filter].input_type ~= '' then
|
||||||
|
local _, _, suggestions = aux.filter.parse_query_string(filter..'/')
|
||||||
|
m.filter_parameter_input:SetNumeric(aux.filter.filters[filter].input_type == 'number')
|
||||||
|
m.filter_parameter_input.complete = aux.completion.complete(function() return suggestions or {} end)
|
||||||
|
m.filter_parameter_input:Show()
|
||||||
|
else
|
||||||
|
m.filter_parameter_input:Hide()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
input:SetScript('OnEnterPressed', function()
|
||||||
|
if m.filter_parameter_input:IsVisible() then
|
||||||
|
m.filter_parameter_input:SetFocus()
|
||||||
|
else
|
||||||
|
m.add_post_filter()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
private.filter_input = input
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local input = aux.gui.editbox(m.frame.filter)
|
local input = aux.gui.editbox(m.frame.filter)
|
||||||
input:SetPoint('LEFT', m.filter_dropdown, 'RIGHT', 10, 0)
|
input:SetPoint('LEFT', m.filter_dropdown, 'RIGHT', 10, 0)
|
||||||
input:SetWidth(150)
|
input:SetWidth(150)
|
||||||
input:SetHeight(25)
|
input:SetScript('OnTabPressed', function()
|
||||||
|
m.filter_parameter_input:SetFocus()
|
||||||
|
end)
|
||||||
input:SetScript('OnChar', function()
|
input:SetScript('OnChar', function()
|
||||||
this:complete()
|
this:complete()
|
||||||
end)
|
end)
|
||||||
input:SetScript('OnEnterPressed', m.add_dropdown_component)
|
input:SetScript('OnEnterPressed', m.add_post_filter)
|
||||||
input:Hide()
|
input:Hide()
|
||||||
private.filter_input = input
|
private.filter_parameter_input = input
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local scroll_frame = CreateFrame('ScrollFrame', nil, m.frame.filter)
|
local scroll_frame = CreateFrame('ScrollFrame', nil, m.frame.filter)
|
||||||
@@ -672,7 +689,7 @@ function private.create_frames()
|
|||||||
}
|
}
|
||||||
|
|
||||||
private.recent_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.recent)
|
private.recent_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.recent)
|
||||||
m.recent_searches_listing:SetColInfo({{name='Recent Searches', width=1}})
|
m.recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
|
||||||
m.recent_searches_listing:EnableSorting(false)
|
m.recent_searches_listing:EnableSorting(false)
|
||||||
m.recent_searches_listing:DisableSelection(true)
|
m.recent_searches_listing:DisableSelection(true)
|
||||||
m.recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
|
m.recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
|
||||||
@@ -680,7 +697,7 @@ function private.create_frames()
|
|||||||
m.recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
|
m.recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
|
||||||
|
|
||||||
private.favorite_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.favorite)
|
private.favorite_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.favorite)
|
||||||
m.favorite_searches_listing:SetColInfo({{name='Favorite Searches', width=1}})
|
m.favorite_searches_listing:SetColInfo{{name='Favorite Searches', width=1}}
|
||||||
m.favorite_searches_listing:EnableSorting(false)
|
m.favorite_searches_listing:EnableSorting(false)
|
||||||
m.favorite_searches_listing:DisableSelection(true)
|
m.favorite_searches_listing:DisableSelection(true)
|
||||||
m.favorite_searches_listing:SetHandler('OnClick', handlers.OnClick)
|
m.favorite_searches_listing:SetHandler('OnClick', handlers.OnClick)
|
||||||
|
|||||||
+8
-2
@@ -1,7 +1,13 @@
|
|||||||
local m, public, private = aux.module'util'
|
local m, public, private = aux.module'util'
|
||||||
|
|
||||||
function public.present(value)
|
function public.present(...)
|
||||||
return value ~= nil and {[value]=true} or {}
|
local called
|
||||||
|
return function()
|
||||||
|
if not called then
|
||||||
|
called = true
|
||||||
|
return unpack(arg)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.unpack(array, ...)
|
function public.unpack(array, ...)
|
||||||
|
|||||||
Reference in New Issue
Block a user