From 9713ce69cf28c3faf75ca4529f9d849d3c2690d4 Mon Sep 17 00:00:00 2001 From: Evan Thibodeau Date: Mon, 7 Feb 2022 13:22:32 +0400 Subject: [PATCH] Fix Mapview fragment for display pages on 7.4. --- .../display/dependencies/map-view/index.html | 49 +++++++++---------- .../display/dependencies/map-view/index.js | 2 +- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/modules/formed-content-display-fragment-collection-contributor/src/main/resources/com/liferay/fragment/collection/contributor/formed/content/display/dependencies/map-view/index.html b/modules/formed-content-display-fragment-collection-contributor/src/main/resources/com/liferay/fragment/collection/contributor/formed/content/display/dependencies/map-view/index.html index 26e1807..866ec1c 100644 --- a/modules/formed-content-display-fragment-collection-contributor/src/main/resources/com/liferay/fragment/collection/contributor/formed/content/display/dependencies/map-view/index.html +++ b/modules/formed-content-display-fragment-collection-contributor/src/main/resources/com/liferay/fragment/collection/contributor/formed/content/display/dependencies/map-view/index.html @@ -4,41 +4,38 @@ [#assign infoListDisplayObject = (request.getAttribute("INFO_LIST_DISPLAY_OBJECT"))! /] [#assign liferaySharedLayoutAssetEntry = (request.getAttribute("LIFERAY_SHARED_LAYOUT_ASSET_ENTRY"))! /] - [#if infoListDisplayObject?has_content] - [#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService") /] - - [#assign modelClassName = infoListDisplayObject.modelClassName! /] - [#assign resourcePrimKey = infoListDisplayObject.resourcePrimKey! /] - - [#if modelClassName?has_content && resourcePrimKey?has_content] - [#assign assetEntry = assetEntryLocalService.getEntry(modelClassName, resourcePrimKey) /] - [/#if] - [#elseif liferaySharedLayoutAssetEntry?has_content] + [#if liferaySharedLayoutAssetEntry?has_content] [#assign assetEntry = (request.getAttribute("LIFERAY_SHARED_LAYOUT_ASSET_ENTRY"))! /] [/#if] [#if assetEntry?has_content && assetEntry.getAssetRenderer??] - [#assign assetRenderer = assetEntry.getAssetRenderer() /] + [#assign + assetRenderer = assetEntry.getAssetRenderer() - [#assign ddmFormValuesReader = assetRenderer.getDDMFormValuesReader() /] + ddmFormValuesReader = assetRenderer.getDDMFormValuesReader() - [#assign ddmFormFieldValues = ddmFormValuesReader.getDDMFormFieldValues("ddm-geolocation") /] + ddmFormFieldValues = ddmFormValuesReader.getDDMFormFieldValues("geolocation") - [#assign coordinatesJSONObjects = [] /] + coordinatesJSONObjects = [] + /] [#list ddmFormFieldValues as ddmFormFieldValue] - [#assign value = ddmFormFieldValue.getValue() - - coordinatesJSONObject = value.getString(locale)?eval /] - -
- [@liferay_map["map-display"] - geolocation=true - latitude=coordinatesJSONObject.latitude - longitude=coordinatesJSONObject.longitude - name="DisplayPageMapView${assetEntry.classPK}" - /] -
+ [#assign + value = ddmFormFieldValue.getValue() + + coordinatesJSONObject = jsonFactoryUtil.createJSONObject(value.getString(locale)) + + coordinatesJSONObjects = coordinatesJSONObjects + [coordinatesJSONObject] + /] [/#list] + +
+ [@liferay_map["map-display"] + geolocation=true + latitude=coordinatesJSONObject.getDouble("lat") + longitude=coordinatesJSONObject.getDouble("lng") + name="DisplayPageMapView${assetEntry.classPK}" + /] +
[/#if] \ No newline at end of file diff --git a/modules/formed-content-display-fragment-collection-contributor/src/main/resources/com/liferay/fragment/collection/contributor/formed/content/display/dependencies/map-view/index.js b/modules/formed-content-display-fragment-collection-contributor/src/main/resources/com/liferay/fragment/collection/contributor/formed/content/display/dependencies/map-view/index.js index b9aa1c1..2d8ca0a 100644 --- a/modules/formed-content-display-fragment-collection-contributor/src/main/resources/com/liferay/fragment/collection/contributor/formed/content/display/dependencies/map-view/index.js +++ b/modules/formed-content-display-fragment-collection-contributor/src/main/resources/com/liferay/fragment/collection/contributor/formed/content/display/dependencies/map-view/index.js @@ -4,7 +4,7 @@ if (document.body.classList.contains('has-edit-mode-menu')) { infoDiv.classList.add("alert"); infoDiv.classList.add("alert-info"); - const newContent = document.createTextNode("Add this fragment to a display page or collection display fragment to show a map for geolocation content."); + const newContent = document.createTextNode("Add this fragment to a display page to show a map for geolocation content."); infoDiv.appendChild(newContent);