liquid_feedback_frontend
view app/main/index/_sidebar_units.lua @ 1638:39bf0af7f5e3
Silence compiler warnings regarding discarded const qualifier in mldap library
| author | jbe | 
|---|---|
| date | Tue Feb 09 16:59:01 2021 +0100 (2021-02-09) | 
| parents | 32cc544d5a5b | 
| children | 
 line source
     1 if true then return end
     3 local member = param.get ( "member", "table" )
     4 local units
     5 if member then
     6   units = member:get_reference_selector("units"):add_order_by("name"):exec()
     7   units:load_delegation_info_once_for_member_id(member.id)
     8 else
     9   units = Unit:new_selector():add_where("active"):add_order_by("name"):exec()
    10   ui.sidebar( "tab-whatcanido", function()
    11     ui.sidebarHead( function()
    12       ui.heading { level = 2, content = _"Organizational units" }
    13     end )
    14     ui.sidebarSection( function()
    15       execute.view { module = "unit", view = "_list" }
    16     end )
    17   end )
    18   return
    19 end
    22 for i, unit in ipairs(units) do
    24   ui.sidebar ( "tab-whatcanido units", function ()
    26     local areas_selector = Area:new_selector()
    27       :reset_fields()
    28       :add_field("area.id", nil, { "grouped" })
    29       :add_field("area.unit_id", nil, { "grouped" })
    30       :add_field("area.name", nil, { "grouped" })
    31       :add_where{ "area.unit_id = ?", unit.id }
    32       :add_where{ "area.active" }
    33       :add_order_by("area.name")
    35     local areas = areas_selector:exec()
    36     if member then
    37       areas:load_delegation_info_once_for_member_id(member.id)
    38     end
    40     if #areas > 0 then
    42       ui.container {
    43         attr = { class = "sidebarHead" },
    44         content = function ()
    45           ui.heading { level = 2, content = function ()
    46             ui.link {
    47               attr = { class = "unit" },
    48               module = "unit", view = "show", id = unit.id,
    49               content = unit.name
    50             }
    52             if member then
    53               local delegation = Delegation:by_pk(member.id, unit.id, nil, nil)
    55               if delegation then
    56                 ui.link { 
    57                   module = "delegation", view = "show", params = {
    58                     unit_id = unit.id
    59                   },
    60                   attr = { class = "delegation_info" }, 
    61                   content = function ()
    62                     ui.delegation(delegation.trustee_id, delegation.trustee.name)
    63                   end
    64                 }
    65               end
    66             end
    67           end }
    69         end
    70       }
    73       ui.tag { tag = "div", attr = { class = "areas areas-" .. unit.id }, content = function ()
    75         for i, area in ipairs(areas) do
    77           ui.tag { tag = "div", attr = { class = "sidebarRow" }, content = function ()
    79             if member then
    80               local delegation = Delegation:by_pk(member.id, nil, area.id, nil)
    82               if delegation then
    83                 ui.link { 
    84                   module = "delegation", view = "show", params = {
    85                     area_id = area.id
    86                   },
    87                   attr = { class = "delegation_info" }, 
    88                   content = function ()
    89                     ui.delegation(delegation.trustee_id, delegation.trustee_id and delegation.trustee.name)
    90                   end
    91                 }
    92               end
    93             end
    95             slot.put ( " " )
    97             ui.link {
    98               attr = { class = "area" },
    99               module = "area", view = "show", id = area.id,
   100               content = area.name
   101             }
   104           end }
   105         end
   106       end }
   107     end 
   108   end )
   109 end
