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