Skip to content

Commit

Permalink
Update retailer list on moveend map event
Browse files Browse the repository at this point in the history
  • Loading branch information
cemag44 committed Mar 21, 2024
1 parent 432d3a8 commit 32a2a35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use Smile\RetailerOffer\Block\Catalog\Product\Retailer\Availability;
</div>
</div>
<div class="action showavailability" data-bind="scope: 'catalog-product-retailer-availability'">
<a href="#" class="text" data-bind="text: getLinkLabel()"></a>
<a href="#" class="text" data-bind="text: getLinkLabel(), click: loadRetailerAvailabilityModal"></a>
</div>
</div>

Expand Down
19 changes: 13 additions & 6 deletions view/frontend/web/js/retailer/product-availability.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ define([

/**
* Geolocalize me button action
*
* @returns {string}
*/
geolocalizeMe: function() {
registry.get(this.name + '.geocoder', function (geocoder) {
Expand All @@ -153,8 +151,6 @@ define([

/**
* Action on geolocation success
*
* @returns {string}
*/
geolocationSuccess: function(position) {
if (position.coords && position.coords.latitude && position.coords.longitude) {
Expand All @@ -169,15 +165,26 @@ define([

/**
* Update list of displayed offers
*
* @returns {string}
*/
updateDisplayedOffers: function () {
registry.get(this.name + '.map', function (map) {
this.map = map;
this.map.refreshDisplayedMarkers();
this.displayedOffers(this.map.displayedMarkers());
}.bind(this));
},

/**
* Load modal function to set moveend event on map
*
* @returns {string}
*/
loadRetailerAvailabilityModal : function () {
let self = this;
registry.get(this.name + '.map', function (map) {
this.map = map;
this.map.map.on('moveend', self.updateDisplayedOffers.bind(self));
}.bind(this));
}
});
});

0 comments on commit 32a2a35

Please sign in to comment.