liquid_feedback_frontend
view app/main/index/index.lua @ 1504:2a0d86117d54
Added hidden and role units
author | bsw |
---|---|
date | Fri Jul 31 00:18:55 2020 +0200 (2020-07-31) |
parents | 32cc544d5a5b |
children | ec0d69b4bb20 |
line source
1 if not app.session:has_access("anonymous") then
2 slot.put("<br /> Closed user group, please login.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />")
3 return
4 end
6 local unit_id = request.get_param{ name = "unit" }
7 local area_id = request.get_param{ name = "area" }
9 if unit_id == "all" then
10 unit_id = nil
11 end
13 if area_id == "all" then
14 area_id = nil
15 end
17 local unit
18 local area
20 if unit_id then
21 unit = Unit:by_id(unit_id)
22 if not unit or unit.attr.hidden then
23 execute.view { module = "index", view = "404" }
24 request.set_status("404 Not Found")
25 return
26 end
27 end
29 if area_id then
30 area = Area:by_id(area_id)
31 end
33 ui.grid{ content = function()
34 ui.cell_main{ content = function()
36 execute.view{ module = "index", view = "_sidebar_motd_public" }
38 execute.view{ module = "issue", view = "_list" }
39 end }
41 ui.cell_sidebar{ content = function()
42 execute.view{ module = "index", view = "_sidebar_motd" }
43 if app.session.member then
44 execute.view{ module = "index", view = "_sidebar_notifications" }
45 end
46 if config.firstlife then
47 ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
48 ui.tag{ tag = "iframe", attr = { src = config.firstlife.areaviewer_url .. "?" .. config.firstlife.coordinates .. "&domain=" .. request.get_absolute_baseurl(), class = "map" }, content = "" }
49 end }
50 end
51 if config.map then
52 local initiatives = Initiative:new_selector():exec()
53 local geo_objects = {}
54 for i, initiative in ipairs(initiatives) do
55 if initiative.location and initiative.location.coordinates then
56 local geo_object = {
57 lon = initiative.location.coordinates[1],
58 lat = initiative.location.coordinates[2],
59 label = "i" .. initiative.id,
60 description = slot.use_temporary(function()
61 ui.link{ module = "initiative", view = "show", id = initiative.id, text = initiative.display_name }
62 end),
63 type = "initiative"
64 }
65 table.insert(geo_objects, geo_object)
66 end
67 end
68 if ontomap_get_instances then
69 local instances = ontomap_get_instances()
70 for i, instance in ipairs(instances) do
71 table.insert(geo_objects, instance)
72 end
73 end
74 ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
75 ui.map(geo_objects)
76 end }
77 end
78 if config.logo then
79 config.logo()
80 end
81 if area then
82 execute.view{ module = "area", view = "_sidebar_whatcanido", params = { area = area } }
83 elseif unit then
84 execute.view{ module = "unit", view = "_sidebar_whatcanido", params = { unit = unit } }
85 else
86 execute.view{ module = "index", view = "_sidebar_whatcanido" }
87 end
89 execute.view { module = "index", view = "_sidebar_members" }
91 end }
92 end }