| rev |
line source |
|
bsw/jbe@4
|
1
|
|
bsw/jbe@4
|
2 local initiative = param.get("initiative", "table")
|
|
bsw/jbe@0
|
3 local suggestions_selector = param.get("suggestions_selector", "table")
|
|
bsw@454
|
4
|
|
bsw@965
|
5 suggestions_selector:add_order_by("plus2_unfulfilled_count + plus1_unfulfilled_count DESC, id")
|
|
bsw@454
|
6
|
|
bsw/jbe@19
|
7 local ui_filters = ui.filters
|
|
bsw@454
|
8 if true or not show_filter then
|
|
bsw/jbe@19
|
9 ui_filters = function(args) args.content() end
|
|
bsw/jbe@19
|
10 end
|
|
bsw/jbe@19
|
11
|
|
bsw@718
|
12
|
|
bsw@978
|
13 ui.tag{ tag = "a", attrs = { name="suggestions" } }
|
|
bsw@718
|
14 ui.container{ attr = { class = "initiative_head" },
|
|
bsw/jbe@0
|
15 content = function()
|
|
bsw@718
|
16 ui.container{ attr = { class = "title" }, content = _"Suggestions" }
|
|
bsw@718
|
17 ui.container{ attr = { class = "content" }, content = function()
|
|
bsw@718
|
18 ui.paginate{
|
|
bsw@718
|
19 selector = suggestions_selector,
|
|
bsw@978
|
20 anchor = "suggestions",
|
|
bsw@718
|
21 content = function()
|
|
bsw@718
|
22 local suggestions = suggestions_selector:exec()
|
|
bsw@718
|
23 if #suggestions < 1 then
|
|
bsw@718
|
24 if not initiative.issue.fully_frozen and not initiative.issue.closed then
|
|
bsw@718
|
25 ui.tag{ content = _"No suggestions yet" }
|
|
bsw@718
|
26 else
|
|
bsw@718
|
27 ui.tag{ content = _"No suggestions" }
|
|
bsw@718
|
28 end
|
|
bsw@718
|
29 else
|
|
bsw@718
|
30 ui.list{
|
|
bsw@718
|
31 attr = { style = "table-layout: fixed;" },
|
|
bsw@718
|
32 records = suggestions,
|
|
bsw@718
|
33 columns = {
|
|
bsw@718
|
34 {
|
|
bsw@718
|
35 label_attr = { style = "width: 101px;" },
|
|
bsw@718
|
36 content = function(record)
|
|
bsw@718
|
37 if record.minus2_unfulfilled_count then
|
|
bsw@718
|
38 local max_value = record.initiative.supporter_count
|
|
bsw@718
|
39 ui.bargraph{
|
|
bsw@718
|
40 max_value = max_value,
|
|
bsw@718
|
41 width = 100,
|
|
bsw@718
|
42 bars = {
|
|
bsw@718
|
43 { color = "#0a0", value = record.plus2_unfulfilled_count + record.plus2_fulfilled_count },
|
|
bsw@718
|
44 { color = "#8f8", value = record.plus1_unfulfilled_count + record.plus1_fulfilled_count },
|
|
bsw@718
|
45 { color = "#eee", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.minus2_fulfilled_count - record.minus1_fulfilled_count - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count},
|
|
bsw@718
|
46 { color = "#f88", value = record.minus1_unfulfilled_count + record.minus1_fulfilled_count },
|
|
bsw@718
|
47 { color = "#a00", value = record.minus2_unfulfilled_count + record.minus2_fulfilled_count },
|
|
bsw@51
|
48 }
|
|
bsw@718
|
49 }
|
|
bsw/jbe@19
|
50 end
|
|
bsw/jbe@5
|
51 end
|
|
bsw@718
|
52 },
|
|
bsw@718
|
53 {
|
|
bsw@718
|
54 content = function(record)
|
|
bsw@718
|
55 ui.link{
|
|
bsw@718
|
56 text = record.name,
|
|
bsw@718
|
57 module = "suggestion",
|
|
bsw@718
|
58 view = "show",
|
|
bsw@718
|
59 id = record.id
|
|
bsw/jbe@4
|
60 }
|
|
bsw@718
|
61 local degree
|
|
bsw@718
|
62 local opinion
|
|
bsw@718
|
63 if app.session.member_id then
|
|
bsw@718
|
64 opinion = Opinion:by_pk(app.session.member.id, record.id)
|
|
bsw@718
|
65 end
|
|
bsw@718
|
66 if opinion then
|
|
bsw@718
|
67 local degrees = {
|
|
bsw@718
|
68 ["-2"] = _"must not",
|
|
bsw@718
|
69 ["-1"] = _"should not",
|
|
bsw@718
|
70 ["0"] = _"neutral",
|
|
bsw@718
|
71 ["1"] = _"should",
|
|
bsw@718
|
72 ["2"] = _"must"
|
|
bsw@718
|
73 }
|
|
bsw@718
|
74 slot.put(" · ")
|
|
bsw@718
|
75 ui.tag{ content = degrees[tostring(opinion.degree)] }
|
|
bsw@718
|
76 slot.put(" · ")
|
|
bsw@718
|
77 if opinion.fulfilled then
|
|
bsw@718
|
78 ui.tag{ content = _"implemented" }
|
|
bsw@718
|
79 else
|
|
bsw@718
|
80 ui.tag{ content = _"not implemented" }
|
|
bsw@718
|
81 end
|
|
bsw@718
|
82 end
|
|
bsw/jbe@4
|
83 end
|
|
bsw@718
|
84 },
|
|
bsw@718
|
85 }
|
|
bsw@718
|
86 }
|
|
bsw@718
|
87 end
|
|
bsw@718
|
88 end
|
|
bsw@718
|
89 }
|
|
bsw@718
|
90 end }
|
|
bsw@720
|
91 if app.session.member_id
|
|
bsw@720
|
92 and not initiative.issue.half_frozen
|
|
bsw@720
|
93 and not initiative.issue.closed
|
|
bsw@720
|
94 and not initiative.revoked
|
|
bsw@720
|
95 and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id)
|
|
bsw@720
|
96 then
|
|
bsw@718
|
97 ui.container{ attr = { class = "content" }, content = function()
|
|
bsw@718
|
98 ui.link{
|
|
bsw@718
|
99 module = "suggestion", view = "new", params = { initiative_id = initiative.id },
|
|
bsw@718
|
100 text = _"New suggestion"
|
|
bsw/jbe@4
|
101 }
|
|
bsw@718
|
102 end }
|
|
bsw@718
|
103 end
|
|
bsw/jbe@0
|
104 end
|
|
bsw/jbe@0
|
105 }
|