homeflowjs 0.9.39 → 0.10.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-dispatch.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import store from '../store';
|
|
2
2
|
import {
|
|
3
|
+
setSearch,
|
|
3
4
|
setSearchField,
|
|
4
5
|
toggleTag,
|
|
5
6
|
} from '../actions/search.actions';
|
|
@@ -8,12 +9,12 @@ import { loadNext } from '../actions/properties.actions';
|
|
|
8
9
|
|
|
9
10
|
const hfDispatch = {
|
|
10
11
|
search: {
|
|
11
|
-
setSearch: payload => store.dispatch(setSearch(payload)),
|
|
12
|
-
setSearchField: payload => store.dispatch(setSearchField(payload)),
|
|
13
|
-
toggleTag: payload => store.dispatch(toggleTag(payload)),
|
|
12
|
+
setSearch: (payload) => store.dispatch(setSearch(payload)),
|
|
13
|
+
setSearchField: (payload) => store.dispatch(setSearchField(payload)),
|
|
14
|
+
toggleTag: (payload) => store.dispatch(toggleTag(payload)),
|
|
14
15
|
},
|
|
15
16
|
user: {
|
|
16
|
-
setCurrentUser: payload => store.dispatch(setCurrentUser(payload)),
|
|
17
|
+
setCurrentUser: (payload) => store.dispatch(setCurrentUser(payload)),
|
|
17
18
|
},
|
|
18
19
|
properties: {
|
|
19
20
|
loadNext: () => store.dispatch(loadNext()),
|
package/app/hf-initialize.jsx
CHANGED
|
@@ -8,6 +8,12 @@ import notify from './notify';
|
|
|
8
8
|
import antiCSRF from './anti-csrf';
|
|
9
9
|
import recaptcha from './recaptcha';
|
|
10
10
|
import bookingCalendar from '../booking-calendar/booking-calendar';
|
|
11
|
+
import { setThemePreferences, setThemeSettings, setAuthenticityToken } from '../actions/app.actions';
|
|
12
|
+
import { fetchUser } from '../actions/user.actions';
|
|
13
|
+
import {
|
|
14
|
+
setProperties, setPagination, setProperty, setPropertyLinksAsync,
|
|
15
|
+
} from '../actions/properties.actions';
|
|
16
|
+
import { setArticles } from '../actions/articles.actions';
|
|
11
17
|
|
|
12
18
|
const hfInitialize = () => {
|
|
13
19
|
if (!window.Homeflow) {
|
|
@@ -68,13 +74,32 @@ const hfInitialize = () => {
|
|
|
68
74
|
);
|
|
69
75
|
});
|
|
70
76
|
|
|
77
|
+
window.addEventListener('DOMContentLoaded', () => {
|
|
78
|
+
try {
|
|
79
|
+
store.dispatch(fetchUser());
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error('Unable to fetch user', e);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
store.dispatch(setProperty(Homeflow.get('property')));
|
|
86
|
+
store.dispatch(setProperties(Homeflow.get('properties')));
|
|
87
|
+
store.dispatch(setPagination(Homeflow.get('pagination')));
|
|
88
|
+
store.dispatch(setThemePreferences(Homeflow.get('theme_preferences')));
|
|
89
|
+
store.dispatch(setThemeSettings(Homeflow.get('theme_settings')));
|
|
90
|
+
store.dispatch(setAuthenticityToken(Homeflow.get('authenticityToken')));
|
|
91
|
+
|
|
92
|
+
// if we're on the property show page, set next and previous links
|
|
93
|
+
if (Homeflow.get('property')) {
|
|
94
|
+
store.dispatch(setPropertyLinksAsync());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// setting articles, pagination and topics on articles index page
|
|
98
|
+
if (Homeflow.get('articles')) {
|
|
99
|
+
store.dispatch(setArticles(Homeflow.get('articles')));
|
|
100
|
+
}
|
|
101
|
+
|
|
71
102
|
return null;
|
|
72
103
|
};
|
|
73
104
|
|
|
74
|
-
// buffer_height = @calcBufferHeight()
|
|
75
|
-
// cur_pos = $(window).scrollTop()
|
|
76
|
-
// $(".infinite_page").each(idx, element) =>
|
|
77
|
-
// ele_top = $(element).offset().top;
|
|
78
|
-
// @setPage(element) if ele_top <= cur_pos and ele_top + $(element).height() > cur_pos
|
|
79
|
-
|
|
80
105
|
export default hfInitialize;
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ const fragmentize = (key, value) => {
|
|
|
13
13
|
if (key === 'poly') return pattern[0] + base64.encode(value);
|
|
14
14
|
|
|
15
15
|
if (typeof pattern === 'string') return pattern;
|
|
16
|
+
|
|
16
17
|
return `${pattern[0] ? pattern[0] : ''}${value}${pattern[1] ? pattern[1] : ''}`;
|
|
17
18
|
};
|
|
18
19
|
|
|
@@ -20,25 +21,28 @@ export const buildQueryString = (search) => {
|
|
|
20
21
|
const queryParams = [];
|
|
21
22
|
const fragmentParams = [];
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
Object.keys(search).forEach((key) => {
|
|
24
25
|
const value = search[key];
|
|
25
26
|
|
|
26
|
-
if (!value)
|
|
27
|
-
|
|
27
|
+
if (!value) return;
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(value) && !value.length) return;
|
|
30
|
+
|
|
28
31
|
// only include either q or place ID
|
|
29
|
-
if (key === 'q' && !search.isQuerySearch
|
|
30
|
-
|| key === 'placeId' && search.isQuerySearch
|
|
31
|
-
|| key === 'place'
|
|
32
|
-
|| key === 'poly' && search.isQuerySearch)
|
|
32
|
+
if ((key === 'q' && !search.isQuerySearch)
|
|
33
|
+
|| (key === 'placeId' && search.isQuerySearch)
|
|
34
|
+
|| (key === 'place')
|
|
35
|
+
|| (key === 'poly' && search.isQuerySearch)) return;
|
|
33
36
|
|
|
34
37
|
// Don't include branch_id if a search term has been entered
|
|
35
|
-
if (key === 'branch_id' && search.isQuerySearch)
|
|
36
|
-
|
|
38
|
+
if (key === 'branch_id' && search.isQuerySearch) return;
|
|
39
|
+
|
|
40
|
+
if (!Object.prototype.hasOwnProperty.call(FRAGMENT_BOOKENDS, key)) {
|
|
37
41
|
queryParams.push(`${camelToSnakeCase(key)}=${value}`);
|
|
38
42
|
} else {
|
|
39
43
|
fragmentParams.push(fragmentize(key, value));
|
|
40
44
|
}
|
|
41
|
-
}
|
|
45
|
+
});
|
|
42
46
|
|
|
43
47
|
let queryString = queryParams.join('&');
|
|
44
48
|
queryString += `&fragment=${fragmentParams.join('/')}`;
|
|
@@ -97,7 +97,7 @@ class SearchForm extends Component {
|
|
|
97
97
|
<form onSubmit={this.handleSubmit.bind(this)} {...otherProps}>
|
|
98
98
|
{children}
|
|
99
99
|
</form>
|
|
100
|
-
)
|
|
100
|
+
);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -116,7 +116,12 @@ SearchForm.propTypes = {
|
|
|
116
116
|
submitCallback: PropTypes.func,
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
SearchForm.defaultProps = {
|
|
120
|
+
defaultSort: null,
|
|
121
|
+
submitCallback: null,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const mapStateToProps = (state) => ({
|
|
120
125
|
search: state.search.currentSearch,
|
|
121
126
|
defaultStatus: state.app.themePreferences.default_search_status,
|
|
122
127
|
});
|
package/store.js
CHANGED
|
@@ -1,54 +1,12 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
1
|
import { createStore, applyMiddleware } from 'redux';
|
|
3
2
|
import thunk from 'redux-thunk';
|
|
4
3
|
import { composeWithDevTools } from 'redux-devtools-extension/developmentOnly';
|
|
5
|
-
// import logger from 'redux-logger';
|
|
6
4
|
import rootReducer from './reducers';
|
|
7
|
-
import { setThemePreferences, setThemeSettings, setAuthenticityToken } from './actions/app.actions';
|
|
8
|
-
import { fetchUser } from './actions/user.actions';
|
|
9
|
-
import {
|
|
10
|
-
setProperties, setPagination, setProperty, setPropertyLinksAsync,
|
|
11
|
-
} from './actions/properties.actions';
|
|
12
|
-
import { setArticles } from './actions/articles.actions';
|
|
13
|
-
// import { fetchCompanyPreferences } from './actions/company-preferences.actions';
|
|
14
|
-
// import { fetchCompanyPreferences } from './actions/company-preferences.actions';
|
|
15
5
|
|
|
16
6
|
const middleware = [thunk];
|
|
17
7
|
|
|
18
|
-
// if (process.env.NODE_ENV !== 'production') {
|
|
19
|
-
// middleware.push(logger);
|
|
20
|
-
// }
|
|
21
|
-
|
|
22
8
|
const store = createStore(rootReducer, composeWithDevTools(
|
|
23
9
|
applyMiddleware(...middleware),
|
|
24
10
|
));
|
|
25
11
|
|
|
26
|
-
window.addEventListener('DOMContentLoaded', () => {
|
|
27
|
-
try {
|
|
28
|
-
store.dispatch(fetchUser());
|
|
29
|
-
} catch (e) {
|
|
30
|
-
console.error('Unable to fetch user', e);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// TODO: This should use data set inline for use setCompanyPreferences.
|
|
35
|
-
// store.dispatch(fetchCompanyPreferences());
|
|
36
|
-
|
|
37
|
-
store.dispatch(setProperty(Homeflow.get('property')));
|
|
38
|
-
store.dispatch(setProperties(Homeflow.get('properties')));
|
|
39
|
-
store.dispatch(setPagination(Homeflow.get('pagination')));
|
|
40
|
-
store.dispatch(setThemePreferences(Homeflow.get('theme_preferences')));
|
|
41
|
-
store.dispatch(setThemeSettings(Homeflow.get('theme_settings')));
|
|
42
|
-
store.dispatch(setAuthenticityToken(Homeflow.get('authenticityToken')));
|
|
43
|
-
|
|
44
|
-
// if we're on the property show page, set next and previous links
|
|
45
|
-
if (Homeflow.get('property')) {
|
|
46
|
-
store.dispatch(setPropertyLinksAsync());
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// setting articles, pagination and topics on articles index page
|
|
50
|
-
if (Homeflow.get('articles')) {
|
|
51
|
-
store.dispatch(setArticles(Homeflow.get('articles')));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
12
|
export default store;
|