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 Apr 2, 2024
1 parent 19dad91 commit c568a80
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 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
5 changes: 3 additions & 2 deletions view/frontend/web/css/source/_module.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}

.store-view-map .map {
max-width: 986px;
max-width: 100%;
height: 400px;
background: #666;
z-index: 1;
Expand All @@ -59,7 +59,8 @@
list-style-type: none;
margin: 10px 0 0;
padding: 0;
max-height: 420px;
max-height: 215px;
min-height: 215px;
overflow-y: scroll;

li.result-item {
Expand Down
21 changes: 21 additions & 0 deletions view/frontend/web/js/retailer/product-availability.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,27 @@ define([
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;

// Update map if geolocation is ON and customer already click to geolocalize button
if (navigator.geolocation && window.location.search === '' && window.location.hash.length > 1) {
self.geolocalizeMe();
}

// Refresh moveen trigger
this.map.map.off('moveend');
this.map.map.on('moveend', self.updateDisplayedOffers.bind(self));
}.bind(this));
}
});
});

0 comments on commit c568a80

Please sign in to comment.