liquid_feedback_frontend

annotate app/main/vote/list.lua @ 1309:32cc544d5a5b

Cumulative patch for upcoming frontend version 4
author bsw/jbe
date Sun Jul 15 14:07:29 2018 +0200 (2018-07-15)
parents 904f6807f7fa
children 09423cf96e9d
rev   line source
bsw/jbe@19 1 local issue = Issue:by_id(param.get("issue_id"), atom.integer)
bsw/jbe@19 2
bsw/jbe@1309 3 -- TODO patch for project voting
bsw/jbe@1309 4 if not issue.closed and config.alternative_voting and config.alternative_voting[tostring(issue.policy.id)] then
bsw/jbe@1309 5 local voting_config = config.alternative_voting[tostring(issue.policy.id)]
bsw/jbe@1309 6
bsw/jbe@1309 7 local url = encode.url {
bsw/jbe@1309 8 module = voting_config.module,
bsw/jbe@1309 9 view = voting_config.view,
bsw/jbe@1309 10 params = { issue_id = issue.id }
bsw/jbe@1309 11 }
bsw/jbe@1309 12
bsw/jbe@1309 13 return request.redirect{ external = url }
bsw/jbe@1309 14 end
bsw/jbe@1309 15
bsw/jbe@1309 16 if not issue then
bsw/jbe@1309 17 execute.view { module = "index", view = "404" }
bsw/jbe@1309 18 return
bsw/jbe@1309 19 end
bsw/jbe@1309 20
bsw/jbe@19 21 local member_id = param.get("member_id", atom.integer)
bsw/jbe@19 22 local member
jbe@945 23 local readonly = false
bsw/jbe@19 24
jbe@950 25 local preview = param.get("preview") and true or false
poelzi@156 26
bsw/jbe@19 27 if member_id then
bsw/jbe@1309 28 if not issue.closed then
bsw/jbe@1309 29 execute.view{ module = "index", view = "403" }
bsw/jbe@1309 30 return
bsw/jbe@19 31 end
bsw/jbe@19 32 member = Member:by_id(member_id)
bsw/jbe@19 33 readonly = true
bsw/jbe@19 34 end
bsw/jbe@19 35
poelzi@138 36 if issue.closed then
poelzi@156 37 if not member then
poelzi@158 38 member = app.session.member
poelzi@158 39 end
poelzi@156 40 readonly = true
poelzi@138 41 end
poelzi@138 42
bsw@1045 43 if preview then
bsw@1045 44 readonly = true
bsw@1045 45 end
bsw@1045 46
bsw@879 47 local submit_button_text = _"Finish voting"
bsw@1045 48 local edit_button_text = _"Edit again"
bsw@879 49
bsw@879 50 if issue.closed then
bsw@1045 51 submit_button_text = _"Save voting comment"
bsw@1045 52 edit_button_text = _"Edit voting comment"
bsw@879 53 end
bsw@879 54
bsw@1045 55 execute.view {
bsw@1045 56 module = "issue", view = "_head", params = { issue = issue }
bsw@1045 57 }
bsw@1045 58
bsw@879 59 local direct_voter
bsw@879 60
bsw/jbe@19 61 if member then
bsw@879 62 direct_voter = DirectVoter:by_pk(issue.id, member.id)
bsw/jbe@19 63 else
bsw/jbe@19 64 member = app.session.member
bsw@879 65 direct_voter = DirectVoter:by_pk(issue.id, member.id)
bsw/jbe@19 66 end
bsw/jbe@19 67
bsw/jbe@19 68
bsw@879 69
bsw/jbe@19 70 local tempvoting_string = param.get("scoring")
bsw/jbe@19 71
bsw/jbe@19 72 local tempvotings = {}
bsw/jbe@19 73 if tempvoting_string then
bsw/jbe@19 74 for match in tempvoting_string:gmatch("([^;]+)") do
bsw/jbe@19 75 for initiative_id, grade in match:gmatch("([^:;]+):([^:;]+)") do
bsw/jbe@19 76 tempvotings[tonumber(initiative_id)] = tonumber(grade)
bsw/jbe@19 77 end
bsw/jbe@5 78 end
bsw/jbe@19 79 end
bsw/jbe@5 80
bsw@95 81 local initiatives = issue:get_reference_selector("initiatives"):add_where("initiative.admitted"):add_order_by("initiative.satisfied_supporter_count DESC"):exec()
bsw/jbe@5 82
bsw/jbe@5 83 local min_grade = -1;
bsw/jbe@5 84 local max_grade = 1;
bsw/jbe@5 85
bsw/jbe@5 86 for i, initiative in ipairs(initiatives) do
bsw/jbe@5 87 -- TODO performance
bsw/jbe@19 88 initiative.vote = Vote:by_pk(initiative.id, member.id)
bsw/jbe@19 89 if tempvotings[initiative.id] then
bsw/jbe@19 90 initiative.vote = {}
bsw/jbe@19 91 initiative.vote.grade = tempvotings[initiative.id]
bsw/jbe@19 92 end
bsw/jbe@5 93 if initiative.vote then
bsw/jbe@5 94 if initiative.vote.grade > max_grade then
bsw/jbe@5 95 max_grade = initiative.vote.grade
bsw/jbe@5 96 end
bsw/jbe@5 97 if initiative.vote.grade < min_grade then
bsw/jbe@5 98 min_grade = initiative.vote.grade
bsw/jbe@5 99 end
bsw/jbe@5 100 end
bsw/jbe@5 101 end
bsw/jbe@5 102
bsw/jbe@5 103 local sections = {}
bsw/jbe@5 104 for i = min_grade, max_grade do
bsw/jbe@5 105 sections[i] = {}
bsw/jbe@5 106 for j, initiative in ipairs(initiatives) do
bsw/jbe@5 107 if (initiative.vote and initiative.vote.grade == i) or (not initiative.vote and i == 0) then
bsw/jbe@5 108 sections[i][#(sections[i])+1] = initiative
bsw/jbe@5 109 end
bsw/jbe@5 110 end
bsw/jbe@5 111 end
bsw/jbe@5 112
bsw/jbe@19 113 local approval_count, disapproval_count = 0, 0
bsw/jbe@19 114 for i = min_grade, -1 do
bsw/jbe@19 115 if #sections[i] > 0 then
bsw/jbe@19 116 disapproval_count = disapproval_count + 1
bsw/jbe@19 117 end
bsw/jbe@19 118 end
bsw/jbe@19 119 local approval_count = 0
bsw/jbe@19 120 for i = 1, max_grade do
bsw/jbe@19 121 if #sections[i] > 0 then
bsw/jbe@19 122 approval_count = approval_count + 1
bsw/jbe@19 123 end
bsw/jbe@19 124 end
bsw/jbe@5 125
bsw/jbe@19 126 if not readonly then
bsw/jbe@19 127 slot.put('<script src="' .. request.get_relative_baseurl() .. 'static/js/dragdrop.js"></script>')
bsw/jbe@19 128 slot.put('<script src="' .. request.get_relative_baseurl() .. 'static/js/voting.js"></script>')
bsw/jbe@19 129 end
bsw/jbe@19 130
bsw/jbe@19 131 ui.script{
bsw/jbe@19 132 script = function()
bsw/jbe@19 133 slot.put(
bsw/jbe@19 134 "voting_text_approval_single = ", encode.json(_"Approval [single entry]"), ";\n",
bsw/jbe@19 135 "voting_text_approval_multi = ", encode.json(_"Approval [many entries]"), ";\n",
bsw/jbe@19 136 "voting_text_first_preference_single = ", encode.json(_"Approval (first preference) [single entry]"), ";\n",
bsw/jbe@19 137 "voting_text_first_preference_multi = ", encode.json(_"Approval (first preference) [many entries]"), ";\n",
bsw/jbe@19 138 "voting_text_second_preference_single = ", encode.json(_"Approval (second preference) [single entry]"), ";\n",
bsw/jbe@19 139 "voting_text_second_preference_multi = ", encode.json(_"Approval (second preference) [many entries]"), ";\n",
bsw/jbe@19 140 "voting_text_third_preference_single = ", encode.json(_"Approval (third preference) [single entry]"), ";\n",
bsw/jbe@19 141 "voting_text_third_preference_multi = ", encode.json(_"Approval (third preference) [many entries]"), ";\n",
bsw/jbe@19 142 "voting_text_numeric_preference_single = ", encode.json(_"Approval (#th preference) [single entry]"), ";\n",
bsw/jbe@19 143 "voting_text_numeric_preference_multi = ", encode.json(_"Approval (#th preference) [many entries]"), ";\n",
bsw/jbe@19 144 "voting_text_abstention_single = ", encode.json(_"Abstention [single entry]"), ";\n",
bsw/jbe@19 145 "voting_text_abstention_multi = ", encode.json(_"Abstention [many entries]"), ";\n",
bsw/jbe@19 146 "voting_text_disapproval_above_one_single = ", encode.json(_"Disapproval (prefer to lower block) [single entry]"), ";\n",
bsw/jbe@19 147 "voting_text_disapproval_above_one_multi = ", encode.json(_"Disapproval (prefer to lower block) [many entries]"), ";\n",
bsw/jbe@19 148 "voting_text_disapproval_above_many_single = ", encode.json(_"Disapproval (prefer to lower blocks) [single entry]"), ";\n",
bsw/jbe@19 149 "voting_text_disapproval_above_many_multi = ", encode.json(_"Disapproval (prefer to lower blocks) [many entries]"), ";\n",
bsw/jbe@19 150 "voting_text_disapproval_above_last_single = ", encode.json(_"Disapproval (prefer to last block) [single entry]"), ";\n",
bsw/jbe@19 151 "voting_text_disapproval_above_last_multi = ", encode.json(_"Disapproval (prefer to last block) [many entries]"), ";\n",
bsw/jbe@19 152 "voting_text_disapproval_single = ", encode.json(_"Disapproval [single entry]"), ";\n",
bsw/jbe@19 153 "voting_text_disapproval_multi = ", encode.json(_"Disapproval [many entries]"), ";\n"
bsw/jbe@19 154 )
bsw/jbe@19 155 end
bsw/jbe@19 156 }
bsw/jbe@5 157
bsw@1045 158 if issue.state == "finished_with_winner"
bsw@1045 159 or issue.state == "finished_without_winner"
bsw@1045 160 then
bsw@1045 161
bsw@1045 162 local members_selector = Member:new_selector()
bsw@1045 163 :join("delegating_voter", nil, "delegating_voter.member_id = member.id")
bsw@1045 164 :add_where{ "delegating_voter.issue_id = ?", issue.id }
bsw@1045 165 :add_where{ "delegating_voter.delegate_member_ids[1] = ?", member.id }
bsw@1045 166 :add_field("delegating_voter.weight", "voter_weight")
bsw@1045 167 :join("issue", nil, "issue.id = delegating_voter.issue_id")
bsw@1045 168
bsw@1045 169 ui.sidebar( "tab-members", function()
bsw@1045 170 ui.sidebarHead(function()
bsw/jbe@1309 171 ui.heading{ level = 4, content = _"Incoming delegations" }
bsw@1045 172 end)
bsw@1045 173 execute.view{
bsw@1045 174 module = "member",
bsw@1045 175 view = "_list",
bsw@1045 176 params = {
bsw@1045 177 members_selector = members_selector,
bsw@1045 178 trustee = member,
bsw@1045 179 issue = issue,
bsw@1045 180 initiative = initiative,
bsw@1045 181 for_votes = true, no_filter = true,
bsw@1045 182 member_class = "sidebarRow sidebarRowNarrow",
bsw/jbe@5 183 }
bsw@1045 184 }
bsw@1045 185 end)
bsw@1045 186 end
bsw@1045 187
bsw/jbe@1309 188 ui.container{ attr = { class = "mdl-grid" }, content = function()
bsw/jbe@1309 189 ui.container{ attr = { class = "mdl-cell mdl-cell--12-col" }, content = function()
bsw@1045 190
bsw/jbe@1309 191 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw/jbe@1309 192 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw/jbe@1309 193 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function()
bsw/jbe@1309 194 if preview then
bsw/jbe@1309 195 ui.tag{ content = _"Preview of voting ballot" }
bsw/jbe@1309 196 elseif readonly then
bsw/jbe@1309 197 local str = _("Ballot of '#{member_name}'", { member_name = string.format(
bsw/jbe@1309 198 '<a href="%s">%s</a>',
bsw/jbe@1309 199 encode.url{ module = "member", view = "show", id = member.id },
bsw/jbe@1309 200 encode.html(member.name)
bsw/jbe@1309 201 ) })
bsw/jbe@1309 202 ui.tag{ content = function () slot.put ( str ) end }
bsw/jbe@1309 203 else
bsw/jbe@1309 204 ui.tag{ content = _"Voting" }
bsw/jbe@5 205 end
bsw/jbe@1309 206 end }
bsw/jbe@1309 207 end }
bsw/jbe@1309 208
bsw/jbe@1309 209 ui.container{ attr = { class = "mdl-card__content" }, content = function()
bsw/jbe@1309 210
bsw/jbe@1309 211 ui.form{
bsw/jbe@1309 212 record = direct_voter,
bsw/jbe@1309 213 attr = {
bsw/jbe@1309 214 id = "voting_form",
bsw/jbe@1309 215 class = readonly and "voting_form_readonly" or "voting_form_active"
bsw/jbe@1309 216 },
bsw/jbe@1309 217 module = "vote",
bsw/jbe@1309 218 action = "update",
bsw/jbe@1309 219 params = { issue_id = issue.id },
bsw@1045 220 content = function()
bsw/jbe@1309 221 if not readonly or preview then
bsw/jbe@1309 222 local scoring = param.get("scoring")
bsw/jbe@1309 223 if not scoring then
bsw/jbe@1309 224 for i, initiative in ipairs(initiatives) do
bsw/jbe@1309 225 local vote = initiative.vote
bsw/jbe@1309 226 if vote then
bsw/jbe@1309 227 tempvotings[initiative.id] = vote.grade
bsw/jbe@1309 228 else
bsw/jbe@1309 229 tempvotings[initiative.id] = 0
bsw/jbe@1309 230 end
bsw/jbe@1309 231 end
bsw/jbe@1309 232 local tempvotings_list = {}
bsw/jbe@1309 233 for key, val in pairs(tempvotings) do
bsw/jbe@1309 234 tempvotings_list[#tempvotings_list+1] = tostring(key) .. ":" .. tostring(val)
bsw/jbe@1309 235 end
bsw/jbe@1309 236 if #tempvotings_list > 0 then
bsw/jbe@1309 237 scoring = table.concat(tempvotings_list, ";")
bsw/jbe@1309 238 else
bsw/jbe@1309 239 scoring = ""
bsw/jbe@1309 240 end
bsw@1045 241 end
bsw/jbe@1309 242 slot.put('<input type="hidden" name="scoring" value="' .. scoring .. '"/>')
bsw/jbe@1309 243 end
bsw/jbe@1309 244 if preview then
bsw/jbe@1309 245 ui.container{ content = _"Your choice" }
bsw/jbe@1309 246 elseif not readonly then
bsw/jbe@1309 247 ui.container{ content = _"Make your choice by placing the initiatives" }
bsw/jbe@1309 248 end
bsw/jbe@1309 249
bsw/jbe@1309 250 ui.container{
bsw/jbe@1309 251 attr = { id = "voting" },
bsw/jbe@1309 252 content = function()
bsw/jbe@1309 253 local approval_index, disapproval_index = 0, 0
bsw/jbe@1309 254 local approval_used, disapproval_used
bsw/jbe@1309 255 for grade = max_grade, min_grade, -1 do
bsw/jbe@1309 256 local entries = sections[grade]
bsw/jbe@1309 257 local class
bsw/jbe@1309 258 if grade > 0 then
bsw/jbe@1309 259 class = "approval"
bsw/jbe@1309 260 elseif grade < 0 then
bsw/jbe@1309 261 class = "disapproval"
bsw/jbe@1309 262 else
bsw/jbe@1309 263 class = "abstention"
bsw/jbe@1309 264 end
bsw/jbe@1309 265 if
bsw/jbe@1309 266 #entries > 0 or
bsw/jbe@1309 267 (grade == 1 and not approval_used) or
bsw/jbe@1309 268 (grade == -1 and not disapproval_used) or
bsw/jbe@1309 269 grade == 0
bsw/jbe@1309 270 then
bsw/jbe@1309 271 ui.container{
bsw/jbe@1309 272 attr = { class = class },
bsw/jbe@1309 273 content = function()
bsw/jbe@1309 274 local heading
bsw/jbe@1309 275 if class == "approval" then
bsw/jbe@1309 276 approval_used = true
bsw/jbe@1309 277 approval_index = approval_index + 1
bsw/jbe@1309 278 if approval_count > 1 then
bsw/jbe@1309 279 if approval_index == 1 then
bsw/jbe@1309 280 if #entries == 1 then
bsw/jbe@1309 281 heading = _"Approval (first preference) [single entry]"
bsw/jbe@1309 282 else
bsw/jbe@1309 283 heading = _"Approval (first preference) [many entries]"
bsw/jbe@1309 284 end
bsw/jbe@1309 285 elseif approval_index == 2 then
bsw/jbe@1309 286 if #entries == 1 then
bsw/jbe@1309 287 heading = _"Approval (second preference) [single entry]"
bsw/jbe@1309 288 else
bsw/jbe@1309 289 heading = _"Approval (second preference) [many entries]"
bsw/jbe@1309 290 end
bsw/jbe@1309 291 elseif approval_index == 3 then
bsw/jbe@1309 292 if #entries == 1 then
bsw/jbe@1309 293 heading = _"Approval (third preference) [single entry]"
bsw/jbe@1309 294 else
bsw/jbe@1309 295 heading = _"Approval (third preference) [many entries]"
bsw/jbe@1309 296 end
bsw/jbe@1309 297 else
bsw/jbe@1309 298 if #entries == 1 then
bsw/jbe@1309 299 heading = _"Approval (#th preference) [single entry]"
bsw/jbe@1309 300 else
bsw/jbe@1309 301 heading = _"Approval (#th preference) [many entries]"
bsw/jbe@1309 302 end
bsw/jbe@1309 303 end
bsw@1045 304 else
bsw/jbe@1309 305 if #entries == 1 then
bsw/jbe@1309 306 heading = _"Approval [single entry]"
bsw/jbe@1309 307 else
bsw/jbe@1309 308 heading = _"Approval [many entries]"
bsw/jbe@1309 309 end
bsw@1045 310 end
bsw/jbe@1309 311 elseif class == "abstention" then
bsw/jbe@1309 312 if #entries == 1 then
bsw/jbe@1309 313 heading = _"Abstention [single entry]"
bsw/jbe@1309 314 else
bsw/jbe@1309 315 heading = _"Abstention [many entries]"
bsw/jbe@1309 316 end
bsw/jbe@1309 317 elseif class == "disapproval" then
bsw/jbe@1309 318 disapproval_used = true
bsw/jbe@1309 319 disapproval_index = disapproval_index + 1
bsw/jbe@1309 320 if disapproval_count > disapproval_index + 1 then
bsw/jbe@1309 321 if #entries == 1 then
bsw/jbe@1309 322 heading = _"Disapproval (prefer to lower blocks) [single entry]"
bsw/jbe@1309 323 else
bsw/jbe@1309 324 heading = _"Disapproval (prefer to lower blocks) [many entries]"
bsw/jbe@1309 325 end
bsw/jbe@1309 326 elseif disapproval_count == 2 and disapproval_index == 1 then
bsw/jbe@1309 327 if #entries == 1 then
bsw/jbe@1309 328 heading = _"Disapproval (prefer to lower block) [single entry]"
bsw/jbe@1309 329 else
bsw/jbe@1309 330 heading = _"Disapproval (prefer to lower block) [many entries]"
bsw/jbe@1309 331 end
bsw/jbe@1309 332 elseif disapproval_index == disapproval_count - 1 then
bsw/jbe@1309 333 if #entries == 1 then
bsw/jbe@1309 334 heading = _"Disapproval (prefer to last block) [single entry]"
bsw/jbe@1309 335 else
bsw/jbe@1309 336 heading = _"Disapproval (prefer to last block) [many entries]"
bsw/jbe@1309 337 end
bsw@1045 338 else
bsw/jbe@1309 339 if #entries == 1 then
bsw/jbe@1309 340 heading = _"Disapproval [single entry]"
bsw/jbe@1309 341 else
bsw/jbe@1309 342 heading = _"Disapproval [many entries]"
bsw/jbe@1309 343 end
bsw@1045 344 end
bsw@1045 345 end
bsw/jbe@1309 346 ui.tag {
bsw/jbe@1309 347 tag = "div",
bsw/jbe@1309 348 attr = { class = "cathead " },
bsw/jbe@1309 349 content = heading
bsw/jbe@1309 350 }
bsw/jbe@1309 351 for i, initiative in ipairs(entries) do
bsw@1045 352 ui.container{
bsw/jbe@1309 353 attr = {
bsw/jbe@1309 354 class = "movable",
bsw/jbe@1309 355 id = "entry_" .. tostring(initiative.id)
bsw/jbe@1309 356 },
bsw@1045 357 content = function()
bsw/jbe@1309 358 local initiators_selector = initiative:get_reference_selector("initiating_members")
bsw/jbe@1309 359 :add_where("accepted")
bsw/jbe@1309 360 local initiators = initiators_selector:exec()
bsw/jbe@1309 361 local initiator_names = {}
bsw/jbe@1309 362 for i, initiator in ipairs(initiators) do
bsw/jbe@1309 363 initiator_names[#initiator_names+1] = initiator.name
bsw/jbe@1309 364 end
bsw/jbe@1309 365 local initiator_names_string = table.concat(initiator_names, ", ")
bsw/jbe@1309 366 ui.container{
bsw/jbe@1309 367 attr = { style = "float: right; position: relative;" },
bsw/jbe@1309 368 content = function()
bsw/jbe@1309 369 ui.link{
bsw/jbe@1309 370 attr = { class = "clickable" },
bsw/jbe@1309 371 content = _"Show",
bsw/jbe@1309 372 module = "initiative",
bsw/jbe@1309 373 view = "show",
bsw/jbe@1309 374 id = initiative.id
bsw/jbe@1309 375 }
bsw/jbe@1309 376 slot.put(" ")
bsw/jbe@1309 377 ui.link{
bsw/jbe@1309 378 attr = { class = "clickable", target = "_blank" },
bsw/jbe@1309 379 content = _"(new window)",
bsw/jbe@1309 380 module = "initiative",
bsw/jbe@1309 381 view = "show",
bsw/jbe@1309 382 id = initiative.id
bsw/jbe@1309 383 }
bsw/jbe@1309 384 if not readonly then
bsw/jbe@1309 385 slot.put(" ")
bsw/jbe@1309 386 ui.image{ attr = { class = "grabber" }, static = "icons/grabber.png" }
bsw/jbe@1309 387 end
bsw/jbe@1309 388 end
bsw@1045 389 }
bsw@1045 390 if not readonly then
bsw/jbe@1309 391 ui.container{
bsw/jbe@1309 392 attr = { style = "float: left; position: relative;" },
bsw/jbe@1309 393 content = function()
bsw/jbe@1309 394 ui.tag{
bsw/jbe@1309 395 tag = "button",
bsw/jbe@1309 396 attr = {
bsw/jbe@1309 397 onclick = "if (jsFail) return true; voting_moveUp(this.parentNode.parentNode); return(false);",
bsw/jbe@1309 398 name = "move_up_" .. tostring(initiative.id),
bsw/jbe@1309 399 class = "clickable mdl-button mdl-js-button mdl-button--icon",
bsw/jbe@1309 400 alt = _"Move up",
bsw/jbe@1309 401 },
bsw/jbe@1309 402 content = function()
bsw/jbe@1309 403 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "arrow_upward" }
bsw/jbe@1309 404 end
bsw/jbe@1309 405 }
bsw/jbe@1309 406 ui.tag{
bsw/jbe@1309 407 tag = "button",
bsw/jbe@1309 408 attr = {
bsw/jbe@1309 409 onclick = "if (jsFail) return true; voting_moveDown(this.parentNode.parentNode); return(false);",
bsw/jbe@1309 410 name = "move_down_" .. tostring(initiative.id),
bsw/jbe@1309 411 class = "clickable mdl-button mdl-js-button mdl-button--icon",
bsw/jbe@1309 412 alt = _"Move down"
bsw/jbe@1309 413 },
bsw/jbe@1309 414 content = function()
bsw/jbe@1309 415 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "arrow_downward" }
bsw/jbe@1309 416 end
bsw/jbe@1309 417 }
bsw/jbe@1309 418 slot.put("&nbsp;")
bsw/jbe@1309 419 end
bsw@286 420 }
bsw@1045 421 end
bsw/jbe@1309 422 ui.container{
bsw/jbe@1309 423 content = function()
bsw/jbe@1309 424 ui.tag{ attr = { class = "initiative_name" }, content = function()
bsw/jbe@1309 425 ui.tag{ content = "i" .. initiative.id .. ": " }
bsw/jbe@1309 426 ui.tag{ content = initiative.shortened_name }
bsw/jbe@1309 427 end }
bsw/jbe@1309 428 slot.put("<br />")
bsw/jbe@1309 429 for i, initiator in ipairs(initiators) do
bsw/jbe@1309 430 ui.link{
bsw/jbe@1309 431 attr = { class = "clickable" },
bsw/jbe@1309 432 content = function ()
bsw/jbe@1309 433 execute.view{
bsw/jbe@1309 434 module = "member_image",
bsw/jbe@1309 435 view = "_show",
bsw/jbe@1309 436 params = {
bsw/jbe@1309 437 member = initiator,
bsw/jbe@1309 438 image_type = "avatar",
bsw/jbe@1309 439 show_dummy = true,
bsw/jbe@1309 440 class = "micro_avatar",
bsw/jbe@1309 441 popup_text = text
bsw/jbe@1309 442 }
bsw/jbe@1309 443 }
bsw/jbe@1309 444 end,
bsw/jbe@1309 445 module = "member", view = "show", id = initiator.id
bsw@1045 446 }
bsw/jbe@1309 447 slot.put(" ")
bsw/jbe@1309 448 ui.tag{ content = initiator.name }
bsw/jbe@1309 449 slot.put(" ")
bsw/jbe@1309 450 end
bsw/jbe@1309 451 end
bsw/jbe@1309 452 }
bsw@1045 453 end
bsw@1045 454 }
bsw/jbe@19 455 end
bsw/jbe@1309 456 end
bsw/jbe@1309 457 }
bsw/jbe@1309 458 end
bsw/jbe@1309 459 end
bsw/jbe@1309 460 end
bsw/jbe@1309 461 }
bsw/jbe@1309 462 if app.session.member_id and preview then
bsw/jbe@1309 463 local formatting_engine = param.get("formatting_engine") or config.enforce_formatting_engine
bsw/jbe@1309 464 local comment = param.get("comment")
bsw/jbe@1309 465 if comment and #comment > 0 then
bsw/jbe@1309 466 local rendered_comment = format.wiki_text(comment, formatting_engine)
bsw/jbe@1309 467 ui.container{ content = _"Voting comment" }
bsw/jbe@1309 468 ui.container { attr = { class = "member_statement" }, content = function()
bsw/jbe@1309 469 slot.put(rendered_comment)
bsw/jbe@1309 470 end }
bsw/jbe@1309 471 slot.put("<br />")
bsw/jbe@1309 472 end
bsw/jbe@1309 473 end
bsw/jbe@1309 474 if (readonly or direct_voter and direct_voter.comment) and not preview and not (app.session.member_id == member.id) then
bsw/jbe@1309 475 local text
bsw/jbe@1309 476 if direct_voter and direct_voter.comment_changed then
bsw/jbe@1309 477 text = _("Voting comment (last updated: #{timestamp})", { timestamp = format.timestamp(direct_voter.comment_changed) })
bsw/jbe@1309 478 elseif direct_voter and direct_voter.comment then
bsw/jbe@1309 479 text = _"Voting comment"
bsw/jbe@1309 480 end
bsw/jbe@1309 481 if text then
bsw/jbe@1309 482 ui.container{ content = text }
bsw/jbe@1309 483 end
bsw/jbe@1309 484 if direct_voter and direct_voter.comment then
bsw/jbe@1309 485 local rendered_comment = direct_voter:get_content('html')
bsw/jbe@1309 486 ui.container { attr = { class = "member_statement" }, content = function()
bsw/jbe@1309 487 slot.put(rendered_comment)
bsw/jbe@1309 488 end }
bsw/jbe@1309 489 slot.put("<br />")
bsw/jbe@1309 490 end
bsw/jbe@1309 491 end
bsw/jbe@1309 492 if app.session.member_id and app.session.member_id == member.id then
bsw/jbe@1309 493 if (not readonly or direct_voter) and not preview then
bsw/jbe@1309 494 ui.container{ content = function()
bsw/jbe@1309 495 if not config.enforce_formatting_engine then
bsw/jbe@1309 496 ui.field.select{
bsw/jbe@1309 497 label = _"Wiki engine for statement",
bsw/jbe@1309 498 name = "formatting_engine",
bsw/jbe@1309 499 foreign_records = config.formatting_engines,
bsw/jbe@1309 500 attr = {id = "formatting_engine"},
bsw/jbe@1309 501 foreign_id = "id",
bsw/jbe@1309 502 foreign_name = "name",
bsw/jbe@1309 503 value = param.get("formatting_engine") or direct_voter and direct_voter.formatting_engine
bsw/jbe@1309 504 }
bsw@1045 505 end
bsw/jbe@1309 506 ui.container{ content = _"Voting comment (optional)" }
bsw/jbe@1309 507 ui.field.text{
bsw/jbe@1309 508 name = "comment",
bsw/jbe@1309 509 multiline = true,
bsw/jbe@1309 510 value = param.get("comment") or direct_voter and direct_voter.comment,
bsw/jbe@1309 511 attr = { style = "height: 10ex; width: 100%;" },
bsw/jbe@1309 512 }
bsw/jbe@1309 513 end }
bsw/jbe@1309 514 end
bsw/jbe@1309 515
bsw/jbe@1309 516 if preview then
bsw/jbe@1309 517 if not config.enforce_formatting_engine then
bsw/jbe@1309 518 ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
bsw/jbe@1309 519 end
bsw/jbe@1309 520 ui.field.hidden{ name = "comment", value = param.get("comment") or direct_voter and direct_voter.comment }
bsw/jbe@1309 521 end
bsw/jbe@1309 522
bsw/jbe@1309 523 if not readonly or direct_voter or preview then
bsw/jbe@1309 524 if preview then
bsw/jbe@1309 525 slot.put(" ")
bsw/jbe@1309 526 ui.tag{
bsw/jbe@1309 527 tag = "input",
bsw/jbe@1309 528 attr = {
bsw/jbe@1309 529 type = "submit",
bsw/jbe@1309 530 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
bsw/jbe@1309 531 name = issue.closed and "update_comment" or nil,
bsw/jbe@1309 532 value = submit_button_text -- finish voting / update comment
bsw/jbe@1309 533 }
bsw/jbe@1309 534 }
bsw/jbe@1309 535 end
bsw/jbe@1309 536 if not preview then
bsw/jbe@1309 537 ui.tag{
bsw/jbe@1309 538 tag = "input",
bsw/jbe@1309 539 attr = {
bsw/jbe@1309 540 type = "submit",
bsw/jbe@1309 541 name = "preview",
bsw/jbe@1309 542 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
bsw/jbe@1309 543 value = _"Preview",
bsw/jbe@1309 544 }
bsw/jbe@1309 545 }
bsw/jbe@1309 546 else
bsw/jbe@1309 547 slot.put(" &nbsp; ")
bsw/jbe@1309 548 ui.tag{
bsw/jbe@1309 549 tag = "input",
bsw/jbe@1309 550 attr = {
bsw/jbe@1309 551 type = "submit",
bsw/jbe@1309 552 name = "edit",
bsw/jbe@1309 553 class = "mdl-button mdl-js-button mdl-button--raised",
bsw/jbe@1309 554 value = edit_button_text,
bsw/jbe@1309 555 }
bsw/jbe@1309 556 }
bsw/jbe@1309 557 end
bsw@1045 558 end
bsw@1045 559 end
bsw@1045 560 end
bsw@1045 561 }
bsw/jbe@1309 562 slot.put("<br />")
bsw/jbe@1309 563 ui.link{
bsw/jbe@1309 564 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
bsw/jbe@1309 565 text = _"Cancel",
bsw/jbe@1309 566 module = "issue",
bsw/jbe@1309 567 view = "show",
bsw/jbe@1309 568 id = issue.id
bsw/jbe@1309 569 }
bsw/jbe@1309 570 if direct_voter then
bsw/jbe@1309 571 slot.put(" &nbsp; ")
bsw/jbe@1309 572 ui.link {
bsw/jbe@1309 573 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
bsw/jbe@1309 574 module = "vote", action = "update",
bsw/jbe@1309 575 params = {
bsw/jbe@1309 576 issue_id = issue.id,
bsw/jbe@1309 577 discard = true
bsw/jbe@1309 578 },
bsw/jbe@1309 579 routing = {
bsw/jbe@1309 580 default = {
bsw/jbe@1309 581 mode = "redirect",
bsw/jbe@1309 582 module = "issue",
bsw/jbe@1309 583 view = "show",
bsw/jbe@1309 584 id = issue.id
bsw@1045 585 }
bsw/jbe@1309 586 },
bsw/jbe@1309 587 text = _"Discard my vote"
bsw/jbe@1309 588 }
bsw/jbe@5 589 end
bsw/jbe@1309 590
bsw/jbe@1309 591 end }
bsw/jbe@1309 592 end }
bsw/jbe@1309 593 end }
bsw/jbe@1309 594 end }

Impressum / About Us