homeflowjs 0.13.21 → 0.13.23

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.13.21",
3
+ "version": "0.13.23",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -146,6 +146,9 @@ export default class DrawableMap extends DraggableMap {
146
146
  });
147
147
 
148
148
  this.map.on("draw:drawstart", e => {
149
+ if (!Homeflow.get('initial_properties_payload')) {
150
+ Homeflow.set('initial_properties_payload', this.properties);
151
+ }
149
152
  this.first = false;
150
153
  this.map.removeLayer(this.marker_layer);
151
154
  if (this.nonClusteringMarkerLayer) { this.map.removeLayer(this.nonClusteringMarkerLayer); }
@@ -242,6 +245,11 @@ export default class DrawableMap extends DraggableMap {
242
245
  store.dispatch(setSearchField({ poly: null }));
243
246
  this.updateURL();
244
247
  Homeflow.kickEvent('deletebannertoggled');
248
+ if (Homeflow.get('initial_properties_payload')) {
249
+ const initialProperties = Homeflow.get('initial_properties_payload');
250
+ this.properties = initialProperties;
251
+ this.setMarkers();
252
+ }
245
253
  if (this.circle != null) {
246
254
  this.map.addLayer(this.circle);
247
255
  this.onMapDrag();
@@ -1,12 +1,15 @@
1
1
  /* eslint-disable */
2
2
  import DraggableMap from './draggable-map';
3
3
  import store from '../../store';
4
- import { currentGeonameId } from '../../utils/index';
4
+ import { currentGeonameId, filterGeonames } from '../../utils/index';
5
5
  import { setProperties, setGeonames, setSelectedMarker } from '../../actions/properties.actions';
6
6
  import { setInitialSearch, setPlace, setSearchField } from '../../actions/search.actions';
7
7
  import { buildQueryString } from '../../search/property-search/property-search';
8
8
  import mapLoader from './map-loader';
9
9
  import './geonames.css';
10
+ import Toastify from 'toastify-js';
11
+ import 'toastify-js/src/toastify.css';
12
+ import { sanitizeText } from '../../utils/index';
10
13
 
11
14
  export default class GeonamesMap extends DraggableMap {
12
15
  constructor() {
@@ -16,6 +19,7 @@ export default class GeonamesMap extends DraggableMap {
16
19
 
17
20
  this.geonameMarkerLayers = [];
18
21
  this.geonameMarkerHoverLayers = [];
22
+ this.currentGeonameIdFromLocationPath = currentGeonameId();
19
23
  }
20
24
 
21
25
  initOnMarkerClick() {
@@ -68,6 +72,16 @@ export default class GeonamesMap extends DraggableMap {
68
72
  this.map.on('zoomend', () => {
69
73
  this.setMarkerTypeforZoomLevel()
70
74
 
75
+ const zoomLevel = this.map.getZoom();
76
+ const pagination = store.getState().properties?.pagination;
77
+ const propertiesShown = this.properties.length;
78
+
79
+ if (zoomLevel > this.locationPinsMaxZoomLevel
80
+ && zoomLevel < 16
81
+ && pagination?.total_count > propertiesShown) {
82
+ this.showToastMessage('Too many properties to show. Zoom in.');
83
+ }
84
+
71
85
  this.setMarkers();
72
86
  });
73
87
 
@@ -258,11 +272,15 @@ export default class GeonamesMap extends DraggableMap {
258
272
 
259
273
  setSearchResponse(json) {
260
274
  if (!json) return;
261
-
275
+
262
276
  if (json.geonames) {
263
277
  this.geonames = this.concatenateDistinctObjects('geoname_id', this.geonames, json.geonames);
264
278
  window.markerType = 'geonames';
265
- store.dispatch(setGeonames(json.geonames));
279
+ const currentAreaId = store.getState().search.currentSearch?.place?.area;
280
+ const geonamesFiltered = filterGeonames(
281
+ this.currentGeonameIdFromLocationPath, Number(currentAreaId), this.geonames
282
+ );
283
+ store.dispatch(setGeonames(geonamesFiltered));
266
284
  } else if (json.properties) {
267
285
  this.properties = this.concatenateDistinctObjects('property_id', this.properties, json.properties);
268
286
  window.markerType = 'properties';
@@ -285,7 +303,11 @@ export default class GeonamesMap extends DraggableMap {
285
303
  this.hideSuggestedDestinations();
286
304
  this.markersInitialized = true;
287
305
  } else if (window.markerType === 'geonames' && this.geonames?.length) {
288
- this.geonames.forEach(geoname => this.setGeonameMarker(geoname));
306
+ const currentAreaId = store.getState().search.currentSearch?.place?.area;
307
+ const geonamesFiltered = filterGeonames(
308
+ this.currentGeonameIdFromLocationPath, Number(currentAreaId), this.geonames
309
+ );
310
+ geonamesFiltered.forEach(geoname => this.setGeonameMarker(geoname));
289
311
  this.showSuggestedDestinations();
290
312
  this.markersInitialized = true;
291
313
  }
@@ -411,6 +433,21 @@ export default class GeonamesMap extends DraggableMap {
411
433
  }
412
434
  }
413
435
 
436
+ showToastMessage(message) {
437
+ const primaryColour = store.getState().app.themePreferences.primaryColour;
438
+ Toastify({
439
+ duration: 5000,
440
+ close: true,
441
+ gravity: 'bottom',
442
+ position: 'center',
443
+ stopOnFocus: true,
444
+ text: sanitizeText(message),
445
+ escapeMarkup: false,
446
+ className: 'properties-map-toast',
447
+ style: { background: primaryColour, marginBottom: '200px', },
448
+ }).showToast();
449
+ }
450
+
414
451
  onMapDrag({ markerPlaceId } = { markerPlaceId: null }) {
415
452
  this.showLoader();
416
453
 
package/utils/index.js CHANGED
@@ -1,3 +1,8 @@
1
+ /* eslint-disable arrow-body-style */
2
+ /* eslint-disable max-len */
3
+ /* eslint-disable semi */
4
+ /* eslint-disable no-undef */
5
+ /* eslint-disable no-restricted-syntax */
1
6
  export { default as stampDutyCalculator } from './stamp-duty-calculator/stamp-duty-calculator';
2
7
 
3
8
  export const capitalizeFirstLetter = (str) => (
@@ -82,8 +87,16 @@ export const sanitizeText = (string) => new Option(string).innerHTML;
82
87
 
83
88
  export const currentGeonameId = (path) => {
84
89
  const pathname = path || window.location.pathname;
85
- const segment = pathname.split('/').reverse().find(item => item.startsWith('gid-'))?.replace(/^gid-/, '')
90
+ const segment = pathname.split('/').reverse().find((item) => item.startsWith('gid-'))?.replace(/^gid-/, '');
86
91
  return parseInt(segment, 10) || null;
87
92
  };
88
93
 
89
94
  export const DEBOUNCE_DELAY = 200;
95
+
96
+ export const filterGeonames = (geonameId = null, areaId = null, geonames) => {
97
+ if (!geonameId) return geonames;
98
+
99
+ if (areaId) return geonames.filter((geoname) => geoname?.geoname_id !== geonameId && geoname?.area < areaId);
100
+
101
+ return geonames.filter((geoname) => geoname?.geoname_id !== geonameId);
102
+ };