# HG changeset patch # User bsw # Date 1597928880 -7200 # Node ID 056bccb61eeec7c1b72f003be877da0ea52adc16 # Parent 9514b3c04ccb891e99c30fbe54879279b5ddf1db Added object reference for geo references diff -r 9514b3c04ccb -r 056bccb61eee app/main/initiative/show.lua --- a/app/main/initiative/show.lua Thu Aug 20 14:36:56 2020 +0200 +++ b/app/main/initiative/show.lua Thu Aug 20 15:08:00 2020 +0200 @@ -37,6 +37,17 @@ } } + if initiative.location and initiative.location.marker_link then + ui.container { + attr = { class = "mdl-card__content mdl-card--no-bottom-pad" }, + content = function() + ui.tag{ content = _"This initiative references a FirstLife object." } + slot.put(" ") + ui.link{ external = initiative.location.marker_link, content = _"Open in FirstLife" } + end + } + end + if direct_supporter and not initiative.issue.closed then local supporter = app.session.member:get_reference_selector("supporters") :add_where{ "initiative_id = ?", initiative.id } diff -r 9514b3c04ccb -r 056bccb61eee env/ui/field/location.lua --- a/env/ui/field/location.lua Thu Aug 20 14:36:56 2020 +0200 +++ b/env/ui/field/location.lua Thu Aug 20 15:08:00 2020 +0200 @@ -13,7 +13,11 @@ tag = "input", attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" } } - 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 = "" } + ui.tag{ + tag = "input", + attr = { type = "hidden", name = args.name .. "_marker_link", value = args.value_marker_link, id = "ui_field_location_marker_link" } + } + 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 = "" } ui.script{ script = [[ @@ -21,12 +25,14 @@ if (e.origin !== "]] .. config.firstlife.inputmap_url .. [[") return; var data = e.data; if (data.src == "InputMap") { + var feature = { "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level }; + if (data.feature) { + feature.marker_link = data.feature.marker_link; + } var el = document.getElementById("ui_field_location_value"); - el.value = JSON.stringify({ "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level }); - console.log(el.value); + el.value = JSON.stringify(feature); } }); - ]] } end) end diff -r 9514b3c04ccb -r 056bccb61eee lib/ontomap/ontomap.lua --- a/lib/ontomap/ontomap.lua Thu Aug 20 14:36:56 2020 +0200 +++ b/lib/ontomap/ontomap.lua Thu Aug 20 15:08:00 2020 +0200 @@ -63,10 +63,11 @@ } end -local function new_reference_object(url, application) +local function new_reference_object(url, application, type) return json.object{ application = application or config.ontomap.application_ident, - external_url = url + external_url = url, + type = type } end @@ -204,17 +205,28 @@ )) log_event.details.new_issue_state = event.state table.insert(log_events, log_event) - + local log_event = new_log_event(event, event.member_id, "object_created") - table.insert(log_event.activity_objects, new_activity_object{ + + local location = event.initiative.location + if location.marker_link then + local marker_link = location.marker_link + location.marker_link = nil + table.insert(log_event.references, new_reference_object( + marker_link, config.firstlife.application_ident, "BELONGS_TO" + )) + end + + local activity_object = new_activity_object{ type = "initiative", url = url_for("initiative", event.initiative_id), - geometry = event.initiative.location - }) + geometry = location + } + activity_object.properties.name = event.initiative.name + table.insert(log_event.activity_objects, activity_object) table.insert(log_event.references, new_reference_object( url_for("issue", event.issue_id) )) - log_event.details.name = event.initiative.name table.insert(log_events, log_event) log_to_ontomap(log_events) @@ -222,15 +234,24 @@ initiative_created_in_existing_issue = function(event) local log_event = new_log_event(event, event.member_id, "object_created") - table.insert(log_event.activity_objects, new_activity_object{ + local location = event.initiative.location + if location and location.marker_link then + local marker_link = location.marker_link + location.marker_link = nil + table.insert(log_event.references, new_reference_object( + marker_link, config.firstlife.application_ident, "BELONGS_TO" + )) + end + local activity_object = new_activity_object{ type = "initiative", url = url_for("initiative", event.initiative_id), - geometry = event.initiative.location - }) + geometry = location + } + activity_object.properties.name = event.initiative.name + table.insert(log_event.activity_objects, activity_object) table.insert(log_event.references, new_reference_object( url_for("issue", event.issue_id) )) - log_event.details.name = event.initiative.name log_to_ontomap(log_event) end,