Skip to content

Commit

Permalink
Fixed geosolutions-it#2809. Moved utility function in the proper place (
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored and kappu committed Apr 26, 2018
1 parent c72ef02 commit 0ae1e3a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 17 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"istanbul-instrumenter-loader": "2.0.0",
"jsdoc": "https://github.com/geosolutions-it/jsdoc/tarball/fix_acorn_jsx",
"jsdoc-jsx": "0.1.0",
"json-loader": "0.5.4",
"karma": "1.5.0",
"karma-chrome-launcher": "2.0.0",
"karma-cli": "1.0.1",
Expand Down Expand Up @@ -219,4 +218,4 @@
},
"author": "GeoSolutions",
"license": "BSD-2-Clause"
}
}
2 changes: 1 addition & 1 deletion web/client/components/app/StandardApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class StandardApp extends React.Component {
onPersist: onInit.bind(null, config)
}, {
initialState: this.parseInitialState(config.initialState, {
mode: this.props.mode || ConfigUtils.getBrowserProperties().mobile ? 'mobile' : 'desktop'
mode: this.props.mode || (ConfigUtils.getBrowserProperties().mobile ? 'mobile' : 'desktop')
}) || {defaultState: {}, mobile: {}}
});
this.store = this.props.appStore(this.props.pluginsDef.plugins, opts);
Expand Down
24 changes: 24 additions & 0 deletions web/client/components/app/__tests__/StandardApp-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('StandardApp', () => {
it('creates a default app and reads initialState from localConfig', (done) => {
const store = (plugins, storeOpts) => {
expect(storeOpts.initialState.defaultState.test).toExist();
expect(storeOpts.initialState.defaultState.testMode).toBe('EXPRESSION_MODE_desktop');
done();
return {
dispatch() {
Expand All @@ -105,6 +106,29 @@ describe('StandardApp', () => {
const app = ReactDOM.render(<StandardApp appStore={store} storeOpts={storeOpts}/>, document.getElementById("container"));
expect(app).toExist();
});
it('creates a default app and reads initialState with mode', (done) => {
const store = (plugins, storeOpts) => {
expect(storeOpts.initialState.defaultState.testMode).toBe('EXPRESSION_MODE_TEST');
done();
return {
dispatch() {
}
};
};

const storeOpts = {
initialState: {
defaultState: {
test: "NOTHING"

},
mobile: {}
}
};
const app = ReactDOM.render(<StandardApp mode={'TEST'} appStore={store} storeOpts={storeOpts} />, document.getElementById("container"));
expect(app).toExist();
});


it('creates a default app and renders the given component', () => {
const store = () => ({
Expand Down
14 changes: 2 additions & 12 deletions web/client/observables/wfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,7 @@ const workaroundGEOS7233 = ({ totalFeatures, features, ...rest } = {}, { startIn
};

};
const getWFSFilterData = (filterObj) => {
let data;
if (typeof filterObj === 'string') {
data = filterObj;
} else {
data = filterObj.filterType === "OGC"
? FilterUtils.toOGCFilter(filterObj.featureTypeName, filterObj, filterObj.ogcVersion, filterObj.sortOptions, filterObj.hits)
: FilterUtils.toCQLFilter(filterObj);
}
return data;
};


const getPagination = (filterObj = {}, options = {}) =>
filterObj.pagination
Expand All @@ -100,7 +90,7 @@ const getPagination = (filterObj = {}, options = {}) =>
* @return {Observable} a stream that emits the GeoJSON or an error.
*/
const getJSONFeature = (searchUrl, filterObj, options = {}) => {
const data = getWFSFilterData(filterObj);
const data = FilterUtils.getWFSFilterData(filterObj);

const urlParsedObj = Url.parse(searchUrl, true);
let params = isObject(urlParsedObj.query) ? urlParsedObj.query : {};
Expand Down
2 changes: 0 additions & 2 deletions web/client/product/pages/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const PropTypes = require('prop-types');
*/
const React = require('react');

require("../assets/css/maps.css");

const {connect} = require('react-redux');

const url = require('url');
Expand Down
1 change: 1 addition & 0 deletions web/client/test-resources/localConfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"initialState": {
"defaultState": {
"testMode": "{'EXPRESSION_MODE_' + context.mode}",
"test": "test"
},
"mobile": {}
Expand Down
11 changes: 11 additions & 0 deletions web/client/utils/FilterUtils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,17 @@ const FilterUtils = {
ogcListField,
ogcBooleanField,
ogcStringField,
getWFSFilterData: (filterObj) => {
let data;
if (typeof filterObj === 'string') {
data = filterObj;
} else {
data = filterObj.filterType === "OGC"
? FilterUtils.toOGCFilter(filterObj.featureTypeName, filterObj, filterObj.ogcVersion, filterObj.sortOptions, filterObj.hits)
: FilterUtils.toCQLFilter(filterObj);
}
return data;
},
isLikeOrIlike: (operator) => operator === "ilike" || operator === "like",
isFilterValid: (f = {}) =>
(f.filterFields && f.filterFields.length > 0)
Expand Down

0 comments on commit 0ae1e3a

Please sign in to comment.