liquid_feedback_frontend
view app/main/index/index.lua @ 1702:4ddc5841e136
Added MOTD top internal
| author | bsw | 
|---|---|
| date | Mon Sep 27 10:57:00 2021 +0200 (2021-09-27) | 
| parents | 97ff2a26c84e | 
| children | 2558d9c15c44 | 
 line source
     1 local unit_id = request.get_param{ name = "unit" }
     2 local area_id = request.get_param{ name = "area" }
     4 if unit_id == "all" then
     5   unit_id = nil
     6   area_id = nil
     7 end
     9 if area_id == "all" then
    10   area_id = nil
    11 end
    13 local unit
    14 local area
    16 if unit_id then
    17   unit = Unit:by_id(unit_id)
    18   if not unit or unit.attr.hidden then
    19     execute.view { module = "index", view = "404" }
    20     request.set_status("404 Not Found")
    21     return
    22   end
    23   unit:load_delegation_info_once_for_member_id(app.session.member_id)
    24 end
    27 if area_id then
    28   area = Area:by_id(area_id)
    29   if not area or (unit and area.unit_id ~= unit.id) then
    30     execute.view { module = "index", view = "404" }
    31     request.set_status("404 Not Found")
    32     return
    33   end
    34   area:load_delegation_info_once_for_member_id(app.session.member_id)
    35 end
    37 if area then
    38   execute.view{ module = "area", view = "_head", params = { area = area } }
    39 elseif unit then
    40   execute.view{ module = "unit", view = "_head", params = { unit = unit } }
    41 end
    44 ui.grid{ content = function()
    45   ui.cell_main{ content = function()
    47     execute.view{ module = "index", view = "_sidebar_motd_public" }
    49     execute.view{ module = "index", view = "_sidebar_motd_intern_top" }
    51     execute.view{ module = "issue", view = "_list" }
    52   end }
    54   ui.cell_sidebar{ content = function()
    55     execute.view{ module = "index", view = "_head" }
    57     execute.view{ module = "index", view = "_sidebar_motd" }
    58     if app.session.member then
    59       execute.view{ module = "index", view = "_sidebar_notifications" }
    60     end
    61     if config.firstlife then
    62       ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
    63         ui.tag{ tag = "iframe", attr = { src = config.firstlife.areaviewer_url .. "?" .. config.firstlife.coordinates .. "&domain=" .. request.get_absolute_baseurl(), class = "map" }, content = "" }
    64       end }
    65     end
    66     if config.map then
    67       local initiatives = Initiative:new_selector():exec()
    68       local geo_objects = {}
    69       for i, initiative in ipairs(initiatives) do
    70         if initiative.location and initiative.location.coordinates then
    71           local geo_object = {
    72             lon = initiative.location.coordinates[1],
    73             lat = initiative.location.coordinates[2],
    74             label = "i" .. initiative.id,
    75             description = slot.use_temporary(function()
    76               ui.link{ module = "initiative", view = "show", id = initiative.id, text = initiative.display_name }
    77             end),
    78             type = "initiative"
    79           }
    80           table.insert(geo_objects, geo_object)
    81         end
    82       end
    83       if ontomap_get_instances then
    84         local instances = ontomap_get_instances()
    85         for i, instance in ipairs(instances) do
    86           table.insert(geo_objects, instance)
    87         end
    88       end
    89       ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
    90         ui.map(geo_objects)  
    91       end }
    92     end
    93     if config.logo then
    94       config.logo()
    95     end
    96     if area then
    97       execute.view{ module = "area", view = "_sidebar_whatcanido", params = { area = area } }
    98     elseif unit then
    99       execute.view{ module = "unit", view = "_sidebar_whatcanido", params = { unit = unit } }
   100     else
   101       execute.view{ module = "index", view = "_sidebar_whatcanido" }
   102     end
   104     execute.view { module = "index", view = "_sidebar_members" }
   106   end }
   107 end }
