| rev | 
   line source | 
| 
bsw/jbe@4
 | 
     1 local issue = param.get("issue", "table")
 | 
| 
poelzi@111
 | 
     2 local initiative = param.get("initiative", "table")
 | 
| 
bsw/jbe@4
 | 
     3 
 | 
| 
bsw@51
 | 
     4 local direct_voter
 | 
| 
bsw@51
 | 
     5 
 | 
| 
bsw@51
 | 
     6 if app.session.member_id then
 | 
| 
bsw@51
 | 
     7   direct_voter = DirectVoter:by_pk(issue.id, app.session.member.id)
 | 
| 
bsw@51
 | 
     8 end
 | 
| 
bsw/jbe@19
 | 
     9 
 | 
| 
bsw/jbe@52
 | 
    10 if config.feature_rss_enabled then
 | 
| 
bsw/jbe@52
 | 
    11   util.html_rss_head{ title = _"Initiatives in this issue (last created first)", module = "initiative", view = "list_rss", params = { issue_id = issue.id } }
 | 
| 
bsw/jbe@52
 | 
    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" } }
 | 
| 
bsw/jbe@52
 | 
    13 end
 | 
| 
bsw/jbe@4
 | 
    14 
 | 
| 
bsw/jbe@4
 | 
    15 slot.select("path", function()
 | 
| 
bsw/jbe@19
 | 
    16 end)
 | 
| 
bsw/jbe@19
 | 
    17 
 | 
| 
bsw/jbe@19
 | 
    18 slot.select("title", function()
 | 
| 
bsw@271
 | 
    19   ui.link{
 | 
| 
bsw@271
 | 
    20     content = _("Issue ##{id}", { id = issue.id }),
 | 
| 
bsw@271
 | 
    21     module = "issue",
 | 
| 
bsw@271
 | 
    22     view = "show",
 | 
| 
bsw@271
 | 
    23     id = issue.id
 | 
| 
bsw@271
 | 
    24   }
 | 
| 
bsw@273
 | 
    25   slot.put(" · ")
 | 
| 
bsw/jbe@4
 | 
    26   ui.link{
 | 
| 
bsw/jbe@19
 | 
    27     content = issue.area.name,
 | 
| 
bsw/jbe@4
 | 
    28     module = "area",
 | 
| 
bsw/jbe@4
 | 
    29     view = "show",
 | 
| 
bsw/jbe@4
 | 
    30     id = issue.area.id
 | 
| 
bsw/jbe@4
 | 
    31   }
 | 
| 
bsw@271
 | 
    32   if not config.single_unit_id then
 | 
| 
bsw@271
 | 
    33     slot.put(" · ")
 | 
| 
bsw@271
 | 
    34     ui.link{
 | 
| 
bsw@271
 | 
    35       content = issue.area.unit.name,
 | 
| 
bsw@271
 | 
    36       module = "area",
 | 
| 
bsw@271
 | 
    37       view = "list",
 | 
| 
bsw@271
 | 
    38       params = { unit_id = issue.area.unit_id }
 | 
| 
bsw@271
 | 
    39     }
 | 
| 
bsw@271
 | 
    40   end
 | 
| 
bsw/jbe@5
 | 
    41 end)
 | 
| 
bsw/jbe@5
 | 
    42 
 | 
| 
bsw/jbe@4
 | 
    43 
 | 
| 
bsw@271
 | 
    44 slot.select("title2", function()
 | 
| 
bsw@271
 | 
    45   ui.tag{
 | 
| 
bsw@271
 | 
    46     tag = "div",
 | 
| 
bsw@271
 | 
    47     content = function()
 | 
| 
bsw@272
 | 
    48     
 | 
| 
bsw@272
 | 
    49       ui.link{
 | 
| 
bsw@272
 | 
    50         text = issue.policy.name,
 | 
| 
bsw@272
 | 
    51         module = "policy",
 | 
| 
bsw@272
 | 
    52         view = "show",
 | 
| 
bsw@272
 | 
    53         id = issue.policy.id
 | 
| 
bsw@272
 | 
    54       }
 | 
| 
bsw@272
 | 
    55 
 | 
| 
bsw@271
 | 
    56       slot.put(" · ")
 | 
| 
bsw@271
 | 
    57       ui.tag{ content = issue.state_name }
 | 
| 
bsw@271
 | 
    58 
 | 
| 
bsw@273
 | 
    59       if issue.state_time_left then
 | 
| 
bsw@273
 | 
    60         slot.put(" · ")
 | 
| 
bsw@273
 | 
    61         ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left }) }
 | 
| 
bsw@271
 | 
    62       end
 | 
| 
bsw@271
 | 
    63 
 | 
| 
bsw@271
 | 
    64     end
 | 
| 
bsw@271
 | 
    65   }
 | 
| 
bsw@271
 | 
    66 
 | 
| 
bsw@271
 | 
    67   
 | 
| 
bsw@271
 | 
    68 end)
 | 
| 
bsw@271
 | 
    69 
 | 
| 
bsw@271
 | 
    70 
 | 
| 
bsw@271
 | 
    71     --[[
 | 
| 
poelzi@127
 | 
    72 slot.select("content_navigation", function()
 | 
| 
poelzi@127
 | 
    73 
 | 
| 
poelzi@127
 | 
    74   if app.session.member_id then
 | 
| 
poelzi@150
 | 
    75     local records
 | 
| 
poelzi@127
 | 
    76     local this = 0
 | 
| 
poelzi@127
 | 
    77     local issues_selector = Issue:new_selector()
 | 
| 
poelzi@127
 | 
    78 
 | 
| 
poelzi@127
 | 
    79     -- FIXME: !DRY
 | 
| 
poelzi@127
 | 
    80     local issue_filter_map = {
 | 
| 
poelzi@127
 | 
    81       new = "new.png",
 | 
| 
poelzi@127
 | 
    82       accepted = "comments.png",
 | 
| 
poelzi@127
 | 
    83       half_frozen = "lock.png",
 | 
| 
poelzi@127
 | 
    84       frozen ="email_open.png",
 | 
| 
poelzi@127
 | 
    85       finished = "tick.png",
 | 
| 
poelzi@127
 | 
    86       cancelled = "cross.png",
 | 
| 
poelzi@127
 | 
    87     }
 | 
| 
poelzi@127
 | 
    88 
 | 
| 
poelzi@127
 | 
    89 
 | 
| 
poelzi@150
 | 
    90     local mk_link = function(index, text, icon, module)
 | 
| 
poelzi@127
 | 
    91        content = function()
 | 
| 
poelzi@150
 | 
    92           if index > 0 then
 | 
| 
poelzi@127
 | 
    93             slot.put(text)
 | 
| 
poelzi@127
 | 
    94             ui.image{ static = "icons/16/"..icon }
 | 
| 
poelzi@127
 | 
    95           else
 | 
| 
poelzi@127
 | 
    96             ui.image{ static = "icons/16/"..icon }
 | 
| 
poelzi@127
 | 
    97             slot.put(text)
 | 
| 
poelzi@127
 | 
    98           end
 | 
| 
poelzi@127
 | 
    99       end
 | 
| 
poelzi@127
 | 
   100       if records[this+index] then
 | 
| 
poelzi@127
 | 
   101         ui.link{
 | 
| 
poelzi@127
 | 
   102           content = content,
 | 
| 
poelzi@150
 | 
   103           module = module,
 | 
| 
poelzi@127
 | 
   104           view = "show",
 | 
| 
poelzi@127
 | 
   105           id = records[this+index].id,
 | 
| 
poelzi@127
 | 
   106         }
 | 
| 
poelzi@127
 | 
   107       else
 | 
| 
poelzi@127
 | 
   108         ui.container{
 | 
| 
poelzi@127
 | 
   109           content = content,
 | 
| 
poelzi@127
 | 
   110         }
 | 
| 
poelzi@127
 | 
   111       end
 | 
| 
poelzi@127
 | 
   112     end
 | 
| 
poelzi@127
 | 
   113 
 | 
| 
poelzi@127
 | 
   114     issues_selector
 | 
| 
poelzi@127
 | 
   115        :add_where{"issue.area_id = ?", issue.area.id}
 | 
| 
poelzi@127
 | 
   116 
 | 
| 
poelzi@127
 | 
   117     local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
 | 
| 
poelzi@127
 | 
   118 
 | 
| 
poelzi@127
 | 
   119     local state = issue.state
 | 
| 
poelzi@127
 | 
   120 
 | 
| 
poelzi@127
 | 
   121     -- FIXME: fix filter names to reflect issue.state values
 | 
| 
poelzi@127
 | 
   122     if state == "voting" then
 | 
| 
poelzi@127
 | 
   123       state = "frozen"
 | 
| 
poelzi@127
 | 
   124     elseif state == "frozen" then
 | 
| 
poelzi@127
 | 
   125       state = "half_frozen"
 | 
| 
poelzi@127
 | 
   126     end
 | 
| 
poelzi@127
 | 
   127 
 | 
| 
poelzi@127
 | 
   128     filter = filters:get_filter("filter", state)
 | 
| 
poelzi@127
 | 
   129     if filter then
 | 
| 
poelzi@127
 | 
   130       filter.selector_modifier(issues_selector)
 | 
| 
poelzi@127
 | 
   131 
 | 
| 
poelzi@127
 | 
   132       -- add subfilter to voting pager, so only not voted entries will be shown
 | 
| 
poelzi@127
 | 
   133       -- as this seems the most usefull exception
 | 
| 
poelzi@127
 | 
   134       if filter.name == "frozen" then
 | 
| 
poelzi@127
 | 
   135         filter_voting_name = "not_voted"
 | 
| 
poelzi@127
 | 
   136         local vfilter = filters:get_filter("filter_voting", "not_voted")
 | 
| 
poelzi@127
 | 
   137         if vfilter then
 | 
| 
poelzi@127
 | 
   138           vfilter.selector_modifier(issues_selector)
 | 
| 
poelzi@127
 | 
   139         end
 | 
| 
poelzi@127
 | 
   140       end
 | 
| 
poelzi@127
 | 
   141     end
 | 
| 
poelzi@127
 | 
   142 
 | 
| 
poelzi@127
 | 
   143     records = issues_selector:exec()
 | 
| 
poelzi@127
 | 
   144 
 | 
| 
poelzi@127
 | 
   145     for i,cissue in ipairs(records) do
 | 
| 
poelzi@127
 | 
   146       if cissue.id == issue.id then
 | 
| 
poelzi@127
 | 
   147         this = i
 | 
| 
poelzi@127
 | 
   148         break
 | 
| 
poelzi@127
 | 
   149       end
 | 
| 
poelzi@127
 | 
   150     end
 | 
| 
poelzi@127
 | 
   151 
 | 
| 
poelzi@150
 | 
   152     mk_link(-1, _("Previous issue"), "resultset_previous.png", "issue")
 | 
| 
poelzi@127
 | 
   153     if issue.area then
 | 
| 
poelzi@127
 | 
   154       ui.link{
 | 
| 
poelzi@127
 | 
   155         content = function()
 | 
| 
poelzi@127
 | 
   156           if issue_filter_map[state] then
 | 
| 
poelzi@127
 | 
   157             ui.image{ static = "icons/16/"..issue_filter_map[state] }
 | 
| 
poelzi@127
 | 
   158           end
 | 
| 
poelzi@127
 | 
   159           slot.put(issue.area.name)
 | 
| 
poelzi@127
 | 
   160         end,
 | 
| 
poelzi@127
 | 
   161         module = "area",
 | 
| 
poelzi@127
 | 
   162         view = "show",
 | 
| 
poelzi@127
 | 
   163         id = issue.area.id,
 | 
| 
poelzi@127
 | 
   164         params = {
 | 
| 
poelzi@127
 | 
   165           filter = filter and filter.name or nil,
 | 
| 
poelzi@127
 | 
   166           filter_voting = filter_voting_name,
 | 
| 
poelzi@127
 | 
   167           tab = "issues"
 | 
| 
poelzi@127
 | 
   168         }
 | 
| 
poelzi@127
 | 
   169       }
 | 
| 
poelzi@127
 | 
   170     end
 | 
| 
poelzi@150
 | 
   171     mk_link(1, _("Next issue"), "resultset_next.png", "issue")
 | 
| 
poelzi@150
 | 
   172 
 | 
| 
poelzi@150
 | 
   173     -- show pager for initiatives if available
 | 
| 
poelzi@150
 | 
   174     if initiative then
 | 
| 
poelzi@150
 | 
   175       ui.container{ content = function() end, attr = {class = "content_navigation_seperator"}}
 | 
| 
poelzi@150
 | 
   176 
 | 
| 
poelzi@150
 | 
   177       records = issue:get_reference_selector("initiatives"):exec()
 | 
| 
poelzi@150
 | 
   178       for i,cissue in ipairs(records) do
 | 
| 
poelzi@150
 | 
   179         if cissue.id == initiative.id then
 | 
| 
poelzi@150
 | 
   180           this = i
 | 
| 
poelzi@150
 | 
   181           break
 | 
| 
poelzi@150
 | 
   182         end
 | 
| 
poelzi@150
 | 
   183       end
 | 
| 
poelzi@150
 | 
   184       mk_link(-1, _("Previous initiative"), "resultset_previous.png", "initiative")
 | 
| 
poelzi@150
 | 
   185       mk_link(1, _("Next initiative"), "resultset_next.png", "initiative")
 | 
| 
poelzi@150
 | 
   186     end
 | 
| 
poelzi@127
 | 
   187   end
 | 
| 
poelzi@127
 | 
   188 end
 | 
| 
poelzi@127
 | 
   189 
 | 
| 
poelzi@127
 | 
   190 )
 | 
| 
bsw@271
 | 
   191     --]]
 | 
| 
poelzi@127
 | 
   192 
 | 
| 
bsw/jbe@4
 | 
   193 slot.select("actions", function()
 | 
| 
bsw/jbe@5
 | 
   194 
 | 
| 
bsw@51
 | 
   195   if app.session.member_id then
 | 
| 
bsw@51
 | 
   196 
 | 
| 
bsw@51
 | 
   197     if issue.state == 'voting' then
 | 
| 
bsw@51
 | 
   198       local text
 | 
| 
bsw@51
 | 
   199       if not direct_voter then
 | 
| 
bsw@51
 | 
   200         text = _"Vote now"
 | 
| 
bsw@51
 | 
   201       else
 | 
| 
bsw@51
 | 
   202         text = _"Change vote"
 | 
| 
bsw@51
 | 
   203       end
 | 
| 
bsw@51
 | 
   204       ui.link{
 | 
| 
bsw@51
 | 
   205         content = function()
 | 
| 
bsw@51
 | 
   206           ui.image{ static = "icons/16/email_open.png" }
 | 
| 
bsw@51
 | 
   207           slot.put(text)
 | 
| 
bsw@51
 | 
   208         end,
 | 
| 
bsw@51
 | 
   209         module = "vote",
 | 
| 
bsw@51
 | 
   210         view = "list",
 | 
| 
bsw@51
 | 
   211         params = { issue_id = issue.id }
 | 
| 
bsw@51
 | 
   212       }
 | 
| 
bsw/jbe@19
 | 
   213     end
 | 
| 
bsw/jbe@5
 | 
   214 
 | 
| 
bsw/jbe@5
 | 
   215     execute.view{
 | 
| 
bsw@51
 | 
   216       module = "interest",
 | 
| 
bsw/jbe@5
 | 
   217       view = "_show_box",
 | 
| 
bsw@51
 | 
   218       params = { issue = issue }
 | 
| 
bsw/jbe@5
 | 
   219     }
 | 
| 
bsw@7
 | 
   220 
 | 
| 
bsw@51
 | 
   221     if not issue.closed then
 | 
| 
bsw@51
 | 
   222       execute.view{
 | 
| 
bsw@51
 | 
   223         module = "delegation",
 | 
| 
bsw@51
 | 
   224         view = "_show_box",
 | 
| 
poelzi@111
 | 
   225         params = { issue_id = issue.id,
 | 
| 
poelzi@111
 | 
   226                    initiative_id = initiative and initiative.id or nil}
 | 
| 
bsw@51
 | 
   227       }
 | 
| 
bsw@51
 | 
   228     end
 | 
| 
bsw@51
 | 
   229 
 | 
| 
bsw@51
 | 
   230   end
 | 
| 
bsw/jbe@4
 | 
   231 
 | 
| 
bsw@10
 | 
   232   if config.issue_discussion_url_func then
 | 
| 
bsw@10
 | 
   233     local url = config.issue_discussion_url_func(issue)
 | 
| 
bsw@10
 | 
   234     ui.link{
 | 
| 
bsw@10
 | 
   235       attr = { target = "_blank" },
 | 
| 
bsw@10
 | 
   236       external = url,
 | 
| 
bsw@10
 | 
   237       content = function()
 | 
| 
bsw@10
 | 
   238         ui.image{ static = "icons/16/comments.png" }
 | 
| 
bsw@10
 | 
   239         slot.put(_"Discussion on issue")
 | 
| 
bsw@10
 | 
   240       end,
 | 
| 
bsw@10
 | 
   241     }
 | 
| 
bsw@10
 | 
   242   end
 | 
| 
bsw/jbe@4
 | 
   243 end)
 | 
| 
bsw/jbe@4
 | 
   244 
 | 
| 
bsw@272
 | 
   245 if app.session.member_id then
 | 
| 
bsw@272
 | 
   246   slot.select("actions", function()
 | 
| 
bsw@272
 | 
   247     if not issue.fully_frozen and not issue.closed then
 | 
| 
bsw@272
 | 
   248       ui.link{
 | 
| 
bsw@272
 | 
   249         image  = { static = "icons/16/script_add.png" },
 | 
| 
bsw@272
 | 
   250         attr   = { class = "action" },
 | 
| 
bsw@272
 | 
   251         text   = _"Create alternative initiative",
 | 
| 
bsw@272
 | 
   252         module = "initiative",
 | 
| 
bsw@272
 | 
   253         view   = "new",
 | 
| 
bsw@272
 | 
   254         params = { issue_id = issue.id }
 | 
| 
bsw@272
 | 
   255       }
 | 
| 
bsw@272
 | 
   256     end
 | 
| 
bsw@272
 | 
   257   end)
 | 
| 
bsw@272
 | 
   258 end
 | 
| 
bsw/jbe@4
 | 
   259 
 | 
| 
bsw@271
 | 
   260 local issue = param.get("issue", "table")
 | 
| 
bsw@271
 | 
   261 
 | 
| 
bsw@271
 | 
   262 
 | 
| 
bsw/jbe@4
 | 
   263 
 | 
| 
bsw/jbe@4
 | 
   264 --  ui.twitter("http://example.com/t" .. tostring(issue.id))
 | 
| 
bsw/jbe@6
 | 
   265 
 | 
| 
bsw@60
 | 
   266 if config.public_access_issue_head and not app.session.member_id then
 | 
| 
bsw@60
 | 
   267   config.public_access_issue_head(issue)
 | 
| 
bsw@60
 | 
   268 end
 | 
| 
bsw/jbe@6
 | 
   269 
 | 
| 
bsw@60
 | 
   270 if app.session.member_id and issue.state == 'voting' and not direct_voter then
 | 
| 
bsw/jbe@6
 | 
   271   ui.container{
 | 
| 
bsw/jbe@6
 | 
   272     attr = { class = "voting_active_info" },
 | 
| 
bsw/jbe@6
 | 
   273     content = function()
 | 
| 
bsw/jbe@6
 | 
   274       slot.put(_"Voting for this issue is currently running!")
 | 
| 
bsw/jbe@6
 | 
   275       slot.put(" ")
 | 
| 
bsw@51
 | 
   276       if app.session.member_id then
 | 
| 
bsw@51
 | 
   277         ui.link{
 | 
| 
bsw@51
 | 
   278           content = function()
 | 
| 
bsw@51
 | 
   279             slot.put(_"Vote now")
 | 
| 
bsw@51
 | 
   280           end,
 | 
| 
bsw@51
 | 
   281           module = "vote",
 | 
| 
bsw@51
 | 
   282           view = "list",
 | 
| 
bsw@51
 | 
   283           params = { issue_id = issue.id }
 | 
| 
bsw@51
 | 
   284         }
 | 
| 
bsw@51
 | 
   285       end
 | 
| 
bsw/jbe@6
 | 
   286     end
 | 
| 
bsw/jbe@6
 | 
   287   }
 | 
| 
bsw/jbe@6
 | 
   288   slot.put("<br />")
 | 
| 
bsw/jbe@6
 | 
   289 end
 | 
| 
bsw/jbe@6
 | 
   290 
 |