bsw@10: local initiative = Initiative:by_id(param.get_id())
bsw@1045: local initiatives = app.session.member
bsw@1045:   :get_reference_selector("supported_initiatives")
bsw@1045:   :join("issue", nil, "issue.id = initiative.issue_id")
bsw@1045:   :add_where("issue.closed ISNULL")
bsw@1565:   :add_where{ "initiative.id <> ?", initiative.id }
bsw@1045:   :add_order_by("issue.id")
bsw@1045:   :exec()
bsw@10: 
bsw@1045:   
bsw@1045: local member = app.session.member
bsw@1045: if member then
bsw@1045:   initiative:load_everything_for_member_id(member.id)
bsw@1045:   initiative.issue:load_everything_for_member_id(member.id)
bsw@1045: end
bsw@1045: 
bsw@1045: 
bsw@1045: local tmp = { { id = -1, myname = _"Suggest no initiative" }}
bsw@1045: for i, initiative in ipairs(initiatives) do
bsw@1045:   initiative.myname = _("Issue ##{issue_id}: #{initiative_name}", {
bsw@1045:     issue_id = initiative.issue.id,
bsw@1045:     initiative_name = initiative.name
bsw@1045:   })
bsw@1045:   tmp[#tmp+1] = initiative
bsw@1045: end
bsw@10: 
bsw@1045: execute.view {
bsw@1045:   module = "issue", view = "_head", params = {
bsw@1045:     issue = initiative.issue,
bsw@1045:     member = member
bsw@10:   }
bsw@1045: }
bsw@1564: 
bsw@1564: ui.grid{ content = function()
bsw@1564:   ui.cell_main{ content = function()
bsw@1564: 
bsw@1564:     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw@10: 
bsw@1564:       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw@1564:         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Revoke initiative" }
bsw@1564:       end }
bsw@1045: 
bsw@1564:       ui.container{ attr = { class = "mdl-card__content" }, content = function()
bsw@1045: 
bsw@1564:         ui.form{
bsw@1564:           attr = { class = "wide section" },
bsw@1564:           module = "initiative",
bsw@1564:           action = "revoke",
bsw@1564:           id = initiative.id,
bsw@1564:           routing = {
bsw@1564:             ok = {
bsw@1564:               mode = "redirect",
bsw@1564:               module = "initiative",
bsw@1564:               view = "show",
bsw@1564:               id = initiative.id
bsw@1564:             }
bsw@1564:           },
bsw@1564:           content = function()
bsw@10: 
bsw@1564:             ui.container{ content = _"Do you want to suggest to support another initiative?" }
bsw@1564:             ui.container{ content = _"You may choose one of the ongoing initiatives you are currently supporting" }
bsw@1564: 
bsw@1564:             slot.put("
")          
bsw@1045: 
bsw@1564:             ui.field.select{
bsw@1564:               name = "suggested_initiative_id",
bsw@1564:               foreign_records = tmp,
bsw@1564:               foreign_id = "id",
bsw@1564:               foreign_name = "myname",
bsw@1564:               value = param.get("suggested_initiative_id", atom.integer)
bsw@1564:             }
bsw@1564:             slot.put("
")
bsw@1564:             ui.container { content = _"Are you aware that revoking an initiative is irrevocable?" }
bsw@1564:             slot.put("
")          
bsw@1564:             ui.container{ content = function()
bsw@1564:               ui.tag{ tag = "input", attr = {
bsw@1564:                 type = "checkbox",
bsw@1564:                 name = "are_you_sure",
bsw@1564:                 value = "1"
bsw@1564:               } }
bsw@1564:               ui.tag { content = _"I understand, that this is not revocable" }
bsw@1564:             end }
bsw@1564:             
bsw@1564:             
bsw@1564:             slot.put("
")
bsw@1564:             ui.tag{
bsw@1564:               tag = "input",
bsw@1564:               attr = {
bsw@1564:                 type = "submit",
bsw@1564:                 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
bsw@1564:                 value = _"Revoke now"
bsw@1564:               },
bsw@1564:               content = ""
bsw@1564:             }
bsw@1564:             slot.put("   ")
bsw@10: 
bsw@1564:             ui.link{
bsw@1564:               attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
bsw@1564:               content = _"Cancel",
bsw@1564:               module = "initiative",
bsw@1564:               view = "show",
bsw@1564:               id = initiative.id,
bsw@1564:               params = {
bsw@1564:                 tab = "initiators"
bsw@1564:               }
bsw@1564:             }
bsw@1564: 
bsw@1564:           end
bsw@1564:         }
bsw@1564: 
bsw@1045:       end }
bsw@1564:     end }
bsw@1564:   end }
bsw@1564: end }