| rev | 
   line source | 
| 
bsw@2
 | 
     1 local delegations_selector = param.get("delegations_selector", "table")
 | 
| 
bsw@2
 | 
     2 local outgoing = param.get("outgoing", atom.boolean)
 | 
| 
bsw@2
 | 
     3 local incoming = param.get("incoming", atom.boolean)
 | 
| 
bsw@2
 | 
     4 
 | 
| 
bsw@2
 | 
     5 local function delegation_scope(delegation)
 | 
| 
bsw@2
 | 
     6   ui.container{
 | 
| 
bsw@2
 | 
     7     attr = { class = "delegation_scope" },
 | 
| 
bsw@2
 | 
     8     content = function()
 | 
| 
bsw@2
 | 
     9       local area
 | 
| 
bsw@599
 | 
    10       local unit
 | 
| 
bsw@2
 | 
    11       if delegation.issue then
 | 
| 
bsw@2
 | 
    12         area = delegation.issue.area
 | 
| 
bsw@599
 | 
    13       elseif delegation.area then
 | 
| 
bsw@599
 | 
    14         area = delegation.area
 | 
| 
bsw@2
 | 
    15       else
 | 
| 
bsw@599
 | 
    16         unit = delegation.unit
 | 
| 
bsw@2
 | 
    17       end
 | 
| 
bsw@599
 | 
    18       if unit then
 | 
| 
bsw@599
 | 
    19         ui.link{
 | 
| 
bsw@599
 | 
    20           content = _"Unit '#{name}'":gsub("#{name}", unit.name),
 | 
| 
bsw@599
 | 
    21           module = "unit",
 | 
| 
bsw@599
 | 
    22           view = "show",
 | 
| 
bsw@599
 | 
    23           id = unit.id
 | 
| 
bsw@599
 | 
    24         }
 | 
| 
bsw@2
 | 
    25       end
 | 
| 
bsw@2
 | 
    26       if area then
 | 
| 
bsw@2
 | 
    27         ui.link{
 | 
| 
bsw@2
 | 
    28           content = _"Area '#{name}'":gsub("#{name}", area.name),
 | 
| 
bsw@2
 | 
    29           module = "area",
 | 
| 
bsw@2
 | 
    30           view = "show",
 | 
| 
bsw@2
 | 
    31           id = area.id
 | 
| 
bsw@2
 | 
    32         }
 | 
| 
bsw@2
 | 
    33       end
 | 
| 
bsw@2
 | 
    34       if delegation.issue then
 | 
| 
bsw@2
 | 
    35         ui.link{
 | 
| 
bsw@2
 | 
    36           content = _"Issue ##{id}":gsub("#{id}", delegation.issue.id),
 | 
| 
bsw@2
 | 
    37           module = "issue",
 | 
| 
bsw@2
 | 
    38           view = "show",
 | 
| 
bsw@2
 | 
    39           id = delegation.issue.id
 | 
| 
bsw@2
 | 
    40         }
 | 
| 
bsw@2
 | 
    41       end
 | 
| 
bsw@2
 | 
    42     end
 | 
| 
bsw@2
 | 
    43   }
 | 
| 
bsw@2
 | 
    44 end
 | 
| 
bsw@2
 | 
    45 
 | 
| 
bsw/jbe@0
 | 
    46 
 | 
| 
bsw/jbe@0
 | 
    47 ui.paginate{
 | 
| 
bsw@2
 | 
    48   selector = delegations_selector,
 | 
| 
bsw/jbe@0
 | 
    49   content = function()
 | 
| 
bsw@2
 | 
    50     for i, delegation in ipairs(delegations_selector:exec()) do
 | 
| 
bsw@2
 | 
    51       ui.container{
 | 
| 
bsw@2
 | 
    52         attr = { class = "delegation_list_entry" },
 | 
| 
bsw@2
 | 
    53         content = function()
 | 
| 
bsw@2
 | 
    54           if outgoing then
 | 
| 
bsw@2
 | 
    55             delegation_scope(delegation)
 | 
| 
bsw@2
 | 
    56           else
 | 
| 
bsw@2
 | 
    57             execute.view{
 | 
| 
bsw/jbe@0
 | 
    58               module = "member",
 | 
| 
bsw@2
 | 
    59               view = "_show_thumb",
 | 
| 
bsw@2
 | 
    60               params = { member = delegation.truster }
 | 
| 
bsw/jbe@0
 | 
    61             }
 | 
| 
bsw/jbe@0
 | 
    62           end
 | 
| 
bsw@2
 | 
    63           ui.image{
 | 
| 
bsw@2
 | 
    64             attr = { class = "delegation_arrow" },
 | 
| 
bsw@2
 | 
    65             static = "delegation_arrow.jpg"
 | 
| 
bsw@2
 | 
    66           }
 | 
| 
bsw@2
 | 
    67           if incoming then
 | 
| 
bsw@2
 | 
    68             delegation_scope(delegation)
 | 
| 
bsw@2
 | 
    69           else
 | 
| 
bsw@187
 | 
    70             if delegation.trustee then
 | 
| 
bsw@187
 | 
    71               execute.view{
 | 
| 
bsw@187
 | 
    72                 module = "member",
 | 
| 
bsw@187
 | 
    73                 view = "_show_thumb",
 | 
| 
bsw@187
 | 
    74                 params = { member = delegation.trustee }
 | 
| 
bsw@187
 | 
    75               }
 | 
| 
bsw@187
 | 
    76             else
 | 
| 
bsw@187
 | 
    77               ui.tag{ content = _"Delegation abandoned" }
 | 
| 
bsw@187
 | 
    78             end
 | 
| 
bsw/jbe@0
 | 
    79           end
 | 
| 
bsw@2
 | 
    80         end
 | 
| 
bsw/jbe@0
 | 
    81       }
 | 
| 
bsw@2
 | 
    82     end
 | 
| 
bsw@2
 | 
    83     slot.put("<br style='clear: left;' />")
 | 
| 
bsw/jbe@0
 | 
    84   end
 | 
| 
bsw/jbe@0
 | 
    85 }
 |