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