liquid_feedback_frontend
annotate app/main/initiative/show.lua @ 4:80c215dbf076
Version alpha5
Many optical changes and improved usability
Support for different wiki-formatting-engines
Help system
Many optical changes and improved usability
Support for different wiki-formatting-engines
Help system
author | bsw/jbe |
---|---|
date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
parents | 768faea1096d |
children | afd9f769c7ae |
rev | line source |
---|---|
bsw/jbe@0 | 1 local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec() |
bsw/jbe@0 | 2 |
bsw/jbe@4 | 3 |
bsw/jbe@4 | 4 |
bsw/jbe@4 | 5 execute.view{ |
bsw/jbe@4 | 6 module = "issue", |
bsw/jbe@4 | 7 view = "_show_head", |
bsw/jbe@4 | 8 params = { issue = initiative.issue } |
bsw/jbe@4 | 9 } |
bsw/jbe@4 | 10 |
bsw/jbe@4 | 11 local initiator = Initiator:by_pk(initiative.id, app.session.member.id) |
bsw/jbe@4 | 12 |
bsw@3 | 13 --slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />') |
bsw/jbe@0 | 14 |
bsw/jbe@0 | 15 execute.view{ |
bsw/jbe@0 | 16 module = "supporter", |
bsw/jbe@0 | 17 view = "_show_box", |
bsw/jbe@0 | 18 params = { initiative = initiative } |
bsw/jbe@0 | 19 } |
bsw/jbe@0 | 20 |
bsw/jbe@4 | 21 --[[ |
bsw/jbe@4 | 22 |
bsw/jbe@0 | 23 execute.view{ |
bsw/jbe@0 | 24 module = "delegation", |
bsw/jbe@0 | 25 view = "_show_box", |
bsw/jbe@0 | 26 params = { issue_id = initiative.issue_id } |
bsw/jbe@0 | 27 } |
bsw/jbe@0 | 28 |
bsw@2 | 29 execute.view{ |
bsw@2 | 30 module = "issue", |
bsw@2 | 31 view = "_show_box", |
bsw@2 | 32 params = { issue = initiative.issue } |
bsw@2 | 33 } |
bsw/jbe@0 | 34 |
bsw/jbe@4 | 35 |
bsw/jbe@0 | 36 slot.select("path", function() |
bsw/jbe@0 | 37 ui.link{ |
bsw/jbe@0 | 38 content = _"Area '#{name}'":gsub("#{name}", initiative.issue.area.name), |
bsw/jbe@0 | 39 module = "area", |
bsw/jbe@0 | 40 view = "show", |
bsw/jbe@0 | 41 id = initiative.issue.area.id |
bsw/jbe@0 | 42 } |
bsw/jbe@0 | 43 ui.container{ content = "::" } |
bsw/jbe@0 | 44 ui.link{ |
bsw@2 | 45 content = _"Issue ##{id}":gsub("#{id}", initiative.issue.id), |
bsw/jbe@0 | 46 module = "issue", |
bsw/jbe@0 | 47 view = "show", |
bsw/jbe@0 | 48 id = initiative.issue.id |
bsw/jbe@0 | 49 } |
bsw/jbe@0 | 50 end) |
bsw/jbe@0 | 51 |
bsw/jbe@0 | 52 slot.put_into("title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) )) |
bsw/jbe@4 | 53 --]] |
bsw/jbe@4 | 54 |
bsw/jbe@4 | 55 slot.put_into("sub_title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) )) |
bsw/jbe@0 | 56 |
bsw/jbe@0 | 57 slot.select("actions", function() |
bsw/jbe@0 | 58 |
bsw/jbe@4 | 59 if not initiative.issue.fully_frozen and not initiative.issue.closed then |
bsw@2 | 60 ui.link{ |
bsw@2 | 61 content = function() |
bsw/jbe@4 | 62 ui.image{ static = "icons/16/script.png" } |
bsw/jbe@4 | 63 slot.put(_"Show other initiatives") |
bsw@2 | 64 end, |
bsw/jbe@4 | 65 module = "issue", |
bsw/jbe@4 | 66 view = "show", |
bsw/jbe@4 | 67 id = initiative.issue.id |
bsw@2 | 68 } |
bsw@3 | 69 ui.link{ |
bsw@3 | 70 attr = { class = "action" }, |
bsw@3 | 71 content = function() |
bsw@3 | 72 ui.image{ static = "icons/16/script_add.png" } |
bsw/jbe@4 | 73 slot.put(_"Create alternative initiative") |
bsw@3 | 74 end, |
bsw@3 | 75 module = "initiative", |
bsw@3 | 76 view = "new", |
bsw@3 | 77 params = { issue_id = initiative.issue.id } |
bsw@3 | 78 } |
bsw@3 | 79 end |
bsw@3 | 80 -- ui.twitter("http://example.com/i" .. tostring(initiative.id) .. " " .. initiative.name) |
bsw/jbe@0 | 81 |
bsw/jbe@4 | 82 end) |
bsw/jbe@4 | 83 |
bsw/jbe@4 | 84 |
bsw/jbe@4 | 85 util.help("initiative.show") |
bsw/jbe@4 | 86 |
bsw/jbe@4 | 87 |
bsw/jbe@4 | 88 ui.container{ |
bsw/jbe@4 | 89 attr = { class = "vertical" }, |
bsw/jbe@4 | 90 content = function() |
bsw/jbe@4 | 91 ui.container{ |
bsw/jbe@4 | 92 attr = { class = "ui_field_label" }, |
bsw/jbe@4 | 93 content = _"Discussion URL" |
bsw/jbe@4 | 94 } |
bsw/jbe@4 | 95 ui.tag{ |
bsw/jbe@4 | 96 tag = "span", |
bsw@3 | 97 content = function() |
bsw/jbe@4 | 98 if initiative.discussion_url and #initiative.discussion_url > 0 then |
bsw/jbe@4 | 99 ui.link{ |
bsw/jbe@4 | 100 attr = { |
bsw/jbe@4 | 101 class = "actions", |
bsw/jbe@4 | 102 target = _"blank", |
bsw/jbe@4 | 103 title = initiative.discussion_url |
bsw/jbe@4 | 104 }, |
bsw/jbe@4 | 105 content = function() |
bsw/jbe@4 | 106 slot.put(encode.html(initiative.discussion_url)) |
bsw/jbe@4 | 107 end, |
bsw/jbe@4 | 108 external = initiative.discussion_url |
bsw/jbe@4 | 109 } |
bsw/jbe@4 | 110 end |
bsw/jbe@4 | 111 slot.put(" ") |
bsw/jbe@4 | 112 if initiator then |
bsw/jbe@4 | 113 ui.link{ |
bsw/jbe@4 | 114 attr = { class = "actions" }, |
bsw/jbe@4 | 115 content = _"(change URL)", |
bsw/jbe@4 | 116 module = "initiative", |
bsw/jbe@4 | 117 view = "edit", |
bsw/jbe@4 | 118 id = initiative.id |
bsw/jbe@4 | 119 } |
bsw/jbe@4 | 120 end |
bsw/jbe@4 | 121 end |
bsw@3 | 122 } |
bsw@3 | 123 end |
bsw/jbe@4 | 124 } |
bsw/jbe@4 | 125 |
bsw/jbe@0 | 126 |
bsw/jbe@0 | 127 |
bsw/jbe@0 | 128 ui.container{ |
bsw/jbe@0 | 129 attr = { id = "add_suggestion_form", class = "hidden_inline_form" }, |
bsw/jbe@0 | 130 content = function() |
bsw/jbe@0 | 131 |
bsw/jbe@0 | 132 ui.link{ |
bsw/jbe@0 | 133 content = _"Close", |
bsw/jbe@0 | 134 attr = { |
bsw/jbe@0 | 135 onclick = "document.getElementById('add_suggestion_form').style.display='none';return(false)", |
bsw/jbe@0 | 136 style = "float: right;" |
bsw/jbe@0 | 137 } |
bsw/jbe@0 | 138 } |
bsw/jbe@0 | 139 |
bsw/jbe@0 | 140 ui.field.text{ attr = { class = "head" }, value = _"Add new suggestion" } |
bsw/jbe@0 | 141 |
bsw/jbe@0 | 142 |
bsw/jbe@0 | 143 ui.form{ |
bsw/jbe@0 | 144 module = "suggestion", |
bsw/jbe@0 | 145 action = "add", |
bsw/jbe@0 | 146 params = { initiative_id = initiative.id }, |
bsw/jbe@0 | 147 routing = { |
bsw/jbe@0 | 148 default = { |
bsw/jbe@0 | 149 mode = "redirect", |
bsw/jbe@0 | 150 module = "initiative", |
bsw/jbe@0 | 151 view = "show", |
bsw/jbe@0 | 152 id = initiative.id, |
bsw/jbe@0 | 153 params = { tab = "suggestion" } |
bsw/jbe@0 | 154 } |
bsw/jbe@0 | 155 }, |
bsw/jbe@0 | 156 attr = { class = "vertical" }, |
bsw/jbe@0 | 157 content = function() |
bsw/jbe@4 | 158 local supported = Supporter:by_pk(initiative.id, app.session.member.id) and true or false |
bsw/jbe@4 | 159 if not supported then |
bsw/jbe@4 | 160 ui.field.text{ |
bsw/jbe@4 | 161 attr = { class = "warning" }, |
bsw/jbe@4 | 162 value = _"You are currently not supporting this initiative. By adding suggestions to this initiative you will automatically become a potential supporter." |
bsw/jbe@4 | 163 } |
bsw/jbe@4 | 164 end |
bsw/jbe@4 | 165 ui.field.text{ label = _"Title (80 chars max)", name = "name" } |
bsw/jbe@0 | 166 ui.field.text{ label = _"Description", name = "description", multiline = true } |
bsw/jbe@0 | 167 ui.field.select{ |
bsw/jbe@0 | 168 label = _"Degree", |
bsw/jbe@0 | 169 name = "degree", |
bsw/jbe@0 | 170 foreign_records = { |
bsw/jbe@0 | 171 { id = 1, name = _"should"}, |
bsw/jbe@0 | 172 { id = 2, name = _"must"}, |
bsw/jbe@0 | 173 }, |
bsw/jbe@0 | 174 foreign_id = "id", |
bsw/jbe@0 | 175 foreign_name = "name" |
bsw/jbe@0 | 176 } |
bsw/jbe@0 | 177 ui.submit{ text = _"Commit suggestion" } |
bsw/jbe@0 | 178 end |
bsw/jbe@0 | 179 } |
bsw/jbe@0 | 180 end |
bsw/jbe@0 | 181 } |
bsw/jbe@0 | 182 |
bsw@2 | 183 local supporter = app.session.member:get_reference_selector("supporters") |
bsw@2 | 184 :add_where{ "initiative_id = ?", initiative.id } |
bsw@2 | 185 :optional_object_mode() |
bsw@2 | 186 :exec() |
bsw@2 | 187 |
bsw@2 | 188 if supporter then |
bsw@2 | 189 local old_draft_id = supporter.draft_id |
bsw@2 | 190 local new_draft_id = initiative.current_draft.id |
bsw@2 | 191 if old_draft_id ~= new_draft_id then |
bsw@2 | 192 ui.container{ |
bsw@2 | 193 attr = { class = "draft_updated_info" }, |
bsw@2 | 194 content = function() |
bsw@2 | 195 slot.put("The draft of this initiative has been updated!") |
bsw@2 | 196 slot.put(" ") |
bsw@2 | 197 ui.link{ |
bsw@2 | 198 content = _"Show diff", |
bsw@2 | 199 module = "draft", |
bsw@2 | 200 view = "diff", |
bsw@2 | 201 params = { |
bsw@2 | 202 old_draft_id = old_draft_id, |
bsw@2 | 203 new_draft_id = new_draft_id |
bsw@2 | 204 } |
bsw@2 | 205 } |
bsw@2 | 206 slot.put(" ") |
bsw@2 | 207 ui.link{ |
bsw@2 | 208 content = _"Refresh support to current draft", |
bsw@2 | 209 module = "initiative", |
bsw@2 | 210 action = "add_support", |
bsw@2 | 211 id = initiative.id, |
bsw@2 | 212 routing = { |
bsw@2 | 213 default = { |
bsw@2 | 214 mode = "redirect", |
bsw@2 | 215 module = "initiative", |
bsw@2 | 216 view = "show", |
bsw@2 | 217 id = initiative.id |
bsw@2 | 218 } |
bsw@2 | 219 } |
bsw@2 | 220 } |
bsw@2 | 221 end |
bsw@2 | 222 } |
bsw@2 | 223 end |
bsw@2 | 224 end |
bsw/jbe@0 | 225 |
bsw/jbe@4 | 226 |
bsw/jbe@0 | 227 ui.tabs{ |
bsw/jbe@0 | 228 { |
bsw/jbe@0 | 229 name = "current_draft", |
bsw/jbe@0 | 230 label = _"Current draft", |
bsw/jbe@0 | 231 content = function() |
bsw/jbe@4 | 232 if initiator then |
bsw/jbe@4 | 233 ui.link{ |
bsw/jbe@4 | 234 content = function() |
bsw/jbe@4 | 235 ui.image{ static = "icons/16/script_add.png" } |
bsw/jbe@4 | 236 slot.put(_"Edit draft") |
bsw/jbe@4 | 237 end, |
bsw/jbe@4 | 238 module = "draft", |
bsw/jbe@4 | 239 view = "new", |
bsw/jbe@4 | 240 params = { initiative_id = initiative.id } |
bsw/jbe@4 | 241 } |
bsw/jbe@4 | 242 end |
bsw/jbe@0 | 243 execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } } |
bsw/jbe@0 | 244 end |
bsw/jbe@0 | 245 }, |
bsw/jbe@0 | 246 { |
bsw/jbe@0 | 247 name = "suggestion", |
bsw/jbe@0 | 248 label = _"Suggestions", |
bsw/jbe@0 | 249 content = function() |
bsw/jbe@4 | 250 execute.view{ |
bsw/jbe@4 | 251 module = "suggestion", |
bsw/jbe@4 | 252 view = "_list", |
bsw/jbe@4 | 253 params = { |
bsw/jbe@4 | 254 initiative = initiative, |
bsw/jbe@4 | 255 suggestions_selector = initiative:get_reference_selector("suggestions") |
bsw/jbe@4 | 256 } |
bsw/jbe@4 | 257 } |
bsw/jbe@0 | 258 slot.put("<br />") |
bsw/jbe@0 | 259 if not initiative.issue.frozen and not initiative.issue.closed then |
bsw/jbe@0 | 260 ui.link{ |
bsw/jbe@0 | 261 content = function() |
bsw/jbe@0 | 262 ui.image{ static = "icons/16/comment_add.png" } |
bsw/jbe@0 | 263 slot.put(_"Add new suggestion") |
bsw/jbe@0 | 264 end, |
bsw/jbe@0 | 265 attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" }, |
bsw/jbe@0 | 266 static = "#" |
bsw/jbe@0 | 267 } |
bsw/jbe@0 | 268 end |
bsw/jbe@0 | 269 end |
bsw/jbe@0 | 270 }, |
bsw/jbe@0 | 271 { |
bsw/jbe@0 | 272 name = "supporter", |
bsw/jbe@0 | 273 label = _"Supporter", |
bsw/jbe@0 | 274 content = function() |
bsw@3 | 275 execute.view{ |
bsw@3 | 276 module = "member", |
bsw@3 | 277 view = "_list", |
bsw@3 | 278 params = { |
bsw@3 | 279 initiative = initiative, |
bsw@3 | 280 members_selector = initiative:get_reference_selector("supporting_members_snapshot") |
bsw@3 | 281 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") |
bsw/jbe@4 | 282 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") |
bsw/jbe@4 | 283 :add_field("direct_interest_snapshot.weight") |
bsw@3 | 284 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") |
bsw@3 | 285 } |
bsw@3 | 286 } |
bsw/jbe@0 | 287 end |
bsw/jbe@0 | 288 }, |
bsw/jbe@0 | 289 { |
bsw/jbe@0 | 290 name = "initiators", |
bsw/jbe@0 | 291 label = _"Initiators", |
bsw/jbe@0 | 292 content = function() |
bsw/jbe@0 | 293 execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } } |
bsw/jbe@0 | 294 end |
bsw/jbe@0 | 295 }, |
bsw/jbe@0 | 296 { |
bsw/jbe@0 | 297 name = "drafts", |
bsw/jbe@0 | 298 label = _"Old drafts", |
bsw/jbe@0 | 299 content = function() |
bsw/jbe@0 | 300 execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } } |
bsw/jbe@0 | 301 end |
bsw/jbe@0 | 302 }, |
bsw@2 | 303 { |
bsw@2 | 304 name = "details", |
bsw@2 | 305 label = _"Details", |
bsw@2 | 306 content = function() |
bsw@2 | 307 ui.form{ |
bsw@2 | 308 attr = { class = "vertical" }, |
bsw@2 | 309 record = initiative, |
bsw@2 | 310 readonly = true, |
bsw@2 | 311 content = function() |
bsw@2 | 312 ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name } |
bsw@2 | 313 ui.field.text{ |
bsw@2 | 314 label = _"Created at", |
bsw@2 | 315 value = tostring(initiative.created) |
bsw@2 | 316 } |
bsw@2 | 317 ui.field.text{ |
bsw@2 | 318 label = _"Created at", |
bsw@2 | 319 value = format.timestamp(initiative.created) |
bsw@2 | 320 } |
bsw@2 | 321 ui.field.date{ label = _"Revoked at", name = "revoked" } |
bsw@2 | 322 ui.field.boolean{ label = _"Admitted", name = "admitted" } |
bsw@2 | 323 end |
bsw@2 | 324 } |
bsw@2 | 325 end |
bsw@2 | 326 }, |
bsw/jbe@0 | 327 } |
bsw/jbe@0 | 328 |
bsw/jbe@0 | 329 |