| 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@1045
 | 
     6   ui.tag{
 | 
| 
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@1045
 | 
    13         unit = area.unit
 | 
| 
bsw@599
 | 
    14       elseif delegation.area then
 | 
| 
bsw@599
 | 
    15         area = delegation.area
 | 
| 
bsw@1045
 | 
    16         unit = area.unit
 | 
| 
bsw@2
 | 
    17       else
 | 
| 
bsw@599
 | 
    18         unit = delegation.unit
 | 
| 
bsw@2
 | 
    19       end
 | 
| 
bsw@1045
 | 
    20       slot.put("<br style='clear: left;' />")
 | 
| 
bsw@1567
 | 
    21       ui.container { attr = { style = "float: left;" }, content = function()
 | 
| 
bsw@599
 | 
    22         ui.link{
 | 
| 
bsw@1045
 | 
    23           content = unit.name,
 | 
| 
bsw@1611
 | 
    24           module = "index",
 | 
| 
bsw@1611
 | 
    25           view = "index",
 | 
| 
bsw@1611
 | 
    26           params = { unit = unit.id }
 | 
| 
bsw@599
 | 
    27         }
 | 
| 
bsw@1045
 | 
    28         if area then
 | 
| 
bsw@1045
 | 
    29           slot.put(" · ")
 | 
| 
bsw@1045
 | 
    30           ui.link{
 | 
| 
bsw@1045
 | 
    31             content = area.name,
 | 
| 
bsw@1611
 | 
    32             module = "index",
 | 
| 
bsw@1611
 | 
    33             view = "index",
 | 
| 
bsw@1611
 | 
    34             params = { unit = area.unit_id, area = area.id }
 | 
| 
bsw@1045
 | 
    35           }
 | 
| 
bsw@1045
 | 
    36         end
 | 
| 
bsw@1045
 | 
    37         if delegation.issue then
 | 
| 
bsw@1045
 | 
    38           slot.put(" · ")
 | 
| 
bsw@1045
 | 
    39           ui.link{
 | 
| 
bsw@1045
 | 
    40             content = delegation.issue.name,
 | 
| 
bsw@1045
 | 
    41             module = "issue",
 | 
| 
bsw@1045
 | 
    42             view = "show",
 | 
| 
bsw@1045
 | 
    43             id = delegation.issue.id
 | 
| 
bsw@1045
 | 
    44           }
 | 
| 
bsw@1045
 | 
    45         end
 | 
| 
bsw@1045
 | 
    46       end }
 | 
| 
bsw@2
 | 
    47     end
 | 
| 
bsw@2
 | 
    48   }
 | 
| 
bsw@2
 | 
    49 end
 | 
| 
bsw@2
 | 
    50 
 | 
| 
bsw@1611
 | 
    51 local last_scope = {}
 | 
| 
bsw@1611
 | 
    52 for i, delegation in ipairs(delegations_selector:exec()) do
 | 
| 
bsw@1611
 | 
    53   if last_scope.unit_id ~= delegation.unit_id
 | 
| 
bsw@1611
 | 
    54     or last_scope.area_id ~= delegation.area_id
 | 
| 
bsw@1611
 | 
    55     or last_scope.issue_id ~= delegation.issue_id
 | 
| 
bsw@1611
 | 
    56   then
 | 
| 
bsw@1611
 | 
    57     last_scope.unit_id = delegation.unit_id
 | 
| 
bsw@1611
 | 
    58     last_scope.area_id = delegation.area_id
 | 
| 
bsw@1611
 | 
    59     last_scope.issue_id = delegation.issue_id
 | 
| 
bsw@1611
 | 
    60     delegation_scope(delegation)
 | 
| 
bsw@1611
 | 
    61   end
 | 
| 
bsw@1611
 | 
    62   if incoming then
 | 
| 
bsw@1611
 | 
    63     execute.view{
 | 
| 
bsw@1611
 | 
    64       module = "member",
 | 
| 
bsw@1611
 | 
    65       view = "_show_thumb",
 | 
| 
bsw@1611
 | 
    66       params = {
 | 
| 
bsw@1611
 | 
    67         member = delegation.truster
 | 
| 
bsw@1611
 | 
    68       }
 | 
| 
bsw@1611
 | 
    69     }
 | 
| 
bsw@1611
 | 
    70   elseif delegation.trustee then
 | 
| 
bsw@1611
 | 
    71     ui.image{
 | 
| 
bsw@1611
 | 
    72       attr = { class = "delegation_arrow" },
 | 
| 
bsw@1611
 | 
    73       static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@1611
 | 
    74     }
 | 
| 
bsw@1611
 | 
    75     execute.view{
 | 
| 
bsw@1611
 | 
    76       module = "member",
 | 
| 
bsw@1611
 | 
    77       view = "_show_thumb",
 | 
| 
bsw@1611
 | 
    78       params = {
 | 
| 
bsw@1611
 | 
    79         member = delegation.trustee
 | 
| 
bsw@1611
 | 
    80       }
 | 
| 
bsw@1611
 | 
    81     }
 | 
| 
bsw@1611
 | 
    82   else
 | 
| 
bsw@1611
 | 
    83     ui.tag{ content = _"Delegation abandoned" }
 | 
| 
bsw@1611
 | 
    84   end
 | 
| 
bsw@1611
 | 
    85 end
 | 
| 
bsw/jbe@0
 | 
    86 
 |