liquid_feedback_frontend
view app/main/issue/_show.lua @ 568:565bcc56ea30
Show unit and area name in new line in issue listing
| author | bsw | 
|---|---|
| date | Tue Jun 19 22:59:48 2012 +0200 (2012-06-19) | 
| parents | c1dc3b14a4f3 | 
| children | 1b799fcdae31 | 
 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)
     5 local direct_voter
     6 if app.session.member_id then
     7   direct_voter = issue.member_info.direct_voted
     8 end
    10 local voteable = app.session.member_id and issue.state == 'voting' and
    11        app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
    13 local vote_link_text = direct_voter and _"Change vote" or "Vote now"
    16 local class = "issue"
    17 if issue.is_interested then
    18   class = class .. " interested"
    19 elseif issue.is_interested_by_delegation_to_member_id then
    20   class = class .. " interested_by_delegation"
    21 end
    23 ui.container{ attr = { class = class }, content = function()
    25   execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
    27   ui.container{ attr = { class = "title" }, content = function()
    29     ui.link{
    30       attr = { class = "issue_id" },
    31       text = _("#{policy_name} ##{issue_id}", {
    32         policy_name = issue.policy.name,
    33         issue_id = issue.id
    34       }),
    35       module = "issue",
    36       view = "show",
    37       id = issue.id
    38     }
    39   end }
    40   if for_listing then
    41     ui.container{ attr = { class = "content" }, content = function()
    42       ui.tag{ content = issue.area.unit.name }
    43       slot.put(" · ")
    44       ui.tag{ content = issue.area.name }
    45     end }
    46   end
    48   ui.tag{
    49     attr = { class = "content issue_policy_info" },
    50     tag = "div",
    51     content = function()
    53       ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
    55       if issue.state_time_left then
    56         slot.put(" · ")
    57         if issue.state_time_left:sub(1,1) == "-" then
    58           if issue.state == "accepted" then
    59             ui.tag{ content = _("Discussion starts soon") }
    60           elseif issue.state == "discussion" then
    61             ui.tag{ content = _("Verification starts soon") }
    62           elseif issue.state == "frozen" then
    63             ui.tag{ content = _("Voting starts soon") }
    64           elseif issue.state == "voting" then
    65             ui.tag{ content = _("Counting starts soon") }
    66           end
    67         else
    68           ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
    69         end
    70       end
    72     end
    73   }
    75   ui.container{
    76     attr = { class = "content actions" }, content = function()
    78     if voteable then
    79       ui.link{
    80         content = vote_link_text,
    81         module = "vote",
    82         view = "list",
    83         params = { issue_id = issue.id }
    84       }
    85       slot.put(" · ")
    86     end
    88     if app.session.member_id then
    89       execute.view{
    90         module = "interest",
    91         view = "_show_box",
    92         params = { issue = issue, initiative = initiative }
    93       }
    94       slot.put(" · ")
    95     end
    97     if not issue.closed and app.session.member_id then
    98       if issue.member_info.own_delegation_scope ~= "issue" then
    99         ui.link{ text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id } }
   100       else
   101         ui.link{ text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id } }
   102       end
   103       slot.put(" · ")
   104     end
   106     if config.issue_discussion_url_func then
   107       local url = config.issue_discussion_url_func(issue)
   108       ui.link{
   109         attr = { target = "_blank" },
   110         external = url,
   111         content = _"Discussion on issue"
   112       }
   113       slot.put(" · ")
   114     end
   116     if config.etherpad and app.session.member then
   117       ui.link{
   118         attr = { target = "_blank" },
   119         external = issue.etherpad_url,
   120         content = _"Issue pad"
   121       }
   122       slot.put(" · ")
   123     end
   126     if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
   127       if not issue.fully_frozen and not issue.closed then
   128         ui.link{
   129           attr   = { class = "action" },
   130           text   = _"Create alternative initiative",
   131           module = "initiative",
   132           view   = "new",
   133           params = { issue_id = issue.id }
   134         }
   135       end
   136     end
   138   end }
   140   if not for_listing then
   142     if voteable then
   143       ui.container{
   144         attr = { class = "voting_active_info" },
   145         content = function()
   146           slot.put(_"Voting for this issue is currently running!")
   147           slot.put(" ")
   148           if app.session.member_id then
   149             ui.link{
   150               content = vote_link_text,
   151               module = "vote",
   152               view = "list",
   153               params = { issue_id = issue.id }
   154             }
   155           end
   156         end
   157       }
   158     end
   160     if issue.state == "cancelled" then
   161       local policy = issue.policy
   162       ui.container{
   163         attr = { class = "not_admitted_info" },
   164         content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
   165       }
   166     end
   168   end
   170   ui.container{ attr = { class = "initiative_list" }, content = function()
   172     local initiatives_selector = issue:get_reference_selector("initiatives")
   173     local highlight_string = param.get("highlight_string")
   174     if highlight_string then
   175       initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
   176     end
   177     execute.view{
   178       module = "initiative",
   179       view = "_list",
   180       params = {
   181         issue = issue,
   182         initiatives_selector = initiatives_selector,
   183         highlight_string = highlight_string,
   184         no_sort = true,
   185         limit = 5,
   186         for_member = for_member
   187       }
   188     }
   189   end }
   190 end }
