| 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@528
 | 
    39     if for_listing then
 | 
| 
bsw@528
 | 
    40       ui.tag{ attr = { class = "extra" }, content = function()
 | 
| 
bsw@528
 | 
    41         ui.tag{ content = issue.area.unit.name }
 | 
| 
bsw@528
 | 
    42         slot.put(" · ")
 | 
| 
bsw@528
 | 
    43         ui.tag{ content = issue.area.name }
 | 
| 
bsw@528
 | 
    44       end }
 | 
| 
bsw@528
 | 
    45     end
 | 
| 
bsw@525
 | 
    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@525
 | 
    75   ui.container{
 | 
| 
bsw@525
 | 
    76     attr = { class = "content actions" }, content = function()
 | 
| 
bsw@525
 | 
    77   
 | 
| 
bsw@525
 | 
    78     if voteable then
 | 
| 
bsw@525
 | 
    79       ui.link{
 | 
| 
bsw@525
 | 
    80         content = vote_link_text,
 | 
| 
bsw@525
 | 
    81         module = "vote",
 | 
| 
bsw@525
 | 
    82         view = "list",
 | 
| 
bsw@525
 | 
    83         params = { issue_id = issue.id }
 | 
| 
bsw@525
 | 
    84       }
 | 
| 
bsw@525
 | 
    85       slot.put(" · ")
 | 
| 
bsw@525
 | 
    86     end
 | 
| 
bsw@525
 | 
    87 
 | 
| 
bsw@525
 | 
    88     if app.session.member_id then
 | 
| 
bsw@525
 | 
    89       execute.view{
 | 
| 
bsw@525
 | 
    90         module = "interest",
 | 
| 
bsw@525
 | 
    91         view = "_show_box",
 | 
| 
bsw@525
 | 
    92         params = { issue = issue, initiative = initiative }
 | 
| 
bsw@525
 | 
    93       }
 | 
| 
bsw@525
 | 
    94       slot.put(" · ")
 | 
| 
bsw@525
 | 
    95     end
 | 
| 
bsw@525
 | 
    96 
 | 
| 
bsw@529
 | 
    97     if not issue.closed then
 | 
| 
bsw@547
 | 
    98       if issue.member_info.own_delegation_scope ~= "issue" then
 | 
| 
bsw@529
 | 
    99         ui.link{ text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id } }
 | 
| 
bsw@529
 | 
   100       else
 | 
| 
bsw@529
 | 
   101         ui.link{ text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id } }
 | 
| 
bsw@529
 | 
   102       end
 | 
| 
bsw@529
 | 
   103       slot.put(" · ")
 | 
| 
bsw@529
 | 
   104     end
 | 
| 
bsw@529
 | 
   105 
 | 
| 
bsw@525
 | 
   106     if config.issue_discussion_url_func then
 | 
| 
bsw@525
 | 
   107       local url = config.issue_discussion_url_func(issue)
 | 
| 
bsw@525
 | 
   108       ui.link{
 | 
| 
bsw@525
 | 
   109         attr = { target = "_blank" },
 | 
| 
bsw@525
 | 
   110         external = url,
 | 
| 
bsw@525
 | 
   111         content = _"Discussion on issue"
 | 
| 
bsw@525
 | 
   112       }
 | 
| 
bsw@525
 | 
   113       slot.put(" · ")
 | 
| 
bsw@525
 | 
   114     end
 | 
| 
bsw@525
 | 
   115 
 | 
| 
bsw@525
 | 
   116     if config.etherpad and app.session.member then
 | 
| 
bsw@525
 | 
   117       ui.link{
 | 
| 
bsw@525
 | 
   118         attr = { target = "_blank" },
 | 
| 
bsw@525
 | 
   119         external = issue.etherpad_url,
 | 
| 
bsw@525
 | 
   120         content = _"Issue pad"
 | 
| 
bsw@525
 | 
   121       }
 | 
| 
bsw@525
 | 
   122       slot.put(" · ")
 | 
| 
bsw@525
 | 
   123     end
 | 
| 
bsw@525
 | 
   124 
 | 
| 
bsw@525
 | 
   125 
 | 
| 
bsw@525
 | 
   126     if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
 | 
| 
bsw@525
 | 
   127       if not issue.fully_frozen and not issue.closed then
 | 
| 
bsw@525
 | 
   128         ui.link{
 | 
| 
bsw@525
 | 
   129           attr   = { class = "action" },
 | 
| 
bsw@525
 | 
   130           text   = _"Create alternative initiative",
 | 
| 
bsw@525
 | 
   131           module = "initiative",
 | 
| 
bsw@525
 | 
   132           view   = "new",
 | 
| 
bsw@525
 | 
   133           params = { issue_id = issue.id }
 | 
| 
bsw@525
 | 
   134         }
 | 
| 
bsw@525
 | 
   135       end
 | 
| 
bsw@525
 | 
   136     end
 | 
| 
bsw@525
 | 
   137 
 | 
| 
bsw@525
 | 
   138   end }
 | 
| 
bsw@525
 | 
   139 
 | 
| 
bsw@525
 | 
   140   if not for_listing then
 | 
| 
bsw@525
 | 
   141     
 | 
| 
bsw@525
 | 
   142     if voteable then
 | 
| 
bsw@525
 | 
   143       ui.container{
 | 
| 
bsw@525
 | 
   144         attr = { class = "voting_active_info" },
 | 
| 
bsw@525
 | 
   145         content = function()
 | 
| 
bsw@525
 | 
   146           slot.put(_"Voting for this issue is currently running!")
 | 
| 
bsw@525
 | 
   147           slot.put(" ")
 | 
| 
bsw@525
 | 
   148           if app.session.member_id then
 | 
| 
bsw@525
 | 
   149             ui.link{
 | 
| 
bsw@525
 | 
   150               content = vote_link_text,
 | 
| 
bsw@525
 | 
   151               module = "vote",
 | 
| 
bsw@525
 | 
   152               view = "list",
 | 
| 
bsw@525
 | 
   153               params = { issue_id = issue.id }
 | 
| 
bsw@525
 | 
   154             }
 | 
| 
bsw@525
 | 
   155           end
 | 
| 
bsw@525
 | 
   156         end
 | 
| 
bsw@525
 | 
   157       }
 | 
| 
bsw@525
 | 
   158     end
 | 
| 
bsw@525
 | 
   159 
 | 
| 
bsw@527
 | 
   160     if issue.state == "cancelled" then
 | 
| 
bsw@527
 | 
   161       local policy = issue.policy
 | 
| 
bsw@527
 | 
   162       ui.container{
 | 
| 
bsw@527
 | 
   163         attr = { class = "not_admitted_info" },
 | 
| 
bsw@527
 | 
   164         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
 | 
   165       }
 | 
| 
bsw@527
 | 
   166     end
 | 
| 
bsw@527
 | 
   167 
 | 
| 
bsw@525
 | 
   168   end
 | 
| 
bsw@525
 | 
   169 
 | 
| 
bsw@525
 | 
   170   ui.container{ attr = { class = "initiative_list" }, content = function()
 | 
| 
bsw@525
 | 
   171 
 | 
| 
bsw@525
 | 
   172     local initiatives_selector = issue:get_reference_selector("initiatives")
 | 
| 
bsw@525
 | 
   173     local highlight_string = param.get("highlight_string")
 | 
| 
bsw@525
 | 
   174     if highlight_string then
 | 
| 
bsw@525
 | 
   175       initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
 | 
| 
bsw@525
 | 
   176     end
 | 
| 
bsw@525
 | 
   177     execute.view{
 | 
| 
bsw@525
 | 
   178       module = "initiative",
 | 
| 
bsw@525
 | 
   179       view = "_list",
 | 
| 
bsw@525
 | 
   180       params = {
 | 
| 
bsw@525
 | 
   181         issue = issue,
 | 
| 
bsw@525
 | 
   182         initiatives_selector = initiatives_selector,
 | 
| 
bsw@525
 | 
   183         highlight_string = highlight_string,
 | 
| 
bsw@525
 | 
   184         per_page = initiative_limit,
 | 
| 
bsw@525
 | 
   185         no_sort = true,
 | 
| 
bsw@525
 | 
   186         limit = initiative_limit,
 | 
| 
bsw@525
 | 
   187         for_member = for_member
 | 
| 
bsw@525
 | 
   188       }
 | 
| 
bsw@525
 | 
   189     }
 | 
| 
bsw@525
 | 
   190   end }
 | 
| 
bsw@525
 | 
   191 end }
 | 
| 
bsw@525
 | 
   192 
 |