rev |
line source |
bsw/jbe@19
|
1 local search_for = param.get("search_for", atom.string) or "global"
|
bsw@1045
|
2 local search_string = param.get("q", atom.string)
|
bsw/jbe@0
|
3
|
bsw@480
|
4 if search_string then
|
bsw@1045
|
5 ui.title ( _("Search results for: '#{search}'", { search = search_string } ) )
|
bsw@480
|
6 else
|
bsw@1045
|
7 ui.title ( _"Search" )
|
bsw/jbe@0
|
8 end
|
bsw/jbe@0
|
9
|
bsw@480
|
10 ui.form{
|
bsw@480
|
11 method = "get", module = "index", view = "search",
|
bsw@480
|
12 routing = { default = { mode = "redirect",
|
bsw@1045
|
13 module = "index", view = "search", search_for = search_for, q = search_string
|
bsw@480
|
14 } },
|
bsw@1045
|
15 attr = { class = "vertical section" },
|
bsw@480
|
16 content = function()
|
bsw@1045
|
17
|
bsw@1045
|
18 ui.sectionHead( function()
|
bsw@1045
|
19 ui.heading { level = 1, content = _"Search" }
|
bsw@1045
|
20 end)
|
bsw@1045
|
21
|
bsw@1045
|
22 ui.sectionRow( function()
|
bsw@1045
|
23 ui.tag { content = _"Search term (only complete words)" }
|
bsw@1045
|
24 ui.tag {
|
bsw@1045
|
25 tag = "input",
|
bsw@1045
|
26 attr = {
|
bsw@1045
|
27 name = "q",
|
bsw@1045
|
28 value = search_string
|
bsw@1045
|
29 }
|
bsw@725
|
30 }
|
bsw@1045
|
31 ui.tag{
|
bsw@1045
|
32 tag = "input",
|
bsw@1045
|
33 attr = {
|
bsw@1045
|
34 class = "btn btn-search",
|
bsw@1045
|
35 type = "submit",
|
bsw@1045
|
36 value = _"search"
|
bsw@1045
|
37 }
|
bsw@1045
|
38 }
|
bsw@1045
|
39 end )
|
bsw@480
|
40 end
|
bsw@480
|
41 }
|
bsw@480
|
42
|
bsw@480
|
43
|
bsw@1045
|
44 if not search_string then
|
bsw@1045
|
45 return
|
bsw@1045
|
46 end
|
bsw@1045
|
47
|
bsw/jbe@19
|
48
|
bsw@1045
|
49 local members_selector = Member:get_search_selector(search_string)
|
bsw@1045
|
50 local count = members_selector:count()
|
bsw@1045
|
51 local text
|
bsw@1045
|
52 if count == 0 then
|
bsw@1045
|
53 text = _"No matching members found"
|
bsw@1045
|
54 elseif count == 1 then
|
bsw@1045
|
55 text = _"1 matching member found"
|
bsw@1045
|
56 else
|
bsw@1045
|
57 text = _"#{count} matching members found"
|
bsw@1045
|
58 end
|
bsw@1045
|
59 if app.session:has_access("everything") then
|
bsw@1045
|
60 ui.section( function()
|
bsw@1045
|
61 ui.sectionHead( function()
|
bsw@1045
|
62 ui.heading { level = 1, content = _(text, { count = count }) }
|
bsw@1045
|
63 end )
|
bsw@1045
|
64 if count > 0 then
|
bsw@725
|
65 execute.view{
|
bsw@725
|
66 module = "member",
|
bsw@725
|
67 view = "_list",
|
bsw@1045
|
68 params = {
|
bsw@1045
|
69 members_selector = members_selector,
|
bsw@1045
|
70 no_filter = true
|
bsw@1045
|
71 },
|
bsw@725
|
72 }
|
bsw@725
|
73 end
|
bsw@1045
|
74 end )
|
bsw@1045
|
75 end
|
bsw@1045
|
76
|
bsw@1045
|
77 slot.put("<br />")
|
bsw@1045
|
78
|
bsw@1045
|
79 local issues_selector = Issue:get_search_selector(search_string)
|
bsw@1045
|
80 local count = issues_selector:count()
|
bsw@1045
|
81 local text
|
bsw@1045
|
82 if count == 0 then
|
bsw@1045
|
83 text = _"No matching issues found"
|
bsw@1045
|
84 elseif count == 1 then
|
bsw@1045
|
85 text = _"1 matching issue found"
|
bsw@1045
|
86 else
|
bsw@1045
|
87 text = _"#{count} matching issues found"
|
bsw@1045
|
88 end
|
bsw@725
|
89
|
bsw@1045
|
90 ui.section( function()
|
bsw@1045
|
91 ui.sectionHead( function()
|
bsw@1045
|
92 ui.heading { level = 1, content = _(text, { count = count }) }
|
bsw@1045
|
93 end )
|
bsw@1045
|
94 if count > 0 then
|
bsw@480
|
95 execute.view{
|
bsw@480
|
96 module = "issue",
|
bsw@1045
|
97 view = "_list2",
|
bsw@480
|
98 params = {
|
bsw@1045
|
99 search = search_string,
|
bsw@480
|
100 no_filter = true
|
bsw@480
|
101 },
|
bsw@480
|
102 }
|
bsw@480
|
103 end
|
bsw@1045
|
104 end)
|