Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-28647: Difference in edit and preview mode for map location #2236

Conversation

mikadamczyk
Copy link
Contributor

JIRA: https://jira.ez.no/browse/EZP-28647

Description

When we set latitude and longitude to '0' we should see proper information, not "Not set" message.
Additionally when we did not provide values for latitude and longitude, we still should see a map on the frontend page, with zoom level 1 and coordinates equal 0,0. This PR also changed google maps to openStreetMaps.

screen shot 2018-01-26 at 2 51 38 pm

screen shot 2018-01-26 at 2 51 57 pm

screen shot 2018-01-26 at 2 52 41 pm

@gggeek
Copy link
Contributor

gggeek commented Jan 26, 2018

I think that the proper handling of NULL vs 0 values should not go together with the switch from gmaps to openstreetmap.
Also, the latter should at least be subject to a config file, and still default to Google, for BC.

@crevillo
Copy link
Contributor

Agree with @gggeek here.

@lserwatka
Copy link
Member

@gggeek @crevillo At the product management we decided to drop Google Maps support for Open Source version of the Product in favour of Open Street Maps. For consistency with new admin UI introduced in 2.0.0 version we have to change it too here. This PR should go to master (kernel 7.1) as it might be unexpected change for .dot release for those who are already started using it. This template has been a bit outdated and we will do more cleanups bringing it up to date, likely BC will happen in version 2.1.0. We will document all possible BCs in the official release note.

@lserwatka lserwatka changed the base branch from 7.0 to master January 27, 2018 08:53
@crevillo
Copy link
Contributor

Dunno.... i'd say this dont fit semantic versioning principles.

@lserwatka
Copy link
Member

It is just a principle, we are at the beginning of .0 for 2.x series and we have to make this cleanup. I fully understand BCs might be painful, but it is temporary pain. But we will document it. Last composer change broke literally all open source projects due to licensing change in .dot release. Things like that will happen. And that did not fit semantic versioning.

@crevillo
Copy link
Contributor

Ok. Probably easy to understand for me, not that easy for possible customers.

@emodric
Copy link
Contributor

emodric commented Jan 27, 2018

I also agree with @gggeek, there should be some kind of BC layer here for existing users. eZ always took pride in its BC policy, so this feels kinda counterproductive. What's wrong in making it configurable?

Will the old version of the template be provided for those who do not want to switch?

The argument that others do it, so we can too is wrong in my opinion. That's not how semver should work.

@lserwatka
Copy link
Member

@crevillo current inconsistent behaviour will do a lot more damaged to developers and customers expectations where admin UI got Open Street Map and frontend got Google Maps. This PR fixes it.

@lserwatka
Copy link
Member

@emodric Netgen Tags introduced BC break be changing param name from eztags to netgen tags prefix, without informing anyone about, that broken ezplatform.com for instance.

We are not using argument that others doing it like that. Main argument is maintenance cost that someone need to take at some point.

@emodric
Copy link
Contributor

emodric commented Jan 27, 2018

That change happened in version 3.0 I think, where BC break is allowed, and it was documented in release notes. If I'm wrong and if it happened in minor release, it should've been reported :)

The problem with this change is that it directly ties into that the frontend will change in most cases on customers' sites after the upgrade, which is far more important than an inconsistency in admin.

@lserwatka
Copy link
Member

@emodric I'm afraid change happened in one of minor versions.

We will document this change as part of upgrade process.

@emodric
Copy link
Contributor

emodric commented Jan 27, 2018

I am sorry about that then, it should've been reported :)

Documenting it is not enough maybe. In my opinion, you should provide a way for people to revert back to Google Maps if they wish.

@crevillo
Copy link
Contributor

What @emodric says is exactly my point. one of the goodness of ez is that you can use ezpublish-kernel without (any) admin bundle. And that's exactly what we're trying in some current projects and what we are offering to some others possible customers. So, i don't think what happened in the admin bundle should introduce a BC change in the kernel.

That said, if finally this goes in, we could remove this line, right? https://github.com/ezsystems/ezpublish-kernel/pull/2236/files#diff-c8b22ddd1af7311bccfea99ccb809930R359

@crevillo
Copy link
Contributor

Finally on my side

  1. we are still calling the block ezgmap_location. I think we should change that in case this is not a google map anymore
  2. Another possible solution which i'd accept is to override that block in the admin bundle. Similar to what is done in demos with the image fields. https://github.com/ezsystems/ezplatform-demo/blob/master/app/Resources/views/themes/demo/content_fields.html.twig

@lserwatka
Copy link
Member

lserwatka commented Jan 27, 2018

  1. We will provide detailed documentation and code snippet for TWIG template to make upgrade process easier by extending kernel template. Most of site implementations are doing this anyway. So the effort will lead towards copy & paste code and placing it in a right place.
  2. Proposed change in this PR touches only UI (presentation layer), does not introduce any API or FieldType PHP implementation backward compatibility breaks.
  3. We will retain gmapl_location FieldType name, as stands for GeoMap Location (provides Map, and geo coordinates), and implementation on PHP level does not require any changes. It is UI layer which might use Open Street Map or Google Maps or what ever is needed. It is up to integrator. We as a vendor will relay on Open Street Map.
  4. We don't have intention to maintain two UI layers for Open Street Map and Google Maps.
  5. Kernel is a key component for our eZ Platform and eZ Platform EE products and must provide up-to-date feature set used on higher levels of the system.

With point #1 I strongly believe upgrade path won't be difficult and time consuming. It is only presentation layer after all. Thank you for your all feedback and understanding.

@andrerom
Copy link
Contributor

andrerom commented Jan 29, 2018

@lserwatka / et al: I think some of the differences here comes from some thinking we follow Symfony's BC promise, and assuming this template code is per SemVer an API, which per SemVer implies increasing major version bump on changes.

We don't necessarily follow Symfony on everything, they are making something a bit different then we do, however we are overdue for clarifying what we follow as SemVer has lots of grey area.

Problem with trying to force us to follow Symfony on everything; this is not the only place we have a need for cleanup, some of the others:

  • Move legacy storage engine out of kernel (to be able to introduce preview of improved storage engine)
  • Move Page field type out of kernel (just long overdue)
  • Remove HttpCache implementation in kernel [7.1] Remove Foshttpcache code, leaving that to ezplatform-http-cache #2194 (in order to be able to move on to FOSHttpCache 2.x and be able to start testing with Symfony 4.x)
  • ... overnights we did not have time, or where not aware of during initial v2 release..

To avoid us being forced to do a major release on every release like browser vendors do, a compromise to allow continued innovation would perhaps be something along:

  • Start process to clarify what API is in eZ, acknowledge more then Public API is counted as API in SemVer term (Public API has a BC promise across major versions btw, so there is a difference, clarify that to)
  • Clarify that we sometimes will cleanup code in minors that has been previously been deprecated before/on current major (something deprecated in 2.0.0 or before will thus be allowed to be fixed in 2.x.0)
  • Allow for moving code out of one package as long as it becomes available in another in a compatible manner
  • Allow for some slack on cleanups first 1-2 minors just after a major in regards to smaller oversights and inconsistencies

I have a draft blog post from end of last year I can try to finish if anyone would like to review and discuss this. For instance if we do a first round @lserwatka and then I do some further rounds with community maintaners to align on this would that be ok for all?

<script>
if (typeof(window.ezgmaplocationMapsScriptLoaded) == 'undefined') {
(function (win, doc) {
var myScript = document.createElement('script');
myScript.src = '//maps.googleapis.com/maps/api/js{% if apiKey %}?key={{ apiKey }}{% endif %}';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not used anymore we should deprecate the setting (including describing that it is not used anymore)

@emodric
Copy link
Contributor

emodric commented Jan 29, 2018

@andrerom It would awesome if things could be explained in detail and to stick with it. I recognize that eZ kernel does not need to follow SemVer or Symfony's BC promise, but the rules we do decide to follow should be explained in the similar manner to http://symfony.com/doc/current/contributing/code/bc.html (with yes/no tables and everything), so your blog post and proper BC policy docs are much needed.

Symfony BC promise and SemVer aside, what I would definitely like to see kept is eZ's strong BC policy. Deprecate things if you need them being deprecated, but don't flat out remove features users depend on without a proper deprecation period, especially since eZ always prided itself in its BC policy, which even held through with eZ 5 and eZ legacy compatibility.

@@ -357,55 +357,59 @@

{% if hasContent and showMap %}
{% set apiKey = ezpublish.configResolver.hasParameter('api_keys.google_maps') ? ezpublish.configResolver.getParameter('api_keys.google_maps'): "" %}
Copy link
Member

@lserwatka lserwatka Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed from here as well. Can you please add info that this config is deprecated now?

@alongosz
Copy link
Member

Guys, I don't really see a BC problem here :)
Here's why: the purpose and function of this Twig template block is to provide an interactive map for ezgmaplocation field. When updating from current master to this PR, a map is still displayed for content with that field and we even got rid of some nasty browser console errors.
I understand that the map looks different, but still the feature is provided.

Personal POV: I also don't like treating Twig templates as an API and also don't like relying on templates coming from Kernel. These are lightweight minimal examples that should be overridden for the purpose of an actual site. But I know I'm alone in that opinion :)

What I disagree about is deprecating api_keys.google_maps. Using Google Maps or Open Street Map should be a choice for the Developer. The fact that we dropped it in our templates doesn't mean that the developer is not allowed to use Google Maps in his own templates (and deprecating means future removal of the feature). // cc @lserwatka @andrerom

So I'm with @lserwatka previous comment, we should make a doc stating that this changed and how to override template with the version using Google Maps. I find it hard to believe someone on production site didn't need to override this particular template (problem doesn't exist in such case), but maybe that's just me and my approach to dev with eZ ;)

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: It would be nice if @sunpietro or @dew326 could do a review of JS 😀

My review remarks:

@@ -280,7 +282,6 @@
{% 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop "Google" from the sentence please :)
Also there's the reference to Google's JS API at the bottom of this comment block (can't point it here). Some updated link to OpenStreet doc would be good.

(function (win) {
var mapView = function (mapId, latitude, longitude) {
var mapConfig = {
dragging: {{ zoom }},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this accurate? I can't find OpenStreetMap API doc on that setting.

Copy link
Member

@dew326 dew326 Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the doc http://leafletjs.com/reference-1.3.0.html#map-dragging

But I think {{ zoom }} is not the proper value for dragging parameter. Shouldn't this config looks like this?:

...
dragging: {{ draggable }},
zoom: {{ zoom }},
...

@crevillo
Copy link
Contributor

@alongosz yes and no. i mean, customers can have projects using ezpublish kernel 7.0, use the default template for showing the google map and modify other templates to interact with this google map. if we change that to open street map, all the code they have written to interact with gmaps will need to be rewritten also.

we can discuss if this is a bc or not, but otoh, i still think that solution proposed by @gggeek is doable and will have more people happy with it.

@emodric
Copy link
Contributor

emodric commented Jan 30, 2018

I also don't like treating Twig templates as an API and also don't like relying on templates coming from Kernel.

I find it hard to believe someone on production site didn't need to override this particular template (problem doesn't exist in such case), but maybe that's just me and my approach to dev with eZ ;)

In my opinion, front facing templates which have a direct impact on how the page looks like in frontend should be considered public API. This includes XSLT transformations for rich text tags, as well as default templates from the kernel. I'm sure there is a number of users who definitely rely on built in templates, or even worse, have other code that directly depends on this template and Google Maps.

But as @andrerom hinted, this all needs a proper discussion with the community to determine what the community wants included in the BC policy.

@alongosz
Copy link
Member

customers can have projects using ezpublish kernel 7.0, use the default template for showing the google map and modify other templates to interact with this google map. if we change that to open street map, all the code they have written to interact with gmaps will need to be rewritten also.

@crevillo I would rather override template with version supporting gmaps. It's just about copying version supporting GMaps to application. Much simpler than rewriting to OpenStreetMap. How to do it - this is what I've suggested for doc about this change.

That said, maybe it's a good idea to provide some config, however I don't see in my head a proper clean solution yet.
The difference is that our Admin UI already uses OpenStreetMap, so overriding config for site would need to happen in Admin UI, which I don't find very nice. It also would make BC layer working only in case of pure ezpublish-kernel usage without ezplatform-admin-ui, thus in most cases pointless config feature, right?

@crevillo
Copy link
Contributor

It also would make BC layer working only in case of pure ezpublish-kernel usage without ezplatform-admin-ui, thus in most cases pointless config feature, right?

Well, i know some cases like this. think in all people that uses ezpublish legacy admin, which, if i'm not wrong, still uses gmaps.

false
);
} else if (win.attachEvent) {
win.attachEvent(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one can be dropped as we don't support IE10 and older browsers. Please, stick to addEventListener method only.

myScript.crossorigin = "";
myCss.rel = "stylesheet";
myCss.href = "https://unpkg.com/leaflet@1.3.1/dist/leaflet.css";
myCss.crossorigin = "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's needed.

myScript.src = '//maps.googleapis.com/maps/api/js{% if apiKey %}?key={{ apiKey }}{% endif %}';
var myCss = document.createElement('link');
myScript.src = 'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js';
myScript.crossorigin = "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's needed.

dragging: {{ zoom }},
scrollWheelZoom: {{ scrollWheel }}
};
var map = L.map(mapId, mapConfig).setView([latitude, longitude], {{ zoom }});
Copy link
Member

@dew326 dew326 Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to call method .setView() it can be set in config:

...
zoom: {{ zoom }},
center: [latitude, longitude],
...

and coords can be cached in variable because are used second time in L.marker()

@mikadamczyk mikadamczyk force-pushed the ezp-28647-difference-in-edit-and-preview-mode-for-map-location branch from 013ca2d to 9d4273e Compare January 30, 2018 13:27
@mikadamczyk mikadamczyk force-pushed the ezp-28647-difference-in-edit-and-preview-mode-for-map-location branch from 9d4273e to 0e6eab9 Compare January 30, 2018 14:33
@barbaragr barbaragr self-assigned this Feb 21, 2018
@barbaragr barbaragr changed the title EZP-28768: Difference in edit and preview mode for map location EZP-28647: Difference in edit and preview mode for map location Feb 21, 2018
@alongosz alongosz merged commit 1fb1b70 into ezsystems:master Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
10 participants