homeflowjs 0.11.10 → 0.12.1

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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.11.10",
3
+ "version": "0.12.1",
4
4
  "description": "JavaScript toolkit for Homeflow themes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -125,7 +125,7 @@ export default class DraggableMap {
125
125
  generateMarker(property) {
126
126
  const marker = L.marker(
127
127
  [property.lat, property.lng],
128
- { title: property.name, icon: Homeflow.get('custom_property_pin')(property) }
128
+ { title: property.name, icon: this.generateMarkerIcon(property) }
129
129
  );
130
130
 
131
131
  // add the property to marker attributes so they can be accessed on click
@@ -10,6 +10,7 @@ const INITIAL_STATE = {
10
10
  suggestions: [],
11
11
  tags: [],
12
12
  poly: '',
13
+ auctionDate: '',
13
14
  },
14
15
  initialSearch: {}, // original search when the page first loads
15
16
  savedSearches: [],
@@ -21,4 +21,5 @@ export const FRAGMENT_BOOKENDS = {
21
21
  shortLets: 'short-lets',
22
22
  tags: ['tag-'],
23
23
  sorted: '',
24
+ auctionDate: 'auction-date-',
24
25
  };
@@ -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 });