homeflowjs 0.11.4 → 0.11.6
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/actions/properties.actions.js +5 -0
- package/actions/properties.types.js +1 -0
- package/package.json +1 -1
- package/properties/properties-map/draggable-map.js +40 -15
- package/properties/stamp-duty-calculator/stamp-duty-calculator.component.jsx +18 -16
- package/reducers/properties.reducer.js +6 -0
- package/reducers/properties.reducer.test.js +8 -0
- package/search/property-search/parse-fragment.js +5 -0
- package/search/property-search/parse-fragment.test.js +6 -0
package/package.json
CHANGED
@@ -23,6 +23,7 @@ export default class DraggableMap {
|
|
23
23
|
this.render = this.render.bind(this);
|
24
24
|
this.generateMap = this.generateMap.bind(this);
|
25
25
|
this.properties = this.getProperties();
|
26
|
+
this.breadcrumbs = null;
|
26
27
|
if (Homeflow.get('select_marker_on_click')) {
|
27
28
|
this.selectedMarker = null;
|
28
29
|
store.subscribe(() => {
|
@@ -35,6 +36,8 @@ export default class DraggableMap {
|
|
35
36
|
}
|
36
37
|
})
|
37
38
|
}
|
39
|
+
|
40
|
+
if (Homeflow.get('breadcrumbs_map')) store.subscribe(() => this.handleBreadcrumbsInit());
|
38
41
|
}
|
39
42
|
|
40
43
|
getSearch() {
|
@@ -53,10 +56,7 @@ export default class DraggableMap {
|
|
53
56
|
this.mapLoadedTimes = 1;
|
54
57
|
this.render();
|
55
58
|
this.buildPolygon();
|
56
|
-
|
57
|
-
if (properties != null) {
|
58
|
-
this.setMarkersFor(properties);
|
59
|
-
}
|
59
|
+
this.setMarkersFor(this.propertiesOrBreadcrumbs());
|
60
60
|
if (this.noLocationfound) { this.setToMarkeredBounds(); }
|
61
61
|
if (Homeflow.get('custom_map_zoom') !== null) {
|
62
62
|
this.map.setZoom(Homeflow.get('custom_map_zoom'));
|
@@ -74,7 +74,9 @@ export default class DraggableMap {
|
|
74
74
|
// }
|
75
75
|
|
76
76
|
this.generateMap();
|
77
|
-
if (!Homeflow.get('free_text_search')
|
77
|
+
if (!Homeflow.get('free_text_search') && !Homeflow.get('breadcrumbs_map')) {
|
78
|
+
this.map.on('zoomend', () => (this.onMapDrag()));
|
79
|
+
}
|
78
80
|
this.map.on('dragend', () => (this.onMapDrag()));
|
79
81
|
const _this = this;
|
80
82
|
|
@@ -120,7 +122,7 @@ export default class DraggableMap {
|
|
120
122
|
}
|
121
123
|
|
122
124
|
generateMarker(property) {
|
123
|
-
const marker = L.marker([property.lat, property.lng], { icon:
|
125
|
+
const marker = L.marker([property.lat, property.lng], { icon: Homeflow.get('custom_property_pin')(property) });
|
124
126
|
|
125
127
|
// add the property to marker attributes so they can be accessed on click
|
126
128
|
marker.property = property;
|
@@ -242,12 +244,12 @@ export default class DraggableMap {
|
|
242
244
|
}
|
243
245
|
}
|
244
246
|
|
245
|
-
setMarkersFor(
|
247
|
+
setMarkersFor(propertiesOrBreadcrumbs) {
|
246
248
|
let bounds;
|
247
249
|
if (this.marker_layer != null) { this.map.removeLayer(this.marker_layer); }
|
248
|
-
if (!
|
250
|
+
if (!propertiesOrBreadcrumbs) { return null }
|
249
251
|
|
250
|
-
if (Homeflow.get('pin_clustering')) {
|
252
|
+
if (Homeflow.get('pin_clustering') && !this.breadcrumbs?.length) {
|
251
253
|
let radius = Homeflow.get('custom_clustering_radius');
|
252
254
|
if (!radius) {
|
253
255
|
radius = 10;
|
@@ -256,10 +258,10 @@ export default class DraggableMap {
|
|
256
258
|
} else {
|
257
259
|
this.marker_layer = L.featureGroup();
|
258
260
|
}
|
259
|
-
const markers =
|
260
|
-
if (
|
261
|
-
if (
|
262
|
-
const m = this.generateMarker(
|
261
|
+
const markers = propertiesOrBreadcrumbs.map((propertyOrBreadcrumb) => {
|
262
|
+
if (propertyOrBreadcrumb.property_id != null || Homeflow.get('breadcrumbs_map')) {
|
263
|
+
if (propertyOrBreadcrumb.lat !== 0 && propertyOrBreadcrumb.lng !== 0) {
|
264
|
+
const m = this.generateMarker(propertyOrBreadcrumb);
|
263
265
|
this.marker_layer.addLayer(m);
|
264
266
|
return m;
|
265
267
|
}
|
@@ -409,7 +411,7 @@ export default class DraggableMap {
|
|
409
411
|
// if (this.tile_view != null) {
|
410
412
|
// this.tile_view = new Ctesius.Views.Tiles({ collection: this.collection });
|
411
413
|
// }
|
412
|
-
return this.setMarkersFor(this.
|
414
|
+
return this.setMarkersFor(this.propertiesOrBreadcrumbs());
|
413
415
|
});
|
414
416
|
}
|
415
417
|
}
|
@@ -573,7 +575,7 @@ export default class DraggableMap {
|
|
573
575
|
// this.tile_view = new Ctesius.Views.Tiles({ collection: this.collection });
|
574
576
|
// }
|
575
577
|
|
576
|
-
return this.setMarkersFor(
|
578
|
+
return this.setMarkersFor(this.propertiesOrBreadcrumbs());
|
577
579
|
})
|
578
580
|
// return $.get(url, (res, status, xhr) => {
|
579
581
|
// s.set('performed_data', res);
|
@@ -623,4 +625,27 @@ export default class DraggableMap {
|
|
623
625
|
|
624
626
|
return new L.LatLng(y, x);
|
625
627
|
}
|
628
|
+
|
629
|
+
propertiesOrBreadcrumbs() {
|
630
|
+
const breadcrumbs = this.breadcrumbs;
|
631
|
+
const properties = this.properties;
|
632
|
+
if (breadcrumbs && breadcrumbs.length) {
|
633
|
+
return breadcrumbs;
|
634
|
+
} else if (breadcrumbs && !breadcrumbs.length) {
|
635
|
+
return properties;
|
636
|
+
} else if (properties !== null && !Homeflow.get('breadcrumbs_map')) {
|
637
|
+
return properties;
|
638
|
+
} else {
|
639
|
+
return null;
|
640
|
+
}
|
641
|
+
}
|
642
|
+
|
643
|
+
handleBreadcrumbsInit() {
|
644
|
+
const { properties: { breadcrumbs } } = store.getState();
|
645
|
+
|
646
|
+
if (breadcrumbs && this.breadcrumbs !== breadcrumbs) {
|
647
|
+
this.breadcrumbs = breadcrumbs;
|
648
|
+
this.setMarkersFor(breadcrumbs);
|
649
|
+
}
|
650
|
+
}
|
626
651
|
}
|
@@ -9,6 +9,8 @@ const StampDutyCalculator = ({ scotland, themePreferences }) => {
|
|
9
9
|
const [type, setType] = useState('residential');
|
10
10
|
const [purchaseType, setPurchaseType] = useState('firstTimeBuyer')
|
11
11
|
const [purchasePrice, setPurchasePrice] = useState();
|
12
|
+
const [firstTimeBuyer, setFirstTimeBuyer] = useState(false);
|
13
|
+
const [additionalProperty, setAdditionalProperty] = useState(false);
|
12
14
|
|
13
15
|
const renderCalculator = () => {
|
14
16
|
if (type === 'residential') {
|
@@ -16,8 +18,8 @@ const StampDutyCalculator = ({ scotland, themePreferences }) => {
|
|
16
18
|
<DefaultCalculator
|
17
19
|
purchasePrice={purchasePrice}
|
18
20
|
setPurchasePrice={setPurchasePrice}
|
19
|
-
firstTimeBuyer={
|
20
|
-
additionalProperty={
|
21
|
+
firstTimeBuyer={firstTimeBuyer}
|
22
|
+
additionalProperty={additionalProperty}
|
21
23
|
ukResident
|
22
24
|
/>
|
23
25
|
);
|
@@ -61,22 +63,22 @@ const StampDutyCalculator = ({ scotland, themePreferences }) => {
|
|
61
63
|
</div>
|
62
64
|
<div className="switches">
|
63
65
|
<div className="form-group">
|
64
|
-
<
|
65
|
-
type="
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
</
|
66
|
+
<input
|
67
|
+
type="checkbox"
|
68
|
+
id="firstTime"
|
69
|
+
checked={firstTimeBuyer}
|
70
|
+
onChange={() => setFirstTimeBuyer(prev => !prev)}
|
71
|
+
/>
|
72
|
+
<label htmlFor="firstTime">First Time Buyer</label>
|
71
73
|
</div>
|
72
74
|
<div className="form-group">
|
73
|
-
<
|
74
|
-
type="
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
</
|
75
|
+
<input
|
76
|
+
type="checkbox"
|
77
|
+
id="additionalProperty"
|
78
|
+
checked={additionalProperty}
|
79
|
+
onChange={() => setAdditionalProperty(prev => !prev)}
|
80
|
+
/>
|
81
|
+
<label htmlFor="additionalProperty">Additional Property</label>
|
80
82
|
</div>
|
81
83
|
</div>
|
82
84
|
{renderCalculator()}
|
@@ -59,4 +59,12 @@ describe('propertiesReducer', () => {
|
|
59
59
|
|
60
60
|
expect(reducedState).toMatchObject(state);
|
61
61
|
});
|
62
|
+
|
63
|
+
it('Sets breadcrumbs when it receives the SET_BREADCRUMBS action', () => {
|
64
|
+
const breadcrumbs = [{ geoname_id: '12345' }, { geoname_id: '45678' }];
|
65
|
+
const state = { properties: [] };
|
66
|
+
const reducedState = propertiesReducer(state, { type: 'SET_BREADCRUMBS', payload: breadcrumbs });
|
67
|
+
|
68
|
+
expect(reducedState.breadcrumbs).toEqual([{ geoname_id: '12345' }, { geoname_id: '45678' }]);
|
69
|
+
});
|
62
70
|
});
|
@@ -37,4 +37,10 @@ describe('parseFragment', () => {
|
|
37
37
|
// Have to use `Array []` to check equality here for some reason
|
38
38
|
expect(parseFragment(fragment).tags).toEqual(Array ['house', 'flat']);
|
39
39
|
});
|
40
|
+
|
41
|
+
it('turns gid-12345 into Place ID', () => {
|
42
|
+
const fragment = '/properties/sales/france/gid-12345/from-3-bed';
|
43
|
+
|
44
|
+
expect(parseFragment(fragment).placeId).toEqual('12345');
|
45
|
+
});
|
40
46
|
});
|