liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 277:bde068b37608
Dropdown boxes except of delegation box removed, optical enhancements and repositioning of elements
| author | bsw | 
|---|---|
| date | Mon Feb 13 00:16:42 2012 +0100 (2012-02-13) | 
| parents | aec9df5b4cd3 | 
| children | fecd4c13054a | 
 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)
    68     --[[
    69 slot.select("content_navigation", function()
    71   if app.session.member_id then
    72     local records
    73     local this = 0
    74     local issues_selector = Issue:new_selector()
    76     -- FIXME: !DRY
    77     local issue_filter_map = {
    78       new = "new.png",
    79       accepted = "comments.png",
    80       half_frozen = "lock.png",
    81       frozen ="email_open.png",
    82       finished = "tick.png",
    83       cancelled = "cross.png",
    84     }
    87     local mk_link = function(index, text, icon, module)
    88        content = function()
    89           if index > 0 then
    90             slot.put(text)
    91             ui.image{ static = "icons/16/"..icon }
    92           else
    93             ui.image{ static = "icons/16/"..icon }
    94             slot.put(text)
    95           end
    96       end
    97       if records[this+index] then
    98         ui.link{
    99           content = content,
   100           module = module,
   101           view = "show",
   102           id = records[this+index].id,
   103         }
   104       else
   105         ui.container{
   106           content = content,
   107         }
   108       end
   109     end
   111     issues_selector
   112        :add_where{"issue.area_id = ?", issue.area.id}
   114     local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
   116     local state = issue.state
   118     -- FIXME: fix filter names to reflect issue.state values
   119     if state == "voting" then
   120       state = "frozen"
   121     elseif state == "frozen" then
   122       state = "half_frozen"
   123     end
   125     filter = filters:get_filter("filter", state)
   126     if filter then
   127       filter.selector_modifier(issues_selector)
   129       -- add subfilter to voting pager, so only not voted entries will be shown
   130       -- as this seems the most usefull exception
   131       if filter.name == "frozen" then
   132         filter_voting_name = "not_voted"
   133         local vfilter = filters:get_filter("filter_voting", "not_voted")
   134         if vfilter then
   135           vfilter.selector_modifier(issues_selector)
   136         end
   137       end
   138     end
   140     records = issues_selector:exec()
   142     for i,cissue in ipairs(records) do
   143       if cissue.id == issue.id then
   144         this = i
   145         break
   146       end
   147     end
   149     mk_link(-1, _("Previous issue"), "resultset_previous.png", "issue")
   150     if issue.area then
   151       ui.link{
   152         content = function()
   153           if issue_filter_map[state] then
   154             ui.image{ static = "icons/16/"..issue_filter_map[state] }
   155           end
   156           slot.put(issue.area.name)
   157         end,
   158         module = "area",
   159         view = "show",
   160         id = issue.area.id,
   161         params = {
   162           filter = filter and filter.name or nil,
   163           filter_voting = filter_voting_name,
   164           tab = "issues"
   165         }
   166       }
   167     end
   168     mk_link(1, _("Next issue"), "resultset_next.png", "issue")
   170     -- show pager for initiatives if available
   171     if initiative then
   172       ui.container{ content = function() end, attr = {class = "content_navigation_seperator"}}
   174       records = issue:get_reference_selector("initiatives"):exec()
   175       for i,cissue in ipairs(records) do
   176         if cissue.id == initiative.id then
   177           this = i
   178           break
   179         end
   180       end
   181       mk_link(-1, _("Previous initiative"), "resultset_previous.png", "initiative")
   182       mk_link(1, _("Next initiative"), "resultset_next.png", "initiative")
   183     end
   184   end
   185 end
   187 )
   188     --]]
   190 slot.select("actions", function()
   192   if app.session.member_id then
   194     if issue.state == 'voting' then
   195       local text
   196       if not direct_voter then
   197         text = _"Vote now"
   198       else
   199         text = _"Change vote"
   200       end
   201       ui.link{
   202         content = function()
   203           ui.image{ static = "icons/16/email_open.png" }
   204           slot.put(text)
   205         end,
   206         module = "vote",
   207         view = "list",
   208         params = { issue_id = issue.id }
   209       }
   210     end
   212     execute.view{
   213       module = "interest",
   214       view = "_show_box",
   215       params = { issue = issue }
   216     }
   218     if not issue.closed then
   219       execute.view{
   220         module = "delegation",
   221         view = "_show_box",
   222         params = { issue_id = issue.id,
   223                    initiative_id = initiative and initiative.id or nil}
   224       }
   225     end
   227   end
   229   if config.issue_discussion_url_func then
   230     local url = config.issue_discussion_url_func(issue)
   231     ui.link{
   232       attr = { target = "_blank" },
   233       external = url,
   234       content = function()
   235         ui.image{ static = "icons/16/comments.png" }
   236         slot.put(_"Discussion on issue")
   237       end,
   238     }
   239   end
   240 end)
   242 if app.session.member_id then
   243   slot.select("actions", function()
   244     if not issue.fully_frozen and not issue.closed then
   245       ui.link{
   246         image  = { static = "icons/16/script_add.png" },
   247         attr   = { class = "action" },
   248         text   = _"Create alternative initiative",
   249         module = "initiative",
   250         view   = "new",
   251         params = { issue_id = issue.id }
   252       }
   253     end
   254   end)
   255 end
   257 local issue = param.get("issue", "table")
   261 --  ui.twitter("http://example.com/t" .. tostring(issue.id))
   263 if config.public_access_issue_head and not app.session.member_id then
   264   config.public_access_issue_head(issue)
   265 end
   267 if app.session.member_id and issue.state == 'voting' and not direct_voter then
   268   ui.container{
   269     attr = { class = "voting_active_info" },
   270     content = function()
   271       slot.put(_"Voting for this issue is currently running!")
   272       slot.put(" ")
   273       if app.session.member_id then
   274         ui.link{
   275           content = function()
   276             slot.put(_"Vote now")
   277           end,
   278           module = "vote",
   279           view = "list",
   280           params = { issue_id = issue.id }
   281         }
   282       end
   283     end
   284   }
   285   slot.put("<br />")
   286 end
