| 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@599
 | 
    24           module = "unit",
 | 
| 
bsw@599
 | 
    25           view = "show",
 | 
| 
bsw@599
 | 
    26           id = 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@1045
 | 
    32             module = "area",
 | 
| 
bsw@1045
 | 
    33             view = "show",
 | 
| 
bsw@1045
 | 
    34             id = 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/jbe@0
 | 
    51 
 | 
| 
bsw@1045
 | 
    52 --ui.paginate{
 | 
| 
bsw@1045
 | 
    53 --  selector = delegations_selector,
 | 
| 
bsw@1045
 | 
    54 --  name = incoming and "delegation_incoming" or "delegation_outgoing",
 | 
| 
bsw@1045
 | 
    55 --  content = function()
 | 
| 
bsw@1045
 | 
    56     local last_scope = {}
 | 
| 
bsw@2
 | 
    57     for i, delegation in ipairs(delegations_selector:exec()) do
 | 
| 
bsw@1045
 | 
    58       if last_scope.unit_id ~= delegation.unit_id
 | 
| 
bsw@1045
 | 
    59         or last_scope.area_id ~= delegation.area_id
 | 
| 
bsw@1045
 | 
    60         or last_scope.issue_id ~= delegation.issue_id
 | 
| 
bsw@1045
 | 
    61       then
 | 
| 
bsw@1045
 | 
    62         last_scope.unit_id = delegation.unit_id
 | 
| 
bsw@1045
 | 
    63         last_scope.area_id = delegation.area_id
 | 
| 
bsw@1045
 | 
    64         last_scope.issue_id = delegation.issue_id
 | 
| 
bsw@1045
 | 
    65         delegation_scope(delegation)
 | 
| 
bsw@1045
 | 
    66       end
 | 
| 
bsw@1045
 | 
    67       if incoming then
 | 
| 
bsw@1045
 | 
    68         execute.view{ module = "member_image", view = "_show", params = {
 | 
| 
bsw@1045
 | 
    69           member_id = delegation.truster_id, class = "micro_avatar", popup_text = delegation.truster.name,
 | 
| 
bsw@1045
 | 
    70           image_type = "avatar", show_dummy = true,
 | 
| 
bsw@1045
 | 
    71         } }
 | 
| 
bsw@1567
 | 
    72         ui.link{ module = "member", view = "show", id = delegation.truster_id, content = delegation.truster.name }
 | 
| 
bsw@1045
 | 
    73       elseif delegation.trustee then
 | 
| 
bsw@1045
 | 
    74         ui.image{
 | 
| 
bsw@1045
 | 
    75           attr = { class = "delegation_arrow" },
 | 
| 
bsw@1045
 | 
    76           static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@1045
 | 
    77         }
 | 
| 
bsw@1045
 | 
    78         execute.view{ module = "member_image", view = "_show", params = {
 | 
| 
bsw@1045
 | 
    79           member_id = delegation.trustee_id, class = "micro_avatar", popup_text = delegation.trustee.name,
 | 
| 
bsw@1045
 | 
    80           image_type = "avatar", show_dummy = true,
 | 
| 
bsw@1045
 | 
    81         } }
 | 
| 
bsw@1567
 | 
    82         ui.link{ module = "member", view = "show", id = delegation.trustee_id, content = delegation.trustee.name }
 | 
| 
bsw@1045
 | 
    83       else
 | 
| 
bsw@1045
 | 
    84         ui.tag{ content = _"Delegation abandoned" }
 | 
| 
bsw@1045
 | 
    85       end
 | 
| 
bsw@2
 | 
    86     end
 | 
| 
bsw@1045
 | 
    87 --  end
 | 
| 
bsw@1045
 | 
    88 --}
 |