liquid_feedback_frontend
changeset 1519:056bccb61eee
Added object reference for geo references
author | bsw |
---|---|
date | Thu Aug 20 15:08:00 2020 +0200 (2020-08-20) |
parents | 9514b3c04ccb |
children | 97b7b783db42 |
files | app/main/initiative/show.lua env/ui/field/location.lua lib/ontomap/ontomap.lua |
line diff
1.1 --- a/app/main/initiative/show.lua Thu Aug 20 14:36:56 2020 +0200 1.2 +++ b/app/main/initiative/show.lua Thu Aug 20 15:08:00 2020 +0200 1.3 @@ -37,6 +37,17 @@ 1.4 } 1.5 } 1.6 1.7 + if initiative.location and initiative.location.marker_link then 1.8 + ui.container { 1.9 + attr = { class = "mdl-card__content mdl-card--no-bottom-pad" }, 1.10 + content = function() 1.11 + ui.tag{ content = _"This initiative references a FirstLife object." } 1.12 + slot.put(" ") 1.13 + ui.link{ external = initiative.location.marker_link, content = _"Open in FirstLife" } 1.14 + end 1.15 + } 1.16 + end 1.17 + 1.18 if direct_supporter and not initiative.issue.closed then 1.19 local supporter = app.session.member:get_reference_selector("supporters") 1.20 :add_where{ "initiative_id = ?", initiative.id }
2.1 --- a/env/ui/field/location.lua Thu Aug 20 14:36:56 2020 +0200 2.2 +++ b/env/ui/field/location.lua Thu Aug 20 15:08:00 2020 +0200 2.3 @@ -13,7 +13,11 @@ 2.4 tag = "input", 2.5 attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" } 2.6 } 2.7 - ui.tag{ tag = "iframe", attr = { src = config.firstlife.inputmap_url .. "/src/index.html?domain=" .. request.get_absolute_baseurl() .. "&" .. config.firstlife.coordinates .. "&lightArea=false&contrast=false&mode=lite", id = "ui_field_location", class = "ui_field_location" }, content = "" } 2.8 + ui.tag{ 2.9 + tag = "input", 2.10 + attr = { type = "hidden", name = args.name .. "_marker_link", value = args.value_marker_link, id = "ui_field_location_marker_link" } 2.11 + } 2.12 + ui.tag{ tag = "iframe", attr = { src = config.firstlife.inputmap_url .. "/src/index.html?domain=" .. request.get_absolute_baseurl() .. "&" .. config.firstlife.coordinates .. "&lightArea=false&contrast=false&mode=lite&onlypointer=false", id = "ui_field_location", class = "ui_field_location" }, content = "" } 2.13 2.14 ui.script{ script = [[ 2.15 2.16 @@ -21,12 +25,14 @@ 2.17 if (e.origin !== "]] .. config.firstlife.inputmap_url .. [[") return; 2.18 var data = e.data; 2.19 if (data.src == "InputMap") { 2.20 + var feature = { "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level }; 2.21 + if (data.feature) { 2.22 + feature.marker_link = data.feature.marker_link; 2.23 + } 2.24 var el = document.getElementById("ui_field_location_value"); 2.25 - el.value = JSON.stringify({ "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level }); 2.26 - console.log(el.value); 2.27 + el.value = JSON.stringify(feature); 2.28 } 2.29 }); 2.30 - 2.31 ]] } 2.32 end) 2.33 end
3.1 --- a/lib/ontomap/ontomap.lua Thu Aug 20 14:36:56 2020 +0200 3.2 +++ b/lib/ontomap/ontomap.lua Thu Aug 20 15:08:00 2020 +0200 3.3 @@ -63,10 +63,11 @@ 3.4 } 3.5 end 3.6 3.7 -local function new_reference_object(url, application) 3.8 +local function new_reference_object(url, application, type) 3.9 return json.object{ 3.10 application = application or config.ontomap.application_ident, 3.11 - external_url = url 3.12 + external_url = url, 3.13 + type = type 3.14 } 3.15 end 3.16 3.17 @@ -204,17 +205,28 @@ 3.18 )) 3.19 log_event.details.new_issue_state = event.state 3.20 table.insert(log_events, log_event) 3.21 - 3.22 + 3.23 local log_event = new_log_event(event, event.member_id, "object_created") 3.24 - table.insert(log_event.activity_objects, new_activity_object{ 3.25 + 3.26 + local location = event.initiative.location 3.27 + if location.marker_link then 3.28 + local marker_link = location.marker_link 3.29 + location.marker_link = nil 3.30 + table.insert(log_event.references, new_reference_object( 3.31 + marker_link, config.firstlife.application_ident, "BELONGS_TO" 3.32 + )) 3.33 + end 3.34 + 3.35 + local activity_object = new_activity_object{ 3.36 type = "initiative", 3.37 url = url_for("initiative", event.initiative_id), 3.38 - geometry = event.initiative.location 3.39 - }) 3.40 + geometry = location 3.41 + } 3.42 + activity_object.properties.name = event.initiative.name 3.43 + table.insert(log_event.activity_objects, activity_object) 3.44 table.insert(log_event.references, new_reference_object( 3.45 url_for("issue", event.issue_id) 3.46 )) 3.47 - log_event.details.name = event.initiative.name 3.48 table.insert(log_events, log_event) 3.49 3.50 log_to_ontomap(log_events) 3.51 @@ -222,15 +234,24 @@ 3.52 3.53 initiative_created_in_existing_issue = function(event) 3.54 local log_event = new_log_event(event, event.member_id, "object_created") 3.55 - table.insert(log_event.activity_objects, new_activity_object{ 3.56 + local location = event.initiative.location 3.57 + if location and location.marker_link then 3.58 + local marker_link = location.marker_link 3.59 + location.marker_link = nil 3.60 + table.insert(log_event.references, new_reference_object( 3.61 + marker_link, config.firstlife.application_ident, "BELONGS_TO" 3.62 + )) 3.63 + end 3.64 + local activity_object = new_activity_object{ 3.65 type = "initiative", 3.66 url = url_for("initiative", event.initiative_id), 3.67 - geometry = event.initiative.location 3.68 - }) 3.69 + geometry = location 3.70 + } 3.71 + activity_object.properties.name = event.initiative.name 3.72 + table.insert(log_event.activity_objects, activity_object) 3.73 table.insert(log_event.references, new_reference_object( 3.74 url_for("issue", event.issue_id) 3.75 )) 3.76 - log_event.details.name = event.initiative.name 3.77 log_to_ontomap(log_event) 3.78 end, 3.79