liquid_feedback_frontend

view app/main/suggestion/_list.lua @ 978:e4ceb185092e

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

Impressum / About Us