liquid_feedback_frontend

annotate app/main/delegation/_info.lua @ 1606:dcbe505ddf24

Removed old views, removed Silk icon set, removed emoticons
author bsw
date Mon Feb 01 21:25:34 2021 +0100 (2021-02-01)
parents d14462e2b38b
children 2f9e1e882de6
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@1603 172 if not param.get("no_star", "boolean") and issue then
bsw@1603 173 local redirect_unit = request.get_param{ name = "unit" }
bsw@1603 174 local redirect_area = request.get_param{ name = "area" }
bsw@1603 175
bsw@1603 176 if issue.fully_frozen and info.own_participation then
bsw@1603 177 ui.link{
bsw@1603 178 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
bsw@1603 179 module = "vote", view = "list", params = {
bsw@1603 180 issue_id = issue.id
bsw@1603 181 },
bsw@1603 182 content = function ()
bsw@1603 183 ui.tag { content = _"you voted" }
bsw@1603 184 end
bsw@1603 185 }
bsw@1603 186 elseif not issue.half_frozen and not info.own_participation then
bsw@1603 187 ui.link{
bsw@1603 188 attr = { class = "float-right mdl-button mdl-js-button mdl-button--icon mdl-button--accent" },
bsw@1603 189 module = "interest", action = "update", params = { issue_id = issue.id },
bsw@1603 190 routing = { default = {
bsw@1603 191 mode = "redirect", module = "index", view = "index", params = {
bsw@1603 192 unit = redirect_unit, area = redirect_area
bsw@1045 193 },
bsw@1603 194 anchor = "issue_" .. issue.id
bsw@1603 195 } },
bsw@1603 196 content = function()
bsw@1603 197 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "star_outline" }
bsw@1603 198 end
bsw@1603 199 }
bsw@1603 200 elseif not issue.half_frozen and info.own_participation then
bsw@1603 201 ui.link{
bsw@1603 202 attr = { class = "float-right mdl-button mdl-js-button mdl-button--icon mdl-button--accent" },
bsw@1603 203 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
bsw@1603 204 routing = { default = {
bsw@1603 205 mode = "redirect", module = "index", view = "index", params = {
bsw@1603 206 unit = redirect_unit, area = redirect_area
bsw@1603 207 },
bsw@1603 208 anchor = "issue_" .. issue.id
bsw@1603 209 } },
bsw@1603 210 content = function()
bsw/jbe@1309 211 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "star" }
bsw@1045 212 end
bsw@1603 213 }
bsw@1603 214 if not issue.closed and info.own_participation and info.weight and info.weight > 1 then
bsw/jbe@1309 215 slot.put(" ")
bsw@1603 216 ui.link {
bsw@1603 217 attr = { class = "right" }, content = "+" .. (info.weight - 1),
bsw@1603 218 module = "interest", view = "show_incoming", params = {
bsw@1603 219 issue_id = issue.id, member_id = member.id
bsw@1603 220 }
bsw@1603 221 }
bsw@1045 222 end
bsw@1603 223 slot.put(" ")
bsw@1045 224 end
bsw@1045 225 end
bsw@1045 226
bsw@529 227
bsw@780 228 if info.own_participation or info.first_trustee_id then
bsw@1045 229 local class = "delegation_info"
bsw@1045 230 if info.own_participation then
bsw@1045 231 class = class .. " suspended"
bsw@1045 232 end
bsw@1045 233
bsw@1045 234 local voting_member_id
bsw@1045 235 local voting_member_name
bsw@1045 236 if issue and issue.fully_frozen and issue.closed then
bsw@1045 237 if issue.member_info.first_trustee_participation then
bsw@1045 238 voting_member_id = issue.member_info.first_trustee_id
bsw@1045 239 voting_member_name = issue.member_info.first_trustee_name
bsw@1045 240 elseif issue.member_info.other_trustee_participation then
bsw@1045 241 voting_member_id = issue.member_info.other_trustee_id
bsw@1045 242 voting_member_name = issue.member_info.other_trustee_name
bsw@1045 243 end
bsw@1045 244 end
bsw@1045 245
bsw@780 246 if app.session.member_id == member.id then
bsw@1045 247
bsw@1045 248 if voting_member_id then
bsw@1045 249 ui.link{
bsw@1045 250 module = "vote", view = "list", params = {
bsw@1045 251 issue_id = issue.id,
bsw@1045 252 member_id = voting_member_id
bsw@1045 253 },
bsw@1045 254 attr = { class = class }, content = function()
bsw@1045 255 print_delegation_info()
bsw@1045 256 end
bsw@1045 257 }
bsw@1045 258
bsw@1045 259 else
bsw@1045 260 ui.link{
bsw@1045 261 module = "delegation", view = "show", params = {
bsw@1045 262 unit_id = unit_id,
bsw@1045 263 area_id = area_id,
bsw@1045 264 issue_id = issue_id
bsw@1045 265 },
bsw@1045 266 attr = { class = class }, content = function()
bsw@1045 267 print_delegation_info()
bsw@1045 268 end
bsw@1045 269 }
bsw@1045 270 end
bsw@780 271 else
bsw@780 272 ui.container{
bsw@1045 273 attr = { class = class }, content = function()
bsw@780 274 print_delegation_info()
bsw@780 275 end
bsw@780 276 }
bsw@780 277 end
bsw@551 278 end
bsw@1045 279
bsw/jbe@1309 280 if issue and app.session.member and issue.fully_frozen and not issue.closed and not issue.member_info.direct_voted and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
bsw/jbe@1309 281 ui.link{
bsw/jbe@1309 282 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
bsw/jbe@1309 283 module = "vote", view = "list", params = {
bsw/jbe@1309 284 issue_id = issue.id
bsw/jbe@1309 285 },
bsw/jbe@1309 286 content = function ()
bsw/jbe@1309 287 ui.tag { content = _"vote now" }
bsw/jbe@1309 288 end
bsw/jbe@1309 289 }
bsw/jbe@1309 290 else
bsw/jbe@1309 291 end

Impressum / About Us