liquid_feedback_frontend
annotate app/main/initiative/_list_element.lua @ 159:5d797c6706d5
implement quorum display
show the initiative quorum as a small 1px line in bargraph
allow to update your support on the diff page
better linked title in diff page
show absolute quorum numbers in detail pages of issue and initiative
show the initiative quorum as a small 1px line in bargraph
allow to update your support on the diff page
better linked title in diff page
show absolute quorum numbers in detail pages of issue and initiative
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Sat Oct 09 03:42:48 2010 +0200 (2010-10-09) |
parents | df5392f114e2 |
children | 86988175dc89 |
rev | line source |
---|---|
bsw/jbe@19 | 1 local initiative = param.get("initiative", "table") |
bsw/jbe@19 | 2 local expanded = param.get("expanded", atom.boolean) |
bsw/jbe@19 | 3 local expandable = param.get("expandable", atom.boolean) |
bsw/jbe@19 | 4 |
bsw/jbe@19 | 5 local head_name = "initiative_head_" .. tostring(initiative.id) |
bsw/jbe@19 | 6 local link_name = "initiative_link_" .. tostring(initiative.id) |
bsw/jbe@19 | 7 local name = "initiative_content_" .. tostring(initiative.id) |
bsw/jbe@19 | 8 local icon_name = "initiative_icon_" .. tostring(initiative.id) |
bsw/jbe@19 | 9 |
bsw/jbe@19 | 10 ui.container{ |
bsw/jbe@19 | 11 attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") }, |
bsw/jbe@19 | 12 content = function() |
bsw/jbe@19 | 13 local web20 = config.user_tab_mode == "accordeon" |
bsw/jbe@19 | 14 or config.user_tab_mode == "accordeon_first_expanded" |
bsw/jbe@19 | 15 or config.user_tab_mode == "accordeon_all_expanded" |
bsw/jbe@19 | 16 local onclick |
bsw/jbe@19 | 17 if web20 then |
bsw/jbe@19 | 18 if expandable then |
bsw/jbe@19 | 19 onclick = |
bsw/jbe@19 | 20 'if (lf_initiative_expanded["' .. name .. '"]) {' .. |
bsw/jbe@19 | 21 'lf_initiative_expanded["' .. name .. '"]=false;' .. |
bsw/jbe@19 | 22 'document.getElementById("' .. name .. '_content").innerHTML=" ";' .. |
bsw/jbe@19 | 23 'document.getElementById("' .. name .. '").style.display="none";' .. |
bsw/jbe@19 | 24 '} else {' .. |
bsw/jbe@19 | 25 'lf_initiative_expanded["' .. name .. '"] = true;' .. |
bsw/jbe@19 | 26 'document.getElementById("' .. name .. '").style.display="block"; ' .. |
bsw/jbe@19 | 27 'var hourglass_el = document.getElementById("' .. icon_name .. '");' .. |
bsw/jbe@19 | 28 'var hourglass_src = hourglass_el.src;' .. |
bsw/jbe@19 | 29 'hourglass_el.src = "' .. encode.url{ static = "icons/16/connect.png" } .. '";' .. |
bsw/jbe@19 | 30 'partialMultiLoad(' .. |
bsw/jbe@19 | 31 '{ trace: "trace", system_error: "system_error", ' .. name .. '_content: "default" },' .. |
bsw/jbe@19 | 32 '{},' .. |
bsw/jbe@19 | 33 '"error",' .. |
bsw/jbe@19 | 34 '"' .. request.get_relative_baseurl() .. 'initiative/show_partial/' .. tostring(initiative.id) .. '.html?&_webmcp_json_slots[]=default&_webmcp_json_slots[]=support&_webmcp_json_slots[]=trace&_webmcp_json_slots[]=system_error",' .. |
bsw/jbe@19 | 35 '{},' .. |
bsw/jbe@19 | 36 '{},' .. |
bsw/jbe@19 | 37 'function() {' .. |
bsw/jbe@19 | 38 'hourglass_el.src = hourglass_src;' .. |
bsw/jbe@19 | 39 '},' .. |
bsw/jbe@19 | 40 'function() {' .. |
bsw/jbe@19 | 41 'hourglass_el.src = hourglass_src;' .. |
bsw/jbe@19 | 42 '}' .. |
bsw/jbe@19 | 43 '); ' .. |
bsw/jbe@19 | 44 '}' .. |
bsw/jbe@19 | 45 'return(false);' |
bsw/jbe@19 | 46 else |
bsw/jbe@19 | 47 onclick = "document.location.href = document.getElementById('" .. link_name .. "').href;" |
bsw/jbe@19 | 48 end |
bsw/jbe@19 | 49 end |
bsw/jbe@19 | 50 local module = "initiative" |
bsw/jbe@19 | 51 local view = "show" |
bsw/jbe@19 | 52 local id = initiative.id |
bsw/jbe@19 | 53 local params = {} |
bsw/jbe@19 | 54 ui.container{ |
bsw/jbe@19 | 55 attr = { |
bsw/jbe@19 | 56 name = name, |
bsw/jbe@19 | 57 class = "ui_tabs_accordeon_head", |
bsw/jbe@19 | 58 id = head_name, |
bsw/jbe@19 | 59 onclick = onclick, |
bsw/jbe@19 | 60 }, |
bsw/jbe@19 | 61 content = function() |
bsw/jbe@19 | 62 |
bsw@29 | 63 ui.list{ |
bsw@29 | 64 attr = { class = "nohover" }, |
bsw@29 | 65 records = { { a = 1} }, |
bsw@29 | 66 columns = { |
bsw@29 | 67 { |
bsw@29 | 68 field_attr = { style = "width: 4em; padding: 0;"}, |
bsw@29 | 69 content = function() |
bsw@29 | 70 if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then |
bsw@29 | 71 ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank } |
bsw@29 | 72 elseif web20 then |
bsw@29 | 73 ui.image{ |
bsw@29 | 74 attr = { |
bsw@29 | 75 width = 16, |
bsw@29 | 76 height = 16, |
bsw@29 | 77 id = icon_name, |
bsw@29 | 78 style = "float: left;" |
bsw@29 | 79 }, |
bsw@29 | 80 static = "icons/16/script.png" |
bsw@29 | 81 } |
bsw@29 | 82 else |
bsw@29 | 83 slot.put(" ") |
bsw@29 | 84 end |
bsw@29 | 85 end |
bsw@29 | 86 }, |
bsw/jbe@19 | 87 |
bsw@29 | 88 { |
bsw@29 | 89 field_attr = { style = "width: 110px; padding: 0;"}, |
bsw@29 | 90 content = function() |
bsw/jbe@48 | 91 if initiative.issue.fully_frozen and initiative.issue.closed then |
bsw@29 | 92 if initiative.issue.ranks_available then |
bsw@29 | 93 if initiative.negative_votes and initiative.positive_votes then |
bsw@29 | 94 local max_value = initiative.issue.voter_count |
bsw@29 | 95 ui.bargraph{ |
bsw@29 | 96 max_value = max_value, |
bsw@29 | 97 width = 100, |
bsw@29 | 98 bars = { |
bsw@29 | 99 { color = "#0a0", value = initiative.positive_votes }, |
bsw@29 | 100 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes }, |
bsw@29 | 101 { color = "#a00", value = initiative.negative_votes }, |
bsw@29 | 102 } |
bsw@29 | 103 } |
bsw@29 | 104 else |
bsw@29 | 105 slot.put(" ") |
bsw@29 | 106 end |
bsw@29 | 107 else |
bsw@29 | 108 slot.put(_"Counting of votes") |
bsw@29 | 109 end |
bsw@29 | 110 elseif initiative.issue.population then |
bsw@29 | 111 local max_value = initiative.issue.population |
bsw/jbe@19 | 112 ui.bargraph{ |
bsw/jbe@19 | 113 max_value = max_value, |
bsw/jbe@19 | 114 width = 100, |
poelzi@159 | 115 quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), |
poelzi@159 | 116 quorum_color = "#00F", |
bsw/jbe@19 | 117 bars = { |
bsw@29 | 118 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, |
bsw@29 | 119 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, |
bsw@29 | 120 { color = "#eee", value = max_value - (initiative.supporter_count or 0) }, |
bsw/jbe@19 | 121 } |
bsw/jbe@19 | 122 } |
bsw/jbe@19 | 123 else |
bsw/jbe@19 | 124 slot.put(" ") |
bsw/jbe@19 | 125 end |
bsw/jbe@19 | 126 end |
bsw@29 | 127 }, |
bsw@29 | 128 |
bsw@29 | 129 { |
bsw@29 | 130 field_attr = { style = "padding: 0;"}, |
bsw/jbe@19 | 131 content = function() |
bsw@29 | 132 local link_class |
bsw@29 | 133 if initiative.revoked then |
bsw@29 | 134 link_class = "revoked" |
bsw/jbe@19 | 135 end |
bsw@29 | 136 ui.link{ |
bsw@29 | 137 attr = { id = link_name, class = link_class }, |
bsw@29 | 138 content = function() |
bsw@29 | 139 local name |
bsw@29 | 140 if initiative.name_highlighted then |
bsw@29 | 141 name = encode.highlight(initiative.name_highlighted) |
bsw@29 | 142 else |
bsw@29 | 143 name = encode.html(initiative.shortened_name) |
bsw@29 | 144 end |
bsw@29 | 145 slot.put(name) |
bsw@29 | 146 end, |
bsw@29 | 147 module = module, |
bsw@29 | 148 view = view, |
bsw@29 | 149 id = id, |
bsw@29 | 150 params = params, |
bsw@29 | 151 } |
bsw@29 | 152 |
bsw@29 | 153 if initiative.issue.state == "new" then |
bsw@29 | 154 ui.image{ |
bsw@29 | 155 static = "icons/16/new.png" |
bsw@29 | 156 } |
bsw@29 | 157 end |
bsw@29 | 158 if initiative.is_supporter then |
bsw@29 | 159 slot.put(" ") |
bsw@29 | 160 local label = _"You are supporting this initiative" |
bsw@29 | 161 ui.image{ |
bsw@29 | 162 attr = { alt = label, title = label }, |
bsw@29 | 163 static = "icons/16/thumb_up_green.png" |
bsw@29 | 164 } |
bsw@29 | 165 end |
bsw@29 | 166 if initiative.is_potential_supporter then |
bsw@29 | 167 slot.put(" ") |
bsw@29 | 168 local label = _"You are potential supporter of this initiative" |
bsw@29 | 169 ui.image{ |
bsw@29 | 170 attr = { alt = label, title = label }, |
bsw@29 | 171 static = "icons/16/thumb_up.png" |
bsw@29 | 172 } |
bsw@29 | 173 end |
bsw@29 | 174 if initiative.is_initiator then |
bsw@29 | 175 slot.put(" ") |
bsw@29 | 176 local label = _"You are iniator of this initiative" |
bsw@29 | 177 ui.image{ |
bsw@29 | 178 attr = { alt = label, title = label }, |
bsw@29 | 179 static = "icons/16/user_edit.png" |
bsw@29 | 180 } |
bsw@29 | 181 end |
bsw@29 | 182 |
bsw@29 | 183 end |
bsw/jbe@19 | 184 } |
bsw/jbe@19 | 185 } |
bsw@29 | 186 } |
bsw/jbe@19 | 187 end |
bsw/jbe@19 | 188 } |
bsw/jbe@19 | 189 end |
bsw/jbe@19 | 190 } |
bsw/jbe@19 | 191 |
bsw/jbe@19 | 192 if ui.is_partial_loading_enabled() then |
bsw/jbe@19 | 193 ui.container{ |
bsw/jbe@19 | 194 attr = { |
bsw/jbe@19 | 195 id = name, |
bsw/jbe@19 | 196 class = "ui_tabs_accordeon_content", |
bsw/jbe@19 | 197 style = not expanded and "display: none;" or nil |
bsw/jbe@19 | 198 }, |
bsw/jbe@19 | 199 content = function() |
bsw/jbe@19 | 200 ui.container{ |
bsw/jbe@19 | 201 attr = { id = name .. "_content", style = "clear: left;" }, |
bsw/jbe@19 | 202 content = function() |
bsw/jbe@19 | 203 execute.view{ |
bsw/jbe@19 | 204 module = "initiative", |
bsw/jbe@19 | 205 view = "show_partial", |
bsw/jbe@19 | 206 params = { |
bsw/jbe@19 | 207 initiative = initiative, |
bsw/jbe@19 | 208 expanded = expanded |
bsw/jbe@19 | 209 } |
bsw/jbe@19 | 210 } |
bsw/jbe@19 | 211 end |
bsw/jbe@19 | 212 } |
bsw/jbe@19 | 213 end |
bsw/jbe@19 | 214 } |
bsw/jbe@19 | 215 end |