liquid_feedback_frontend

annotate app/main/index/index.lua @ 1695:97ff2a26c84e

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

Impressum / About Us