| rev | 
   line source | 
| 
bsw@10
 | 
     1 local initiative = Initiative:by_id(param.get("initiative_id"))
 | 
| 
bsw@10
 | 
     2 
 | 
| 
bsw@1045
 | 
     3 local member = app.session.member
 | 
| 
bsw@1045
 | 
     4 if member then
 | 
| 
bsw@1045
 | 
     5   initiative:load_everything_for_member_id(member.id)
 | 
| 
bsw@1045
 | 
     6   initiative.issue:load_everything_for_member_id(member.id)
 | 
| 
bsw@1045
 | 
     7 end
 | 
| 
bsw@1045
 | 
     8 
 | 
| 
bsw@1045
 | 
     9 
 | 
| 
bsw@1045
 | 
    10 local records = {
 | 
| 
bsw@1045
 | 
    11   {
 | 
| 
bsw@1045
 | 
    12     id = "-1",
 | 
| 
bsw@1045
 | 
    13     name = _"Choose member"
 | 
| 
bsw@1045
 | 
    14   }
 | 
| 
bsw@1045
 | 
    15 }
 | 
| 
bsw@1045
 | 
    16 local contact_members = app.session.member:get_reference_selector("saved_members"):add_order_by("name"):exec()
 | 
| 
bsw@1045
 | 
    17 for i, record in ipairs(contact_members) do
 | 
| 
bsw@1045
 | 
    18   records[#records+1] = record
 | 
| 
bsw@1045
 | 
    19 end
 | 
| 
bsw@10
 | 
    20 
 | 
| 
bsw@1045
 | 
    21 execute.view {
 | 
| 
bsw@1045
 | 
    22   module = "issue", view = "_head", params = {
 | 
| 
bsw@1045
 | 
    23     issue = initiative.issue,
 | 
| 
bsw@1045
 | 
    24     member = app.session.member
 | 
| 
bsw@10
 | 
    25   }
 | 
| 
bsw@1045
 | 
    26 }
 | 
| 
bsw@1045
 | 
    27 
 | 
| 
bsw@1045
 | 
    28 execute.view{ module = "issue", view = "_sidebar_state", params = {
 | 
| 
bsw@1045
 | 
    29   initiative = initiative
 | 
| 
bsw@1045
 | 
    30 } }
 | 
| 
bsw@10
 | 
    31 
 | 
| 
bsw@1045
 | 
    32 execute.view { 
 | 
| 
bsw@1045
 | 
    33   module = "issue", view = "_sidebar_issue", 
 | 
| 
bsw@1045
 | 
    34   params = {
 | 
| 
bsw@1045
 | 
    35     issue = initiative.issue,
 | 
| 
bsw@1045
 | 
    36     highlight_initiative_id = initiative.id
 | 
| 
bsw@1045
 | 
    37   }
 | 
| 
bsw@1045
 | 
    38 }
 | 
| 
bsw@1045
 | 
    39 
 | 
| 
bsw@1045
 | 
    40 execute.view {
 | 
| 
bsw@1045
 | 
    41   module = "issue", view = "_sidebar_whatcanido",
 | 
| 
bsw@1045
 | 
    42   params = { initiative = initiative }
 | 
| 
bsw@1045
 | 
    43 }
 | 
| 
bsw@1045
 | 
    44 
 | 
| 
bsw@1045
 | 
    45 execute.view { 
 | 
| 
bsw@1045
 | 
    46   module = "issue", view = "_sidebar_members", params = {
 | 
| 
bsw@1045
 | 
    47     issue = initiative.issue, initiative = initiative
 | 
| 
bsw@1045
 | 
    48   }
 | 
| 
bsw@1045
 | 
    49 }
 | 
| 
bsw@10
 | 
    50 
 | 
| 
bsw@10
 | 
    51 ui.form{
 | 
| 
bsw@1045
 | 
    52   attr = { class = "wide section" },
 | 
| 
bsw@10
 | 
    53   module = "initiative",
 | 
| 
bsw@10
 | 
    54   action = "add_initiator",
 | 
| 
bsw@10
 | 
    55   params = {
 | 
| 
bsw@10
 | 
    56     initiative_id = initiative.id,
 | 
| 
bsw@10
 | 
    57   },
 | 
| 
bsw@10
 | 
    58   routing = {
 | 
| 
bsw@10
 | 
    59     ok = {
 | 
| 
bsw@10
 | 
    60       mode = "redirect",
 | 
| 
bsw@10
 | 
    61       module = "initiative",
 | 
| 
bsw@10
 | 
    62       view = "show",
 | 
| 
bsw@10
 | 
    63       id = initiative.id,
 | 
| 
bsw@10
 | 
    64       params = {
 | 
| 
bsw@10
 | 
    65         tab = "initiators",
 | 
| 
bsw@10
 | 
    66       }
 | 
| 
bsw@10
 | 
    67     }
 | 
| 
bsw@10
 | 
    68   },
 | 
| 
bsw@10
 | 
    69   content = function()
 | 
| 
bsw@1045
 | 
    70 
 | 
| 
bsw@1045
 | 
    71     ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
    72       ui.link{
 | 
| 
bsw@1045
 | 
    73         module = "initiative", view = "show", id = initiative.id,
 | 
| 
bsw@1045
 | 
    74         content = function ()
 | 
| 
bsw@1045
 | 
    75           ui.heading { 
 | 
| 
bsw@1045
 | 
    76             level = 1,
 | 
| 
bsw@1045
 | 
    77             content = initiative.display_name
 | 
| 
bsw@1045
 | 
    78           }
 | 
| 
bsw@1045
 | 
    79         end
 | 
| 
bsw@1045
 | 
    80       }
 | 
| 
bsw@1045
 | 
    81       ui.heading { level = 2, content = _"Invite an initiator to initiative" }
 | 
| 
bsw@1045
 | 
    82     end )
 | 
| 
bsw@1045
 | 
    83 
 | 
| 
bsw@1045
 | 
    84     ui.sectionRow( function()
 | 
| 
bsw@1045
 | 
    85       ui.heading { level = 2, content = _"Choose a member to invite" }
 | 
| 
bsw@1045
 | 
    86       ui.field.select{
 | 
| 
bsw@1045
 | 
    87         name = "member_id",
 | 
| 
bsw@1045
 | 
    88         foreign_records = records,
 | 
| 
bsw@1045
 | 
    89         foreign_id = "id",
 | 
| 
bsw@1045
 | 
    90         foreign_name = "name"
 | 
| 
bsw@10
 | 
    91       }
 | 
| 
bsw@1045
 | 
    92       ui.container{ content = _"You can choose only members which you have been saved as contact before." }
 | 
| 
bsw@1045
 | 
    93       slot.put("<br />")
 | 
| 
bsw@1045
 | 
    94       ui.tag{
 | 
| 
bsw@1045
 | 
    95         tag = "input",
 | 
| 
bsw@1045
 | 
    96         attr = {
 | 
| 
bsw@1045
 | 
    97           type = "submit",
 | 
| 
bsw@1045
 | 
    98           class = "btn btn-default",
 | 
| 
bsw@1045
 | 
    99           value = _"Invite member"
 | 
| 
bsw@1045
 | 
   100         },
 | 
| 
bsw@1045
 | 
   101         content = ""
 | 
| 
bsw@1045
 | 
   102       }
 | 
| 
bsw@1045
 | 
   103       slot.put("<br />")
 | 
| 
bsw@1045
 | 
   104       slot.put("<br />")
 | 
| 
bsw@1045
 | 
   105       ui.link{
 | 
| 
bsw@1045
 | 
   106         content = _"Cancel",
 | 
| 
bsw@1045
 | 
   107         module = "initiative",
 | 
| 
bsw@1045
 | 
   108         view = "show",
 | 
| 
bsw@1045
 | 
   109         id = initiative.id,
 | 
| 
bsw@1045
 | 
   110         params = {
 | 
| 
bsw@1045
 | 
   111           tab = "initiators"
 | 
| 
bsw@1045
 | 
   112         }
 | 
| 
bsw@1045
 | 
   113       }
 | 
| 
bsw@1045
 | 
   114     end )
 | 
| 
bsw@10
 | 
   115   end
 | 
| 
bsw@10
 | 
   116 } |