liquid_feedback_frontend
annotate app/main/issue/_show_head.lua @ 139:bc2570b97c09
fix spelling
fixed bug #330
fixed bug #330
| author | Daniel Poelzleithner <poelzi@poelzi.org> | 
|---|---|
| date | Wed Oct 06 13:52:23 2010 +0200 (2010-10-06) | 
| parents | 850d02b1fc6d | 
| children | eaf3db89a6e1 | 
| 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(" · ") | 
| 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(" · ") | 
| 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@127 | 43 | 
| 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@127 | 58 local mk_link = function(index, text, icon, ltr) | 
| poelzi@127 | 59 content = function() | 
| poelzi@127 | 60 if ltr 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@127 | 71 module = "issue", | 
| 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@129 | 120 mk_link(-1, _("Previous issue"), "resultset_previous.png") | 
| 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@129 | 139 mk_link(1, _("Next issue"), "resultset_next.png", 1) | 
| poelzi@127 | 140 end | 
| poelzi@127 | 141 end | 
| poelzi@127 | 142 | 
| poelzi@127 | 143 ) | 
| poelzi@127 | 144 | 
| bsw/jbe@4 | 145 slot.select("actions", function() | 
| bsw/jbe@5 | 146 | 
| bsw@51 | 147 if app.session.member_id then | 
| bsw@51 | 148 | 
| bsw@51 | 149 if issue.state == 'voting' then | 
| bsw@51 | 150 local text | 
| bsw@51 | 151 if not direct_voter then | 
| bsw@51 | 152 text = _"Vote now" | 
| bsw@51 | 153 else | 
| bsw@51 | 154 text = _"Change vote" | 
| bsw@51 | 155 end | 
| bsw@51 | 156 ui.link{ | 
| bsw@51 | 157 content = function() | 
| bsw@51 | 158 ui.image{ static = "icons/16/email_open.png" } | 
| bsw@51 | 159 slot.put(text) | 
| bsw@51 | 160 end, | 
| bsw@51 | 161 module = "vote", | 
| bsw@51 | 162 view = "list", | 
| bsw@51 | 163 params = { issue_id = issue.id } | 
| bsw@51 | 164 } | 
| bsw/jbe@19 | 165 end | 
| bsw/jbe@5 | 166 | 
| bsw/jbe@5 | 167 execute.view{ | 
| bsw@51 | 168 module = "interest", | 
| bsw/jbe@5 | 169 view = "_show_box", | 
| bsw@51 | 170 params = { issue = issue } | 
| bsw/jbe@5 | 171 } | 
| bsw@7 | 172 | 
| bsw@51 | 173 if not issue.closed then | 
| bsw@51 | 174 execute.view{ | 
| bsw@51 | 175 module = "delegation", | 
| bsw@51 | 176 view = "_show_box", | 
| poelzi@111 | 177 params = { issue_id = issue.id, | 
| poelzi@111 | 178 initiative_id = initiative and initiative.id or nil} | 
| bsw@51 | 179 } | 
| bsw@51 | 180 end | 
| bsw@51 | 181 | 
| bsw@51 | 182 execute.view{ | 
| bsw@51 | 183 module = "issue", | 
| bsw@51 | 184 view = "_show_vote_later_box", | 
| bsw@51 | 185 params = { issue = issue } | 
| bsw@51 | 186 } | 
| bsw@51 | 187 | 
| bsw@51 | 188 end | 
| bsw/jbe@4 | 189 | 
| bsw@10 | 190 if config.issue_discussion_url_func then | 
| bsw@10 | 191 local url = config.issue_discussion_url_func(issue) | 
| bsw@10 | 192 ui.link{ | 
| bsw@10 | 193 attr = { target = "_blank" }, | 
| bsw@10 | 194 external = url, | 
| bsw@10 | 195 content = function() | 
| bsw@10 | 196 ui.image{ static = "icons/16/comments.png" } | 
| bsw@10 | 197 slot.put(_"Discussion on issue") | 
| bsw@10 | 198 end, | 
| bsw@10 | 199 } | 
| bsw@10 | 200 end | 
| bsw/jbe@4 | 201 end) | 
| bsw/jbe@4 | 202 | 
| bsw/jbe@4 | 203 | 
| bsw/jbe@4 | 204 execute.view{ | 
| bsw/jbe@4 | 205 module = "issue", | 
| bsw/jbe@4 | 206 view = "_show_box", | 
| bsw/jbe@4 | 207 params = { issue = issue } | 
| bsw/jbe@4 | 208 } | 
| bsw/jbe@4 | 209 | 
| bsw/jbe@4 | 210 -- ui.twitter("http://example.com/t" .. tostring(issue.id)) | 
| bsw/jbe@6 | 211 | 
| bsw@60 | 212 if config.public_access_issue_head and not app.session.member_id then | 
| bsw@60 | 213 config.public_access_issue_head(issue) | 
| bsw@60 | 214 end | 
| bsw/jbe@6 | 215 | 
| bsw@60 | 216 if app.session.member_id and issue.state == 'voting' and not direct_voter then | 
| bsw/jbe@6 | 217 ui.container{ | 
| bsw/jbe@6 | 218 attr = { class = "voting_active_info" }, | 
| bsw/jbe@6 | 219 content = function() | 
| bsw/jbe@6 | 220 slot.put(_"Voting for this issue is currently running!") | 
| bsw/jbe@6 | 221 slot.put(" ") | 
| bsw@51 | 222 if app.session.member_id then | 
| bsw@51 | 223 ui.link{ | 
| bsw@51 | 224 content = function() | 
| bsw@51 | 225 slot.put(_"Vote now") | 
| bsw@51 | 226 end, | 
| bsw@51 | 227 module = "vote", | 
| bsw@51 | 228 view = "list", | 
| bsw@51 | 229 params = { issue_id = issue.id } | 
| bsw@51 | 230 } | 
| bsw@51 | 231 end | 
| bsw/jbe@6 | 232 end | 
| bsw/jbe@6 | 233 } | 
| bsw/jbe@6 | 234 slot.put("<br />") | 
| bsw/jbe@6 | 235 end | 
| bsw/jbe@6 | 236 |