This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
AuctionatorSearchQuery.lua
executable file
·110 lines (87 loc) · 2.46 KB
/
AuctionatorSearchQuery.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Auctionator.SearchQuery = {
text = '',
filter = nil,
minLevel = nil,
maxLevel = nil,
parentKey = nil,
subClassKey = nil,
resolvedKey = nil,
filterResolved = false,
exactMatch = false,
advanced = false
}
function Auctionator.SearchQuery:new( options )
options = options or {}
setmetatable( options, self )
self.__index = self
return options
end
function Auctionator.SearchQuery:Start()
end
function Auctionator.SearchQuery:ToString()
if self.advanced then
return self.text .. [[ (Advanced)]]
else
return self.text
end
end
function Auctionator.SearchQuery:RecentToString()
local buffer = { self.text }
local levelBuffer = {}
if not self.filterResolved then
self:Filter()
end
if self.resolvedKey ~= nil then
table.insert( buffer, [[(]] .. self.resolvedKey .. [[)]] )
end
if self.minLevel ~= nil then
table.insert( levelBuffer, self.minLevel )
end
if self.minLevel ~= nil and self.maxLevel ~= nil then
table.insert( levelBuffer, '-' )
end
if self.maxLevel ~= nil then
table.insert( levelBuffer, self.maxLevel )
end
if self.minLevel ~= nil or self.maxLevel ~= nil then
table.insert( buffer, table.concat( levelBuffer, '' ) )
end
if self.exactMatch then
table.insert( buffer, '(exact)' )
end
return table.concat( buffer, ' ' )
end
function Auctionator.SearchQuery:Filter()
-- TODO: This could be made easier by tracking state on dropdown click in AuctionatorShop
if not self.filterResolved and self.filter == nil then
if self.subClassKey and self.subClassKey ~= 0 then
self.resolvedKey = self.subClassKey
self.filter = Auctionator.FilterLookup[ self.subClassKey ].filter
elseif self.parentKey and self.parentKey ~= 0 then
self.resolvedKey = self.parentKey
self.filter = Auctionator.FilterLookup[ self.parentKey ].filter
end
self.filterResolved = true
end
return self.filter
end
function Auctionator.SearchQuery:SearchText()
return Auctionator.Util.UTF8_Truncate( self.text )
end
function Auctionator.SearchQuery:SearchMinLevel()
if self.minLevel == 0 then
return nil
else
return self.minLevel
end
end
function Auctionator.SearchQuery:SearchMaxLevel()
if self.maxLevel == 0 then
return nil
else
return self.maxLevel
end
end
function Auctionator.SearchQuery:ToParams( currentPage )
return self:SearchText(), self:SearchMinLevel(), self:SearchMaxLevel(), currentPage, nil, nil, false, self.exactMatch, self.filter
end