liquid_feedback_frontend

annotate app/main/issue/_show_head.lua @ 150:eaf3db89a6e1

implement initiative pager in content_navigation

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

Impressum / About Us