liquid_feedback_frontend

view env/ui/filters.lua @ 852:376e3ed9b245

Removed not needed code from ui.filters, handle invalid filter options better
author bsw
date Fri Aug 17 00:22:48 2012 +0200 (2012-08-17)
parents 76d7eafb3893
children 701a5cf6b067
line source
1 function ui.filters(args)
2 local el_id = ui.create_unique_id()
3 ui.container{
4 attr = { class = "ui_filter" },
5 content = function()
6 for idx, filter in ipairs(args) do
7 local filter_name = filter.name or "filter"
8 local current_option = atom.string:load(cgi.params[filter_name])
9 if not current_option then
10 current_option = param.get(filter_name)
11 end
12 local current_option_valid = false
13 for idx, option in ipairs(filter) do
14 if current_option == option.name then
15 current_option_valid = true
16 end
17 end
18 if not current_option or #current_option == 0 or not current_option_valid then
19 current_option = filter[1].name
20 end
21 local id = param.get_id_cgi()
22 local params = param.get_all_cgi()
23 ui.container{
24 attr = { class = "ui_filter_head" },
25 content = function()
26 slot.put(filter.label)
27 for idx, option in ipairs(filter) do
28 params[filter_name] = option.name
29 local attr = {}
30 if current_option == option.name then
31 attr.class = "active"
32 option.selector_modifier(args.selector)
33 end
34 if idx > 1 then
35 slot.put(" ")
36 end
37 ui.link{
38 attr = attr,
39 module = request.get_module(),
40 view = request.get_view(),
41 id = id,
42 params = params,
43 text = option.label,
44 partial = {
45 params = {
46 [filter_name] = option.name
47 }
48 }
49 }
50 end
51 end
52 }
53 end
54 end
55 }
56 ui.container{
57 attr = { class = "ui_filter_content" },
58 content = function()
59 args.content()
60 end
61 }
62 end

Impressum / About Us