homeflowjs 1.0.12 → 1.0.14
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.
@@ -129,12 +129,25 @@ export const setPagination = (payload) => ({
|
|
129
129
|
|
130
130
|
export const postPropertyView = (payload) => () => {
|
131
131
|
const domain = location.hostname;
|
132
|
+
const { sendAsFormData } = Homeflow.get('propertyViewsOptions') ?? {};
|
133
|
+
const data = { property_id: payload, domain };
|
134
|
+
|
135
|
+
let contentType;
|
136
|
+
let body;
|
137
|
+
if (sendAsFormData) {
|
138
|
+
contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
|
139
|
+
body = JSON_to_URLEncoded(data);
|
140
|
+
} else {
|
141
|
+
contentType = 'application/json'
|
142
|
+
body = JSON.stringify(data);
|
143
|
+
}
|
144
|
+
|
132
145
|
fetch('/property_views',
|
133
146
|
{
|
134
147
|
method: 'POST',
|
135
148
|
mode: 'no-cors',
|
136
|
-
headers: { 'Content-Type':
|
137
|
-
body
|
149
|
+
headers: { 'Content-Type': contentType },
|
150
|
+
body,
|
138
151
|
});
|
139
152
|
};
|
140
153
|
|
package/package.json
CHANGED
@@ -21,6 +21,10 @@ const PropertiesDisplay = ({
|
|
21
21
|
previousBtnClasses,
|
22
22
|
...other
|
23
23
|
}) => {
|
24
|
+
if (!properties?.length) {
|
25
|
+
return noResultsMessage;
|
26
|
+
}
|
27
|
+
|
24
28
|
const propertiesPagination = useSelector((state) => state.properties?.pagination);
|
25
29
|
const infiniteScrollRef = useRef();
|
26
30
|
const {
|
@@ -53,10 +57,6 @@ const PropertiesDisplay = ({
|
|
53
57
|
};
|
54
58
|
}, [properties]);
|
55
59
|
|
56
|
-
if (!properties?.length) {
|
57
|
-
return noResultsMessage;
|
58
|
-
}
|
59
|
-
|
60
60
|
const addWrapper = displayType === 'list';
|
61
61
|
|
62
62
|
const showPreviousBtn = includePreviousBtn && hasPreviousPage && !loadingPreviousProperties;
|
@@ -18,7 +18,7 @@ const element = function (X, Y) {
|
|
18
18
|
// TODO: subscribe to store for when properties change and refresh the map
|
19
19
|
|
20
20
|
export default class DraggableMap {
|
21
|
-
constructor() {
|
21
|
+
constructor({ updateMapOnPropertiesLoadMore, dragWithoutUpdate } = {}) {
|
22
22
|
this.updateURL = this.updateURL.bind(this);
|
23
23
|
this.onPolygonDrawn = this.onPolygonDrawn.bind(this);
|
24
24
|
this.init = this.init.bind(this);
|
@@ -31,9 +31,10 @@ export default class DraggableMap {
|
|
31
31
|
this.removeOverlay = this.removeOverlay.bind(this);
|
32
32
|
this.showOverlay = this.showOverlay.bind(this);
|
33
33
|
this.hideOverlay = this.hideOverlay.bind(this);
|
34
|
+
this.updateMapOnPropertiesLoadMore = updateMapOnPropertiesLoadMore || false;
|
35
|
+
this.dragWithoutUpdate = dragWithoutUpdate || false;
|
34
36
|
this.initOnMarkerClick();
|
35
37
|
}
|
36
|
-
|
37
38
|
initOnMarkerClick() {
|
38
39
|
if (!Homeflow.get('select_marker_on_click')) return;
|
39
40
|
|
@@ -59,8 +60,26 @@ export default class DraggableMap {
|
|
59
60
|
return store.getState().properties.properties;
|
60
61
|
}
|
61
62
|
|
63
|
+
/*
|
64
|
+
* theme needs both Homeflow.kickEvent('performed_previous_infinite_scroll')
|
65
|
+
* and Homeflow.kickEvent('preformed_next_infinite_scroll')
|
66
|
+
* to kick the map updates
|
67
|
+
*/
|
68
|
+
initMapUpdateOnPropertiesLoadMore() {
|
69
|
+
Homeflow.registerEvent('performed_previous_infinite_scroll', () => {
|
70
|
+
this.properties = this.getProperties();
|
71
|
+
this.setMarkers();
|
72
|
+
});
|
73
|
+
|
74
|
+
Homeflow.registerEvent('performed_next_infinite_scroll', () => {
|
75
|
+
this.properties = this.getProperties();
|
76
|
+
this.setMarkers();
|
77
|
+
})
|
78
|
+
}
|
79
|
+
|
62
80
|
init() {
|
63
|
-
store.dispatch(setSearchField({ page: null }));
|
81
|
+
if (!this.updateMapOnPropertiesLoadMore) store.dispatch(setSearchField({ page: null }));
|
82
|
+
|
64
83
|
//@setElement( $(Homeflow.get('small_map_element')))
|
65
84
|
if (Homeflow.get('draggable_map_view') != null) {
|
66
85
|
this.element = Homeflow.get('draggable_map_view');
|
@@ -81,6 +100,9 @@ export default class DraggableMap {
|
|
81
100
|
}
|
82
101
|
Homeflow.kickEvent('map_view_rendered', this);
|
83
102
|
store.dispatch(setLoading({ propertiesMap: false }));
|
103
|
+
|
104
|
+
if (this.updateMapOnPropertiesLoadMore) this.initMapUpdateOnPropertiesLoadMore();
|
105
|
+
|
84
106
|
if (Homeflow.get('draw_map_search_loader')) {
|
85
107
|
this.drawSearchLoader = document.querySelector(`${Homeflow.get('draw_map_search_loader')}`);
|
86
108
|
}
|
@@ -476,8 +498,12 @@ export default class DraggableMap {
|
|
476
498
|
|
477
499
|
|
478
500
|
onMapDrag({ markerPlaceId } = { markerPlaceId: null }) {
|
501
|
+
// no drag allowed.
|
479
502
|
if (Homeflow.get('disable_draggable_map') || this.drawableMapInitialized) return;
|
480
503
|
|
504
|
+
// drag map but no fetching properties within the new boundaries.
|
505
|
+
if(this.dragWithoutUpdate) return null;
|
506
|
+
|
481
507
|
let url;
|
482
508
|
const bounds = this.getSearchableBounds();
|
483
509
|
const has_expanded = this.getSearch().expandedPolygon;
|
@@ -16,7 +16,7 @@ import './marker_cluster.css';
|
|
16
16
|
import './marker_cluster.default.css';
|
17
17
|
|
18
18
|
// global callback to run when maps scripts are loaded
|
19
|
-
window.initLegacyMap = (options) => {
|
19
|
+
window.initLegacyMap = (options, updateMap, updateDragg) => {
|
20
20
|
let map;
|
21
21
|
if (Homeflow.get('geonames_map')) {
|
22
22
|
map = new GeonamesMap();
|
@@ -25,7 +25,10 @@ window.initLegacyMap = (options) => {
|
|
25
25
|
map = new DrawableMap();
|
26
26
|
map.init();
|
27
27
|
} else {
|
28
|
-
map = new DraggableMap(
|
28
|
+
map = new DraggableMap({
|
29
|
+
updateMapOnPropertiesLoadMore: updateMap,
|
30
|
+
dragWithoutUpdate: updateDragg,
|
31
|
+
});
|
29
32
|
map.init();
|
30
33
|
}
|
31
34
|
|
@@ -67,7 +70,9 @@ window.$ = () => ({
|
|
67
70
|
// )
|
68
71
|
// end
|
69
72
|
|
70
|
-
const PropertiesMap = ({
|
73
|
+
const PropertiesMap = ({
|
74
|
+
leaflet, gmapKey, googleLayer, legacyMapOptions, updateMapOnPropertiesLoadMore, dragWithoutUpdate
|
75
|
+
}) => {
|
71
76
|
const addLegacyMaps = () => {
|
72
77
|
const needsGoogle = !leaflet || googleLayer;
|
73
78
|
|
@@ -84,7 +89,7 @@ const PropertiesMap = ({ leaflet, gmapKey, googleLayer, legacyMapOptions }) => {
|
|
84
89
|
script.setAttribute('id', 'hfjs-legacy-maps');
|
85
90
|
script.setAttribute(
|
86
91
|
'onload',
|
87
|
-
`window.initLegacyMap(${legacyMapOptions ? JSON.stringify(legacyMapOptions) :
|
92
|
+
`window.initLegacyMap(${legacyMapOptions ? JSON.stringify(legacyMapOptions) : null}, ${updateMapOnPropertiesLoadMore}, ${dragWithoutUpdate})`,
|
88
93
|
);
|
89
94
|
document.head.appendChild(script);
|
90
95
|
} else {
|
@@ -108,6 +113,8 @@ PropertiesMap.propTypes = {
|
|
108
113
|
gmapKey: PropTypes.string,
|
109
114
|
leaflet: PropTypes.bool,
|
110
115
|
googleLayer: PropTypes.bool,
|
116
|
+
updateMapOnPropertiesLoadMore: PropTypes.bool,
|
117
|
+
dragWithoutUpdate: PropTypes.bool,
|
111
118
|
legacyMapOptions: PropTypes.shape({
|
112
119
|
disableHandlersOnInit: PropTypes.bool,
|
113
120
|
overlayText: PropTypes.string,
|
@@ -119,6 +126,8 @@ PropertiesMap.defaultProps = {
|
|
119
126
|
leaflet: false,
|
120
127
|
googleLayer: false,
|
121
128
|
legacyMapOptions: null,
|
129
|
+
updateMapOnPropertiesLoadMore: false,
|
130
|
+
dragWithoutUpdate: false,
|
122
131
|
};
|
123
132
|
|
124
133
|
const mapStateToProps = (state) => ({
|