| rev | 
   line source | 
| 
bsw@525
 | 
     1 local issue = param.get("issue", "table")
 | 
| 
bsw@525
 | 
     2 local initiative_limit = param.get("initiative_limit", atom.integer)
 | 
| 
bsw@525
 | 
     3 local for_listing = param.get("for_listing", atom.boolean)
 | 
| 
bsw@525
 | 
     4 
 | 
| 
bsw@525
 | 
     5 local direct_voter
 | 
| 
bsw@525
 | 
     6 if app.session.member_id then
 | 
| 
bsw@547
 | 
     7   direct_voter = issue.member_info.direct_voted
 | 
| 
bsw@525
 | 
     8 end
 | 
| 
bsw@525
 | 
     9 
 | 
| 
bsw@525
 | 
    10 local voteable = app.session.member_id and issue.state == 'voting' and
 | 
| 
bsw@525
 | 
    11        app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
 | 
| 
bsw@525
 | 
    12 
 | 
| 
bsw@525
 | 
    13 local vote_link_text = direct_voter and _"Change vote" or "Vote now"
 | 
| 
bsw@525
 | 
    14 
 | 
| 
bsw@525
 | 
    15 
 | 
| 
bsw@525
 | 
    16 local class = "issue"
 | 
| 
bsw@525
 | 
    17 if issue.is_interested then
 | 
| 
bsw@525
 | 
    18   class = class .. " interested"
 | 
| 
bsw@525
 | 
    19 elseif issue.is_interested_by_delegation_to_member_id then
 | 
| 
bsw@525
 | 
    20   class = class .. " interested_by_delegation"
 | 
| 
bsw@525
 | 
    21 end
 | 
| 
bsw@525
 | 
    22 
 | 
| 
bsw@525
 | 
    23 ui.container{ attr = { class = class }, content = function()
 | 
| 
bsw@525
 | 
    24 
 | 
| 
bsw@525
 | 
    25   execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
 | 
| 
bsw@525
 | 
    26 
 | 
| 
bsw@525
 | 
    27   ui.container{ attr = { class = "title" }, content = function()
 | 
| 
bsw@525
 | 
    28     
 | 
| 
bsw@525
 | 
    29     ui.link{
 | 
| 
bsw@525
 | 
    30       attr = { class = "issue_id" },
 | 
| 
bsw@525
 | 
    31       text = _("#{policy_name} ##{issue_id}", {
 | 
| 
bsw@525
 | 
    32         policy_name = issue.policy.name,
 | 
| 
bsw@525
 | 
    33         issue_id = issue.id
 | 
| 
bsw@525
 | 
    34       }),
 | 
| 
bsw@525
 | 
    35       module = "issue",
 | 
| 
bsw@525
 | 
    36       view = "show",
 | 
| 
bsw@525
 | 
    37       id = issue.id
 | 
| 
bsw@525
 | 
    38     }
 | 
| 
bsw@525
 | 
    39   end }
 | 
| 
bsw@568
 | 
    40   if for_listing then
 | 
| 
bsw@568
 | 
    41     ui.container{ attr = { class = "content" }, content = function()
 | 
| 
bsw@568
 | 
    42       ui.tag{ content = issue.area.unit.name }
 | 
| 
bsw@568
 | 
    43       slot.put(" · ")
 | 
| 
bsw@568
 | 
    44       ui.tag{ content = issue.area.name }
 | 
| 
bsw@568
 | 
    45     end }
 | 
| 
bsw@568
 | 
    46   end
 | 
| 
bsw@525
 | 
    47   
 | 
| 
bsw@525
 | 
    48   ui.tag{
 | 
| 
bsw@525
 | 
    49     attr = { class = "content issue_policy_info" },
 | 
| 
bsw@525
 | 
    50     tag = "div",
 | 
| 
bsw@525
 | 
    51     content = function()
 | 
| 
bsw@525
 | 
    52     
 | 
| 
bsw@525
 | 
    53       ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
 | 
| 
bsw@525
 | 
    54 
 | 
| 
bsw@525
 | 
    55       if issue.state_time_left then
 | 
| 
bsw@525
 | 
    56         slot.put(" · ")
 | 
| 
bsw@525
 | 
    57         if issue.state_time_left:sub(1,1) == "-" then
 | 
| 
bsw@550
 | 
    58           if issue.state == "accepted" then
 | 
| 
bsw@525
 | 
    59             ui.tag{ content = _("Discussion starts soon") }
 | 
| 
bsw@525
 | 
    60           elseif issue.state == "discussion" then
 | 
| 
bsw@525
 | 
    61             ui.tag{ content = _("Verification starts soon") }
 | 
| 
bsw@525
 | 
    62           elseif issue.state == "frozen" then
 | 
| 
bsw@525
 | 
    63             ui.tag{ content = _("Voting starts soon") }
 | 
| 
bsw@525
 | 
    64           elseif issue.state == "voting" then
 | 
| 
bsw@525
 | 
    65             ui.tag{ content = _("Counting starts soon") }
 | 
| 
bsw@525
 | 
    66           end
 | 
| 
bsw@525
 | 
    67         else
 | 
| 
bsw@525
 | 
    68           ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
 | 
| 
bsw@525
 | 
    69         end
 | 
| 
bsw@525
 | 
    70       end
 | 
| 
bsw@525
 | 
    71 
 | 
| 
bsw@525
 | 
    72     end
 | 
| 
bsw@525
 | 
    73   }
 | 
| 
bsw@525
 | 
    74 
 | 
| 
bsw@572
 | 
    75   local links = {}
 | 
| 
bsw@525
 | 
    76   
 | 
| 
bsw@525
 | 
    77     if voteable then
 | 
| 
bsw@572
 | 
    78       links[#links+1] ={
 | 
| 
bsw@525
 | 
    79         content = vote_link_text,
 | 
| 
bsw@525
 | 
    80         module = "vote",
 | 
| 
bsw@525
 | 
    81         view = "list",
 | 
| 
bsw@525
 | 
    82         params = { issue_id = issue.id }
 | 
| 
bsw@525
 | 
    83       }
 | 
| 
bsw@525
 | 
    84     end
 | 
| 
bsw@525
 | 
    85 
 | 
| 
bsw@525
 | 
    86     if app.session.member_id then
 | 
| 
bsw@572
 | 
    87 
 | 
| 
bsw@572
 | 
    88       if issue.member_info.own_participation then
 | 
| 
bsw@572
 | 
    89         if issue.closed then
 | 
| 
bsw@572
 | 
    90           links[#links+1] = { content = _"You were interested" }
 | 
| 
bsw@572
 | 
    91         else
 | 
| 
bsw@572
 | 
    92           links[#links+1] = { content = _"You are interested" }
 | 
| 
bsw@572
 | 
    93         end
 | 
| 
bsw@572
 | 
    94       end
 | 
| 
bsw@572
 | 
    95       
 | 
| 
bsw@572
 | 
    96       if not issue.closed and not issue.fully_frozen then
 | 
| 
bsw@572
 | 
    97         if issue.member_info.own_participation then
 | 
| 
bsw@572
 | 
    98           links[#links+1] = {
 | 
| 
bsw@572
 | 
    99             in_brackets = true,
 | 
| 
bsw@572
 | 
   100             text    = _"Withdraw",
 | 
| 
bsw@572
 | 
   101             module  = "interest",
 | 
| 
bsw@572
 | 
   102             action  = "update",
 | 
| 
bsw@572
 | 
   103             params  = { issue_id = issue.id, delete = true },
 | 
| 
bsw@572
 | 
   104             routing = {
 | 
| 
bsw@572
 | 
   105               default = {
 | 
| 
bsw@572
 | 
   106                 mode = "redirect",
 | 
| 
bsw@572
 | 
   107                 module = request.get_module(),
 | 
| 
bsw@572
 | 
   108                 view = request.get_view(),
 | 
| 
bsw@572
 | 
   109                 id = param.get_id_cgi(),
 | 
| 
bsw@572
 | 
   110                 params = param.get_all_cgi()
 | 
| 
bsw@572
 | 
   111               }
 | 
| 
bsw@572
 | 
   112             }
 | 
| 
bsw@572
 | 
   113           }
 | 
| 
bsw@572
 | 
   114         elseif app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
 | 
| 
bsw@572
 | 
   115           links[#links+1] = {
 | 
| 
bsw@572
 | 
   116             text    = _"Add my interest",
 | 
| 
bsw@572
 | 
   117             module  = "interest",
 | 
| 
bsw@572
 | 
   118             action  = "update",
 | 
| 
bsw@572
 | 
   119             params  = { issue_id = issue.id },
 | 
| 
bsw@572
 | 
   120             routing = {
 | 
| 
bsw@572
 | 
   121               default = {
 | 
| 
bsw@572
 | 
   122                 mode = "redirect",
 | 
| 
bsw@572
 | 
   123                 module = request.get_module(),
 | 
| 
bsw@572
 | 
   124                 view = request.get_view(),
 | 
| 
bsw@572
 | 
   125                 id = param.get_id_cgi(),
 | 
| 
bsw@572
 | 
   126                 params = param.get_all_cgi()
 | 
| 
bsw@572
 | 
   127               }
 | 
| 
bsw@572
 | 
   128             }
 | 
| 
bsw@572
 | 
   129           }
 | 
| 
bsw@572
 | 
   130         end
 | 
| 
bsw@572
 | 
   131       end
 | 
| 
bsw@525
 | 
   132     end
 | 
| 
bsw@525
 | 
   133 
 | 
| 
bsw@573
 | 
   134     if not issue.closed and app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
 | 
| 
bsw@547
 | 
   135       if issue.member_info.own_delegation_scope ~= "issue" then
 | 
| 
bsw@572
 | 
   136         links[#links+1] = { text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id } }
 | 
| 
bsw@529
 | 
   137       else
 | 
| 
bsw@572
 | 
   138         links[#links+1] = { text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id } }
 | 
| 
bsw@529
 | 
   139       end
 | 
| 
bsw@529
 | 
   140     end
 | 
| 
bsw@529
 | 
   141 
 | 
| 
bsw@525
 | 
   142     if config.issue_discussion_url_func then
 | 
| 
bsw@525
 | 
   143       local url = config.issue_discussion_url_func(issue)
 | 
| 
bsw@572
 | 
   144       links[#links+1] = {
 | 
| 
bsw@525
 | 
   145         attr = { target = "_blank" },
 | 
| 
bsw@525
 | 
   146         external = url,
 | 
| 
bsw@525
 | 
   147         content = _"Discussion on issue"
 | 
| 
bsw@525
 | 
   148       }
 | 
| 
bsw@525
 | 
   149     end
 | 
| 
bsw@525
 | 
   150 
 | 
| 
bsw@525
 | 
   151     if config.etherpad and app.session.member then
 | 
| 
bsw@572
 | 
   152       links[#links+1] = {
 | 
| 
bsw@525
 | 
   153         attr = { target = "_blank" },
 | 
| 
bsw@525
 | 
   154         external = issue.etherpad_url,
 | 
| 
bsw@525
 | 
   155         content = _"Issue pad"
 | 
| 
bsw@525
 | 
   156       }
 | 
| 
bsw@525
 | 
   157     end
 | 
| 
bsw@525
 | 
   158 
 | 
| 
bsw@525
 | 
   159 
 | 
| 
bsw@525
 | 
   160     if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
 | 
| 
bsw@525
 | 
   161       if not issue.fully_frozen and not issue.closed then
 | 
| 
bsw@572
 | 
   162       links[#links+1] = {
 | 
| 
bsw@525
 | 
   163           attr   = { class = "action" },
 | 
| 
bsw@525
 | 
   164           text   = _"Create alternative initiative",
 | 
| 
bsw@525
 | 
   165           module = "initiative",
 | 
| 
bsw@525
 | 
   166           view   = "new",
 | 
| 
bsw@525
 | 
   167           params = { issue_id = issue.id }
 | 
| 
bsw@525
 | 
   168         }
 | 
| 
bsw@525
 | 
   169       end
 | 
| 
bsw@525
 | 
   170     end
 | 
| 
bsw@525
 | 
   171 
 | 
| 
bsw@572
 | 
   172   ui.container{ attr = { class = "content actions" }, content = function()
 | 
| 
bsw@572
 | 
   173     for i, link in ipairs(links) do
 | 
| 
bsw@572
 | 
   174       if link.in_brackets then
 | 
| 
bsw@572
 | 
   175         slot.put(" (")
 | 
| 
bsw@572
 | 
   176       elseif i > 1 then
 | 
| 
bsw@572
 | 
   177         slot.put(" · ")
 | 
| 
bsw@572
 | 
   178       end
 | 
| 
bsw@572
 | 
   179       if link.module then
 | 
| 
bsw@572
 | 
   180         ui.link(link)
 | 
| 
bsw@572
 | 
   181       else
 | 
| 
bsw@572
 | 
   182         ui.tag(link)
 | 
| 
bsw@572
 | 
   183       end
 | 
| 
bsw@572
 | 
   184       if link.in_brackets then
 | 
| 
bsw@572
 | 
   185         slot.put(")")
 | 
| 
bsw@572
 | 
   186       end
 | 
| 
bsw@572
 | 
   187     end
 | 
| 
bsw@525
 | 
   188   end }
 | 
| 
bsw@525
 | 
   189 
 | 
| 
bsw@525
 | 
   190   if not for_listing then
 | 
| 
bsw@525
 | 
   191     
 | 
| 
bsw@525
 | 
   192     if voteable then
 | 
| 
bsw@525
 | 
   193       ui.container{
 | 
| 
bsw@525
 | 
   194         attr = { class = "voting_active_info" },
 | 
| 
bsw@525
 | 
   195         content = function()
 | 
| 
bsw@525
 | 
   196           slot.put(_"Voting for this issue is currently running!")
 | 
| 
bsw@525
 | 
   197           slot.put(" ")
 | 
| 
bsw@525
 | 
   198           if app.session.member_id then
 | 
| 
bsw@525
 | 
   199             ui.link{
 | 
| 
bsw@525
 | 
   200               content = vote_link_text,
 | 
| 
bsw@525
 | 
   201               module = "vote",
 | 
| 
bsw@525
 | 
   202               view = "list",
 | 
| 
bsw@525
 | 
   203               params = { issue_id = issue.id }
 | 
| 
bsw@525
 | 
   204             }
 | 
| 
bsw@525
 | 
   205           end
 | 
| 
bsw@525
 | 
   206         end
 | 
| 
bsw@525
 | 
   207       }
 | 
| 
bsw@525
 | 
   208     end
 | 
| 
bsw@525
 | 
   209 
 | 
| 
bsw@527
 | 
   210     if issue.state == "cancelled" then
 | 
| 
bsw@527
 | 
   211       local policy = issue.policy
 | 
| 
bsw@527
 | 
   212       ui.container{
 | 
| 
bsw@527
 | 
   213         attr = { class = "not_admitted_info" },
 | 
| 
bsw@527
 | 
   214         content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
 | 
| 
bsw@527
 | 
   215       }
 | 
| 
bsw@527
 | 
   216     end
 | 
| 
bsw@527
 | 
   217 
 | 
| 
bsw@525
 | 
   218   end
 | 
| 
bsw@525
 | 
   219 
 | 
| 
bsw@525
 | 
   220   ui.container{ attr = { class = "initiative_list" }, content = function()
 | 
| 
bsw@525
 | 
   221 
 | 
| 
bsw@525
 | 
   222     local initiatives_selector = issue:get_reference_selector("initiatives")
 | 
| 
bsw@525
 | 
   223     local highlight_string = param.get("highlight_string")
 | 
| 
bsw@525
 | 
   224     if highlight_string then
 | 
| 
bsw@525
 | 
   225       initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
 | 
| 
bsw@525
 | 
   226     end
 | 
| 
bsw@525
 | 
   227     execute.view{
 | 
| 
bsw@525
 | 
   228       module = "initiative",
 | 
| 
bsw@525
 | 
   229       view = "_list",
 | 
| 
bsw@525
 | 
   230       params = {
 | 
| 
bsw@525
 | 
   231         issue = issue,
 | 
| 
bsw@525
 | 
   232         initiatives_selector = initiatives_selector,
 | 
| 
bsw@525
 | 
   233         highlight_string = highlight_string,
 | 
| 
bsw@525
 | 
   234         no_sort = true,
 | 
| 
bsw@551
 | 
   235         limit = 5,
 | 
| 
bsw@525
 | 
   236         for_member = for_member
 | 
| 
bsw@525
 | 
   237       }
 | 
| 
bsw@525
 | 
   238     }
 | 
| 
bsw@525
 | 
   239   end }
 | 
| 
bsw@525
 | 
   240 end }
 | 
| 
bsw@525
 | 
   241 
 |