liquid_feedback_frontend

view app/main/issue/_list.lua @ 211:4993b71b383f

First checkin of lf2 (frontend second generation) prototype
author bsw
date Wed Mar 02 20:06:26 2011 +0100 (2011-03-02)
parents 4fb486bce608
children 7196685f9dd7
line source
1 local issues_selector = param.get("issues_selector", "table")
3 if app.session.member_id then
4 issues_selector
5 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id} )
6 :add_field("(_interest.member_id NOTNULL)", "is_interested")
7 end
9 ui.add_partial_param_names{
10 "filter",
11 "filter_open",
12 "filter_voting",
13 "filter_interest",
14 "issue_list"
15 }
17 local filters = execute.load_chunk{module="issue", chunk="_filters.lua"}
19 filters.content = function()
20 local ui_paginate = ui.paginate
21 if param.get("per_page") == "all" then
22 ui_paginate = function(args) args.content() end
23 end
24 ui_paginate{
25 per_page = tonumber(param.get("per_page")),
26 selector = issues_selector,
27 content = function()
28 local highlight_string = param.get("highlight_string", "string")
29 local issues = issues or issues_selector:exec()
30 -- issues:load(initiatives)
31 ui.list{
32 attr = { class = "issues" },
33 records = issues,
34 columns = {
35 {
36 label = _"Issue",
37 content = function(record)
38 if not param.get("for_area_list", atom.boolean) then
39 ui.field.text{
40 value = record.area.name
41 }
42 slot.put("<br />")
43 end
44 if record.is_interested then
45 local label = _"You are interested in this issue",
46 ui.image{
47 attr = { alt = label, title = label },
48 static = "icons/16/eye.png"
49 }
50 slot.put("&nbsp;")
51 end
52 ui.link{
53 text = _("Issue ##{id}", { id = tostring(record.id) }),
54 module = "issue",
55 view = "show",
56 id = record.id
57 }
58 if record.state == "new" then
59 ui.image{
60 static = "icons/16/new.png"
61 }
62 end
63 slot.put("<br />")
64 slot.put("<br />")
65 if record.old_state then
66 ui.field.text{ value = format.time(record.sort) }
67 ui.field.text{ value = Issue:get_state_name_for_state(record.old_state) .. " > " .. Issue:get_state_name_for_state(record.new_state) }
68 else
69 end
70 end
71 },
72 {
73 label = _"State",
74 content = function(record)
75 if record.state == "voting" then
76 ui.link{
77 content = _"Voting",
78 module = "vote",
79 view = "list",
80 params = { issue_id = record.id }
81 }
82 else
83 ui.field.issue_state{ value = record.state }
84 end
85 end
86 },
87 {
88 label = _"Initiatives",
89 content = function(record)
90 local initiatives_selector = record:get_reference_selector("initiatives")
91 local highlight_string = param.get("highlight_string")
92 if highlight_string then
93 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
94 end
95 execute.view{
96 module = "initiative",
97 view = "_list",
98 params = {
99 issue = record,
100 initiatives_selector = initiatives_selector,
101 highlight_string = highlight_string,
102 per_page = app.session.member_id and tonumber(app.session.member:get_setting_value("initiatives_preview_limit") or 3) or 3,
103 no_sort = true,
104 limit = app.session.member_id and tonumber(app.session.member:get_setting_value("initiatives_preview_limit") or 3) or 3
105 }
106 }
107 end
108 },
109 }
110 }
111 end
112 }
113 end
115 filters.selector = issues_selector
116 filters.label = _"Change filters and order"
118 if param.get("no_filter", atom.boolean) then
119 filters.content()
120 else
121 ui.filters(filters)
122 end
124 if param.get("legend", atom.boolean) ~= false then
125 local filter = param.get_all_cgi().filter
126 if not filter or filter == "any" or filter ~= "finished" then
127 ui.bargraph_legend{
128 width = 25,
129 bars = {
130 { color = "#0a0", label = _"Supporter" },
131 { color = "#777", label = _"Potential supporter" },
132 { color = "#ddd", label = _"No support at all" },
133 }
134 }
135 end
136 if not filter or filter == "any" or filter == "finished" then
137 ui.bargraph_legend{
138 width = 25,
139 bars = {
140 { color = "#0a0", label = _"Yes" },
141 { color = "#aaa", label = _"Abstention" },
142 { color = "#a00", label = _"No" },
143 }
144 }
145 end
146 end

Impressum / About Us