-
Notifications
You must be signed in to change notification settings - Fork 117
[ADD] html_builder: convert s_google_map #4242
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
Conversation
This PR targets the un-managed branch odoo-dev/odoo:master-mysterious-egg, it needs to be retargeted before it can be merged. |
c69d4b5
to
fe40bfa
Compare
f468b7f
to
80b3d5d
Compare
27a1402
to
8c6b756
Compare
50652bf
to
fc4217f
Compare
addons/html_builder/static/src/plugins/google_map_option/google_map_option_plugin.js
Outdated
Show resolved
Hide resolved
addons/html_builder/static/src/plugins/google_map_option/google_map_option.js
Outdated
Show resolved
Hide resolved
...r/static/src/website_builder/plugins/options/google_maps_option/google_maps_option_plugin.js
Outdated
Show resolved
Hide resolved
...r/static/src/website_builder/plugins/options/google_maps_option/google_maps_option_plugin.js
Outdated
Show resolved
Hide resolved
7fb25ce
to
f5b6b0a
Compare
...ml_builder/static/src/website_builder/plugins/options/google_map_option/google_map_option.js
Outdated
Show resolved
Hide resolved
...ml_builder/static/src/website_builder/plugins/options/google_map_option/google_map_option.js
Outdated
Show resolved
Hide resolved
...ml_builder/static/src/website_builder/plugins/options/google_map_option/google_map_option.js
Outdated
Show resolved
Hide resolved
...ml_builder/static/src/website_builder/plugins/options/google_map_option/google_map_option.js
Outdated
Show resolved
Hide resolved
...ml_builder/static/src/website_builder/plugins/options/google_map_option/google_map_option.js
Outdated
Show resolved
Hide resolved
this.googleMapsAutocomplete = new google.maps.places.Autocomplete( | ||
inputEl, | ||
{ types: [ "geocode" ] }, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How it works with the history ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a history of stuff that's in the sidebar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I m not sure. What we want to do exactly with this inputEl. What happens when you type a char or you press enter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just that Google's API asks for an Input element to initialize its autocomplete feature on. So when I call google.maps.places.Autocomplete
with that element it attaches its feature to it and now when I type it makes places suggestions. If I type enter it closes the suggestion dropdown. If I select one of the suggestions Google triggers a "place_changed" event, which I listen to to update the state.
I checked and nothing happens in the history when I do any of these things. That seems correct to me, except for the address change which should actually trigger a step. What I should probably do is add a history step in the commitPlace
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There, I did that and it works perfectly.
...der/static/src/website_builder/plugins/options/google_map_option/google_map_option_plugin.js
Outdated
Show resolved
Hide resolved
...ml_builder/static/src/website_builder/plugins/options/google_map_option/google_map_option.js
Outdated
Show resolved
Hide resolved
76e0bc9
to
1c3e7c7
Compare
this.mapsAPI = google?.maps; | ||
this.placesAPI = google?.maps.places; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a difference between window.google?.maps
and google?.maps
. If not, why you do need to store them in this
instead of directly calling google?.maps
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get an error when window.google
is not defined and I try to do google?.maps
: google is not defined
. I store it on this
for convenience, it's not really needed.
}, | ||
], | ||
builder_actions: this.getActions(), | ||
on_snippet_dropped_handlers: ({ snippetEl }) => this.loadGoogleMaps(snippetEl), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really needed? The normalize_handlers
should catch it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it was but I'll test again.
gMapsAPIKeyProm = new Promise(async resolve => { | ||
const data = await rpc('/website/google_maps_api_key'); | ||
resolve(JSON.parse(data).google_maps_api_key || ''); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gMapsAPIKeyProm = rpc('/website/google_maps_api_key').then(
data => JSON.parse(data).google_maps_api_key || ''
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a file I duplicated from website
.
4648461
to
2d7aa09
Compare
8297be0
to
8dbfd0d
Compare
daf794e
to
c944779
Compare
Steps to reproduce: - Activate developer mode - Install website Google Maps module - Navigate to Website in edit mode - Drop the google maps snippet - Enter a correct API key - The dialog closes but the snippet is removed This is due to a promise not resolved when confirming the API key. closes odoo#204845 X-original-commit: 61ede67 Signed-off-by: Benjamin Vray (bvr) <[email protected]> Signed-off-by: Serge Bayet (seba) <[email protected]>
bdf1424
to
235699e
Compare
This is a departure from the original implementation. It ensures things are done in proper order in the case of an API error. It also addresses a specific broken case: 1. Drop a Google Maps snippet 2. Enter an API key with billing, static and javascript, but no places 3. Try again with the same key 4. Now the snippet is removed, so insert it again -> the snippet is blank. This is because the google_maps_service (like the website_map_service it copies), when an API key is found, resolves its promise in a callback triggered by Google's API when calling it via `loadJS`. But the second time, the URL was cached so we never actually fetch the URL and the callback is never triggered, leading to the promise remaining unfulfilled forever. This returns the old promise if requesting the same url a second time.
Because it drives me crazy.
235699e
to
d1d4fc8
Compare
Conversion of the Google Maps ("s_google_map") snippet.