| rev | 
   line source | 
| 
bsw/jbe@0
 | 
     1 local area = Area:by_id(param.get("area_id", atom.integer))
 | 
| 
bsw/jbe@0
 | 
     2 if area then
 | 
| 
bsw/jbe@0
 | 
     3   slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name)))
 | 
| 
bsw/jbe@4
 | 
     4   util.help("delegation.new.area")
 | 
| 
bsw/jbe@0
 | 
     5 end
 | 
| 
bsw/jbe@0
 | 
     6 
 | 
| 
bsw/jbe@0
 | 
     7 local issue = Issue:by_id(param.get("issue_id", atom.integer))
 | 
| 
bsw/jbe@0
 | 
     8 if issue then
 | 
| 
bsw/jbe@0
 | 
     9   slot.put_into("title", encode.html(_"Set delegation for Issue ##{number} in Area '#{area_name}'":gsub("#{number}", issue.id):gsub("#{area_name}", issue.area.name)))
 | 
| 
bsw/jbe@4
 | 
    10   util.help("delegation.new.issue")
 | 
| 
bsw/jbe@0
 | 
    11 end
 | 
| 
bsw/jbe@0
 | 
    12 
 | 
| 
bsw/jbe@4
 | 
    13 if not area and not issue then
 | 
| 
bsw/jbe@4
 | 
    14   slot.put_into("title", encode.html(_"Set global delegation"))
 | 
| 
bsw/jbe@4
 | 
    15   util.help("delegation.new.global")
 | 
| 
bsw/jbe@4
 | 
    16 end
 | 
| 
bsw/jbe@4
 | 
    17 
 | 
| 
bsw/jbe@4
 | 
    18 slot.select("actions", function()
 | 
| 
bsw/jbe@4
 | 
    19   if issue then
 | 
| 
bsw/jbe@4
 | 
    20     ui.link{
 | 
| 
bsw/jbe@4
 | 
    21       module = "issue",
 | 
| 
bsw/jbe@4
 | 
    22       view = "show",
 | 
| 
bsw/jbe@4
 | 
    23       id = issue.id,
 | 
| 
bsw/jbe@4
 | 
    24       content = function()
 | 
| 
bsw/jbe@4
 | 
    25           ui.image{ static = "icons/16/cancel.png" }
 | 
| 
bsw/jbe@4
 | 
    26           slot.put(_"Cancel")
 | 
| 
bsw/jbe@4
 | 
    27       end,
 | 
| 
bsw/jbe@4
 | 
    28     }
 | 
| 
bsw/jbe@4
 | 
    29   elseif area then
 | 
| 
bsw/jbe@4
 | 
    30     ui.link{
 | 
| 
bsw/jbe@4
 | 
    31       module = "area",
 | 
| 
bsw/jbe@4
 | 
    32       view = "show",
 | 
| 
bsw/jbe@4
 | 
    33       id = area.id,
 | 
| 
bsw/jbe@4
 | 
    34       content = function()
 | 
| 
bsw/jbe@4
 | 
    35           ui.image{ static = "icons/16/cancel.png" }
 | 
| 
bsw/jbe@4
 | 
    36           slot.put(_"Cancel")
 | 
| 
bsw/jbe@4
 | 
    37       end,
 | 
| 
bsw/jbe@4
 | 
    38     }
 | 
| 
bsw/jbe@4
 | 
    39   else
 | 
| 
bsw/jbe@4
 | 
    40     ui.link{
 | 
| 
bsw/jbe@4
 | 
    41       module = "index",
 | 
| 
bsw/jbe@4
 | 
    42       view = "index",
 | 
| 
bsw/jbe@4
 | 
    43       content = function()
 | 
| 
bsw/jbe@4
 | 
    44           ui.image{ static = "icons/16/cancel.png" }
 | 
| 
bsw/jbe@4
 | 
    45           slot.put(_"Cancel")
 | 
| 
bsw/jbe@4
 | 
    46       end,
 | 
| 
bsw/jbe@4
 | 
    47     }
 | 
| 
bsw/jbe@4
 | 
    48   end
 | 
| 
bsw/jbe@4
 | 
    49 end)
 | 
| 
bsw/jbe@4
 | 
    50 
 | 
| 
bsw/jbe@4
 | 
    51 
 | 
| 
bsw/jbe@0
 | 
    52 
 | 
| 
bsw/jbe@0
 | 
    53 local contact_members = Member:new_selector()
 | 
| 
bsw/jbe@0
 | 
    54   :add_where{ "contact.member_id = ?", app.session.member.id }
 | 
| 
bsw/jbe@0
 | 
    55   :join("contact", nil, "member.id = contact.other_member_id")
 | 
| 
bsw/jbe@4
 | 
    56   :add_order_by("member.name")
 | 
| 
bsw/jbe@0
 | 
    57   :exec()
 | 
| 
bsw/jbe@0
 | 
    58 
 | 
| 
bsw/jbe@0
 | 
    59 
 | 
| 
bsw/jbe@0
 | 
    60 ui.form{
 | 
| 
bsw/jbe@0
 | 
    61   attr = { class = "vertical" },
 | 
| 
bsw/jbe@0
 | 
    62   module = "delegation",
 | 
| 
bsw/jbe@0
 | 
    63   action = "update",
 | 
| 
bsw/jbe@0
 | 
    64   params = {
 | 
| 
bsw/jbe@0
 | 
    65     area_id = area and area.id or nil,
 | 
| 
bsw/jbe@0
 | 
    66     issue_id = issue and issue.id or nil,
 | 
| 
bsw/jbe@0
 | 
    67   },
 | 
| 
bsw/jbe@0
 | 
    68   routing = {
 | 
| 
bsw/jbe@0
 | 
    69     default = {
 | 
| 
bsw/jbe@0
 | 
    70       mode = "redirect",
 | 
| 
bsw/jbe@4
 | 
    71       module = area and "area" or issue and "issue" or "index",
 | 
| 
bsw/jbe@4
 | 
    72       view = (area or issue) and "show" or "index",
 | 
| 
bsw/jbe@4
 | 
    73       id = area and area.id or issue and issue.id or nil,
 | 
| 
bsw/jbe@0
 | 
    74     }
 | 
| 
bsw/jbe@0
 | 
    75   },
 | 
| 
bsw/jbe@0
 | 
    76   content = function()
 | 
| 
bsw@10
 | 
    77     local records = {
 | 
| 
bsw/jbe@4
 | 
    78       {
 | 
| 
bsw/jbe@4
 | 
    79         id = "-1",
 | 
| 
bsw/jbe@4
 | 
    80         name = _"No delegation"
 | 
| 
bsw/jbe@4
 | 
    81       }
 | 
| 
bsw/jbe@4
 | 
    82     }
 | 
| 
bsw/jbe@4
 | 
    83     for i, record in ipairs(contact_members) do
 | 
| 
bsw/jbe@4
 | 
    84       records[#records+1] = record
 | 
| 
bsw/jbe@4
 | 
    85     end
 | 
| 
bsw/jbe@4
 | 
    86 
 | 
| 
bsw/jbe@0
 | 
    87     ui.field.select{
 | 
| 
bsw/jbe@0
 | 
    88       label = _"Trustee",
 | 
| 
bsw/jbe@0
 | 
    89       name = "trustee_id",
 | 
| 
bsw/jbe@4
 | 
    90       foreign_records = records,
 | 
| 
bsw/jbe@0
 | 
    91       foreign_id = "id",
 | 
| 
bsw/jbe@4
 | 
    92       foreign_name = "name",
 | 
| 
bsw/jbe@0
 | 
    93     }
 | 
| 
bsw/jbe@0
 | 
    94     ui.submit{ text = _"Save" }
 | 
| 
bsw/jbe@0
 | 
    95   end
 | 
| 
bsw/jbe@4
 | 
    96 }
 |