| 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/jbe@1309
 | 
   158 ui.container{ attr = { class = "mdl-grid" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   159   ui.container{ attr = { class = "mdl-cell mdl-cell--12-col" }, content = function()
 | 
| 
bsw@1045
 | 
   160 
 | 
| 
bsw/jbe@1309
 | 
   161     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   162       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   163         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function()
 | 
| 
bsw/jbe@1309
 | 
   164           if preview then
 | 
| 
bsw/jbe@1309
 | 
   165             ui.tag{ content = _"Preview of voting ballot" }
 | 
| 
bsw/jbe@1309
 | 
   166           elseif readonly then
 | 
| 
bsw/jbe@1309
 | 
   167             local str = _("Ballot of '#{member_name}'", { member_name = string.format(
 | 
| 
bsw/jbe@1309
 | 
   168               '<a href="%s">%s</a>', 
 | 
| 
bsw/jbe@1309
 | 
   169               encode.url{ module = "member", view = "show", id = member.id },
 | 
| 
bsw/jbe@1309
 | 
   170               encode.html(member.name)
 | 
| 
bsw/jbe@1309
 | 
   171             ) })
 | 
| 
bsw/jbe@1309
 | 
   172             ui.tag{ content = function () slot.put ( str ) end }
 | 
| 
bsw/jbe@1309
 | 
   173           else
 | 
| 
bsw/jbe@1309
 | 
   174             ui.tag{ content = _"Voting" }
 | 
| 
bsw/jbe@5
 | 
   175           end
 | 
| 
bsw/jbe@1309
 | 
   176         end }
 | 
| 
bsw/jbe@1309
 | 
   177       end }
 | 
| 
bsw/jbe@1309
 | 
   178 
 | 
| 
bsw/jbe@1309
 | 
   179       ui.container{ attr = { class = "mdl-card__content" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   180 
 | 
| 
bsw/jbe@1309
 | 
   181         ui.form{
 | 
| 
bsw/jbe@1309
 | 
   182           record = direct_voter,
 | 
| 
bsw/jbe@1309
 | 
   183           attr = {
 | 
| 
bsw/jbe@1309
 | 
   184             id = "voting_form",
 | 
| 
bsw/jbe@1309
 | 
   185             class = readonly and "voting_form_readonly" or "voting_form_active"
 | 
| 
bsw/jbe@1309
 | 
   186           },
 | 
| 
bsw/jbe@1309
 | 
   187           module = "vote",
 | 
| 
bsw/jbe@1309
 | 
   188           action = "update",
 | 
| 
bsw/jbe@1309
 | 
   189           params = { issue_id = issue.id },
 | 
| 
bsw@1045
 | 
   190           content = function()
 | 
| 
bsw/jbe@1309
 | 
   191             if not readonly or preview then
 | 
| 
bsw/jbe@1309
 | 
   192               local scoring = param.get("scoring")
 | 
| 
bsw/jbe@1309
 | 
   193               if not scoring then
 | 
| 
bsw/jbe@1309
 | 
   194                 for i, initiative in ipairs(initiatives) do
 | 
| 
bsw/jbe@1309
 | 
   195                   local vote = initiative.vote
 | 
| 
bsw/jbe@1309
 | 
   196                   if vote then
 | 
| 
bsw/jbe@1309
 | 
   197                     tempvotings[initiative.id] = vote.grade
 | 
| 
bsw/jbe@1309
 | 
   198                   else
 | 
| 
bsw/jbe@1309
 | 
   199                     tempvotings[initiative.id] = 0
 | 
| 
bsw/jbe@1309
 | 
   200                   end
 | 
| 
bsw/jbe@1309
 | 
   201                 end
 | 
| 
bsw/jbe@1309
 | 
   202                 local tempvotings_list = {}
 | 
| 
bsw/jbe@1309
 | 
   203                 for key, val in pairs(tempvotings) do
 | 
| 
bsw/jbe@1309
 | 
   204                   tempvotings_list[#tempvotings_list+1] = tostring(key) .. ":" .. tostring(val)
 | 
| 
bsw/jbe@1309
 | 
   205                 end
 | 
| 
bsw/jbe@1309
 | 
   206                 if #tempvotings_list > 0 then
 | 
| 
bsw/jbe@1309
 | 
   207                   scoring = table.concat(tempvotings_list, ";")
 | 
| 
bsw/jbe@1309
 | 
   208                 else
 | 
| 
bsw/jbe@1309
 | 
   209                   scoring = ""
 | 
| 
bsw/jbe@1309
 | 
   210                 end
 | 
| 
bsw@1045
 | 
   211               end
 | 
| 
bsw/jbe@1309
 | 
   212               slot.put('<input type="hidden" name="scoring" value="' .. scoring .. '"/>')
 | 
| 
bsw/jbe@1309
 | 
   213             end
 | 
| 
bsw/jbe@1309
 | 
   214             if preview then
 | 
| 
bsw/jbe@1309
 | 
   215               ui.container{ content = _"Your choice" }
 | 
| 
bsw/jbe@1309
 | 
   216             elseif not readonly then
 | 
| 
bsw/jbe@1309
 | 
   217               ui.container{ content = _"Make your choice by placing the initiatives" }
 | 
| 
bsw/jbe@1309
 | 
   218             end
 | 
| 
bsw/jbe@1309
 | 
   219             
 | 
| 
bsw/jbe@1309
 | 
   220             ui.container{
 | 
| 
bsw/jbe@1309
 | 
   221               attr = { id = "voting" },
 | 
| 
bsw/jbe@1309
 | 
   222               content = function()
 | 
| 
bsw/jbe@1309
 | 
   223                 local approval_index, disapproval_index = 0, 0
 | 
| 
bsw/jbe@1309
 | 
   224                 local approval_used, disapproval_used
 | 
| 
bsw/jbe@1309
 | 
   225                 for grade = max_grade, min_grade, -1 do 
 | 
| 
bsw/jbe@1309
 | 
   226                   local entries = sections[grade]
 | 
| 
bsw/jbe@1309
 | 
   227                   local class
 | 
| 
bsw/jbe@1309
 | 
   228                   if grade > 0 then
 | 
| 
bsw/jbe@1309
 | 
   229                     class = "approval"
 | 
| 
bsw/jbe@1309
 | 
   230                   elseif grade < 0 then
 | 
| 
bsw/jbe@1309
 | 
   231                     class = "disapproval"
 | 
| 
bsw/jbe@1309
 | 
   232                   else
 | 
| 
bsw/jbe@1309
 | 
   233                     class = "abstention"
 | 
| 
bsw/jbe@1309
 | 
   234                   end
 | 
| 
bsw/jbe@1309
 | 
   235                   if
 | 
| 
bsw/jbe@1309
 | 
   236                     #entries > 0 or
 | 
| 
bsw/jbe@1309
 | 
   237                     (grade == 1 and not approval_used) or
 | 
| 
bsw/jbe@1309
 | 
   238                     (grade == -1 and not disapproval_used) or
 | 
| 
bsw/jbe@1309
 | 
   239                     grade == 0
 | 
| 
bsw/jbe@1309
 | 
   240                   then
 | 
| 
bsw/jbe@1309
 | 
   241                     ui.container{
 | 
| 
bsw/jbe@1309
 | 
   242                       attr = { class = class },
 | 
| 
bsw/jbe@1309
 | 
   243                       content = function()
 | 
| 
bsw/jbe@1309
 | 
   244                         local heading
 | 
| 
bsw/jbe@1309
 | 
   245                         if class == "approval" then
 | 
| 
bsw/jbe@1309
 | 
   246                           approval_used = true
 | 
| 
bsw/jbe@1309
 | 
   247                           approval_index = approval_index + 1
 | 
| 
bsw/jbe@1309
 | 
   248                           if approval_count > 1 then
 | 
| 
bsw/jbe@1309
 | 
   249                             if approval_index == 1 then
 | 
| 
bsw/jbe@1309
 | 
   250                               if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   251                                 heading = _"Approval (first preference) [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   252                               else
 | 
| 
bsw/jbe@1309
 | 
   253                                 heading = _"Approval (first preference) [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   254                               end
 | 
| 
bsw/jbe@1309
 | 
   255                             elseif approval_index == 2 then
 | 
| 
bsw/jbe@1309
 | 
   256                               if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   257                                 heading = _"Approval (second preference) [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   258                               else
 | 
| 
bsw/jbe@1309
 | 
   259                                 heading = _"Approval (second preference) [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   260                               end
 | 
| 
bsw/jbe@1309
 | 
   261                             elseif approval_index == 3 then
 | 
| 
bsw/jbe@1309
 | 
   262                               if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   263                                 heading = _"Approval (third preference) [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   264                               else
 | 
| 
bsw/jbe@1309
 | 
   265                                 heading = _"Approval (third preference) [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   266                               end
 | 
| 
bsw/jbe@1309
 | 
   267                             else
 | 
| 
bsw/jbe@1309
 | 
   268                               if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   269                                 heading = _"Approval (#th preference) [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   270                               else
 | 
| 
bsw/jbe@1309
 | 
   271                                 heading = _"Approval (#th preference) [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   272                               end
 | 
| 
bsw/jbe@1309
 | 
   273                             end
 | 
| 
bsw@1045
 | 
   274                           else
 | 
| 
bsw/jbe@1309
 | 
   275                             if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   276                               heading = _"Approval [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   277                             else
 | 
| 
bsw/jbe@1309
 | 
   278                               heading = _"Approval [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   279                             end
 | 
| 
bsw@1045
 | 
   280                           end
 | 
| 
bsw/jbe@1309
 | 
   281                         elseif class == "abstention" then
 | 
| 
bsw/jbe@1309
 | 
   282                             if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   283                               heading = _"Abstention [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   284                             else
 | 
| 
bsw/jbe@1309
 | 
   285                               heading = _"Abstention [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   286                             end
 | 
| 
bsw/jbe@1309
 | 
   287                         elseif class == "disapproval" then
 | 
| 
bsw/jbe@1309
 | 
   288                           disapproval_used = true
 | 
| 
bsw/jbe@1309
 | 
   289                           disapproval_index = disapproval_index + 1
 | 
| 
bsw/jbe@1309
 | 
   290                           if disapproval_count > disapproval_index + 1 then
 | 
| 
bsw/jbe@1309
 | 
   291                             if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   292                               heading = _"Disapproval (prefer to lower blocks) [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   293                             else
 | 
| 
bsw/jbe@1309
 | 
   294                               heading = _"Disapproval (prefer to lower blocks) [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   295                             end
 | 
| 
bsw/jbe@1309
 | 
   296                           elseif disapproval_count == 2 and disapproval_index == 1 then
 | 
| 
bsw/jbe@1309
 | 
   297                             if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   298                               heading = _"Disapproval (prefer to lower block) [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   299                             else
 | 
| 
bsw/jbe@1309
 | 
   300                               heading = _"Disapproval (prefer to lower block) [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   301                             end
 | 
| 
bsw/jbe@1309
 | 
   302                           elseif disapproval_index == disapproval_count - 1 then
 | 
| 
bsw/jbe@1309
 | 
   303                             if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   304                               heading = _"Disapproval (prefer to last block) [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   305                             else
 | 
| 
bsw/jbe@1309
 | 
   306                               heading = _"Disapproval (prefer to last block) [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   307                             end
 | 
| 
bsw@1045
 | 
   308                           else
 | 
| 
bsw/jbe@1309
 | 
   309                             if #entries == 1 then
 | 
| 
bsw/jbe@1309
 | 
   310                               heading = _"Disapproval [single entry]"
 | 
| 
bsw/jbe@1309
 | 
   311                             else
 | 
| 
bsw/jbe@1309
 | 
   312                               heading = _"Disapproval [many entries]"
 | 
| 
bsw/jbe@1309
 | 
   313                             end
 | 
| 
bsw@1045
 | 
   314                           end
 | 
| 
bsw@1045
 | 
   315                         end
 | 
| 
bsw/jbe@1309
 | 
   316                         ui.tag {
 | 
| 
bsw/jbe@1309
 | 
   317                           tag     = "div",
 | 
| 
bsw/jbe@1309
 | 
   318                           attr    = { class = "cathead " },
 | 
| 
bsw/jbe@1309
 | 
   319                           content = heading
 | 
| 
bsw/jbe@1309
 | 
   320                         }
 | 
| 
bsw/jbe@1309
 | 
   321                         for i, initiative in ipairs(entries) do
 | 
| 
bsw@1045
 | 
   322                           ui.container{
 | 
| 
bsw/jbe@1309
 | 
   323                             attr = {
 | 
| 
bsw/jbe@1309
 | 
   324                               class = "movable",
 | 
| 
bsw/jbe@1309
 | 
   325                               id = "entry_" .. tostring(initiative.id)
 | 
| 
bsw/jbe@1309
 | 
   326                             },
 | 
| 
bsw@1045
 | 
   327                             content = function()
 | 
| 
bsw/jbe@1309
 | 
   328                               local initiators_selector = initiative:get_reference_selector("initiating_members")
 | 
| 
bsw/jbe@1309
 | 
   329                                 :add_where("accepted")
 | 
| 
bsw/jbe@1309
 | 
   330                               local initiators = initiators_selector:exec()
 | 
| 
bsw/jbe@1309
 | 
   331                               local initiator_names = {}
 | 
| 
bsw/jbe@1309
 | 
   332                               for i, initiator in ipairs(initiators) do
 | 
| 
bsw/jbe@1309
 | 
   333                                 initiator_names[#initiator_names+1] = initiator.name
 | 
| 
bsw/jbe@1309
 | 
   334                               end
 | 
| 
bsw/jbe@1309
 | 
   335                               local initiator_names_string = table.concat(initiator_names, ", ")
 | 
| 
bsw/jbe@1309
 | 
   336                               ui.container{
 | 
| 
bsw/jbe@1309
 | 
   337                                 attr = { style = "float: right; position: relative;" },
 | 
| 
bsw/jbe@1309
 | 
   338                                 content = function()
 | 
| 
bsw/jbe@1309
 | 
   339                                   ui.link{
 | 
| 
bsw/jbe@1309
 | 
   340                                     attr = { class = "clickable" },
 | 
| 
bsw/jbe@1309
 | 
   341                                     content = _"Show",
 | 
| 
bsw/jbe@1309
 | 
   342                                     module = "initiative",
 | 
| 
bsw/jbe@1309
 | 
   343                                     view = "show",
 | 
| 
bsw/jbe@1309
 | 
   344                                     id = initiative.id
 | 
| 
bsw/jbe@1309
 | 
   345                                   }
 | 
| 
bsw/jbe@1309
 | 
   346                                   slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   347                                   ui.link{
 | 
| 
bsw/jbe@1309
 | 
   348                                     attr = { class = "clickable", target = "_blank" },
 | 
| 
bsw/jbe@1309
 | 
   349                                     content = _"(new window)",
 | 
| 
bsw/jbe@1309
 | 
   350                                     module = "initiative",
 | 
| 
bsw/jbe@1309
 | 
   351                                     view = "show",
 | 
| 
bsw/jbe@1309
 | 
   352                                     id = initiative.id
 | 
| 
bsw/jbe@1309
 | 
   353                                   }
 | 
| 
bsw/jbe@1309
 | 
   354                                   if not readonly then
 | 
| 
bsw/jbe@1309
 | 
   355                                     slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   356                                     ui.image{ attr = { class = "grabber" }, static = "icons/grabber.png" }
 | 
| 
bsw/jbe@1309
 | 
   357                                   end
 | 
| 
bsw/jbe@1309
 | 
   358                                 end
 | 
| 
bsw@1045
 | 
   359                               }
 | 
| 
bsw@1045
 | 
   360                               if not readonly then
 | 
| 
bsw/jbe@1309
 | 
   361                                 ui.container{
 | 
| 
bsw/jbe@1309
 | 
   362                                   attr = { style = "float: left; position: relative;" },
 | 
| 
bsw/jbe@1309
 | 
   363                                   content = function()
 | 
| 
bsw/jbe@1309
 | 
   364                                     ui.tag{
 | 
| 
bsw/jbe@1309
 | 
   365                                       tag = "button",
 | 
| 
bsw/jbe@1309
 | 
   366                                       attr = {
 | 
| 
bsw/jbe@1309
 | 
   367                                         onclick = "if (jsFail) return true; voting_moveUp(this.parentNode.parentNode); return(false);",
 | 
| 
bsw/jbe@1309
 | 
   368                                         name = "move_up_" .. tostring(initiative.id),
 | 
| 
bsw/jbe@1309
 | 
   369                                         class = "clickable mdl-button mdl-js-button mdl-button--icon",
 | 
| 
bsw/jbe@1309
 | 
   370                                         alt = _"Move up",
 | 
| 
bsw/jbe@1309
 | 
   371                                       },
 | 
| 
bsw/jbe@1309
 | 
   372                                       content = function()
 | 
| 
bsw/jbe@1309
 | 
   373                                         ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "arrow_upward" }
 | 
| 
bsw/jbe@1309
 | 
   374                                       end
 | 
| 
bsw/jbe@1309
 | 
   375                                     }
 | 
| 
bsw/jbe@1309
 | 
   376                                     ui.tag{
 | 
| 
bsw/jbe@1309
 | 
   377                                       tag = "button",
 | 
| 
bsw/jbe@1309
 | 
   378                                       attr = {
 | 
| 
bsw/jbe@1309
 | 
   379                                         onclick = "if (jsFail) return true; voting_moveDown(this.parentNode.parentNode); return(false);",
 | 
| 
bsw/jbe@1309
 | 
   380                                         name = "move_down_" .. tostring(initiative.id),
 | 
| 
bsw/jbe@1309
 | 
   381                                         class = "clickable mdl-button mdl-js-button mdl-button--icon",
 | 
| 
bsw/jbe@1309
 | 
   382                                         alt = _"Move down"
 | 
| 
bsw/jbe@1309
 | 
   383                                       },
 | 
| 
bsw/jbe@1309
 | 
   384                                       content = function()
 | 
| 
bsw/jbe@1309
 | 
   385                                         ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "arrow_downward" }
 | 
| 
bsw/jbe@1309
 | 
   386                                       end
 | 
| 
bsw/jbe@1309
 | 
   387                                     }
 | 
| 
bsw/jbe@1309
 | 
   388                                     slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   389                                   end
 | 
| 
bsw@286
 | 
   390                                 }
 | 
| 
bsw@1045
 | 
   391                               end
 | 
| 
bsw/jbe@1309
 | 
   392                               ui.container{
 | 
| 
bsw/jbe@1309
 | 
   393                                 content = function()
 | 
| 
bsw/jbe@1309
 | 
   394                                   ui.tag{ attr = { class = "initiative_name" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   395                                     ui.tag{ content = "i" .. initiative.id .. ": " }
 | 
| 
bsw/jbe@1309
 | 
   396                                     ui.tag{ content = initiative.shortened_name }
 | 
| 
bsw/jbe@1309
 | 
   397                                   end }
 | 
| 
bsw/jbe@1309
 | 
   398                                   slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
   399                                   for i, initiator in ipairs(initiators) do
 | 
| 
bsw/jbe@1309
 | 
   400                                     ui.link{
 | 
| 
bsw/jbe@1309
 | 
   401                                       attr = { class = "clickable" },
 | 
| 
bsw/jbe@1309
 | 
   402                                       content = function ()
 | 
| 
bsw/jbe@1309
 | 
   403                                         execute.view{
 | 
| 
bsw/jbe@1309
 | 
   404                                           module = "member_image",
 | 
| 
bsw/jbe@1309
 | 
   405                                           view = "_show",
 | 
| 
bsw/jbe@1309
 | 
   406                                           params = {
 | 
| 
bsw/jbe@1309
 | 
   407                                             member = initiator,
 | 
| 
bsw/jbe@1309
 | 
   408                                             image_type = "avatar",
 | 
| 
bsw/jbe@1309
 | 
   409                                             show_dummy = true,
 | 
| 
bsw/jbe@1309
 | 
   410                                             class = "micro_avatar",
 | 
| 
bsw/jbe@1309
 | 
   411                                             popup_text = text
 | 
| 
bsw/jbe@1309
 | 
   412                                           }
 | 
| 
bsw/jbe@1309
 | 
   413                                         }
 | 
| 
bsw/jbe@1309
 | 
   414                                       end,
 | 
| 
bsw/jbe@1309
 | 
   415                                       module = "member", view = "show", id = initiator.id
 | 
| 
bsw@1045
 | 
   416                                     }
 | 
| 
bsw/jbe@1309
 | 
   417                                     slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   418                                     ui.tag{ content = initiator.name }
 | 
| 
bsw/jbe@1309
 | 
   419                                     slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   420                                   end
 | 
| 
bsw/jbe@1309
 | 
   421                                 end
 | 
| 
bsw/jbe@1309
 | 
   422                               }
 | 
| 
bsw@1045
 | 
   423                             end
 | 
| 
bsw@1045
 | 
   424                           }
 | 
| 
bsw/jbe@19
 | 
   425                         end
 | 
| 
bsw/jbe@1309
 | 
   426                       end
 | 
| 
bsw/jbe@1309
 | 
   427                     }
 | 
| 
bsw/jbe@1309
 | 
   428                   end
 | 
| 
bsw/jbe@1309
 | 
   429                 end
 | 
| 
bsw/jbe@1309
 | 
   430               end
 | 
| 
bsw/jbe@1309
 | 
   431             }
 | 
| 
bsw/jbe@1309
 | 
   432             if app.session.member_id and preview then
 | 
| 
bsw/jbe@1309
 | 
   433               local formatting_engine = param.get("formatting_engine") or config.enforce_formatting_engine
 | 
| 
bsw/jbe@1309
 | 
   434               local comment = param.get("comment")
 | 
| 
bsw/jbe@1309
 | 
   435               if comment and #comment > 0 then
 | 
| 
bsw/jbe@1309
 | 
   436                 local rendered_comment = format.wiki_text(comment, formatting_engine)
 | 
| 
bsw/jbe@1309
 | 
   437                 ui.container{ content = _"Voting comment" }
 | 
| 
bsw/jbe@1309
 | 
   438                 ui.container { attr = { class = "member_statement" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   439                   slot.put(rendered_comment)
 | 
| 
bsw/jbe@1309
 | 
   440                 end }
 | 
| 
bsw/jbe@1309
 | 
   441                 slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
   442               end
 | 
| 
bsw/jbe@1309
 | 
   443             end
 | 
| 
bsw/jbe@1309
 | 
   444             if (readonly or direct_voter and direct_voter.comment) and not preview and not (app.session.member_id == member.id) then
 | 
| 
bsw/jbe@1309
 | 
   445               local text
 | 
| 
bsw/jbe@1309
 | 
   446               if direct_voter and direct_voter.comment_changed then
 | 
| 
bsw/jbe@1309
 | 
   447                 text = _("Voting comment (last updated: #{timestamp})", { timestamp = format.timestamp(direct_voter.comment_changed) })
 | 
| 
bsw/jbe@1309
 | 
   448               elseif direct_voter and direct_voter.comment then
 | 
| 
bsw/jbe@1309
 | 
   449                 text = _"Voting comment"
 | 
| 
bsw/jbe@1309
 | 
   450               end
 | 
| 
bsw/jbe@1309
 | 
   451               if text then
 | 
| 
bsw/jbe@1309
 | 
   452                 ui.container{ content = text }
 | 
| 
bsw/jbe@1309
 | 
   453               end
 | 
| 
bsw/jbe@1309
 | 
   454               if direct_voter and direct_voter.comment then
 | 
| 
bsw/jbe@1309
 | 
   455                 local rendered_comment = direct_voter:get_content('html')
 | 
| 
bsw/jbe@1309
 | 
   456                 ui.container { attr = { class = "member_statement" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   457                   slot.put(rendered_comment)
 | 
| 
bsw/jbe@1309
 | 
   458                 end }
 | 
| 
bsw/jbe@1309
 | 
   459                 slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
   460               end
 | 
| 
bsw/jbe@1309
 | 
   461             end
 | 
| 
bsw/jbe@1309
 | 
   462             if app.session.member_id and app.session.member_id == member.id then
 | 
| 
bsw/jbe@1309
 | 
   463               if (not readonly or direct_voter) and not preview then
 | 
| 
bsw/jbe@1309
 | 
   464                 ui.container{ content = function()
 | 
| 
bsw/jbe@1309
 | 
   465                   if not config.enforce_formatting_engine then
 | 
| 
bsw/jbe@1309
 | 
   466                     ui.field.select{
 | 
| 
bsw/jbe@1309
 | 
   467                       label = _"Wiki engine for statement",
 | 
| 
bsw/jbe@1309
 | 
   468                       name = "formatting_engine",
 | 
| 
bsw/jbe@1309
 | 
   469                       foreign_records = config.formatting_engines,
 | 
| 
bsw/jbe@1309
 | 
   470                       attr = {id = "formatting_engine"},
 | 
| 
bsw/jbe@1309
 | 
   471                       foreign_id = "id",
 | 
| 
bsw/jbe@1309
 | 
   472                       foreign_name = "name",
 | 
| 
bsw/jbe@1309
 | 
   473                       value = param.get("formatting_engine") or direct_voter and direct_voter.formatting_engine
 | 
| 
bsw/jbe@1309
 | 
   474                     }
 | 
| 
bsw@1045
 | 
   475                   end
 | 
| 
bsw/jbe@1309
 | 
   476                   ui.container{ content = _"Voting comment (optional)" }
 | 
| 
bsw/jbe@1309
 | 
   477                   ui.field.text{
 | 
| 
bsw/jbe@1309
 | 
   478                     name = "comment",
 | 
| 
bsw/jbe@1309
 | 
   479                     multiline = true,
 | 
| 
bsw/jbe@1309
 | 
   480                     value = param.get("comment") or direct_voter and direct_voter.comment,
 | 
| 
bsw/jbe@1309
 | 
   481                     attr = { style = "height: 10ex; width: 100%;" },
 | 
| 
bsw/jbe@1309
 | 
   482                   }
 | 
| 
bsw/jbe@1309
 | 
   483                 end }
 | 
| 
bsw/jbe@1309
 | 
   484               end
 | 
| 
bsw/jbe@1309
 | 
   485 
 | 
| 
bsw/jbe@1309
 | 
   486               if preview then
 | 
| 
bsw/jbe@1309
 | 
   487                 if not config.enforce_formatting_engine then
 | 
| 
bsw/jbe@1309
 | 
   488                   ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
 | 
| 
bsw/jbe@1309
 | 
   489                 end
 | 
| 
bsw/jbe@1309
 | 
   490                 ui.field.hidden{ name = "comment", value = param.get("comment") or direct_voter and direct_voter.comment }
 | 
| 
bsw/jbe@1309
 | 
   491               end
 | 
| 
bsw/jbe@1309
 | 
   492               
 | 
| 
bsw/jbe@1309
 | 
   493               if not readonly or direct_voter or preview then
 | 
| 
bsw/jbe@1309
 | 
   494                 if preview  then
 | 
| 
bsw/jbe@1309
 | 
   495                   slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   496                   ui.tag{
 | 
| 
bsw/jbe@1309
 | 
   497                     tag = "input",
 | 
| 
bsw/jbe@1309
 | 
   498                     attr = {
 | 
| 
bsw/jbe@1309
 | 
   499                       type = "submit",
 | 
| 
bsw/jbe@1309
 | 
   500                       class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
 | 
| 
bsw/jbe@1309
 | 
   501                       name = issue.closed and "update_comment" or nil,
 | 
| 
bsw/jbe@1309
 | 
   502                       value = submit_button_text -- finish voting / update comment
 | 
| 
bsw/jbe@1309
 | 
   503                     }
 | 
| 
bsw/jbe@1309
 | 
   504                   }
 | 
| 
bsw/jbe@1309
 | 
   505                 end
 | 
| 
bsw/jbe@1309
 | 
   506                 if not preview then
 | 
| 
bsw/jbe@1309
 | 
   507                   ui.tag{
 | 
| 
bsw/jbe@1309
 | 
   508                     tag = "input",
 | 
| 
bsw/jbe@1309
 | 
   509                     attr = {
 | 
| 
bsw/jbe@1309
 | 
   510                       type = "submit",
 | 
| 
bsw/jbe@1309
 | 
   511                       name = "preview",
 | 
| 
bsw/jbe@1309
 | 
   512                       class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
 | 
| 
bsw/jbe@1309
 | 
   513                       value = _"Preview",
 | 
| 
bsw/jbe@1309
 | 
   514                     }
 | 
| 
bsw/jbe@1309
 | 
   515                   }
 | 
| 
bsw/jbe@1309
 | 
   516                 else
 | 
| 
bsw/jbe@1309
 | 
   517                   slot.put("   ")
 | 
| 
bsw/jbe@1309
 | 
   518                   ui.tag{
 | 
| 
bsw/jbe@1309
 | 
   519                     tag = "input",
 | 
| 
bsw/jbe@1309
 | 
   520                     attr = {
 | 
| 
bsw/jbe@1309
 | 
   521                       type = "submit",
 | 
| 
bsw/jbe@1309
 | 
   522                       name = "edit",
 | 
| 
bsw/jbe@1309
 | 
   523                       class = "mdl-button mdl-js-button mdl-button--raised",
 | 
| 
bsw/jbe@1309
 | 
   524                       value = edit_button_text,
 | 
| 
bsw/jbe@1309
 | 
   525                     }
 | 
| 
bsw/jbe@1309
 | 
   526                   }
 | 
| 
bsw/jbe@1309
 | 
   527                 end
 | 
| 
bsw@1045
 | 
   528               end
 | 
| 
bsw@1045
 | 
   529             end
 | 
| 
bsw@1045
 | 
   530           end
 | 
| 
bsw@1045
 | 
   531         }
 | 
| 
bsw/jbe@1309
 | 
   532         slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
   533         ui.link{
 | 
| 
bsw/jbe@1309
 | 
   534           attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
 | 
| 
bsw/jbe@1309
 | 
   535           text = _"Cancel",
 | 
| 
bsw/jbe@1309
 | 
   536           module = "issue",
 | 
| 
bsw/jbe@1309
 | 
   537           view = "show",
 | 
| 
bsw/jbe@1309
 | 
   538           id = issue.id
 | 
| 
bsw/jbe@1309
 | 
   539         }
 | 
| 
bsw@1558
 | 
   540         if direct_voter and not issue.closed then
 | 
| 
bsw/jbe@1309
 | 
   541           slot.put("   ")
 | 
| 
bsw/jbe@1309
 | 
   542           ui.link {
 | 
| 
bsw/jbe@1309
 | 
   543             attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
 | 
| 
bsw/jbe@1309
 | 
   544             module = "vote", action = "update",
 | 
| 
bsw/jbe@1309
 | 
   545             params = {
 | 
| 
bsw/jbe@1309
 | 
   546               issue_id = issue.id,
 | 
| 
bsw/jbe@1309
 | 
   547               discard = true
 | 
| 
bsw/jbe@1309
 | 
   548             },
 | 
| 
bsw/jbe@1309
 | 
   549             routing = {
 | 
| 
bsw/jbe@1309
 | 
   550               default = {
 | 
| 
bsw/jbe@1309
 | 
   551                 mode = "redirect",
 | 
| 
bsw/jbe@1309
 | 
   552                 module = "issue",
 | 
| 
bsw/jbe@1309
 | 
   553                 view = "show",
 | 
| 
bsw/jbe@1309
 | 
   554                 id = issue.id
 | 
| 
bsw@1045
 | 
   555               }
 | 
| 
bsw/jbe@1309
 | 
   556             },
 | 
| 
bsw/jbe@1309
 | 
   557             text = _"Discard my vote"
 | 
| 
bsw/jbe@1309
 | 
   558           }
 | 
| 
bsw/jbe@5
 | 
   559         end
 | 
| 
bsw/jbe@1309
 | 
   560         
 | 
| 
bsw/jbe@1309
 | 
   561       end }
 | 
| 
bsw/jbe@1309
 | 
   562     end }
 | 
| 
bsw@1559
 | 
   563 
 | 
| 
bsw@1559
 | 
   564     if issue.state == "finished_with_winner" 
 | 
| 
bsw@1559
 | 
   565       or issue.state == "finished_without_winner" 
 | 
| 
bsw@1559
 | 
   566     then
 | 
| 
bsw@1559
 | 
   567 
 | 
| 
bsw@1559
 | 
   568       local members_selector = Member:new_selector()
 | 
| 
bsw@1559
 | 
   569         :join("delegating_voter", nil, "delegating_voter.member_id = member.id")
 | 
| 
bsw@1559
 | 
   570         :add_where{ "delegating_voter.issue_id = ?", issue.id }
 | 
| 
bsw@1559
 | 
   571         :add_where{ "delegating_voter.delegate_member_ids[1] = ?", member.id }
 | 
| 
bsw@1559
 | 
   572         :add_field("delegating_voter.weight", "voter_weight")
 | 
| 
bsw@1559
 | 
   573         :add_field("delegating_voter.ownweight", "ownweight")
 | 
| 
bsw@1559
 | 
   574         :join("issue", nil, "issue.id = delegating_voter.issue_id")
 | 
| 
bsw@1559
 | 
   575         
 | 
| 
bsw@1559
 | 
   576       ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw@1559
 | 
   577         ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw@1559
 | 
   578           ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function()
 | 
| 
bsw@1559
 | 
   579             ui.tag{ content = _"Incoming delegations" }
 | 
| 
bsw@1559
 | 
   580           end }
 | 
| 
bsw@1559
 | 
   581         end }
 | 
| 
bsw@1559
 | 
   582 
 | 
| 
bsw@1559
 | 
   583         ui.container{ attr = { class = "mdl-card__content" }, content = function()
 | 
| 
bsw@1559
 | 
   584           execute.view{
 | 
| 
bsw@1559
 | 
   585             module = "member",
 | 
| 
bsw@1559
 | 
   586             view = "_list",
 | 
| 
bsw@1559
 | 
   587             params = {
 | 
| 
bsw@1559
 | 
   588               members_selector = members_selector,
 | 
| 
bsw@1559
 | 
   589               trustee = member,
 | 
| 
bsw@1559
 | 
   590               issue = issue,
 | 
| 
bsw@1559
 | 
   591               initiative = initiative,
 | 
| 
bsw@1559
 | 
   592               for_votes = true, no_filter = true,
 | 
| 
bsw@1559
 | 
   593               member_class = "sidebarRow sidebarRowNarrow",
 | 
| 
bsw@1559
 | 
   594             }
 | 
| 
bsw@1559
 | 
   595           }
 | 
| 
bsw@1559
 | 
   596         end }
 | 
| 
bsw@1559
 | 
   597       end }
 | 
| 
bsw@1559
 | 
   598     end
 | 
| 
bsw@1559
 | 
   599 
 | 
| 
bsw@1559
 | 
   600 
 | 
| 
bsw/jbe@1309
 | 
   601   end }
 | 
| 
bsw/jbe@1309
 | 
   602 end }
 |