-
Notifications
You must be signed in to change notification settings - Fork 2
/
EventHandlers.lua
58 lines (50 loc) · 1.53 KB
/
EventHandlers.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
--- Event handlers related to archivespace search, event registration usually in main.lua
function CallNumberSubmitCheck(sender, args)
if tostring(args.KeyCode) == "Return: 13" then
performSearch(searchTerm, 'call number')
end
end
function TitleSubmitCheck(sender, args)
if tostring(args.KeyCode) == "Return: 13" then
performSearch(collectionTitle, 'title')
end
end
function EADIDSubmitCheck(sender, args)
if tostring(args.KeyCode) == "Return: 13" then
performSearch(eadidTerm, 'ead_id')
end
end
function BarcodeSubmitCheck(sender, args)
if tostring(args.KeyCode) == "Return: 13" then
performSearch(barcodeTerm, 'barcode')
end
end
function performSearch(field, fieldName)
if field.Value == nil or field.Value == '' then
LogDebug('Containers '.. fieldName ..' search run but no search term provided')
else
local res = nil
if field == eadidTerm then
collectionTitle.Value = ''
searchTerm.Value = ''
barcodeTerm.Value = ''
res = getTopContainersByEADID(field.Value)
elseif field == collectionTitle then
eadidTerm.Value = ''
searchTerm.Value = ''
barcodeTerm.Value = ''
res = getTopContainersByTitle(field.Value)
elseif field == searchTerm then
collectionTitle.Value = ''
eadidTerm.Value = ''
barcodeTerm.Value = ''
res = getTopContainersByCallNumber(field.Value)
elseif field == barcodeTerm then
collectionTitle.Value = ''
searchTerm.Value = ''
eadidTerm.Value = ''
res = getTopContainersByBarcode(field.Value)
end
GetBoxes(convertResultsIntoDataTable(res), fieldName)
end
end