bsw@10: local initiative = Initiative:by_id(param.get("initiative_id"))
bsw@10: 
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 records = {
bsw@1045:   {
bsw@1045:     id = "-1",
bsw@1045:     name = _"Choose member"
bsw@1045:   }
bsw@1045: }
bsw@1045: local contact_members = app.session.member:get_reference_selector("saved_members"):add_order_by("name"):exec()
bsw@1045: for i, record in ipairs(contact_members) do
bsw@1045:   records[#records+1] = record
bsw@1045: end
bsw@10: 
bsw@1045: execute.view {
bsw@1045:   module = "issue", view = "_head", params = {
bsw@1045:     issue = initiative.issue,
bsw@1045:     member = app.session.member
bsw@10:   }
bsw@1045: }
bsw@1045: 
bsw@1561: ui.grid{ content = function()
bsw@1561:   ui.cell_main{ content = function()
bsw@10: 
bsw@1561:     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw@1045: 
bsw@1561:       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw@1561:         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = initiative.display_name }
bsw@1561:       end }
bsw@1045: 
bsw@1561:       ui.container{ attr = { class = "mdl-card__content" }, content = function()
bsw@1561:         ui.form{
bsw@1561:           attr = { class = "wide section" },
bsw@1561:           module = "initiative",
bsw@1561:           action = "add_initiator",
bsw@1561:           params = {
bsw@1561:             initiative_id = initiative.id,
bsw@1561:           },
bsw@1561:           routing = {
bsw@1561:             ok = {
bsw@1561:               mode = "redirect",
bsw@1561:               module = "initiative",
bsw@1561:               view = "show",
bsw@1561:               id = initiative.id,
bsw@1561:               params = {
bsw@1561:                 tab = "initiators",
bsw@1561:               }
bsw@1561:             }
bsw@1561:           },
bsw@1561:           content = function()
bsw@1045: 
bsw@1561:             ui.heading { level = 3, content = _"Invite an initiator to initiative" }
bsw@1561:             ui.container{ content = _"You can choose only members which you have been saved as contact before." }
bsw@1561:             slot.put("
")
bsw@1561:             ui.field.select{
bsw@1561:               name = "member_id",
bsw@1561:               foreign_records = records,
bsw@1561:               foreign_id = "id",
bsw@1561:               foreign_name = "name"
bsw@1561:             }
bsw@1561:            slot.put("
")
bsw@1561:            slot.put("
")
bsw@1561:             ui.tag{
bsw@1561:               tag = "input",
bsw@1561:               attr = {
bsw@1561:                 type = "submit",
bsw@1561:                 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
bsw@1561:                 value = _"Invite member"
bsw@1561:               },
bsw@1561:               content = ""
bsw@1561:             }
bsw@1561:             slot.put("   ")
bsw@1561:             ui.link{
bsw@1561:               attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
bsw@1561:               content = _"Cancel",
bsw@1561:               module = "initiative",
bsw@1561:               view = "show",
bsw@1561:               id = initiative.id,
bsw@1561:               params = {
bsw@1561:                 tab = "initiators"
bsw@1561:               }
bsw@1561:             }
bsw@1561:           end
bsw@1561:         }
bsw@1045: 
bsw@1561:       end }
bsw@1561:     end }
bsw@1561:   end }
bsw@1561: 
bsw@1561: end }
bsw@1561: 
bsw@1561: