liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 287:ee477a136fd4
Moved notification functions to model
| author | bsw | 
|---|---|
| date | Sat Feb 25 12:04:36 2012 +0100 (2012-02-25) | 
| parents | c587d8762e62 | 
| children | 22e4e26717ac | 
 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 = "area",
    34       view = "list",
    35       params = { unit_id = issue.area.unit_id }
    36     }
    37   end
    38 end)
    41 slot.select("title2", function()
    42   ui.tag{
    43     tag = "div",
    44     content = function()
    46       ui.link{
    47         text = issue.policy.name,
    48         module = "policy",
    49         view = "show",
    50         id = issue.policy.id
    51       }
    53       slot.put(" · ")
    54       ui.tag{ content = issue.state_name }
    56       if issue.state_time_left then
    57         slot.put(" · ")
    58         ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left }) }
    59       end
    61     end
    62   }
    65 end)
    67 slot.select("actions", function()
    69   if app.session.member_id then
    71     if issue.state == 'voting' and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
    72       local text
    73       if not direct_voter then
    74         text = _"Vote now"
    75       else
    76         text = _"Change vote"
    77       end
    78       ui.link{
    79         content = function()
    80           ui.image{ static = "icons/16/email_open.png" }
    81           slot.put(text)
    82         end,
    83         module = "vote",
    84         view = "list",
    85         params = { issue_id = issue.id }
    86       }
    87     end
    89     execute.view{
    90       module = "interest",
    91       view = "_show_box",
    92       params = { issue = issue }
    93     }
    95     if not issue.closed then
    96       execute.view{
    97         module = "delegation",
    98         view = "_show_box",
    99         params = { issue_id = issue.id,
   100                    initiative_id = initiative and initiative.id or nil}
   101       }
   102     end
   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 = function()
   112         ui.image{ static = "icons/16/comments.png" }
   113         slot.put(_"Discussion on issue")
   114       end,
   115     }
   116   end
   118   if config.etherpad and app.session.member then
   119     local url = config.etherpad.base_url .. "p/" .. config.etherpad.group_id .. "$Issue" .. issue.id
   120     ui.link{
   121       attr = { target = "_blank" },
   122       external = url,
   123       content = function()
   124         ui.image{ static = "icons/16/comments.png" }
   125         slot.put(_"Issue pad")
   126       end,
   127     }
   128   end
   130 end)
   132 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
   133   slot.select("actions", function()
   134     if not issue.fully_frozen and not issue.closed then
   135       ui.link{
   136         image  = { static = "icons/16/script_add.png" },
   137         attr   = { class = "action" },
   138         text   = _"Create alternative initiative",
   139         module = "initiative",
   140         view   = "new",
   141         params = { issue_id = issue.id }
   142       }
   143     end
   144   end)
   145 end
   147 local issue = param.get("issue", "table")
   149 if config.public_access_issue_head and not app.session.member_id then
   150   config.public_access_issue_head(issue)
   151 end
   153 if app.session.member_id and issue.state == 'voting' and not direct_voter
   154   and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
   155 then
   156   ui.container{
   157     attr = { class = "voting_active_info" },
   158     content = function()
   159       slot.put(_"Voting for this issue is currently running!")
   160       slot.put(" ")
   161       if app.session.member_id then
   162         ui.link{
   163           content = function()
   164             slot.put(_"Vote now")
   165           end,
   166           module = "vote",
   167           view = "list",
   168           params = { issue_id = issue.id }
   169         }
   170       end
   171     end
   172   }
   173   slot.put("<br />")
   174 end
