liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 271:d13b27a37ad5
Optical enhancements, some repositioning of ui elements
| author | bsw | 
|---|---|
| date | Tue Feb 07 22:30:48 2012 +0100 (2012-02-07) | 
| parents | aab7b0c5543f | 
| children | 65a1f7a01e7b | 
 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 ##{id}", { id = issue.id }),
    21     module = "issue",
    22     view = "show",
    23     id = issue.id
    24   }
    25     slot.put(" · ")
    26   ui.link{
    27     content = issue.area.name,
    28     module = "area",
    29     view = "show",
    30     id = issue.area.id
    31   }
    32   if not config.single_unit_id then
    33     slot.put(" · ")
    34     ui.link{
    35       content = issue.area.unit.name,
    36       module = "area",
    37       view = "list",
    38       params = { unit_id = issue.area.unit_id }
    39     }
    40   end
    41 end)
    44 slot.select("title2", function()
    45   ui.tag{
    46     tag = "div",
    47     content = function()
    48       ui.tag{
    49         content = function()
    50           ui.link{
    51             text = issue.policy.name,
    52             module = "policy",
    53             view = "show",
    54             id = issue.policy.id
    55           }
    56         end
    57       }
    58       slot.put(" · ")
    59       ui.tag{ content = issue.state_name }
    61       slot.put(" · ")
    62       local time_left = issue.state_time_left
    63       if time_left then
    64         ui.tag{ content = _("#{time_left} left", { time_left = time_left }) }
    65       end
    67       slot.put(" · ")
    68       local next_state_names = issue.next_states_names
    69       if next_state_names then
    70         ui.tag{ content = _("Next state: #{state}", { state = next_state_names }) }
    71       end
    72     end
    73   }
    76 end)
    79     --[[
    80 slot.select("content_navigation", function()
    82   if app.session.member_id then
    83     local records
    84     local this = 0
    85     local issues_selector = Issue:new_selector()
    87     -- FIXME: !DRY
    88     local issue_filter_map = {
    89       new = "new.png",
    90       accepted = "comments.png",
    91       half_frozen = "lock.png",
    92       frozen ="email_open.png",
    93       finished = "tick.png",
    94       cancelled = "cross.png",
    95     }
    98     local mk_link = function(index, text, icon, module)
    99        content = function()
   100           if index > 0 then
   101             slot.put(text)
   102             ui.image{ static = "icons/16/"..icon }
   103           else
   104             ui.image{ static = "icons/16/"..icon }
   105             slot.put(text)
   106           end
   107       end
   108       if records[this+index] then
   109         ui.link{
   110           content = content,
   111           module = module,
   112           view = "show",
   113           id = records[this+index].id,
   114         }
   115       else
   116         ui.container{
   117           content = content,
   118         }
   119       end
   120     end
   122     issues_selector
   123        :add_where{"issue.area_id = ?", issue.area.id}
   125     local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
   127     local state = issue.state
   129     -- FIXME: fix filter names to reflect issue.state values
   130     if state == "voting" then
   131       state = "frozen"
   132     elseif state == "frozen" then
   133       state = "half_frozen"
   134     end
   136     filter = filters:get_filter("filter", state)
   137     if filter then
   138       filter.selector_modifier(issues_selector)
   140       -- add subfilter to voting pager, so only not voted entries will be shown
   141       -- as this seems the most usefull exception
   142       if filter.name == "frozen" then
   143         filter_voting_name = "not_voted"
   144         local vfilter = filters:get_filter("filter_voting", "not_voted")
   145         if vfilter then
   146           vfilter.selector_modifier(issues_selector)
   147         end
   148       end
   149     end
   151     records = issues_selector:exec()
   153     for i,cissue in ipairs(records) do
   154       if cissue.id == issue.id then
   155         this = i
   156         break
   157       end
   158     end
   160     mk_link(-1, _("Previous issue"), "resultset_previous.png", "issue")
   161     if issue.area then
   162       ui.link{
   163         content = function()
   164           if issue_filter_map[state] then
   165             ui.image{ static = "icons/16/"..issue_filter_map[state] }
   166           end
   167           slot.put(issue.area.name)
   168         end,
   169         module = "area",
   170         view = "show",
   171         id = issue.area.id,
   172         params = {
   173           filter = filter and filter.name or nil,
   174           filter_voting = filter_voting_name,
   175           tab = "issues"
   176         }
   177       }
   178     end
   179     mk_link(1, _("Next issue"), "resultset_next.png", "issue")
   181     -- show pager for initiatives if available
   182     if initiative then
   183       ui.container{ content = function() end, attr = {class = "content_navigation_seperator"}}
   185       records = issue:get_reference_selector("initiatives"):exec()
   186       for i,cissue in ipairs(records) do
   187         if cissue.id == initiative.id then
   188           this = i
   189           break
   190         end
   191       end
   192       mk_link(-1, _("Previous initiative"), "resultset_previous.png", "initiative")
   193       mk_link(1, _("Next initiative"), "resultset_next.png", "initiative")
   194     end
   195   end
   196 end
   198 )
   199     --]]
   201 slot.select("actions", function()
   203   if app.session.member_id then
   205     if issue.state == 'voting' then
   206       local text
   207       if not direct_voter then
   208         text = _"Vote now"
   209       else
   210         text = _"Change vote"
   211       end
   212       ui.link{
   213         content = function()
   214           ui.image{ static = "icons/16/email_open.png" }
   215           slot.put(text)
   216         end,
   217         module = "vote",
   218         view = "list",
   219         params = { issue_id = issue.id }
   220       }
   221     end
   223     execute.view{
   224       module = "interest",
   225       view = "_show_box",
   226       params = { issue = issue }
   227     }
   229     if not issue.closed then
   230       execute.view{
   231         module = "delegation",
   232         view = "_show_box",
   233         params = { issue_id = issue.id,
   234                    initiative_id = initiative and initiative.id or nil}
   235       }
   236     end
   238   end
   240   if config.issue_discussion_url_func then
   241     local url = config.issue_discussion_url_func(issue)
   242     ui.link{
   243       attr = { target = "_blank" },
   244       external = url,
   245       content = function()
   246         ui.image{ static = "icons/16/comments.png" }
   247         slot.put(_"Discussion on issue")
   248       end,
   249     }
   250   end
   251 end)
   254 local issue = param.get("issue", "table")
   258 --  ui.twitter("http://example.com/t" .. tostring(issue.id))
   260 if config.public_access_issue_head and not app.session.member_id then
   261   config.public_access_issue_head(issue)
   262 end
   264 if app.session.member_id and issue.state == 'voting' and not direct_voter then
   265   ui.container{
   266     attr = { class = "voting_active_info" },
   267     content = function()
   268       slot.put(_"Voting for this issue is currently running!")
   269       slot.put(" ")
   270       if app.session.member_id then
   271         ui.link{
   272           content = function()
   273             slot.put(_"Vote now")
   274           end,
   275           module = "vote",
   276           view = "list",
   277           params = { issue_id = issue.id }
   278         }
   279       end
   280     end
   281   }
   282   slot.put("<br />")
   283 end
