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