homeflowjs 0.11.9 → 0.12.0
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/app/hf-initialize.jsx +36 -0
- package/package.json +1 -1
- package/properties/properties-map/draggable-map.js +64 -18
- package/reducers/search.reducer.js +1 -0
- package/search/property-search/constants.js +1 -0
- package/search/property-search/parse-fragment.js +5 -0
- package/search/property-search/property-search.js +2 -0
- package/search/search-form/search-form.component.jsx +0 -24
package/app/hf-initialize.jsx
CHANGED
@@ -14,7 +14,10 @@ import { fetchUser } from '../actions/user.actions';
|
|
14
14
|
import {
|
15
15
|
setProperties, setPagination, setProperty, setPropertyLinksAsync,
|
16
16
|
} from '../actions/properties.actions';
|
17
|
+
import { setSearch, setInitialSearch, setSearchField, setPlace } from '../actions/search.actions';
|
17
18
|
import { setArticles } from '../actions/articles.actions';
|
19
|
+
import parseFragment from '../search/property-search/parse-fragment';
|
20
|
+
import { isEmpty } from '../utils';
|
18
21
|
|
19
22
|
const hfInitialize = () => {
|
20
23
|
if (!window.Homeflow) {
|
@@ -102,6 +105,39 @@ const hfInitialize = () => {
|
|
102
105
|
store.dispatch(setArticles(Homeflow.get('articles')));
|
103
106
|
}
|
104
107
|
|
108
|
+
if (pageRoute === 'properties#index') {
|
109
|
+
const searchFromFragment = parseFragment(window.location.pathname);
|
110
|
+
const defaultStatus = store.getState().app.themePreferences.default_search_status;
|
111
|
+
|
112
|
+
if (!isEmpty(searchFromFragment)) {
|
113
|
+
if (defaultStatus && !searchFromFragment.status) {
|
114
|
+
searchFromFragment.status = defaultStatus;
|
115
|
+
}
|
116
|
+
|
117
|
+
const branchID = Homeflow.get('branch_id');
|
118
|
+
if (branchID) searchFromFragment.branch_id = branchID;
|
119
|
+
|
120
|
+
store.dispatch(setInitialSearch(searchFromFragment));
|
121
|
+
store.dispatch(setSearch(searchFromFragment));
|
122
|
+
} else {
|
123
|
+
if (defaultStatus && !search.status) store.dispatch(setSearchField({ status: defaultStatus }));
|
124
|
+
}
|
125
|
+
|
126
|
+
const place = Homeflow.get('place');
|
127
|
+
if (place) {
|
128
|
+
store.dispatch(setPlace(place));
|
129
|
+
store.dispatch(setInitialSearch({
|
130
|
+
q: place.name + (place.county_name ? `, ${place.county_name}` : ''),
|
131
|
+
place,
|
132
|
+
}));
|
133
|
+
}
|
134
|
+
const expandedPolygon = Homeflow.get('expanded_polygon');
|
135
|
+
if (expandedPolygon) {
|
136
|
+
store.dispatch(setSearchField({ expandedPolygon }));
|
137
|
+
store.dispatch(setInitialSearch({ expandedPolygon }));
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
105
141
|
return null;
|
106
142
|
};
|
107
143
|
|
package/package.json
CHANGED
@@ -58,7 +58,7 @@ export default class DraggableMap {
|
|
58
58
|
this.render();
|
59
59
|
this.buildPolygon();
|
60
60
|
this.setMarkers();
|
61
|
-
if (this.noLocationfound) { this.setToMarkeredBounds(); }
|
61
|
+
if (this.noLocationfound || Homeflow.get('breadcrumbs_map')) { this.setToMarkeredBounds(); }
|
62
62
|
if (Homeflow.get('custom_map_zoom') !== null) {
|
63
63
|
this.map.setZoom(Homeflow.get('custom_map_zoom'));
|
64
64
|
}
|
@@ -123,7 +123,10 @@ export default class DraggableMap {
|
|
123
123
|
}
|
124
124
|
|
125
125
|
generateMarker(property) {
|
126
|
-
const marker = L.marker(
|
126
|
+
const marker = L.marker(
|
127
|
+
[property.lat, property.lng],
|
128
|
+
{ title: property.name, icon: Homeflow.get('custom_property_pin')(property) }
|
129
|
+
);
|
127
130
|
|
128
131
|
// add the property to marker attributes so they can be accessed on click
|
129
132
|
marker.property = property;
|
@@ -139,7 +142,6 @@ export default class DraggableMap {
|
|
139
142
|
|
140
143
|
if (Homeflow.get('pop_up_on_mouseover')) {
|
141
144
|
marker.on("mouseover", e => marker.openPopup());
|
142
|
-
|
143
145
|
marker.on("mouseout", e => setTimeout((() => marker.closePopup()), 4000));
|
144
146
|
}
|
145
147
|
}
|
@@ -260,14 +262,16 @@ export default class DraggableMap {
|
|
260
262
|
|
261
263
|
if (!this.properties && !this.breadcrumbs) { return null }
|
262
264
|
|
263
|
-
|
264
|
-
|
265
|
+
|
266
|
+
if (this.isDisplayProperties()) {
|
267
|
+
this.properties?.map(property => this.setPropertyMarker(property));
|
268
|
+
} else {
|
269
|
+
this.breadcrumbs?.map(breadcrumb => this.setBreadcrumbMarker(breadcrumb));
|
270
|
+
}
|
271
|
+
|
265
272
|
this.clusteringMarkerLayer.addTo(this.map);
|
266
273
|
this.nonClusteringMarkerLayer.addTo(this.map);
|
267
274
|
|
268
|
-
// TODO: Combine bounds.
|
269
|
-
this.bounds = this.clusteringMarkerLayer.getBounds() || this.nonClusteringMarkerLayer.getBounds();
|
270
|
-
|
271
275
|
return this.bounds;
|
272
276
|
}
|
273
277
|
|
@@ -288,18 +292,60 @@ export default class DraggableMap {
|
|
288
292
|
}
|
289
293
|
|
290
294
|
setToMarkeredBounds() {
|
291
|
-
|
292
|
-
|
293
|
-
this.map.fitBounds(this.bounds, Homeflow.get('custom_map_bounds_padding'));
|
294
|
-
} else {
|
295
|
-
this.map.fitBounds(this.bounds);
|
296
|
-
}
|
295
|
+
const options = Homeflow.get('custom_map_bounds_padding');
|
296
|
+
const bounds = this.getMarkerBounds();
|
297
297
|
|
298
|
-
|
299
|
-
|
300
|
-
|
298
|
+
if (!bounds || !bounds.isValid()) return;
|
299
|
+
|
300
|
+
this.map.fitBounds(bounds, options);
|
301
|
+
|
302
|
+
if (Homeflow.get('custom_map_centre_lat') && Homeflow.get('custom_map_centre_lng')) {
|
303
|
+
this.map.setView([Homeflow.get('custom_map_centre_lat'), Homeflow.get('custom_map_centre_lng')], 7);
|
304
|
+
}
|
305
|
+
|
306
|
+
Homeflow.kickEvent('non_standard_zoom', this.map, 4);
|
307
|
+
}
|
301
308
|
|
302
|
-
|
309
|
+
getMarkerBounds() {
|
310
|
+
if (this.bounds && this.bounds.isValid()) {
|
311
|
+
return this.bounds;
|
312
|
+
} else {
|
313
|
+
const bounds = [this.getTopLeftMarkerCoordinates(), this.getBottomRightMarkerCoordinates()];
|
314
|
+
if (bounds.flat().find(coordinate => coordinate === Infinity)) return null;
|
315
|
+
|
316
|
+
return L.latLngBounds(...bounds.map(bound => L.latLng(...bound)));
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
getTopLeftMarkerCoordinates() {
|
321
|
+
return [
|
322
|
+
Math.min(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lat')),
|
323
|
+
Math.min(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lng'))
|
324
|
+
];
|
325
|
+
}
|
326
|
+
|
327
|
+
getBottomRightMarkerCoordinates() {
|
328
|
+
return [
|
329
|
+
Math.max(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lat')),
|
330
|
+
Math.max(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lng'))
|
331
|
+
];
|
332
|
+
}
|
333
|
+
|
334
|
+
parseCoordinateArray(items, coordinateType) {
|
335
|
+
if (!items) return [];
|
336
|
+
|
337
|
+
return items.filter(item => item).map(item => parseFloat(item[coordinateType])).filter(Number);
|
338
|
+
}
|
339
|
+
|
340
|
+
isDisplayProperties() {
|
341
|
+
const { properties: { pagination: { total_count: totalCount } } } = store.getState();
|
342
|
+
|
343
|
+
if (!this.breadcrumbs || !Homeflow.get('breadcrumbs_map')) {
|
344
|
+
return true;
|
345
|
+
} else if (this.properties && totalCount <= this.properties.length) {
|
346
|
+
return true;
|
347
|
+
} else {
|
348
|
+
return false;
|
303
349
|
}
|
304
350
|
}
|
305
351
|
|
@@ -41,6 +41,11 @@ export default (fragment) => {
|
|
41
41
|
return;
|
42
42
|
}
|
43
43
|
|
44
|
+
if (part.startsWith('auction-date-')) {
|
45
|
+
search.auctionDate = part.replace('auction-date-', '');
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
|
44
49
|
if (part.startsWith('gid-')) {
|
45
50
|
search.placeId = part.replace(/^gid-/, '');
|
46
51
|
return;
|
@@ -12,6 +12,8 @@ const fragmentize = (key, value) => {
|
|
12
12
|
|
13
13
|
if (key === 'poly') return pattern[0] + base64.encode(value);
|
14
14
|
|
15
|
+
if (key === 'auctionDate') return `${pattern}${value}`;
|
16
|
+
|
15
17
|
if (typeof pattern === 'string') return pattern;
|
16
18
|
|
17
19
|
return `${pattern[0] ? pattern[0] : ''}${value}${pattern[1] ? pattern[1] : ''}`;
|
@@ -26,32 +26,8 @@ class SearchForm extends Component {
|
|
26
26
|
if (defaultSort && !searchFromFragment.sorted) {
|
27
27
|
searchFromFragment.sorted = defaultSort;
|
28
28
|
}
|
29
|
-
if (defaultStatus && !searchFromFragment.status) {
|
30
|
-
searchFromFragment.status = defaultStatus;
|
31
|
-
}
|
32
|
-
|
33
|
-
const branchID = Homeflow.get('branch_id');
|
34
|
-
if (branchID) searchFromFragment.branch_id = branchID;
|
35
|
-
|
36
|
-
setInitialSearch(searchFromFragment);
|
37
|
-
setSearch(searchFromFragment);
|
38
29
|
} else {
|
39
30
|
if (defaultSort && !search.sorted) setSearchField({ sorted: defaultSort });
|
40
|
-
if (defaultStatus && !search.status) setSearchField({ status: defaultStatus });
|
41
|
-
}
|
42
|
-
|
43
|
-
const place = Homeflow.get('place');
|
44
|
-
if (place) {
|
45
|
-
setPlace(place);
|
46
|
-
setInitialSearch({
|
47
|
-
q: place.name + (place.county_name ? `, ${place.county_name}` : ''),
|
48
|
-
place,
|
49
|
-
});
|
50
|
-
}
|
51
|
-
const expandedPolygon = Homeflow.get('expanded_polygon');
|
52
|
-
if (expandedPolygon) {
|
53
|
-
setSearchField({ expandedPolygon });
|
54
|
-
setInitialSearch({ expandedPolygon });
|
55
31
|
}
|
56
32
|
|
57
33
|
if (defaultChannel) setSearchField({ channel: defaultChannel });
|