liquid_feedback_frontend

annotate app/main/initiative/show.lua @ 3:768faea1096d

Version alpha4

Members interested in an issue or supporting an initiative have a weight information attached. Browsing the members causing that weight is possible.

Initiatives may provide a link to an external discussion platform

Direct link on every initiative page to create an alternative initiative

Bugfix: No error when clicking "neutral", when "neutral" is currently selected
author bsw
date Mon Nov 30 12:00:00 2009 +0100 (2009-11-30)
parents 5c601807d397
children 80c215dbf076
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@3 3 --slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />')
bsw/jbe@0 4
bsw/jbe@0 5 execute.view{
bsw/jbe@0 6 module = "supporter",
bsw/jbe@0 7 view = "_show_box",
bsw/jbe@0 8 params = { initiative = initiative }
bsw/jbe@0 9 }
bsw/jbe@0 10
bsw/jbe@0 11 execute.view{
bsw/jbe@0 12 module = "delegation",
bsw/jbe@0 13 view = "_show_box",
bsw/jbe@0 14 params = { issue_id = initiative.issue_id }
bsw/jbe@0 15 }
bsw/jbe@0 16
bsw@2 17 execute.view{
bsw@2 18 module = "issue",
bsw@2 19 view = "_show_box",
bsw@2 20 params = { issue = initiative.issue }
bsw@2 21 }
bsw/jbe@0 22
bsw/jbe@0 23 slot.select("path", function()
bsw/jbe@0 24 ui.link{
bsw/jbe@0 25 content = _"Area '#{name}'":gsub("#{name}", initiative.issue.area.name),
bsw/jbe@0 26 module = "area",
bsw/jbe@0 27 view = "show",
bsw/jbe@0 28 id = initiative.issue.area.id
bsw/jbe@0 29 }
bsw/jbe@0 30 ui.container{ content = "::" }
bsw/jbe@0 31 ui.link{
bsw@2 32 content = _"Issue ##{id}":gsub("#{id}", initiative.issue.id),
bsw/jbe@0 33 module = "issue",
bsw/jbe@0 34 view = "show",
bsw/jbe@0 35 id = initiative.issue.id
bsw/jbe@0 36 }
bsw/jbe@0 37 end)
bsw/jbe@0 38
bsw/jbe@0 39 slot.put_into("title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) ))
bsw/jbe@0 40
bsw/jbe@0 41 slot.select("actions", function()
bsw/jbe@0 42
bsw@3 43 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
bsw@3 44
bsw@3 45 if initiator then
bsw@2 46 ui.link{
bsw@2 47 content = function()
bsw@2 48 ui.image{ static = "icons/16/script_add.png" }
bsw@2 49 slot.put(_"Edit draft")
bsw@2 50 end,
bsw@2 51 module = "draft",
bsw@2 52 view = "new",
bsw@2 53 params = { initiative_id = initiative.id }
bsw@2 54 }
bsw@2 55 end
bsw@2 56
bsw@3 57 if not initiative.issue.fully_frozen and not initiative.issue.closed then
bsw@3 58 ui.link{
bsw@3 59 attr = { class = "action" },
bsw@3 60 content = function()
bsw@3 61 ui.image{ static = "icons/16/script_add.png" }
bsw@3 62 slot.put(_"Create alternative initiative" )
bsw@3 63 end,
bsw@3 64 module = "initiative",
bsw@3 65 view = "new",
bsw@3 66 params = { issue_id = initiative.issue.id }
bsw@3 67 }
bsw@3 68 end
bsw@3 69 -- ui.twitter("http://example.com/i" .. tostring(initiative.id) .. " " .. initiative.name)
bsw/jbe@0 70
bsw@3 71 if initiative.discussion_url and #initiative.discussion_url > 0 then
bsw@3 72 ui.link{
bsw@3 73 attr = {
bsw@3 74 target = _"blank",
bsw@3 75 title = initiative.discussion_url
bsw@3 76 },
bsw@3 77 content = function()
bsw@3 78 ui.image{ static = "icons/16/comments.png" }
bsw@3 79 slot.put(_"External discussion")
bsw@3 80 end,
bsw@3 81 external = initiative.discussion_url
bsw@3 82 }
bsw@3 83 end
bsw@3 84 if initiator then
bsw@3 85 ui.link{
bsw@3 86 content = _"(change)",
bsw@3 87 module = "initiative",
bsw@3 88 view = "edit",
bsw@3 89 id = initiative.id
bsw@3 90 }
bsw@3 91 end
bsw/jbe@0 92 end)
bsw/jbe@0 93
bsw/jbe@0 94
bsw/jbe@0 95 ui.container{
bsw/jbe@0 96 attr = { id = "add_suggestion_form", class = "hidden_inline_form" },
bsw/jbe@0 97 content = function()
bsw/jbe@0 98
bsw/jbe@0 99 ui.link{
bsw/jbe@0 100 content = _"Close",
bsw/jbe@0 101 attr = {
bsw/jbe@0 102 onclick = "document.getElementById('add_suggestion_form').style.display='none';return(false)",
bsw/jbe@0 103 style = "float: right;"
bsw/jbe@0 104 }
bsw/jbe@0 105 }
bsw/jbe@0 106
bsw/jbe@0 107 ui.field.text{ attr = { class = "head" }, value = _"Add new suggestion" }
bsw/jbe@0 108
bsw/jbe@0 109
bsw/jbe@0 110 ui.form{
bsw/jbe@0 111 module = "suggestion",
bsw/jbe@0 112 action = "add",
bsw/jbe@0 113 params = { initiative_id = initiative.id },
bsw/jbe@0 114 routing = {
bsw/jbe@0 115 default = {
bsw/jbe@0 116 mode = "redirect",
bsw/jbe@0 117 module = "initiative",
bsw/jbe@0 118 view = "show",
bsw/jbe@0 119 id = initiative.id,
bsw/jbe@0 120 params = { tab = "suggestion" }
bsw/jbe@0 121 }
bsw/jbe@0 122 },
bsw/jbe@0 123 attr = { class = "vertical" },
bsw/jbe@0 124 content = function()
bsw/jbe@0 125 ui.field.text{ label = _"Name", name = "name" }
bsw/jbe@0 126 ui.field.text{ label = _"Description", name = "description", multiline = true }
bsw/jbe@0 127 ui.field.select{
bsw/jbe@0 128 label = _"Degree",
bsw/jbe@0 129 name = "degree",
bsw/jbe@0 130 foreign_records = {
bsw/jbe@0 131 { id = 1, name = _"should"},
bsw/jbe@0 132 { id = 2, name = _"must"},
bsw/jbe@0 133 },
bsw/jbe@0 134 foreign_id = "id",
bsw/jbe@0 135 foreign_name = "name"
bsw/jbe@0 136 }
bsw/jbe@0 137 ui.submit{ text = _"Commit suggestion" }
bsw/jbe@0 138 end
bsw/jbe@0 139 }
bsw/jbe@0 140 end
bsw/jbe@0 141 }
bsw/jbe@0 142
bsw@2 143 local supporter = app.session.member:get_reference_selector("supporters")
bsw@2 144 :add_where{ "initiative_id = ?", initiative.id }
bsw@2 145 :optional_object_mode()
bsw@2 146 :exec()
bsw@2 147
bsw@2 148 if supporter then
bsw@2 149 local old_draft_id = supporter.draft_id
bsw@2 150 local new_draft_id = initiative.current_draft.id
bsw@2 151 if old_draft_id ~= new_draft_id then
bsw@2 152 ui.container{
bsw@2 153 attr = { class = "draft_updated_info" },
bsw@2 154 content = function()
bsw@2 155 slot.put("The draft of this initiative has been updated!")
bsw@2 156 slot.put(" ")
bsw@2 157 ui.link{
bsw@2 158 content = _"Show diff",
bsw@2 159 module = "draft",
bsw@2 160 view = "diff",
bsw@2 161 params = {
bsw@2 162 old_draft_id = old_draft_id,
bsw@2 163 new_draft_id = new_draft_id
bsw@2 164 }
bsw@2 165 }
bsw@2 166 slot.put(" ")
bsw@2 167 ui.link{
bsw@2 168 content = _"Refresh support to current draft",
bsw@2 169 module = "initiative",
bsw@2 170 action = "add_support",
bsw@2 171 id = initiative.id,
bsw@2 172 routing = {
bsw@2 173 default = {
bsw@2 174 mode = "redirect",
bsw@2 175 module = "initiative",
bsw@2 176 view = "show",
bsw@2 177 id = initiative.id
bsw@2 178 }
bsw@2 179 }
bsw@2 180 }
bsw@2 181 end
bsw@2 182 }
bsw@2 183 end
bsw@2 184 end
bsw/jbe@0 185
bsw/jbe@0 186 ui.tabs{
bsw/jbe@0 187 {
bsw/jbe@0 188 name = "current_draft",
bsw/jbe@0 189 label = _"Current draft",
bsw/jbe@0 190 content = function()
bsw/jbe@0 191 execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } }
bsw/jbe@0 192 end
bsw/jbe@0 193 },
bsw/jbe@0 194 {
bsw/jbe@0 195 name = "suggestion",
bsw/jbe@0 196 label = _"Suggestions",
bsw/jbe@0 197 content = function()
bsw/jbe@0 198 execute.view{ module = "suggestion", view = "_list", params = { suggestions_selector = initiative:get_reference_selector("suggestions") } }
bsw/jbe@0 199 slot.put("<br />")
bsw/jbe@0 200 if not initiative.issue.frozen and not initiative.issue.closed then
bsw/jbe@0 201 ui.link{
bsw/jbe@0 202 content = function()
bsw/jbe@0 203 ui.image{ static = "icons/16/comment_add.png" }
bsw/jbe@0 204 slot.put(_"Add new suggestion")
bsw/jbe@0 205 end,
bsw/jbe@0 206 attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" },
bsw/jbe@0 207 static = "#"
bsw/jbe@0 208 }
bsw/jbe@0 209 end
bsw/jbe@0 210 end
bsw/jbe@0 211 },
bsw/jbe@0 212 {
bsw/jbe@0 213 name = "supporter",
bsw/jbe@0 214 label = _"Supporter",
bsw/jbe@0 215 content = function()
bsw@3 216 execute.view{
bsw@3 217 module = "member",
bsw@3 218 view = "_list",
bsw@3 219 params = {
bsw@3 220 initiative = initiative,
bsw@3 221 members_selector = initiative:get_reference_selector("supporting_members_snapshot")
bsw@3 222 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
bsw@3 223 :join("direct_population_snapshot", nil, "direct_population_snapshot.event = issue.latest_snapshot_event AND direct_population_snapshot.issue_id = issue.id AND direct_population_snapshot.member_id = member.id")
bsw@3 224 :add_field("direct_population_snapshot.weight")
bsw@3 225 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
bsw@3 226 }
bsw@3 227 }
bsw/jbe@0 228 end
bsw/jbe@0 229 },
bsw/jbe@0 230 {
bsw/jbe@0 231 name = "initiators",
bsw/jbe@0 232 label = _"Initiators",
bsw/jbe@0 233 content = function()
bsw/jbe@0 234 execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } }
bsw/jbe@0 235 end
bsw/jbe@0 236 },
bsw/jbe@0 237 {
bsw/jbe@0 238 name = "drafts",
bsw/jbe@0 239 label = _"Old drafts",
bsw/jbe@0 240 content = function()
bsw/jbe@0 241 execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } }
bsw/jbe@0 242 end
bsw/jbe@0 243 },
bsw@2 244 {
bsw@2 245 name = "details",
bsw@2 246 label = _"Details",
bsw@2 247 content = function()
bsw@2 248 ui.form{
bsw@2 249 attr = { class = "vertical" },
bsw@2 250 record = initiative,
bsw@2 251 readonly = true,
bsw@2 252 content = function()
bsw@2 253 ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name }
bsw@2 254 ui.field.text{
bsw@2 255 label = _"Created at",
bsw@2 256 value = tostring(initiative.created)
bsw@2 257 }
bsw@2 258 ui.field.text{
bsw@2 259 label = _"Created at",
bsw@2 260 value = format.timestamp(initiative.created)
bsw@2 261 }
bsw@2 262 ui.field.date{ label = _"Revoked at", name = "revoked" }
bsw@2 263 ui.field.boolean{ label = _"Admitted", name = "admitted" }
bsw@2 264 end
bsw@2 265 }
bsw@2 266 end
bsw@2 267 },
bsw/jbe@0 268 }
bsw/jbe@0 269
bsw/jbe@0 270

Impressum / About Us