From 6313495c41079657c8c6a14ec7af62569c1a0e52 Mon Sep 17 00:00:00 2001 From: Lorenzo Pini Date: Tue, 14 Feb 2017 16:06:00 +0100 Subject: [PATCH] Manage errors on featureType load --- .../components/data/query/QueryBuilder.jsx | 18 ++++++++++++------ .../data/query/__tests__/QueryBuilder-test.jsx | 18 ++++++++++++++++++ web/client/plugins/TOC.jsx | 5 ++++- web/client/translations/data.de-DE | 3 ++- web/client/translations/data.en-US | 3 ++- web/client/translations/data.fr-FR | 3 ++- web/client/translations/data.it-IT | 3 ++- 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/web/client/components/data/query/QueryBuilder.jsx b/web/client/components/data/query/QueryBuilder.jsx index 5cb3c190f3..6f8d9f6e21 100644 --- a/web/client/components/data/query/QueryBuilder.jsx +++ b/web/client/components/data/query/QueryBuilder.jsx @@ -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, @@ -56,6 +58,7 @@ const QueryBuilder = React.createClass({ groupFields: [], filterFields: [], attributes: [], + featureTypeError: "", spatialField: {}, removeButtonIcon: "glyphicon glyphicon-minus", addButtonIcon: "glyphicon glyphicon-plus", @@ -98,6 +101,12 @@ 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; @@ -105,13 +114,10 @@ const QueryBuilder = React.createClass({ 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 (
{this.props.featureTypeErrorText}
); + } return this.props.attributes.length > 0 ? (
{ 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(, + document.getElementById("container")); + + expect(querybuilder).toExist(); + expect(spy.calls.length).toEqual(1); + }); }); diff --git a/web/client/plugins/TOC.jsx b/web/client/plugins/TOC.jsx index 7611e27227..0fca906f74 100644 --- a/web/client/plugins/TOC.jsx +++ b/web/client/plugins/TOC.jsx @@ -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, @@ -237,7 +238,9 @@ const LayerTree = React.createClass({ renderQueryPanel() { return (
- + } + />
); }, render() { diff --git a/web/client/translations/data.de-DE b/web/client/translations/data.de-DE index d71442d506..19078712ba 100644 --- a/web/client/translations/data.de-DE +++ b/web/client/translations/data.de-DE @@ -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", diff --git a/web/client/translations/data.en-US b/web/client/translations/data.en-US index 10fc6318fa..e62b593c4d 100644 --- a/web/client/translations/data.en-US +++ b/web/client/translations/data.en-US @@ -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", diff --git a/web/client/translations/data.fr-FR b/web/client/translations/data.fr-FR index 0f703ec15f..f8c0eb1f0d 100644 --- a/web/client/translations/data.fr-FR +++ b/web/client/translations/data.fr-FR @@ -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", diff --git a/web/client/translations/data.it-IT b/web/client/translations/data.it-IT index 96c62662b7..62f7be2e25 100644 --- a/web/client/translations/data.it-IT +++ b/web/client/translations/data.it-IT @@ -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",