liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 542:7bcff48f70b7
Added tag beta35 for changeset f7bc22fbf660
| author | bsw | 
|---|---|
| date | Sun May 27 23:04:10 2012 +0200 (2012-05-27) | 
| parents | eaf3db89a6e1 | 
| children | 6725c13b6ce0 | 
 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("path", function()
    16 end)
    18 slot.select("title", function()
    19   ui.link{
    20     content = issue.area.name,
    21     module = "area",
    22     view = "show",
    23     id = issue.area.id
    24   }
    25   slot.put(" · ")
    26   ui.link{
    27     content = _("Issue ##{id}", { id = issue.id }),
    28     module = "issue",
    29     view = "show",
    30     id = issue.id
    31   }
    32   slot.put(" · ")
    33   ui.tag{
    34     tag = "span",
    35     content = issue.state_name,
    36   }
    37 end)
    40 slot.select("content_navigation", function()
    42   if app.session.member_id then
    43     local records
    44     local this = 0
    45     local issues_selector = Issue:new_selector()
    47     -- FIXME: !DRY
    48     local issue_filter_map = {
    49       new = "new.png",
    50       accepted = "comments.png",
    51       half_frozen = "lock.png",
    52       frozen ="email_open.png",
    53       finished = "tick.png",
    54       cancelled = "cross.png",
    55     }
    58     local mk_link = function(index, text, icon, module)
    59        content = function()
    60           if index > 0 then
    61             slot.put(text)
    62             ui.image{ static = "icons/16/"..icon }
    63           else
    64             ui.image{ static = "icons/16/"..icon }
    65             slot.put(text)
    66           end
    67       end
    68       if records[this+index] then
    69         ui.link{
    70           content = content,
    71           module = module,
    72           view = "show",
    73           id = records[this+index].id,
    74         }
    75       else
    76         ui.container{
    77           content = content,
    78         }
    79       end
    80     end
    82     issues_selector
    83        :add_where{"issue.area_id = ?", issue.area.id}
    85     local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
    87     local state = issue.state
    89     -- FIXME: fix filter names to reflect issue.state values
    90     if state == "voting" then
    91       state = "frozen"
    92     elseif state == "frozen" then
    93       state = "half_frozen"
    94     end
    96     filter = filters:get_filter("filter", state)
    97     if filter then
    98       filter.selector_modifier(issues_selector)
   100       -- add subfilter to voting pager, so only not voted entries will be shown
   101       -- as this seems the most usefull exception
   102       if filter.name == "frozen" then
   103         filter_voting_name = "not_voted"
   104         local vfilter = filters:get_filter("filter_voting", "not_voted")
   105         if vfilter then
   106           vfilter.selector_modifier(issues_selector)
   107         end
   108       end
   109     end
   111     records = issues_selector:exec()
   113     for i,cissue in ipairs(records) do
   114       if cissue.id == issue.id then
   115         this = i
   116         break
   117       end
   118     end
   120     mk_link(-1, _("Previous issue"), "resultset_previous.png", "issue")
   121     if issue.area then
   122       ui.link{
   123         content = function()
   124           if issue_filter_map[state] then
   125             ui.image{ static = "icons/16/"..issue_filter_map[state] }
   126           end
   127           slot.put(issue.area.name)
   128         end,
   129         module = "area",
   130         view = "show",
   131         id = issue.area.id,
   132         params = {
   133           filter = filter and filter.name or nil,
   134           filter_voting = filter_voting_name,
   135           tab = "issues"
   136         }
   137       }
   138     end
   139     mk_link(1, _("Next issue"), "resultset_next.png", "issue")
   141     -- show pager for initiatives if available
   142     if initiative then
   143       ui.container{ content = function() end, attr = {class = "content_navigation_seperator"}}
   145       records = issue:get_reference_selector("initiatives"):exec()
   146       for i,cissue in ipairs(records) do
   147         if cissue.id == initiative.id then
   148           this = i
   149           break
   150         end
   151       end
   152       mk_link(-1, _("Previous initiative"), "resultset_previous.png", "initiative")
   153       mk_link(1, _("Next initiative"), "resultset_next.png", "initiative")
   154     end
   155   end
   156 end
   158 )
   160 slot.select("actions", function()
   162   if app.session.member_id then
   164     if issue.state == 'voting' then
   165       local text
   166       if not direct_voter then
   167         text = _"Vote now"
   168       else
   169         text = _"Change vote"
   170       end
   171       ui.link{
   172         content = function()
   173           ui.image{ static = "icons/16/email_open.png" }
   174           slot.put(text)
   175         end,
   176         module = "vote",
   177         view = "list",
   178         params = { issue_id = issue.id }
   179       }
   180     end
   182     execute.view{
   183       module = "interest",
   184       view = "_show_box",
   185       params = { issue = issue }
   186     }
   188     if not issue.closed then
   189       execute.view{
   190         module = "delegation",
   191         view = "_show_box",
   192         params = { issue_id = issue.id,
   193                    initiative_id = initiative and initiative.id or nil}
   194       }
   195     end
   197     execute.view{
   198       module = "issue",
   199       view = "_show_vote_later_box",
   200       params = { issue = issue }
   201     }
   203   end
   205   if config.issue_discussion_url_func then
   206     local url = config.issue_discussion_url_func(issue)
   207     ui.link{
   208       attr = { target = "_blank" },
   209       external = url,
   210       content = function()
   211         ui.image{ static = "icons/16/comments.png" }
   212         slot.put(_"Discussion on issue")
   213       end,
   214     }
   215   end
   216 end)
   219 execute.view{
   220   module = "issue",
   221   view = "_show_box",
   222   params = { issue = issue }
   223 }
   225 --  ui.twitter("http://example.com/t" .. tostring(issue.id))
   227 if config.public_access_issue_head and not app.session.member_id then
   228   config.public_access_issue_head(issue)
   229 end
   231 if app.session.member_id and issue.state == 'voting' and not direct_voter then
   232   ui.container{
   233     attr = { class = "voting_active_info" },
   234     content = function()
   235       slot.put(_"Voting for this issue is currently running!")
   236       slot.put(" ")
   237       if app.session.member_id then
   238         ui.link{
   239           content = function()
   240             slot.put(_"Vote now")
   241           end,
   242           module = "vote",
   243           view = "list",
   244           params = { issue_id = issue.id }
   245         }
   246       end
   247     end
   248   }
   249   slot.put("<br />")
   250 end
