liquid_feedback_frontend

annotate app/main/delegation/_info.lua @ 1045:701a5cf6b067

Imported LiquidFeedback Frontend 3.0 branch
author bsw
date Thu Jul 10 01:19:48 2014 +0200 (2014-07-10)
parents 9d4398195faf
children 32cc544d5a5b
rev   line source
bsw@526 1 if not app.session.member_id then
bsw@526 2 return
bsw@526 3 end
bsw@526 4
bsw@774 5 local member = param.get("member", "table") or app.session.member
bsw@774 6
bsw@525 7 local unit = param.get("unit", "table")
bsw@525 8 local area = param.get("area", "table")
bsw@525 9 local issue = param.get("issue", "table")
bsw@525 10
bsw@1045 11 local for_title = param.get("for_title", "boolean")
bsw@1045 12
bsw@525 13 local unit_id = unit and unit.id or nil
bsw@525 14 local area_id = area and area.id or nil
bsw@525 15 local issue_id = issue and issue.id or nil
bsw@525 16
bsw@525 17 local info
bsw@525 18 local delegation_text
bsw@525 19
bsw@525 20 if unit then
bsw@525 21 info = unit.delegation_info
bsw@525 22 delegation_text = _"Delegate unit"
bsw@525 23 end
bsw@525 24
bsw@525 25 if area then
bsw@525 26 info = area.delegation_info
bsw@525 27 delegation_text = _"Delegate area"
bsw@525 28 end
bsw@525 29
bsw@525 30 if issue then
bsw@774 31 info = issue.member_info
bsw@525 32 delegation_text = _"Delegate issue"
bsw@525 33 end
bsw@525 34
bsw@1045 35 if not info then
bsw@1045 36 --return
bsw@1045 37 end
bsw@1045 38
bsw@780 39 local function print_delegation_info()
bsw@1045 40 local participant_occured = info.own_participation
bsw@780 41
bsw@780 42 if not (issue and issue.state == "voting" and info.own_participation) then
bsw@780 43
bsw@780 44 if info.first_trustee_id then
bsw@780 45
bsw@780 46 local text = _"delegates to"
bsw@780 47 ui.image{
bsw@780 48 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@780 49 static = "delegation_arrow_24_horizontal.png"
bsw@780 50 }
bsw@780 51
bsw@780 52 local class = "micro_avatar"
bsw@780 53 if not participant_occured and info.first_trustee_participation then
bsw@780 54 participant_occured = true
bsw@780 55 class = class .. " highlighted"
bsw@780 56 end
bsw@525 57
bsw@780 58 execute.view{ module = "member_image", view = "_show", params = {
bsw@780 59 member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
bsw@780 60 image_type = "avatar", show_dummy = true,
bsw@780 61 } }
bsw@780 62
bsw@780 63 end
bsw@780 64
bsw@780 65 if info.first_trustee_ellipsis then
bsw@780 66
bsw@780 67 local text = _"delegates to"
bsw@780 68 ui.image{
bsw@780 69 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@780 70 static = "delegation_arrow_24_horizontal.png"
bsw@780 71 }
bsw@525 72
bsw@780 73 slot.put("...")
bsw@780 74
bsw@780 75 end
bsw@780 76
bsw@780 77 if info.other_trustee_id then
bsw@780 78
bsw@780 79 local text = _"delegates to"
bsw@780 80 ui.image{
bsw@780 81 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@780 82 static = "delegation_arrow_24_horizontal.png"
bsw@780 83 }
bsw@525 84
bsw@780 85 local class = "micro_avatar"
bsw@780 86 if not participant_occured and info.other_trustee_participation then
bsw@780 87 participant_occured = true
bsw@780 88 class = class .. " highlighted"
bsw@780 89 end
bsw@780 90
bsw@780 91 execute.view{ module = "member_image", view = "_show", params = {
bsw@780 92 member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
bsw@780 93 image_type = "avatar", show_dummy = true,
bsw@780 94 } }
bsw@780 95
bsw@780 96 end
bsw@780 97
bsw@780 98 if info.other_trustee_ellipsis then
bsw@525 99
bsw@780 100 local text = _"delegates to"
bsw@780 101 ui.image{
bsw@780 102 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@780 103 static = "delegation_arrow_24_horizontal.png"
bsw@780 104 }
bsw@529 105
bsw@780 106 slot.put("...")
bsw@780 107
bsw@780 108 end
bsw@780 109
bsw@780 110 local trailing_ellipsis = info.other_trustee_ellipsis or
bsw@780 111 (info.first_trustee_ellipsis and not info.other_trustee_id)
bsw@780 112
bsw@780 113 if info.delegation_loop == "own" then
bsw@780 114
bsw@780 115 local text = _"delegates to"
bsw@780 116 ui.image{
bsw@780 117 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@780 118 static = "delegation_arrow_24_horizontal.png"
bsw@780 119 }
bsw@780 120
bsw@780 121 execute.view{ module = "member_image", view = "_show", params = {
bsw@780 122 member = member, class = "micro_avatar", popup_text = member.name,
bsw@780 123 image_type = "avatar", show_dummy = true,
bsw@780 124 } }
bsw@780 125
bsw@780 126 elseif info.delegation_loop == "first" then
bsw@780 127 if info.first_trustee_ellipsis then
bsw@780 128 if not trailing_ellipsis then
bsw@529 129
bsw@529 130 local text = _"delegates to"
bsw@529 131 ui.image{
bsw@529 132 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@529 133 static = "delegation_arrow_24_horizontal.png"
bsw@529 134 }
bsw@529 135
bsw@529 136 slot.put("...")
bsw@780 137 end
bsw@529 138
bsw@780 139 else
bsw@529 140
bsw@780 141 local text = _"delegates to"
bsw@780 142 ui.image{
bsw@780 143 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@780 144 static = "delegation_arrow_24_horizontal.png"
bsw@780 145 }
bsw@525 146
bsw@1045 147 execute.view{
bsw@1045 148 module = "member_image", view = "_show", params = {
bsw@1045 149 member_id = info.first_trustee_id,
bsw@1045 150 class = "micro_avatar",
bsw@1045 151 popup_text = info.first_trustee_name,
bsw@1045 152 image_type = "avatar",
bsw@1045 153 show_dummy = true,
bsw@1045 154 }
bsw@1045 155 }
bsw@780 156 end
bsw@780 157
bsw@529 158
bsw@780 159 elseif info.delegation_loop and not trailing_ellipsis then
bsw@780 160 local text = _"delegates to"
bsw@780 161 ui.image{
bsw@780 162 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@780 163 static = "delegation_arrow_24_horizontal.png"
bsw@780 164 }
bsw@525 165
bsw@780 166 slot.put("...")
bsw@780 167 end
bsw@529 168
bsw@780 169 end
bsw@780 170 end
bsw@529 171
bsw@1045 172 if not param.get("no_star", "boolean") then
bsw@1045 173
bsw@1045 174 if info.own_participation then
bsw@1045 175 if issue and issue.fully_frozen then
bsw@1045 176 ui.link{
bsw@1045 177 attr = { class = "right" },
bsw@1045 178 module = "vote", view = "list", params = {
bsw@1045 179 issue_id = issue.id
bsw@1045 180 },
bsw@1045 181 content = function ()
bsw@1045 182 ui.tag { content = _"you voted" }
bsw@1045 183 end
bsw@1045 184 }
bsw@1045 185 else
bsw@1045 186 if issue then
bsw@1045 187 local text = _"you are interested"
bsw@1045 188 ui.image { attr = { class = "star", title = text, alt = text }, static = "icons/48/eye.png" }
bsw@1045 189 if not issue.closed and info.own_participation and info.weight and info.weight > 1 then
bsw@1045 190 ui.link {
bsw@1045 191 attr = { class = "right" }, content = "+" .. (info.weight - 1),
bsw@1045 192 module = "delegation", view = "show_incoming", params = {
bsw@1045 193 issue_id = issue.id, member_id = member.id
bsw@1045 194 }
bsw@1045 195 }
bsw@1045 196 end
bsw@1045 197 else
bsw@1045 198 local text = _"you are subscribed"
bsw@1045 199 ui.image { attr = { class = "icon24 star", title = text, alt = text }, static = "icons/48/star.png" }
bsw@1045 200 end
bsw@1045 201 if not for_title then
bsw@1045 202 slot.put("<br />")
bsw@1045 203 else
bsw@1045 204 slot.put(" ")
bsw@1045 205 end
bsw@1045 206 end
bsw@1045 207 end
bsw@1045 208 end
bsw@1045 209
bsw@529 210
bsw@780 211 if info.own_participation or info.first_trustee_id then
bsw@1045 212 local class = "delegation_info"
bsw@1045 213 if info.own_participation then
bsw@1045 214 class = class .. " suspended"
bsw@1045 215 end
bsw@1045 216
bsw@1045 217 local voting_member_id
bsw@1045 218 local voting_member_name
bsw@1045 219 if issue and issue.fully_frozen and issue.closed then
bsw@1045 220 if issue.member_info.first_trustee_participation then
bsw@1045 221 voting_member_id = issue.member_info.first_trustee_id
bsw@1045 222 voting_member_name = issue.member_info.first_trustee_name
bsw@1045 223 elseif issue.member_info.other_trustee_participation then
bsw@1045 224 voting_member_id = issue.member_info.other_trustee_id
bsw@1045 225 voting_member_name = issue.member_info.other_trustee_name
bsw@1045 226 end
bsw@1045 227 end
bsw@1045 228
bsw@780 229 if app.session.member_id == member.id then
bsw@1045 230
bsw@1045 231 if voting_member_id then
bsw@1045 232 ui.link{
bsw@1045 233 module = "vote", view = "list", params = {
bsw@1045 234 issue_id = issue.id,
bsw@1045 235 member_id = voting_member_id
bsw@1045 236 },
bsw@1045 237 attr = { class = class }, content = function()
bsw@1045 238 print_delegation_info()
bsw@1045 239 end
bsw@1045 240 }
bsw@1045 241
bsw@1045 242 else
bsw@1045 243 ui.link{
bsw@1045 244 module = "delegation", view = "show", params = {
bsw@1045 245 unit_id = unit_id,
bsw@1045 246 area_id = area_id,
bsw@1045 247 issue_id = issue_id
bsw@1045 248 },
bsw@1045 249 attr = { class = class }, content = function()
bsw@1045 250 print_delegation_info()
bsw@1045 251 end
bsw@1045 252 }
bsw@1045 253 end
bsw@780 254 else
bsw@780 255 ui.container{
bsw@1045 256 attr = { class = class }, content = function()
bsw@780 257 print_delegation_info()
bsw@780 258 end
bsw@780 259 }
bsw@780 260 end
bsw@551 261 end
bsw@1045 262

Impressum / About Us