module refactoring

This commit is contained in:
Simon Hirsig
2017-11-01 15:01:41 +01:00
parent 9989ceb42f
commit 8823b34904
36 changed files with 669 additions and 646 deletions
+13 -11
View File
@@ -1,5 +1,7 @@
module 'aux.tabs.search'
local T = require 'T'
local completion = require 'aux.util.completion'
local filter_util = require 'aux.util.filter'
local scan = require 'aux.core.scan'
@@ -126,7 +128,7 @@ do
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
btn:SetScript('OnClick', function()
if arg1 == 'RightButton' then
filter = current_search.filter_string
set_filter(get_current_search().filter_string)
end
execute()
end)
@@ -161,7 +163,7 @@ do
return queries and join(map(copy(queries), function(query) return query.prettified end), ';') or color.red(str)
end
editbox.complete = completion.complete_filter
editbox.focus_loss = function() this:SetText(current_search.filter_string or '') end
editbox.focus_loss = function() this:SetText(get_current_search().filter_string or '') end
editbox:SetHeight(25)
editbox.char = function()
this:complete()
@@ -185,7 +187,7 @@ do
btn:SetWidth(243)
btn:SetHeight(22)
btn:SetText('Search Results')
btn:SetScript('OnClick', function() subtab = RESULTS end)
btn:SetScript('OnClick', function() set_subtab(RESULTS) end)
search_results_button = btn
end
do
@@ -194,7 +196,7 @@ do
btn:SetWidth(243)
btn:SetHeight(22)
btn:SetText('Saved Searches')
btn:SetScript('OnClick', function() subtab = SAVED end)
btn:SetScript('OnClick', function() set_subtab(SAVED) end)
saved_searches_button = btn
end
do
@@ -203,7 +205,7 @@ do
btn:SetWidth(243)
btn:SetHeight(22)
btn:SetText('Filter Builder')
btn:SetScript('OnClick', function() subtab = FILTER end)
btn:SetScript('OnClick', function() set_subtab(FILTER) end)
new_filter_button = btn
end
do
@@ -232,8 +234,8 @@ do
btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0)
btn:SetText('Clear')
btn:SetScript('OnClick', function()
while tremove(current_search.records) do end
current_search.table:SetDatabase()
while tremove(get_current_search().records) do end
get_current_search().table:SetDatabase()
end)
end
do
@@ -432,14 +434,14 @@ do
input:SetPoint('CENTER', filter_dropdown, 'CENTER', 0, 0)
input:SetWidth(150)
input:SetScript('OnTabPressed', function() filter_parameter_input:SetFocus() end)
input.complete = completion.complete(function() return temp-A('and', 'or', 'not', unpack(keys(filter_util.filters))) end)
input.complete = completion.complete(function() return T.temp-T.list('and', 'or', 'not', unpack(keys(filter_util.filters))) end)
input.char = function() this:complete() end
input.change = function()
local text = this:GetText()
if filter_util.filters[text] and filter_util.filters[text].input_type ~= '' then
local _, _, suggestions = filter_util.parse_filter_string(text .. '/')
filter_parameter_input:SetNumeric(filter_util.filters[text].input_type == 'number')
filter_parameter_input.complete = completion.complete(function() return suggestions or empty end)
filter_parameter_input.complete = completion.complete(function() return suggestions or T.empty end)
filter_parameter_input:Show()
else
filter_parameter_input:Hide()
@@ -519,7 +521,7 @@ for _ = 1, 5 do
local table = auction_listing.new(frame.results, 16, auction_listing.search_columns)
table:SetHandler('OnClick', function(row, button)
if IsAltKeyDown() and current_search.table:GetSelection().record == row.record then
if IsAltKeyDown() and get_current_search().table:GetSelection().record == row.record then
if button == 'LeftButton' then
buyout_button:Click()
elseif button == 'RightButton' then
@@ -541,7 +543,7 @@ favorite_searches_listing:SetColInfo{{name='Auto Buy', width=.07, align='CENTER'
recent_searches_listing = listing.new(frame.saved.recent)
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
for listing in pairs(temp-S(favorite_searches_listing, recent_searches_listing)) do
for listing in pairs(T.temp-T.set(favorite_searches_listing, recent_searches_listing)) do
for k, v in pairs(handlers) do
listing:SetHandler(k, v)
end