liquid_feedback_frontend

annotate app/main/initiative/_show.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
author bsw/jbe
date Sat Feb 20 22:10:31 2010 +0100 (2010-02-20)
parents
children 81586ea68d57
rev   line source
bsw/jbe@19 1 local initiative = param.get("initiative", "table")
bsw/jbe@19 2 local initiator = param.get("initiator", "table")
bsw/jbe@19 3
bsw/jbe@19 4 util.help("initiative.show")
bsw/jbe@19 5
bsw/jbe@19 6 if initiative.issue.ranks_available and initiative.admitted then
bsw/jbe@19 7 local class = initiative.rank == 1 and "admitted_info" or "not_admitted_info"
bsw/jbe@19 8 ui.container{
bsw/jbe@19 9 attr = { class = class },
bsw/jbe@19 10 content = function()
bsw/jbe@19 11 local max_value = initiative.issue.voter_count
bsw/jbe@19 12 slot.put(" ")
bsw/jbe@19 13 local positive_votes = initiative.positive_votes
bsw/jbe@19 14 local negative_votes = initiative.negative_votes
bsw/jbe@19 15 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. "</b>")
bsw/jbe@19 16 slot.put(" &middot; ")
bsw/jbe@19 17 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
bsw/jbe@19 18 slot.put(" &middot; ")
bsw/jbe@19 19 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. "</b>")
bsw/jbe@19 20 slot.put(" &middot; ")
bsw/jbe@19 21 slot.put("<b>")
bsw/jbe@19 22 if initiative.rank == 1 then
bsw/jbe@19 23 slot.put(_"Approved")
bsw/jbe@19 24 elseif initiative.rank then
bsw/jbe@19 25 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
bsw/jbe@19 26 end
bsw/jbe@19 27 slot.put("</b>")
bsw/jbe@19 28 end
bsw/jbe@19 29 }
bsw/jbe@19 30 end
bsw/jbe@19 31
bsw/jbe@19 32 if initiative.admitted == false then
bsw/jbe@19 33 local policy = initiative.issue.policy
bsw/jbe@19 34 ui.container{
bsw/jbe@19 35 attr = { class = "not_admitted_info" },
bsw/jbe@19 36 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
bsw/jbe@19 37 }
bsw/jbe@19 38 end
bsw/jbe@19 39
bsw/jbe@19 40 local web20 = config.user_tab_mode == "accordeon"
bsw/jbe@19 41 or config.user_tab_mode == "accordeon_first_expanded"
bsw/jbe@19 42 or config.user_tab_mode == "accordeon_all_expanded"
bsw/jbe@19 43
bsw/jbe@19 44 if not web20 and initiative.issue.state == "cancelled" then
bsw/jbe@19 45 local policy = initiative.issue.policy
bsw/jbe@19 46 ui.container{
bsw/jbe@19 47 attr = { class = "not_admitted_info" },
bsw/jbe@19 48 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
bsw/jbe@19 49 }
bsw/jbe@19 50 end
bsw/jbe@19 51
bsw/jbe@19 52 if initiative.revoked then
bsw/jbe@19 53 ui.container{
bsw/jbe@19 54 attr = { class = "revoked_info" },
bsw/jbe@19 55 content = function()
bsw/jbe@19 56 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
bsw/jbe@19 57 local suggested_initiative = initiative.suggested_initiative
bsw/jbe@19 58 if suggested_initiative then
bsw/jbe@19 59 slot.put("<br /><br />")
bsw/jbe@19 60 slot.put(_("The initiators suggest to support the following initiative:"))
bsw/jbe@19 61 slot.put(" ")
bsw/jbe@19 62 ui.link{
bsw/jbe@19 63 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
bsw/jbe@19 64 module = "initiative",
bsw/jbe@19 65 view = "show",
bsw/jbe@19 66 id = suggested_initiative.id
bsw/jbe@19 67 }
bsw/jbe@19 68 end
bsw/jbe@19 69 end
bsw/jbe@19 70 }
bsw/jbe@19 71 end
bsw/jbe@19 72
bsw/jbe@19 73 if initiator and initiator.accepted == nil then
bsw/jbe@19 74 ui.container{
bsw/jbe@19 75 attr = { class = "initiator_invite_info" },
bsw/jbe@19 76 content = function()
bsw/jbe@19 77 slot.put(_"You are invited to become initiator of this initiative.")
bsw/jbe@19 78 slot.put(" ")
bsw/jbe@19 79 ui.link{
bsw/jbe@19 80 image = { static = "icons/16/tick.png" },
bsw/jbe@19 81 text = _"Accept invitation",
bsw/jbe@19 82 module = "initiative",
bsw/jbe@19 83 action = "accept_invitation",
bsw/jbe@19 84 id = initiative.id,
bsw/jbe@19 85 routing = {
bsw/jbe@19 86 default = {
bsw/jbe@19 87 mode = "redirect",
bsw/jbe@19 88 module = request.get_module(),
bsw/jbe@19 89 view = request.get_view(),
bsw/jbe@19 90 id = param.get_id_cgi(),
bsw/jbe@19 91 params = param.get_all_cgi()
bsw/jbe@19 92 }
bsw/jbe@19 93 }
bsw/jbe@19 94 }
bsw/jbe@19 95 slot.put(" ")
bsw/jbe@19 96 ui.link{
bsw/jbe@19 97 image = { static = "icons/16/cross.png" },
bsw/jbe@19 98 text = _"Refuse invitation",
bsw/jbe@19 99 module = "initiative",
bsw/jbe@19 100 action = "reject_initiator_invitation",
bsw/jbe@19 101 params = {
bsw/jbe@19 102 initiative_id = initiative.id,
bsw/jbe@19 103 member_id = app.session.member.id
bsw/jbe@19 104 },
bsw/jbe@19 105 routing = {
bsw/jbe@19 106 default = {
bsw/jbe@19 107 mode = "redirect",
bsw/jbe@19 108 module = request.get_module(),
bsw/jbe@19 109 view = request.get_view(),
bsw/jbe@19 110 id = param.get_id_cgi(),
bsw/jbe@19 111 params = param.get_all_cgi()
bsw/jbe@19 112 }
bsw/jbe@19 113 }
bsw/jbe@19 114 }
bsw/jbe@19 115 end
bsw/jbe@19 116 }
bsw/jbe@19 117 slot.put("<br />")
bsw/jbe@19 118 end
bsw/jbe@19 119
bsw/jbe@19 120
bsw/jbe@19 121 local supporter = app.session.member:get_reference_selector("supporters")
bsw/jbe@19 122 :add_where{ "initiative_id = ?", initiative.id }
bsw/jbe@19 123 :optional_object_mode()
bsw/jbe@19 124 :exec()
bsw/jbe@19 125
bsw/jbe@19 126 if supporter and not initiative.issue.closed then
bsw/jbe@19 127 local old_draft_id = supporter.draft_id
bsw/jbe@19 128 local new_draft_id = initiative.current_draft.id
bsw/jbe@19 129 if old_draft_id ~= new_draft_id then
bsw/jbe@19 130 ui.container{
bsw/jbe@19 131 attr = { class = "draft_updated_info" },
bsw/jbe@19 132 content = function()
bsw/jbe@19 133 slot.put(_"The draft of this initiative has been updated!")
bsw/jbe@19 134 slot.put(" ")
bsw/jbe@19 135 ui.link{
bsw/jbe@19 136 content = _"Show diff",
bsw/jbe@19 137 module = "draft",
bsw/jbe@19 138 view = "diff",
bsw/jbe@19 139 params = {
bsw/jbe@19 140 old_draft_id = old_draft_id,
bsw/jbe@19 141 new_draft_id = new_draft_id
bsw/jbe@19 142 }
bsw/jbe@19 143 }
bsw/jbe@19 144 slot.put(" ")
bsw/jbe@19 145 ui.link{
bsw/jbe@19 146 text = _"Refresh support to current draft",
bsw/jbe@19 147 module = "initiative",
bsw/jbe@19 148 action = "add_support",
bsw/jbe@19 149 id = initiative.id,
bsw/jbe@19 150 routing = {
bsw/jbe@19 151 default = {
bsw/jbe@19 152 mode = "redirect",
bsw/jbe@19 153 module = "initiative",
bsw/jbe@19 154 view = "show",
bsw/jbe@19 155 id = initiative.id
bsw/jbe@19 156 }
bsw/jbe@19 157 }
bsw/jbe@19 158 }
bsw/jbe@19 159 end
bsw/jbe@19 160 }
bsw/jbe@19 161 end
bsw/jbe@19 162 end
bsw/jbe@19 163
bsw/jbe@19 164
bsw/jbe@19 165
bsw/jbe@19 166 ui.container{
bsw/jbe@19 167 attr = {
bsw/jbe@19 168 id = "initiative_" .. tostring(initiative.id) .. "_support"
bsw/jbe@19 169 },
bsw/jbe@19 170 content = function()
bsw/jbe@19 171 execute.view{
bsw/jbe@19 172 module = "initiative",
bsw/jbe@19 173 view = "show_support",
bsw/jbe@19 174 params = {
bsw/jbe@19 175 initiative = initiative
bsw/jbe@19 176 }
bsw/jbe@19 177 }
bsw/jbe@19 178 end
bsw/jbe@19 179 }
bsw/jbe@19 180
bsw/jbe@19 181 if (initiative.discussion_url and #initiative.discussion_url > 0)
bsw/jbe@19 182 or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then
bsw/jbe@19 183 ui.container{
bsw/jbe@19 184 attr = { class = "vertical" },
bsw/jbe@19 185 content = function()
bsw/jbe@19 186 ui.container{
bsw/jbe@19 187 attr = { class = "ui_field_label" },
bsw/jbe@19 188 content = _"Discussion with initiators"
bsw/jbe@19 189 }
bsw/jbe@19 190 ui.tag{
bsw/jbe@19 191 tag = "span",
bsw/jbe@19 192 content = function()
bsw/jbe@19 193 if initiative.discussion_url:find("^https?://") then
bsw/jbe@19 194 if initiative.discussion_url and #initiative.discussion_url > 0 then
bsw/jbe@19 195 ui.link{
bsw/jbe@19 196 attr = {
bsw/jbe@19 197 class = "actions",
bsw/jbe@19 198 target = "_blank",
bsw/jbe@19 199 title = initiative.discussion_url
bsw/jbe@19 200 },
bsw/jbe@19 201 content = function()
bsw/jbe@19 202 slot.put(encode.html(initiative.discussion_url))
bsw/jbe@19 203 end,
bsw/jbe@19 204 external = initiative.discussion_url
bsw/jbe@19 205 }
bsw/jbe@19 206 end
bsw/jbe@19 207 else
bsw/jbe@19 208 slot.put(encode.html(initiative.discussion_url))
bsw/jbe@19 209 end
bsw/jbe@19 210 slot.put(" ")
bsw/jbe@19 211 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw/jbe@19 212 ui.link{
bsw/jbe@19 213 attr = { class = "actions" },
bsw/jbe@19 214 text = _"(change URL)",
bsw/jbe@19 215 module = "initiative",
bsw/jbe@19 216 view = "edit",
bsw/jbe@19 217 id = initiative.id
bsw/jbe@19 218 }
bsw/jbe@19 219 end
bsw/jbe@19 220 end
bsw/jbe@19 221 }
bsw/jbe@19 222 end
bsw/jbe@19 223 }
bsw/jbe@19 224 end
bsw/jbe@19 225
bsw/jbe@19 226
bsw/jbe@19 227
bsw/jbe@19 228 execute.view{
bsw/jbe@19 229 module = "initiative",
bsw/jbe@19 230 view = "show_tab",
bsw/jbe@19 231 params = {
bsw/jbe@19 232 initiative = initiative,
bsw/jbe@19 233 initiator = initiator
bsw/jbe@19 234 }
bsw/jbe@19 235 }
bsw/jbe@19 236

Impressum / About Us