Skip to content

Commit

Permalink
Manage errors on featureType load
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnafu committed Feb 14, 2017
1 parent 4bf72d4 commit 6313495
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 11 deletions.
18 changes: 12 additions & 6 deletions web/client/components/data/query/QueryBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const QueryBuilder = React.createClass({
featureTypeConfigUrl: React.PropTypes.string,
useMapProjection: React.PropTypes.bool,
attributes: React.PropTypes.array,
featureTypeError: React.PropTypes.string,
featureTypeErrorText: React.PropTypes.node,
groupLevels: React.PropTypes.number,
filterFields: React.PropTypes.array,
groupFields: React.PropTypes.array,
Expand Down Expand Up @@ -56,6 +58,7 @@ const QueryBuilder = React.createClass({
groupFields: [],
filterFields: [],
attributes: [],
featureTypeError: "",
spatialField: {},
removeButtonIcon: "glyphicon glyphicon-minus",
addButtonIcon: "glyphicon glyphicon-plus",
Expand Down Expand Up @@ -98,20 +101,23 @@ const QueryBuilder = React.createClass({
}
};
},
componentDidMount() {
if (this.props.featureTypeConfigUrl && this.props.attributes.length < 1) {
this.props.attributeFilterActions.onLoadFeatureTypeConfig(
this.props.featureTypeConfigUrl, this.props.params);
}
},
componentWillReceiveProps(props) {
let url = props.featureTypeConfigUrl;
let params = props.params !== this.props.params ? props.params : this.props.params;
if (url !== this.props.featureTypeConfigUrl) {
this.props.attributeFilterActions.onLoadFeatureTypeConfig(url, params);
}
},
componentDidMount() {
if (this.props.featureTypeConfigUrl && this.props.attributes.length < 1) {
this.props.attributeFilterActions.onLoadFeatureTypeConfig(
this.props.featureTypeConfigUrl, this.props.params);
}
},
render() {
if (this.props.featureTypeError !== "") {
return (<div style={{margin: "0 auto", "text-align": "center"}}>{this.props.featureTypeErrorText}</div>);
}
return this.props.attributes.length > 0 ? (
<div id="queryFormPanel">
<QueryToolbar
Expand Down
18 changes: 18 additions & 0 deletions web/client/components/data/query/__tests__/QueryBuilder-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,22 @@ describe('QueryBuilder', () => {
let childNodes = queryBuilderDOMNode.actual.childNodes;
expect(childNodes.length).toBe(2);
});

it('creates the QueryBuilder component in error state', () => {

let attributeFilterActions = {
onLoadFeatureTypeConfig: () => {}
};
let spy = expect.spyOn(attributeFilterActions, 'onLoadFeatureTypeConfig');

const querybuilder = ReactDOM.render(<QueryBuilder
featureTypeError={"true"}
featureTypeErrorText={"bla bla"}
attributeFilterActions={attributeFilterActions}
featureTypeConfigUrl={"randomurl"} />,
document.getElementById("container"));

expect(querybuilder).toExist();
expect(spy.calls.length).toEqual(1);
});
});
5 changes: 4 additions & 1 deletion web/client/plugins/TOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const SmartQueryForm = connect((state) => {
groupFields: state.queryform.groupFields,
filterFields: state.queryform.filterFields,
attributes: state.query && state.query.typeName && state.query.featureTypes && state.query.featureTypes[state.query.typeName] && state.query.featureTypes[state.query.typeName].attributes,
featureTypeError: state.query && state.query.typeName && state.query.featureTypes && state.query.featureTypes[state.query.typeName] && state.query.featureTypes[state.query.typeName].error,
spatialField: state.queryform.spatialField,
showDetailsPanel: state.queryform.showDetailsPanel,
toolbarEnabled: state.queryform.toolbarEnabled,
Expand Down Expand Up @@ -237,7 +238,9 @@ const LayerTree = React.createClass({
renderQueryPanel() {
return (<div>
<Button id="query-close-button" bsStyle="primary" key="menu-button" className="square-button" onClick={this.props.onToggleQuery.bind(this, null, null)}><Glyphicon glyph="arrow-left"/></Button>
<SmartQueryForm/>
<SmartQueryForm
featureTypeErrorText={<Message msgId="layerProperties.featureTypeError"/>}
/>
</div>);
},
render() {
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.de-DE
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"delete": "Löschen",
"deleteLayer":"Ebene löschen",
"deleteLayerMessage": "Möchtest du wirklich diese Ebene löschen?",
"confirmDelete": "Bist du sicher?"
"confirmDelete": "Bist du sicher?",
"featureTypeError": "Layerattribute können nicht geladen werden"
},
"background": "Hintergrund",
"language": "Sprache",
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.en-US
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"delete": "Delete",
"deleteLayer":"Delete Layer",
"deleteLayerMessage": "Do you really want to delete this Layer?",
"confirmDelete": "Are you sure?"
"confirmDelete": "Are you sure?",
"featureTypeError": "Cannot load layer attributes"
},
"background": "Background",
"language": "Language",
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.fr-FR
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"delete": "Effacer",
"deleteLayer":"Supprimer le calque",
"deleteLayerMessage": "Voulez-vous vraiment supprimer cette couche?",
"confirmDelete": "Êtes-vous sûr?"
"confirmDelete": "Êtes-vous sûr?",
"featureTypeError": "Impossible de charger les attributs de calque"
},
"enable": "Activer",
"background": "Fond de plan",
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.it-IT
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"delete": "Elimina",
"deleteLayer":"Elimina Livello",
"deleteLayerMessage": "Sei sicuro di voler eliminare questo livello?",
"confirmDelete": "Sei sicuro?"
"confirmDelete": "Sei sicuro?",
"featureTypeError": "Impossibile caricare gli attributi del layer"
},
"background": "Sfondo",
"language": "Lingua",
Expand Down

0 comments on commit 6313495

Please sign in to comment.