Skip to content

Commit

Permalink
Fix Mapview fragment for display pages on 7.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
ethib137 committed Feb 7, 2022
1 parent 256243d commit 9713ce6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 /]

<div>
[@liferay_map["map-display"]
geolocation=true
latitude=coordinatesJSONObject.latitude
longitude=coordinatesJSONObject.longitude
name="DisplayPageMapView${assetEntry.classPK}"
/]
</div>
[#assign
value = ddmFormFieldValue.getValue()

coordinatesJSONObject = jsonFactoryUtil.createJSONObject(value.getString(locale))

coordinatesJSONObjects = coordinatesJSONObjects + [coordinatesJSONObject]
/]
[/#list]

<div>
[@liferay_map["map-display"]
geolocation=true
latitude=coordinatesJSONObject.getDouble("lat")
longitude=coordinatesJSONObject.getDouble("lng")
name="DisplayPageMapView${assetEntry.classPK}"
/]
</div>
[/#if]
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 9713ce6

Please sign in to comment.