liquid_feedback_frontend

annotate 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
author bsw/jbe
date Sat Feb 20 22:10:31 2010 +0100 (2010-02-20)
parents
children 0849be391140
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 if not initiative then
bsw/jbe@19 5 initiative = Initiative:by_id(param.get("initiative_id", atom.number))
bsw/jbe@19 6 end
bsw/jbe@19 7
bsw/jbe@19 8 if not initiator then
bsw/jbe@19 9 initiator = Initiator:by_pk(initiative.id, app.session.member.id)
bsw/jbe@19 10 end
bsw/jbe@19 11
bsw/jbe@19 12 local current_draft_name = _"Current draft"
bsw/jbe@19 13 if initiative.issue.half_frozen then
bsw/jbe@19 14 current_draft_name = _"Voting proposal"
bsw/jbe@19 15 end
bsw/jbe@19 16
bsw/jbe@19 17 if initiative.issue.state == "finished" then
bsw/jbe@19 18 current_draft_name = _"Voted proposal"
bsw/jbe@19 19 end
bsw/jbe@19 20
bsw/jbe@19 21 local tabs = {
bsw/jbe@19 22 {
bsw/jbe@19 23 name = "current_draft",
bsw/jbe@19 24 label = current_draft_name,
bsw/jbe@19 25 icon = { static = "icons/16/script.png" },
bsw/jbe@19 26 module = "initiative",
bsw/jbe@19 27 view = "_current_draft",
bsw/jbe@19 28 params = {
bsw/jbe@19 29 initiative = initiative,
bsw/jbe@19 30 initiator = initiator
bsw/jbe@19 31 }
bsw/jbe@19 32 }
bsw/jbe@19 33 }
bsw/jbe@19 34
bsw/jbe@19 35 if initiative.issue.ranks_available then
bsw/jbe@19 36 tabs[#tabs+1] = {
bsw/jbe@19 37 name = "voting",
bsw/jbe@19 38 label = _"Voting details",
bsw/jbe@19 39 icon = { static = "icons/16/email_open.png" },
bsw/jbe@19 40 module = "initiative",
bsw/jbe@19 41 view = "_show_voting",
bsw/jbe@19 42 params = {
bsw/jbe@19 43 initiative = initiative
bsw/jbe@19 44 }
bsw/jbe@19 45 }
bsw/jbe@19 46 end
bsw/jbe@19 47
bsw/jbe@19 48 local suggestion_count = initiative:get_reference_selector("suggestions"):count()
bsw/jbe@19 49
bsw/jbe@19 50 tabs[#tabs+1] = {
bsw/jbe@19 51 name = "suggestions",
bsw/jbe@19 52 label = _"Suggestions" .. " (" .. tostring(suggestion_count) .. ")",
bsw/jbe@19 53 icon = { static = "icons/16/comments.png" },
bsw/jbe@19 54 module = "initiative",
bsw/jbe@19 55 view = "_suggestions",
bsw/jbe@19 56 params = {
bsw/jbe@19 57 initiative = initiative
bsw/jbe@19 58 }
bsw/jbe@19 59 }
bsw/jbe@19 60
bsw/jbe@19 61 local members_selector = initiative:get_reference_selector("supporting_members_snapshot")
bsw/jbe@19 62 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
bsw/jbe@19 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")
bsw/jbe@19 64 :add_field("direct_interest_snapshot.weight")
bsw/jbe@19 65 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
bsw/jbe@19 66 :add_where("direct_supporter_snapshot.satisfied")
bsw/jbe@19 67 :add_field("direct_supporter_snapshot.informed", "is_informed")
bsw/jbe@19 68
bsw/jbe@19 69 local tmp = db:query("SELECT count(1) AS count, sum(weight) AS weight FROM (" .. tostring(members_selector) .. ") as subquery", "object")
bsw/jbe@19 70 local direct_satisfied_supporter_count = tmp.count
bsw/jbe@19 71 local indirect_satisfied_supporter_count = (tmp.weight or 0) - tmp.count
bsw/jbe@19 72
bsw/jbe@19 73 local count_string
bsw/jbe@19 74 if indirect_satisfied_supporter_count > 0 then
bsw/jbe@19 75 count_string = "(" .. tostring(direct_satisfied_supporter_count) .. "+" .. tostring(indirect_satisfied_supporter_count) .. ")"
bsw/jbe@19 76 else
bsw/jbe@19 77 count_string = "(" .. tostring(direct_satisfied_supporter_count) .. ")"
bsw/jbe@19 78 end
bsw/jbe@19 79
bsw/jbe@19 80 tabs[#tabs+1] = {
bsw/jbe@19 81 name = "satisfied_supporter",
bsw/jbe@19 82 label = _"Supporter" .. " " .. count_string,
bsw/jbe@19 83 icon = { static = "icons/16/thumb_up_green.png" },
bsw/jbe@19 84 module = "member",
bsw/jbe@19 85 view = "_list",
bsw/jbe@19 86 params = {
bsw/jbe@19 87 initiative = initiative,
bsw/jbe@19 88 members_selector = members_selector
bsw/jbe@19 89 }
bsw/jbe@19 90 }
bsw/jbe@19 91
bsw/jbe@19 92 local members_selector = initiative:get_reference_selector("supporting_members_snapshot")
bsw/jbe@19 93 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
bsw/jbe@19 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")
bsw/jbe@19 95 :add_field("direct_interest_snapshot.weight")
bsw/jbe@19 96 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
bsw/jbe@19 97 :add_where("NOT direct_supporter_snapshot.satisfied")
bsw/jbe@19 98 :add_field("direct_supporter_snapshot.informed", "is_informed")
bsw/jbe@19 99
bsw/jbe@19 100 local tmp = db:query("SELECT count(1) AS count, sum(weight) AS weight FROM (" .. tostring(members_selector) .. ") as subquery", "object")
bsw/jbe@19 101 local direct_potential_supporter_count = tmp.count
bsw/jbe@19 102 local indirect_potential_supporter_count = (tmp.weight or 0) - tmp.count
bsw/jbe@19 103
bsw/jbe@19 104 local count_string
bsw/jbe@19 105 if indirect_potential_supporter_count > 0 then
bsw/jbe@19 106 count_string = "(" .. tostring(direct_potential_supporter_count) .. "+" .. tostring(indirect_potential_supporter_count) .. ")"
bsw/jbe@19 107 else
bsw/jbe@19 108 count_string = "(" .. tostring(direct_potential_supporter_count) .. ")"
bsw/jbe@19 109 end
bsw/jbe@19 110
bsw/jbe@19 111 tabs[#tabs+1] = {
bsw/jbe@19 112 name = "supporter",
bsw/jbe@19 113 label = _"Potential supporter" .. " " .. count_string,
bsw/jbe@19 114 icon = { static = "icons/16/thumb_up.png" },
bsw/jbe@19 115 module = "member",
bsw/jbe@19 116 view = "_list",
bsw/jbe@19 117 params = {
bsw/jbe@19 118 initiative = initiative,
bsw/jbe@19 119 members_selector = members_selector
bsw/jbe@19 120 }
bsw/jbe@19 121 }
bsw/jbe@19 122
bsw/jbe@19 123 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
bsw/jbe@19 124 :add_field("initiator.accepted", "accepted")
bsw/jbe@19 125
bsw/jbe@19 126 if not (initiator and initiator.accepted) then
bsw/jbe@19 127 initiators_members_selector:add_where("initiator.accepted")
bsw/jbe@19 128 end
bsw/jbe@19 129
bsw/jbe@19 130 local initiator_count = initiators_members_selector:count()
bsw/jbe@19 131
bsw/jbe@19 132 tabs[#tabs+1] = {
bsw/jbe@19 133 name = "initiators",
bsw/jbe@19 134 label = _"Initiators" .. " (" .. tostring(initiator_count) .. ")",
bsw/jbe@19 135 icon = { static = "icons/16/user_edit.png" },
bsw/jbe@19 136 module = "initiative",
bsw/jbe@19 137 view = "_initiators",
bsw/jbe@19 138 params = {
bsw/jbe@19 139 initiative = initiative,
bsw/jbe@19 140 initiator = initiator,
bsw/jbe@19 141 initiators_members_selector = initiators_members_selector
bsw/jbe@19 142 }
bsw/jbe@19 143 }
bsw/jbe@19 144
bsw/jbe@19 145 local drafts_count = initiative:get_reference_selector("drafts"):count()
bsw/jbe@19 146
bsw/jbe@19 147 tabs[#tabs+1] = {
bsw/jbe@19 148 name = "drafts",
bsw/jbe@19 149 label = _"Draft history" .. " (" .. tostring(drafts_count) .. ")",
bsw/jbe@19 150 icon = { static = "icons/16/script.png" },
bsw/jbe@19 151 module = "draft",
bsw/jbe@19 152 view = "_list",
bsw/jbe@19 153 params = { drafts = initiative.drafts }
bsw/jbe@19 154 }
bsw/jbe@19 155
bsw/jbe@19 156 tabs[#tabs+1] = {
bsw/jbe@19 157 name = "details",
bsw/jbe@19 158 label = _"Details",
bsw/jbe@19 159 icon = { static = "icons/16/magnifier.png" },
bsw/jbe@19 160 module = "initiative",
bsw/jbe@19 161 view = "_details",
bsw/jbe@19 162 params = {
bsw/jbe@19 163 initiative = initiative,
bsw/jbe@19 164 members_selector = members_selector
bsw/jbe@19 165 }
bsw/jbe@19 166 }
bsw/jbe@19 167
bsw/jbe@19 168 tabs.module = "initiative"
bsw/jbe@19 169 tabs.view = "show_tab"
bsw/jbe@19 170 tabs.static_params = {
bsw/jbe@19 171 initiative_id = initiative.id
bsw/jbe@19 172 }
bsw/jbe@19 173
bsw/jbe@19 174 ui.tabs(tabs)
bsw/jbe@19 175

Impressum / About Us