liquid_feedback_frontend
diff app/main/index/index.lua @ 1309:32cc544d5a5b
Cumulative patch for upcoming frontend version 4
| author | bsw/jbe |
|---|---|
| date | Sun Jul 15 14:07:29 2018 +0200 (2018-07-15) |
| parents | 8288027edb54 |
| children | 2a0d86117d54 |
line diff
1.1 --- a/app/main/index/index.lua Thu Jun 23 03:30:57 2016 +0200 1.2 +++ b/app/main/index/index.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -1,114 +1,88 @@ 1.4 -local function getIssuesSelector() 1.5 - return Issue:new_selector() 1.6 - :add_order_by([[ 1.7 - coalesce( 1.8 - issue.fully_frozen + issue.voting_time, 1.9 - issue.half_frozen + issue.verification_time, 1.10 - issue.accepted + issue.discussion_time, 1.11 - issue.created + issue.max_admission_time 1.12 - ) - now() 1.13 - ]]) 1.14 +if not app.session:has_access("anonymous") then 1.15 + slot.put("<br /> Closed user group, please login.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />") 1.16 + return 1.17 +end 1.18 + 1.19 +local unit_id = request.get_param{ name = "unit" } 1.20 +local area_id = request.get_param{ name = "area" } 1.21 + 1.22 +if unit_id == "all" then 1.23 + unit_id = nil 1.24 +end 1.25 + 1.26 +if area_id == "all" then 1.27 + area_id = nil 1.28 +end 1.29 + 1.30 +local unit 1.31 +local area 1.32 + 1.33 +if unit_id then 1.34 + unit = Unit:by_id(unit_id) 1.35 +end 1.36 + 1.37 +if area_id then 1.38 + area = Area:by_id(area_id) 1.39 end 1.40 1.41 ---[[ 1.42 -ui.title( function () 1.43 - ui.link { attr = { class = "home" }, module = "index", view = "index", text = _"Home" } 1.44 -end) 1.45 ---]] 1.46 - 1.47 -ui.title() 1.48 +ui.grid{ content = function() 1.49 + ui.cell_main{ content = function() 1.50 1.51 -if false then 1.52 -slot.select ( "tabs", function () 1.53 - 1.54 - ui.tag { 1.55 - attr = { onclick = "showTab(0);" }, 1.56 - content = "units", 1.57 - } 1.58 - slot.put ( " " ) 1.59 - ui.tag { 1.60 - attr = { onclick = "showTab(1);" }, 1.61 - content = "timeline" 1.62 - } 1.63 - slot.put ( " " ) 1.64 - ui.tag { 1.65 - attr = { onclick = "showTab(2);" }, 1.66 - content = "what" 1.67 - } 1.68 - slot.put ( " " ) 1.69 - ui.tag { 1.70 - attr = { onclick = "showTab(3);" }, 1.71 - content = "members" 1.72 - } 1.73 - 1.74 -end ) 1.75 + execute.view{ module = "index", view = "_sidebar_motd_public" } 1.76 + 1.77 + execute.view{ module = "issue", view = "_list" } 1.78 + end } 1.79 1.80 -ui.script { script = [[ 1.81 - 1.82 - var tabs = ["tab1", "main", "tab2", "tab3"] 1.83 - var currentId; 1.84 - 1.85 - function showTab(id) { 1.86 - var tabId = tabs[id]; 1.87 - $('.tab').hide(); 1.88 - $('.main').hide(); 1.89 - $('.' + tabId).show(); 1.90 - currentId = id; 1.91 - }; 1.92 - 1.93 - showTab(0); 1.94 - 1.95 - $(function(){ 1.96 - // Bind the swipeHandler callback function to the swipe event on div.box 1.97 - $( "body" ).on( "swiperight", function swipeHandler( event ) { 1.98 - newId = currentId - 1; 1.99 - if (newId < 0) return; 1.100 - showTab(newId); 1.101 - } ) 1.102 - $( "body" ).on( "swipeleft", function swipeHandler( event ) { 1.103 - newId = currentId + 1; 1.104 - if (newId > tabs.length - 1) return; 1.105 - showTab(newId); 1.106 - } ) 1.107 - }); 1.108 - 1.109 -]]} 1.110 -end 1.111 - 1.112 + ui.cell_sidebar{ content = function() 1.113 + execute.view{ module = "index", view = "_sidebar_motd" } 1.114 + if app.session.member then 1.115 + execute.view{ module = "index", view = "_sidebar_notifications" } 1.116 + end 1.117 + if config.firstlife then 1.118 + ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function() 1.119 + ui.tag{ tag = "iframe", attr = { src = config.firstlife.areaviewer_url .. "?" .. config.firstlife.coordinates .. "&domain=" .. request.get_absolute_baseurl(), class = "map" }, content = "" } 1.120 + end } 1.121 + end 1.122 + if config.map then 1.123 + local initiatives = Initiative:new_selector():exec() 1.124 + local geo_objects = {} 1.125 + for i, initiative in ipairs(initiatives) do 1.126 + if initiative.location and initiative.location.coordinates then 1.127 + local geo_object = { 1.128 + lon = initiative.location.coordinates[1], 1.129 + lat = initiative.location.coordinates[2], 1.130 + label = "i" .. initiative.id, 1.131 + description = slot.use_temporary(function() 1.132 + ui.link{ module = "initiative", view = "show", id = initiative.id, text = initiative.display_name } 1.133 + end), 1.134 + type = "initiative" 1.135 + } 1.136 + table.insert(geo_objects, geo_object) 1.137 + end 1.138 + end 1.139 + if ontomap_get_instances then 1.140 + local instances = ontomap_get_instances() 1.141 + for i, instance in ipairs(instances) do 1.142 + table.insert(geo_objects, instance) 1.143 + end 1.144 + end 1.145 + ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function() 1.146 + ui.map(geo_objects) 1.147 + end } 1.148 + end 1.149 + if config.logo then 1.150 + config.logo() 1.151 + end 1.152 + if area then 1.153 + execute.view{ module = "area", view = "_sidebar_whatcanido", params = { area = area } } 1.154 + elseif unit then 1.155 + execute.view{ module = "unit", view = "_sidebar_whatcanido", params = { unit = unit } } 1.156 + else 1.157 + execute.view{ module = "index", view = "_sidebar_whatcanido" } 1.158 + end 1.159 + 1.160 + execute.view { module = "index", view = "_sidebar_members" } 1.161 + 1.162 + end } 1.163 +end } 1.164 1.165 -if app.session.member then 1.166 - execute.view{ module = "index", view = "_sidebar_motd_intern" } 1.167 -else 1.168 - execute.view{ module = "index", view = "_sidebar_motd_public" } 1.169 -end 1.170 - 1.171 -if app.session:has_access("anonymous") then 1.172 - -- show the units the member has voting privileges for 1.173 - execute.view { 1.174 - module = "index", view = "_sidebar_units", params = { 1.175 - member = app.session.member 1.176 - } 1.177 - } 1.178 -end 1.179 - 1.180 --- show the user what can be done 1.181 -execute.view { module = "index", view = "_sidebar_whatcanido" } 1.182 - 1.183 --- show active members 1.184 -if app.session:has_access("all_pseudonymous") then 1.185 - execute.view{ module = "index", view = "_sidebar_members" } 1.186 -end 1.187 - 1.188 -if app.session:has_access("anonymous") then 1.189 - 1.190 - if not app.session.member then 1.191 --- execute.view { 1.192 --- module = "slideshow", view = "_index" 1.193 --- } 1.194 - end 1.195 - 1.196 - execute.view { 1.197 - module = "issue", view = "_list2", params = { } 1.198 - } 1.199 - 1.200 -end -- if app.session:has_access "anonymous" 1.201 \ No newline at end of file