Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #2219 zoom to page #2419

Merged
merged 6 commits into from
Nov 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/client/components/data/featuregrid/toolbars/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const getSaveMessageId = ({saving, saved}) => {
return "featuregrid.toolbar.saveChanges";
};

module.exports = ({events = {}, mode = "VIEW", selectedCount, hasChanges, hasGeometry, hasNewFeatures, isSimpleGeom, isDrawing = false, isEditingAllowed, saving = false, saved = false, isDownloadOpen, isColumnsOpen, disableToolbar, isSearchAllowed, disableDownload, displayDownload, isSyncActive = false, hasSupportedGeometry = true} = {}) =>
module.exports = ({events = {}, mode = "VIEW", selectedCount, hasChanges, hasGeometry, hasNewFeatures, isSimpleGeom, isDrawing = false, isEditingAllowed, saving = false, saved = false, isDownloadOpen, isColumnsOpen, disableToolbar, isSearchAllowed, disableDownload, displayDownload, isSyncActive = false, hasSupportedGeometry = true, disableZoomAll = false} = {}) =>

(<ButtonGroup id="featuregrid-toolbar" className="featuregrid-toolbar featuregrid-toolbar-margin">
<TButton
Expand All @@ -36,7 +36,7 @@ module.exports = ({events = {}, mode = "VIEW", selectedCount, hasChanges, hasGeo
<TButton
id="zoom-all"
tooltip={<Message msgId="featuregrid.toolbar.zoomAll"/>}
disabled={disableToolbar}
disabled={disableToolbar || disableZoomAll}
visible={mode === "VIEW"}
onClick={events.zoomAll}
glyph="zoom-to"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,20 @@ describe('Featuregrid toolbar component', () => {
expect(isVisibleButton(document.getElementById("fg-save-feature"))).toBe(true);
expect(isVisibleButton(document.getElementById("fg-cancel-editing"))).toBe(true);
});

it('check zoom-all button if all features has no geom', () => {
const events = {
switchEditMode: () => {}
};
spyOn(events, "switchEditMode");
ReactDOM.render(<Toolbar events={events} mode="VIEW" disableZoomAll/>, document.getElementById("container"));
const el = document.getElementsByClassName("featuregrid-toolbar")[0];
expect(el).toExist();
let zoomAllButton = document.getElementById("fg-zoom-all");
expect(isVisibleButton(zoomAllButton)).toBe(true);
expect(el.children[2].disabled).toBe(true);
ReactDOM.render(<Toolbar events={events} mode="VIEW" disableZoomAll={false}/>, document.getElementById("container"));
zoomAllButton = document.getElementById("fg-zoom-all");
expect(el.children[2].disabled).toBe(false);
});
});
3 changes: 2 additions & 1 deletion web/client/plugins/featuregrid/panels/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {connect} = require('react-redux');
const {bindActionCreators} = require('redux');
const {createSelector, createStructuredSelector} = require('reselect');
const {wfsDownloadAvailable} = require('../../../selectors/controls');
const {paginationInfo, featureLoadingSelector, resultsSelector, isSyncWmsActive} = require('../../../selectors/query');
const {paginationInfo, featureLoadingSelector, resultsSelector, isSyncWmsActive, featureCollectionResultSelector} = require('../../../selectors/query');
const {getTitleSelector, modeSelector, selectedFeaturesCount, hasChangesSelector, hasGeometrySelector, isSimpleGeomSelector, hasNewFeaturesSelector, isSavingSelector, isSavedSelector, isDrawingSelector, canEditSelector, getAttributeFilter, hasSupportedGeometry, editingAllowedRolesSelector} = require('../../../selectors/featuregrid');
const {userRoleSelector} = require('../../../selectors/security');
const {isCesium} = require('../../../selectors/maptype');
Expand Down Expand Up @@ -43,6 +43,7 @@ const Toolbar = connect(
isDownloadOpen: state => state && state.controls && state.controls.wfsdownload && state.controls.wfsdownload.enabled,
isSyncActive: isSyncWmsActive,
isColumnsOpen: state => state && state.featuregrid && state.featuregrid.tools && state.featuregrid.tools.settings,
disableZoomAll: (state) => featureCollectionResultSelector(state).features.length === 0,
isSearchAllowed: (state) => !isCesium(state),
isEditingAllowed: (state) => (filterEditingAllowedUser(userRoleSelector(state), editingAllowedRolesSelector(state)) || canEditSelector(state)) && !isCesium(state),
hasSupportedGeometry
Expand Down
13 changes: 11 additions & 2 deletions web/client/selectors/__tests__/query-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,16 @@ const initialState = {
properties: {
name: 'vvvv'
}
},
{
type: 'Feature',
id: 'poligoni.8',
geometry: null,
geometry_name: 'geometry',
properties: {
name: 'no geom'
}
}
],
crs: {
type: 'name',
Expand Down Expand Up @@ -317,7 +326,7 @@ describe('Test query selectors', () => {
it('test resultsSelector selector', () => {
const res = resultsSelector(initialState);
expect(res).toExist();
expect(res.length).toBe(4);
expect(res.length).toBe(5);
});
it('test paginationInfo.startIndex selector', () => {
const startIndex = paginationInfo.startIndex(initialState);
Expand All @@ -329,7 +338,7 @@ describe('Test query selectors', () => {
});
it('test paginationInfo.resultSize selector', () => {
const featuresLength = paginationInfo.resultSize(initialState);
expect(featuresLength).toBe(4);
expect(featuresLength).toBe(5);
});
it('test paginationInfo.totalFeatures selector', () => {
const totalFeatures = paginationInfo.totalFeatures(initialState);
Expand Down
2 changes: 1 addition & 1 deletion web/client/selectors/__tests__/queryform-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const initialState = {
}
};

describe('Test query selectors', () => {
describe('Test queryform selectors', () => {
it(' 1) - spatialFieldSelector', () => {
const spatialfield = spatialFieldSelector(initialState);
expect(spatialfield).toExist();
Expand Down
10 changes: 8 additions & 2 deletions web/client/selectors/query.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
const {get, head} = require('lodash');
const {isNil, get, head} = require('lodash');
module.exports = {
wfsURL: state => state && state.query && state.query.searchUrl,
wfsURLSelector: state => state && state.query && state.query.url,
wfsFilter: state => state && state.query && state.query.filterObj,
attributesSelector: state => get(state, `query.featureTypes.${get(state, "query.filterObj.featureTypeName")}.attributes`),
typeNameSelector: state => get(state, "query.typeName"),
resultsSelector: (state) => get(state, "query.result.features"),
featureCollectionResultSelector: state => get(state, "query.result"),
featureCollectionResultSelector: state => {
const results = get(state, "query.result");
return {
...results,
features: (results && results.features || []).filter(f => !isNil(f.geometry))
};
},
getFeatureById: (state, id) => {
let features = state && state.query && state.query.result && state.query.result.features;
return head(features.filter(f => f.id === id));
Expand Down