liquid_feedback_frontend
view app/main/initiative/show_tab.lua @ 19:00d1004545f1
Dynamic interface using XMLHttpRequests, and many other changes
Bugfixes:
- Only allow voting on admitted initiatives
- Repaired issue search
- Don't display delegations for closed issues on member page
- Don't show revoke link in initiative, when issue is already half_frozen
- Localization for voting JavaScript
- Display author of suggestions
Disclosure of voting data after voting is finished:
- Possibility to inspect every ballot including preferences
- Show number of voters preferring one initiative to another initiative
Interface behaviour changes:
- Reversed default order of drafts
- Default order of suggestions changed
- Show new drafts of initiatives only once per day in timeline
Accessibility:
- Barrier-free voting implemented
- POST links are now accessible without JavaScript
- Changed gray for unsatisfied supporters in bar graph to a lighter gray
Other interface improvements:
- Optical enhancements
- Dynamic interface using XMLHttpRequests
- Show usage terms in about section
- Show own membership in area listing
- Show uninformed supporters greyed out and marked with yellow question mark
- Warning box in non-admitted initiatives
- When voted, don't display voting notice and change label of voting link
- Show object counts in more tabulator heads
- Enlarged member statement input field
Miscellaneous:
- Code cleanup
- Added README file containing installation instructions
- Use new WebMCP function ui.filters{...} instead of own ui.filter and ui.order functions
Bugfixes:
- Only allow voting on admitted initiatives
- Repaired issue search
- Don't display delegations for closed issues on member page
- Don't show revoke link in initiative, when issue is already half_frozen
- Localization for voting JavaScript
- Display author of suggestions
Disclosure of voting data after voting is finished:
- Possibility to inspect every ballot including preferences
- Show number of voters preferring one initiative to another initiative
Interface behaviour changes:
- Reversed default order of drafts
- Default order of suggestions changed
- Show new drafts of initiatives only once per day in timeline
Accessibility:
- Barrier-free voting implemented
- POST links are now accessible without JavaScript
- Changed gray for unsatisfied supporters in bar graph to a lighter gray
Other interface improvements:
- Optical enhancements
- Dynamic interface using XMLHttpRequests
- Show usage terms in about section
- Show own membership in area listing
- Show uninformed supporters greyed out and marked with yellow question mark
- Warning box in non-admitted initiatives
- When voted, don't display voting notice and change label of voting link
- Show object counts in more tabulator heads
- Enlarged member statement input field
Miscellaneous:
- Code cleanup
- Added README file containing installation instructions
- Use new WebMCP function ui.filters{...} instead of own ui.filter and ui.order functions
| author | bsw/jbe |
|---|---|
| date | Sat Feb 20 22:10:31 2010 +0100 (2010-02-20) |
| parents | |
| children | 0849be391140 |
line source
1 local initiative = param.get("initiative", "table")
2 local initiator = param.get("initiator", "table")
4 if not initiative then
5 initiative = Initiative:by_id(param.get("initiative_id", atom.number))
6 end
8 if not initiator then
9 initiator = Initiator:by_pk(initiative.id, app.session.member.id)
10 end
12 local current_draft_name = _"Current draft"
13 if initiative.issue.half_frozen then
14 current_draft_name = _"Voting proposal"
15 end
17 if initiative.issue.state == "finished" then
18 current_draft_name = _"Voted proposal"
19 end
21 local tabs = {
22 {
23 name = "current_draft",
24 label = current_draft_name,
25 icon = { static = "icons/16/script.png" },
26 module = "initiative",
27 view = "_current_draft",
28 params = {
29 initiative = initiative,
30 initiator = initiator
31 }
32 }
33 }
35 if initiative.issue.ranks_available then
36 tabs[#tabs+1] = {
37 name = "voting",
38 label = _"Voting details",
39 icon = { static = "icons/16/email_open.png" },
40 module = "initiative",
41 view = "_show_voting",
42 params = {
43 initiative = initiative
44 }
45 }
46 end
48 local suggestion_count = initiative:get_reference_selector("suggestions"):count()
50 tabs[#tabs+1] = {
51 name = "suggestions",
52 label = _"Suggestions" .. " (" .. tostring(suggestion_count) .. ")",
53 icon = { static = "icons/16/comments.png" },
54 module = "initiative",
55 view = "_suggestions",
56 params = {
57 initiative = initiative
58 }
59 }
61 local members_selector = initiative:get_reference_selector("supporting_members_snapshot")
62 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
63 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id")
64 :add_field("direct_interest_snapshot.weight")
65 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
66 :add_where("direct_supporter_snapshot.satisfied")
67 :add_field("direct_supporter_snapshot.informed", "is_informed")
69 local tmp = db:query("SELECT count(1) AS count, sum(weight) AS weight FROM (" .. tostring(members_selector) .. ") as subquery", "object")
70 local direct_satisfied_supporter_count = tmp.count
71 local indirect_satisfied_supporter_count = (tmp.weight or 0) - tmp.count
73 local count_string
74 if indirect_satisfied_supporter_count > 0 then
75 count_string = "(" .. tostring(direct_satisfied_supporter_count) .. "+" .. tostring(indirect_satisfied_supporter_count) .. ")"
76 else
77 count_string = "(" .. tostring(direct_satisfied_supporter_count) .. ")"
78 end
80 tabs[#tabs+1] = {
81 name = "satisfied_supporter",
82 label = _"Supporter" .. " " .. count_string,
83 icon = { static = "icons/16/thumb_up_green.png" },
84 module = "member",
85 view = "_list",
86 params = {
87 initiative = initiative,
88 members_selector = members_selector
89 }
90 }
92 local members_selector = initiative:get_reference_selector("supporting_members_snapshot")
93 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
94 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id")
95 :add_field("direct_interest_snapshot.weight")
96 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
97 :add_where("NOT direct_supporter_snapshot.satisfied")
98 :add_field("direct_supporter_snapshot.informed", "is_informed")
100 local tmp = db:query("SELECT count(1) AS count, sum(weight) AS weight FROM (" .. tostring(members_selector) .. ") as subquery", "object")
101 local direct_potential_supporter_count = tmp.count
102 local indirect_potential_supporter_count = (tmp.weight or 0) - tmp.count
104 local count_string
105 if indirect_potential_supporter_count > 0 then
106 count_string = "(" .. tostring(direct_potential_supporter_count) .. "+" .. tostring(indirect_potential_supporter_count) .. ")"
107 else
108 count_string = "(" .. tostring(direct_potential_supporter_count) .. ")"
109 end
111 tabs[#tabs+1] = {
112 name = "supporter",
113 label = _"Potential supporter" .. " " .. count_string,
114 icon = { static = "icons/16/thumb_up.png" },
115 module = "member",
116 view = "_list",
117 params = {
118 initiative = initiative,
119 members_selector = members_selector
120 }
121 }
123 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
124 :add_field("initiator.accepted", "accepted")
126 if not (initiator and initiator.accepted) then
127 initiators_members_selector:add_where("initiator.accepted")
128 end
130 local initiator_count = initiators_members_selector:count()
132 tabs[#tabs+1] = {
133 name = "initiators",
134 label = _"Initiators" .. " (" .. tostring(initiator_count) .. ")",
135 icon = { static = "icons/16/user_edit.png" },
136 module = "initiative",
137 view = "_initiators",
138 params = {
139 initiative = initiative,
140 initiator = initiator,
141 initiators_members_selector = initiators_members_selector
142 }
143 }
145 local drafts_count = initiative:get_reference_selector("drafts"):count()
147 tabs[#tabs+1] = {
148 name = "drafts",
149 label = _"Draft history" .. " (" .. tostring(drafts_count) .. ")",
150 icon = { static = "icons/16/script.png" },
151 module = "draft",
152 view = "_list",
153 params = { drafts = initiative.drafts }
154 }
156 tabs[#tabs+1] = {
157 name = "details",
158 label = _"Details",
159 icon = { static = "icons/16/magnifier.png" },
160 module = "initiative",
161 view = "_details",
162 params = {
163 initiative = initiative,
164 members_selector = members_selector
165 }
166 }
168 tabs.module = "initiative"
169 tabs.view = "show_tab"
170 tabs.static_params = {
171 initiative_id = initiative.id
172 }
174 ui.tabs(tabs)
