homeflowjs 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -222,6 +222,49 @@ export default class DraggableMap {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
generateMarker(property) {
|
|
225
|
+
const rates = Homeflow.get('currency_rates') || null;
|
|
226
|
+
const selectedCurrency = localStorage.getItem('currency') || 'GBP';
|
|
227
|
+
const localCurrencyCode = property.local_currency_code || '';
|
|
228
|
+
const localCurrencyPrice= property.local_currency_price || '';
|
|
229
|
+
const propertyPrice = property.price;
|
|
230
|
+
|
|
231
|
+
// Function to extract the number for properties having price with symbols such as £1,000,000
|
|
232
|
+
const extractNumber = (str) => {
|
|
233
|
+
const numbers = str.match(/\d+/g);
|
|
234
|
+
return numbers ? numbers.join('') : '0';
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const convertPriceOnPopup = (price, currency) => {
|
|
238
|
+
const numericPrice = parseInt(extractNumber(price), 10);
|
|
239
|
+
const formatter = new Intl.NumberFormat('en-US', {
|
|
240
|
+
style: 'currency',
|
|
241
|
+
currency: selectedCurrency,
|
|
242
|
+
minimumFractionDigits: 0,
|
|
243
|
+
maximumFractionDigits: 0,
|
|
244
|
+
});
|
|
245
|
+
const value = rates && rates[currency] * numericPrice || propertyPrice;
|
|
246
|
+
const convertedValue = formatter.format(Math.round(value));
|
|
247
|
+
|
|
248
|
+
/*
|
|
249
|
+
Properties which have different currencies set in admin
|
|
250
|
+
should display the value without converting it.
|
|
251
|
+
*/
|
|
252
|
+
if (localCurrencyCode === selectedCurrency) return formatter.format(Math.round(localCurrencyPrice));
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Converting the property price to the selected currency
|
|
256
|
+
* this could either be from GBP to EUR, GBP to USD, EUR to USD, etc
|
|
257
|
+
*/
|
|
258
|
+
if ( selectedCurrency === 'GBP' && localCurrencyCode !== null && localCurrencyPrice !== null && localCurrencyCode !== 'GBP' ) {
|
|
259
|
+
const value = localCurrencyPrice / rates[localCurrencyCode];
|
|
260
|
+
return formatter.format(Math.round(value));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return convertedValue;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const propertyWithConvertedPrice = { ...property, price: convertPriceOnPopup(propertyPrice, selectedCurrency) };
|
|
267
|
+
|
|
225
268
|
const marker = L.marker(
|
|
226
269
|
[property.lat, property.lng],
|
|
227
270
|
{ title: property.name, icon: this.generateMarkerIcon(property) }
|
|
@@ -232,33 +275,17 @@ export default class DraggableMap {
|
|
|
232
275
|
|
|
233
276
|
if (!Homeflow.get('do_not_show_marker_popup')) {
|
|
234
277
|
const lodashTemplatePopup = document.getElementById('property-map-popup-template');
|
|
235
|
-
const liquidTemplatePopup = document.querySelector(`.property-map-popup-template[data-property-id="${property.property_id}"]`);
|
|
236
278
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const t = compiled({ property });
|
|
279
|
+
const compiled = template(lodashTemplatePopup.innerHTML);
|
|
280
|
+
const t = compiled( rates ? { property: propertyWithConvertedPrice } : {property});
|
|
240
281
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
282
|
+
Homeflow.kickEvent('map_marker_rendered', property);
|
|
283
|
+
const popup = new L.Point(Homeflow.get('autopan_padding')[0], Homeflow.get('autopan_padding')[1]);
|
|
284
|
+
marker.bindPopup(t, { autoPanPadding: popup, autoPan: !Homeflow.get('disable_map_pop_up_scroll') });
|
|
244
285
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (liquidTemplatePopup) {
|
|
252
|
-
const html = liquidTemplatePopup.innerHTML;
|
|
253
|
-
|
|
254
|
-
Homeflow.kickEvent('map_marker_rendered', property);
|
|
255
|
-
const popup = new L.Point(Homeflow.get('autopan_padding')[0], Homeflow.get('autopan_padding')[1]);
|
|
256
|
-
marker.bindPopup(html, { autoPanPadding: popup, autoPan: !Homeflow.get('disable_map_pop_up_scroll') });
|
|
257
|
-
|
|
258
|
-
if (Homeflow.get('pop_up_on_mouseover')) {
|
|
259
|
-
marker.on("mouseover", e => marker.openPopup());
|
|
260
|
-
marker.on("mouseout", e => setTimeout((() => marker.closePopup()), 4000));
|
|
261
|
-
}
|
|
286
|
+
if (Homeflow.get('pop_up_on_mouseover')) {
|
|
287
|
+
marker.on("mouseover", e => marker.openPopup());
|
|
288
|
+
marker.on("mouseout", e => setTimeout((() => marker.closePopup()), 4000));
|
|
262
289
|
}
|
|
263
290
|
}
|
|
264
291
|
|
|
@@ -56,7 +56,7 @@ const fetchBranchesDataByPostcode = ({
|
|
|
56
56
|
const polygonPrm = (usingPolygon && channel) ? '&using_polygon=true' : '';
|
|
57
57
|
const channelPrm = channel ? `&channel=${channel}` : '';
|
|
58
58
|
const departmentPrm = (isDepartmentSearch && channel) ? `&department=true` : '';
|
|
59
|
-
const crossAgencyPrm = `&
|
|
59
|
+
const crossAgencyPrm = `&include_cross_agency_branches=true`
|
|
60
60
|
|
|
61
61
|
return fetch(`/postcode_branches_lookup?postcode=${postcode}${departmentPrm}${channelPrm}${polygonPrm}${crossAgencyPrm}`)
|
|
62
62
|
.then(handleRequest)
|