From 0e6eab92379585baad1134a0740ea9748c58e107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Adamczyk?= Date: Fri, 26 Jan 2018 13:40:21 +0100 Subject: [PATCH] EZP-28768: Difference in edit and preview mode for map location --- .../Configuration/Parser/Common.php | 1 + .../translations/content_fields.en.xlf | 21 +++++ .../Resources/views/content_fields.html.twig | 79 +++++++++---------- 3 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 eZ/Bundle/EzPublishCoreBundle/Resources/translations/content_fields.en.xlf diff --git a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Common.php b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Common.php index 862306985a6..61bfdb74940 100644 --- a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Common.php +++ b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Common.php @@ -71,6 +71,7 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder) ->addDefaultsIfNotSet() ->children() ->scalarNode('google_maps') + ->setDeprecated('The child node "%node%" at path "%path%" is no longer used and deprecated.') ->info('Google Maps API Key, required as of Google Maps v3 to make sure maps show up correctly.') ->defaultNull() ->end() diff --git a/eZ/Bundle/EzPublishCoreBundle/Resources/translations/content_fields.en.xlf b/eZ/Bundle/EzPublishCoreBundle/Resources/translations/content_fields.en.xlf new file mode 100644 index 00000000000..696fb92681b --- /dev/null +++ b/eZ/Bundle/EzPublishCoreBundle/Resources/translations/content_fields.en.xlf @@ -0,0 +1,21 @@ + + + +
+ + The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message. +
+ + + Not set + Not set + key: content-field.latitude.not_set + + + Not set + Not set + key: content-field.longitude.not_set + + +
+
diff --git a/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig b/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig index 9a9eaa88227..e88ad758143 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig +++ b/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig @@ -10,6 +10,8 @@ # containing -field #} +{% trans_default_domain "content_fields" %} + {% block ezstring_field %} {% spaceless %} {% set field_value = field.value.text %} @@ -280,8 +282,7 @@ {% block ezgmaplocation_field %} {## # This field type block accepts the following parameters: - # - string mapType the Google map type (ROADMAP, SATELLITE, HYBRID or TERRAIN), default is ROADMAP - # - boolean showMap whether to show the Google map or not, default is true + # - boolean showMap whether to show the map or not, default is true # - boolean showInfo whether to show the latitude, longitude and address or not, default is true # - integer zoom the default zoom level, default is 13 # - boolean draggable whether to enable or not draggable map (useful on mobile / responsive layout), default is true @@ -291,7 +292,9 @@ # set to false to not set any height style inline, default is 200px # - boolean scrollWheel If false, disables scrollwheel zooming on the map. Enabled by default. # - # For further reading: https://developers.google.com/maps/documentation/javascript/reference + # For further reading: + # - https://wiki.openstreetmap.org + # - http://leafletjs.com/reference-1.3.0.html #} {% spaceless %}
@@ -299,19 +302,18 @@ {% set defaultHeight = '200px' %} {% set defaultShowMap = true %} {% set defaultShowInfo = true %} - {% set defaultZoom = 13 %} - {% set defaultMapType = 'ROADMAP' %} {% set defaultDraggable = 'true' %} {% set defaultScrollWheel = 'true' %} {% set hasContent = field.value is not null %} - {% set latitude = field.value.latitude|default( 0 ) %} - {% set longitude = field.value.longitude|default( 0 ) %} + {% set latitude = field.value.latitude %} + {% set longitude = field.value.longitude %} {% set address = field.value.address|default( "" ) %} {% set mapId = "maplocation-map-" ~ field.id %} + {% set defaultZoom = latitude is null and longitude is null ? 1 : 15 %} + {% set zoom = parameters.zoom|default( defaultZoom ) %} - {% set mapType = parameters.mapType|default( defaultMapType ) %} {% set mapWidth, mapHeight = defaultWidth, defaultHeight %} {% if parameters.width is defined %} @@ -345,9 +347,9 @@ {% if showInfo %}
Latitude
-
{{ hasContent ? latitude : "Not set" }}
+
{{ latitude is not null ? latitude : 'content-field.latitude.not_set'|trans|desc("Not set") }}
Longitude
-
{{ longitude ? longitude : "Not set" }}
+
{{ longitude is not null ? longitude : 'content-field.longitude.not_set'|trans|desc("Not set") }}
{% if address %}
Address
{{ address }}
@@ -356,37 +358,40 @@ {% endif %} {% if hasContent and showMap %} - {% set apiKey = ezpublish.configResolver.hasParameter('api_keys.google_maps') ? ezpublish.configResolver.getParameter('api_keys.google_maps'): "" %} + {% set latitude = latitude|default(0) %} + {% set longitude = longitude|default(0) %} {% set mapStyle = mapWidth ? "width:" ~ mapWidth ~ ";": "" %} - {% set mapStyle = mapHeight ? mapStyle ~ " height:" ~ mapHeight : mapStyle %} + {% set mapStyle = mapHeight ? mapStyle ~ " height:" ~ mapHeight : mapStyle %}
{% endif %}