liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 405:2f121e50d15c
Translation of event messages completed
| author | bsw | 
|---|---|
| date | Thu Mar 08 15:09:03 2012 +0100 (2012-03-08) | 
| parents | 3f2ae4f7a045 | 
| children | b04d1f79508e | 
 line source
     1 local issue = param.get("issue", "table")
     2 local initiative = param.get("initiative", "table")
     4 local direct_voter
     6 if app.session.member_id then
     7   direct_voter = DirectVoter:by_pk(issue.id, app.session.member.id)
     8 end
    10 if config.feature_rss_enabled then
    11   util.html_rss_head{ title = _"Initiatives in this issue (last created first)", module = "initiative", view = "list_rss", params = { issue_id = issue.id } }
    12   util.html_rss_head{ title = _"Initiatives in this issue (last updated first)", module = "initiative", view = "list_rss", params = { issue_id = issue.id, order = "last_updated" } }
    13 end
    15 slot.select("title", function()
    16   ui.link{
    17     content = _("Issue ##{id}", { id = issue.id }),
    18     module = "issue",
    19     view = "show",
    20     id = issue.id
    21   }
    22   slot.put(" · ")
    23   ui.link{
    24     content = issue.area.name,
    25     module = "area",
    26     view = "show",
    27     id = issue.area.id
    28   }
    29   if not config.single_unit_id then
    30     slot.put(" · ")
    31     ui.link{
    32       content = issue.area.unit.name,
    33       module = "unit",
    34       view = "show",
    35       id = issue.area.unit_id
    36     }
    37   end
    38 end)
    41 slot.select("title2", function()
    42   ui.tag{
    43     tag = "div",
    44     attr = { class = "issue_policy_info" },
    45     content = function()
    47       ui.link{
    48         text = issue.policy.name,
    49         module = "policy",
    50         view = "show",
    51         id = issue.policy.id
    52       }
    54       slot.put(" · ")
    55       ui.tag{ content = issue.state_name }
    57       if issue.state_time_left then
    58         slot.put(" · ")
    59         ui.tag{ content = _("#{time_left} left", { 
    60           time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day")
    61         }) }
    62       end
    64     end
    65   }
    68 end)
    70 slot.select("actions", function()
    72   if app.session.member_id then
    74     if issue.state == 'voting' and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
    75       local text
    76       if not direct_voter then
    77         text = _"Vote now"
    78       else
    79         text = _"Change vote"
    80       end
    81       ui.link{
    82         content = function()
    83           ui.image{ static = "icons/16/email_open.png" }
    84           slot.put(text)
    85         end,
    86         module = "vote",
    87         view = "list",
    88         params = { issue_id = issue.id }
    89       }
    90     end
    92     execute.view{
    93       module = "interest",
    94       view = "_show_box",
    95       params = { issue = issue, initiative = initiative }
    96     }
    98     if not issue.closed then
    99       execute.view{
   100         module = "delegation",
   101         view = "_show_box",
   102         params = { issue_id = issue.id,
   103                    initiative_id = initiative and initiative.id or nil}
   104       }
   105     end
   107   end
   109   if config.issue_discussion_url_func then
   110     local url = config.issue_discussion_url_func(issue)
   111     ui.link{
   112       attr = { target = "_blank" },
   113       external = url,
   114       content = function()
   115         ui.image{ static = "icons/16/comments.png" }
   116         slot.put(_"Discussion on issue")
   117       end,
   118     }
   119   end
   121   if config.etherpad and app.session.member then
   122     local url = config.etherpad.base_url .. "p/" .. config.etherpad.group_id .. "$Issue" .. issue.id
   123     ui.link{
   124       attr = { target = "_blank" },
   125       external = url,
   126       content = function()
   127         ui.image{ static = "icons/16/comments.png" }
   128         slot.put(_"Issue pad")
   129       end,
   130     }
   131   end
   133 end)
   135 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
   136   slot.select("actions", function()
   137     if not issue.fully_frozen and not issue.closed then
   138       ui.link{
   139         image  = { static = "icons/16/script_add.png" },
   140         attr   = { class = "action" },
   141         text   = _"Create alternative initiative",
   142         module = "initiative",
   143         view   = "new",
   144         params = { issue_id = issue.id }
   145       }
   146     end
   147   end)
   148 end
   150 local issue = param.get("issue", "table")
   152 if config.public_access_issue_head and not app.session.member_id then
   153   config.public_access_issue_head(issue)
   154 end
   156 if app.session.member_id and issue.state == 'voting' and not direct_voter
   157   and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
   158 then
   159   ui.container{
   160     attr = { class = "voting_active_info" },
   161     content = function()
   162       slot.put(_"Voting for this issue is currently running!")
   163       slot.put(" ")
   164       if app.session.member_id then
   165         ui.link{
   166           content = function()
   167             slot.put(_"Vote now")
   168           end,
   169           module = "vote",
   170           view = "list",
   171           params = { issue_id = issue.id }
   172         }
   173       end
   174     end
   175   }
   176   slot.put("<br />")
   177 end
