liquid_feedback_frontend
view app/main/index/index.lua @ 1659:4b74a177884b
Do not show interest add button when issue is cancelled
| author | bsw | 
|---|---|
| date | Sun Feb 14 13:29:56 2021 +0100 (2021-02-14) | 
| parents | a3a7120a67be | 
| children | cbce4491c93e | 
 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   area_id = nil
    12 end
    14 if area_id == "all" then
    15   area_id = nil
    16 end
    18 local unit
    19 local area
    21 if unit_id then
    22   unit = Unit:by_id(unit_id)
    23   if not unit or unit.attr.hidden then
    24     execute.view { module = "index", view = "404" }
    25     request.set_status("404 Not Found")
    26     return
    27   end
    28   unit:load_delegation_info_once_for_member_id(app.session.member_id)
    29 end
    32 if area_id then
    33   area = Area:by_id(area_id)
    34   if not area or area.unit_id ~= unit.id then
    35     execute.view { module = "index", view = "404" }
    36     request.set_status("404 Not Found")
    37     return
    38   end
    39   area:load_delegation_info_once_for_member_id(app.session.member_id)
    40 end
    42 if area then
    43   execute.view{ module = "area", view = "_head", params = { area = area } }
    44 elseif unit then
    45   execute.view{ module = "unit", view = "_head", params = { unit = unit } }
    46 end
    49 ui.grid{ content = function()
    50   ui.cell_main{ content = function()
    52     execute.view{ module = "index", view = "_sidebar_motd_public" }
    54     execute.view{ module = "issue", view = "_list" }
    55   end }
    57   ui.cell_sidebar{ content = function()
    58     execute.view{ module = "index", view = "_head" }
    60     execute.view{ module = "index", view = "_sidebar_motd" }
    61     if app.session.member then
    62       execute.view{ module = "index", view = "_sidebar_notifications" }
    63     end
    64     if config.firstlife then
    65       ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
    66         ui.tag{ tag = "iframe", attr = { src = config.firstlife.areaviewer_url .. "?" .. config.firstlife.coordinates .. "&domain=" .. request.get_absolute_baseurl(), class = "map" }, content = "" }
    67       end }
    68     end
    69     if config.map then
    70       local initiatives = Initiative:new_selector():exec()
    71       local geo_objects = {}
    72       for i, initiative in ipairs(initiatives) do
    73         if initiative.location and initiative.location.coordinates then
    74           local geo_object = {
    75             lon = initiative.location.coordinates[1],
    76             lat = initiative.location.coordinates[2],
    77             label = "i" .. initiative.id,
    78             description = slot.use_temporary(function()
    79               ui.link{ module = "initiative", view = "show", id = initiative.id, text = initiative.display_name }
    80             end),
    81             type = "initiative"
    82           }
    83           table.insert(geo_objects, geo_object)
    84         end
    85       end
    86       if ontomap_get_instances then
    87         local instances = ontomap_get_instances()
    88         for i, instance in ipairs(instances) do
    89           table.insert(geo_objects, instance)
    90         end
    91       end
    92       ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
    93         ui.map(geo_objects)  
    94       end }
    95     end
    96     if config.logo then
    97       config.logo()
    98     end
    99     if area then
   100       execute.view{ module = "area", view = "_sidebar_whatcanido", params = { area = area } }
   101     elseif unit then
   102       execute.view{ module = "unit", view = "_sidebar_whatcanido", params = { unit = unit } }
   103     else
   104       execute.view{ module = "index", view = "_sidebar_whatcanido" }
   105     end
   107     execute.view { module = "index", view = "_sidebar_members" }
   109   end }
   110 end }
