rev |
line source |
bsw/jbe@0
|
1 local issues_selector = param.get("issues_selector", "table")
|
bsw/jbe@0
|
2
|
bsw@51
|
3 if app.session.member_id then
|
bsw@51
|
4 issues_selector
|
bsw@51
|
5 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id} )
|
bsw@51
|
6 :add_field("(_interest.member_id NOTNULL)", "is_interested")
|
bsw@51
|
7 end
|
bsw@11
|
8
|
bsw/jbe@19
|
9 ui.add_partial_param_names{
|
bsw/jbe@19
|
10 "filter",
|
bsw/jbe@19
|
11 "filter_open",
|
bsw/jbe@19
|
12 "filter_voting",
|
bsw/jbe@19
|
13 "filter_interest",
|
bsw/jbe@19
|
14 "issue_list"
|
bsw/jbe@19
|
15 }
|
bsw/jbe@0
|
16
|
poelzi@127
|
17 local filters = execute.load_chunk{module="issue", chunk="_filters.lua"}
|
bsw/jbe@19
|
18
|
bsw/jbe@19
|
19 filters.content = function()
|
bsw/jbe@19
|
20 local ui_paginate = ui.paginate
|
bsw/jbe@19
|
21 if param.get("per_page") == "all" then
|
bsw/jbe@19
|
22 ui_paginate = function(args) args.content() end
|
bsw/jbe@19
|
23 end
|
bsw/jbe@19
|
24 ui_paginate{
|
bsw/jbe@19
|
25 per_page = tonumber(param.get("per_page")),
|
bsw/jbe@19
|
26 selector = issues_selector,
|
bsw/jbe@19
|
27 content = function()
|
bsw/jbe@19
|
28 local highlight_string = param.get("highlight_string", "string")
|
bsw/jbe@19
|
29 local issues = issues or issues_selector:exec()
|
bsw/jbe@19
|
30 -- issues:load(initiatives)
|
bsw@273
|
31 ui.container{ attr = { class = "issues" }, content = function()
|
bsw@273
|
32
|
bsw@273
|
33 for i, issue in ipairs(issues) do
|
bsw@273
|
34
|
bsw@273
|
35 local class = "issue"
|
bsw@273
|
36 if issue.is_interested then
|
bsw@273
|
37 class = class .. " interested"
|
bsw@273
|
38 end
|
bsw@273
|
39 ui.container{ attr = { class = class }, content = function()
|
bsw@273
|
40
|
bsw@273
|
41 ui.container{ attr = { class = "issue_info" }, content = function()
|
bsw@273
|
42
|
bsw@273
|
43 ui.tag{
|
bsw@273
|
44 tag = "div",
|
bsw@273
|
45 content = function()
|
bsw@273
|
46 ui.link{
|
bsw@273
|
47 attr = { class = "issue_id" },
|
bsw@273
|
48 text = _("Issue ##{id}", { id = tostring(issue.id) }),
|
bsw@273
|
49 module = "issue",
|
bsw@273
|
50 view = "show",
|
bsw@273
|
51 id = issue.id
|
bsw@273
|
52 }
|
bsw@273
|
53
|
bsw@273
|
54 -- if not param.get("for_area_list", atom.boolean) then
|
bsw@273
|
55 slot.put(" · ")
|
bsw@273
|
56 ui.tag{ content = issue.area.unit.name }
|
bsw@273
|
57 slot.put(" · ")
|
bsw@273
|
58 ui.tag{ content = issue.area.name }
|
bsw@273
|
59 -- end
|
bsw@273
|
60 end
|
bsw/jbe@19
|
61 }
|
bsw@273
|
62 ui.tag{
|
bsw@273
|
63 tag = "div",
|
bsw@273
|
64 content = function()
|
bsw@273
|
65
|
bsw@273
|
66 ui.tag{ content = issue.policy.name }
|
bsw@273
|
67
|
bsw@273
|
68 slot.put(" · ")
|
bsw@273
|
69 ui.tag{ content = issue.state_name }
|
bsw@273
|
70
|
bsw@273
|
71 if issue.state_time_left then
|
bsw@273
|
72 slot.put(" · ")
|
bsw@273
|
73 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left }) }
|
bsw@273
|
74 end
|
bsw@273
|
75
|
bsw@273
|
76 end
|
bsw@273
|
77 }
|
bsw@273
|
78
|
bsw@273
|
79
|
bsw@273
|
80 if issue.old_state then
|
bsw@273
|
81 ui.field.text{ value = format.time(issue.sort) }
|
bsw@273
|
82 ui.field.text{ value = Issue:get_state_name_for_state(issue.old_state) .. " > " .. Issue:get_state_name_for_state(issue.new_state) }
|
bsw/jbe@19
|
83 else
|
bsw/jbe@19
|
84 end
|
bsw@273
|
85 end }
|
bsw@273
|
86
|
bsw@273
|
87 ui.container{ attr = { class = "initiative_list" }, content = function()
|
bsw@273
|
88
|
bsw@273
|
89 local initiatives_selector = issue:get_reference_selector("initiatives")
|
bsw/jbe@19
|
90 local highlight_string = param.get("highlight_string")
|
bsw/jbe@19
|
91 if highlight_string then
|
bsw/jbe@19
|
92 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
|
bsw/jbe@19
|
93 end
|
bsw/jbe@19
|
94 execute.view{
|
bsw/jbe@19
|
95 module = "initiative",
|
bsw/jbe@19
|
96 view = "_list",
|
bsw/jbe@19
|
97 params = {
|
bsw@273
|
98 issue = issue,
|
bsw/jbe@19
|
99 initiatives_selector = initiatives_selector,
|
bsw/jbe@19
|
100 highlight_string = highlight_string,
|
bsw@51
|
101 per_page = app.session.member_id and tonumber(app.session.member:get_setting_value("initiatives_preview_limit") or 3) or 3,
|
bsw/jbe@19
|
102 no_sort = true,
|
bsw@51
|
103 limit = app.session.member_id and tonumber(app.session.member:get_setting_value("initiatives_preview_limit") or 3) or 3
|
bsw/jbe@19
|
104 }
|
bsw/jbe@19
|
105 }
|
bsw@273
|
106 end }
|
bsw@273
|
107 end }
|
bsw@273
|
108 end
|
bsw@273
|
109 end }
|
bsw/jbe@19
|
110 end
|
bsw/jbe@19
|
111 }
|
bsw/jbe@19
|
112 end
|
bsw/jbe@19
|
113
|
bsw/jbe@19
|
114 filters.selector = issues_selector
|
bsw/jbe@19
|
115 filters.label = _"Change filters and order"
|
bsw/jbe@19
|
116
|
bsw/jbe@19
|
117 if param.get("no_filter", atom.boolean) then
|
bsw/jbe@19
|
118 filters.content()
|
bsw/jbe@19
|
119 else
|
bsw/jbe@19
|
120 ui.filters(filters)
|
bsw/jbe@19
|
121 end
|
bsw/jbe@19
|
122
|
bsw/jbe@19
|
123 if param.get("legend", atom.boolean) ~= false then
|
bsw/jbe@19
|
124 local filter = param.get_all_cgi().filter
|
bsw/jbe@19
|
125 if not filter or filter == "any" or filter ~= "finished" then
|
bsw/jbe@19
|
126 ui.bargraph_legend{
|
bsw/jbe@19
|
127 width = 25,
|
bsw/jbe@19
|
128 bars = {
|
bsw/jbe@19
|
129 { color = "#0a0", label = _"Supporter" },
|
bsw/jbe@19
|
130 { color = "#777", label = _"Potential supporter" },
|
bsw/jbe@19
|
131 { color = "#ddd", label = _"No support at all" },
|
bsw/jbe@19
|
132 }
|
bsw/jbe@0
|
133 }
|
bsw/jbe@0
|
134 end
|
bsw/jbe@19
|
135 if not filter or filter == "any" or filter == "finished" then
|
bsw/jbe@19
|
136 ui.bargraph_legend{
|
bsw/jbe@19
|
137 width = 25,
|
bsw/jbe@19
|
138 bars = {
|
bsw/jbe@19
|
139 { color = "#0a0", label = _"Yes" },
|
bsw/jbe@19
|
140 { color = "#aaa", label = _"Abstention" },
|
bsw/jbe@19
|
141 { color = "#a00", label = _"No" },
|
bsw/jbe@19
|
142 }
|
bsw/jbe@19
|
143 }
|
bsw/jbe@19
|
144 end
|
bsw/jbe@19
|
145 end
|
bsw/jbe@19
|
146
|