Skip to content

Commit

Permalink
Implemented Feature Editor Plugin (#2064)
Browse files Browse the repository at this point in the history
* Extended DrawSupport to edit existing Geometries (leaflet and OpenLayers). Fix #1819
* Replaces agGrid with react-data-grid (moved old to FeatureGrid_ag). Fix #1812
* Implementation of FeatureEditor plugin. Fix #1102 
* Added support for editing/drowing features. Fix #2038 
* Finalized support for WFST. Fix #1885

We should evaluate to:
 * Replace the hold grid example with the new grid
 * Hide unwanted tools in edit mode as in the [mockup](http://demo.geo-solutions.it/mockups/mapstore2/edit/000.html)

Other minor fixes: 
 * Opacity changes  does not refresh the whole layer now. Fix #2063
 * Now only a request is performed (2 only if a "wfs natural order missing primary key" error is detected). Fix #2043
  • Loading branch information
offtherailz authored Jul 31, 2017
1 parent 6cb59b3 commit a981157
Show file tree
Hide file tree
Showing 142 changed files with 6,343 additions and 1,383 deletions.
1 change: 1 addition & 0 deletions docma-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"web/client/components/notifications/NotificationContainer.jsx",
"web/client/components/buttons/ToggleButton.jsx",
"web/client/components/data/query/AutocompleteField.jsx",
"web/client/components/map/leaflet/DrawSupport.jsx",
"web/client/components/plugins/PluginsContainer.jsx",

"web/client/actions/index.jsdoc",
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"//": "replace react-sortable-items with official on npm when it will support React 15",
"dependencies": {
"@carnesen/redux-add-action-listener-enhancer": "0.0.1",
"@turf/bbox": "4.1.0",
"@turf/inside": "4.1.0",
"@turf/line-intersect": "4.1.0",
"@turf/polygon-to-linestring": "4.1.0",
Expand Down Expand Up @@ -160,6 +161,7 @@
"react-twitter-widgets": "1.3.0",
"react-widgets": "3.4.8",
"recharts": "0.22.4",
"recompose": "0.24.0",
"redux": "3.6.0",
"redux-logger": "2.6.1",
"redux-observable": "0.13.0",
Expand Down Expand Up @@ -188,6 +190,7 @@
"compile": "npm run clean && mkdirp ./web/client/dist && webpack --progress --config prod-webpack.config.js",
"analyze": "npm run clean && mkdirp ./web/client/dist && webpack --json | webpack-bundle-size-analyzer",
"start": "webpack-dev-server --progress --colors --port 8081 --hot --inline --content-base web/client",
"startprod": "webpack-dev-server --progress --colors --port 8081 --hot --inline --content-base web/client --config prod-webpack.config.js",
"examples": "webpack-dev-server --progress --colors --port 8081 --hot --inline --content-base web/client --config examples-webpack.config.js",
"test": "karma start ./karma.conf.single-run.js",
"pretest": "npm run cleandoc && npm run lint",
Expand Down
42 changes: 35 additions & 7 deletions web/client/actions/__tests__/draw-test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/**
* Copyright 2016, GeoSolutions Sas.
/*
* Copyright 2017, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
*/

const expect = require('expect');
const {
CHANGE_DRAWING_STATUS,
END_DRAWING,
changeDrawingStatus,
endDrawing
CHANGE_DRAWING_STATUS, changeDrawingStatus,
END_DRAWING, endDrawing,
geometryChanged, GEOMETRY_CHANGED,
drawStopped, DRAW_SUPPORT_STOPPED,
setCurrentStyle, SET_CURRENT_STYLE
} = require('../draw');

describe('Test correctness of the draw actions', () => {
Expand Down Expand Up @@ -43,4 +44,31 @@ describe('Test correctness of the draw actions', () => {
expect(retval.geometry).toBe("geometry");
expect(retval.owner).toBe("queryform");
});

it('Test geometryChanged action creator', () => {
const features = [{
geometry: {
type: "Point",
coordinates: []
}
}];

const retval = geometryChanged(features);

expect(retval).toExist();
expect(retval.type).toBe(GEOMETRY_CHANGED);
expect(retval.features).toExist();
expect(retval.features).toBe(features);
});
it('Test drawStopped action creator', () => {
const retval = drawStopped();
expect(retval).toExist();
expect(retval.type).toBe(DRAW_SUPPORT_STOPPED);
});
it('Test setCurrentStyle action creator', () => {
const retval = setCurrentStyle("somestyle");
expect(retval).toExist();
expect(retval.type).toBe(SET_CURRENT_STYLE);
expect(retval.currentStyle).toBe("somestyle");
});
});
168 changes: 162 additions & 6 deletions web/client/actions/__tests__/featuregrid-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,177 @@

const expect = require('expect');
const {
SELECT_FEATURES,
selectFeatures
SELECT_FEATURES, selectFeatures,
changePage, CHANGE_PAGE,
sort, SORT_BY,
setSelectionOptions, SET_SELECTION_OPTIONS,
MODES, TOGGLE_MODE, toggleEditMode, toggleViewMode,
featureModified, FEATURES_MODIFIED,
createNewFeatures, CREATE_NEW_FEATURE,
saveChanges, SAVE_CHANGES,
saveSuccess, SAVE_SUCCESS,
deleteFeatures, DELETE_SELECTED_FEATURES,
startEditingFeature, START_EDITING_FEATURE,
featureSaving, SAVING,
saveError, SAVE_ERROR,
clearChanges, CLEAR_CHANGES,
geometryChanged, GEOMETRY_CHANGED,
startDrawingFeature, START_DRAWING_FEATURE,
deleteGeometry, DELETE_GEOMETRY,
deleteGeometryFeature, DELETE_GEOMETRY_FEATURE,
clearChangeConfirmed, CLEAR_CHANGES_CONFIRMED,
deleteFeaturesConfirm, DELETE_SELECTED_FEATURES_CONFIRM,
closeFeatureGridConfirmed, FEATURE_GRID_CLOSE_CONFIRMED
} = require('../featuregrid');

const idFeature = "2135";
const feature = {
type: "Feature",
id: idFeature,
properties: {
name: "f.name"
},
geometry: {
type: "Point",
coordinates: [1, 2]
}
};
const features = [feature, feature];
const options = {editEnabled: true};
describe('Test correctness of featurgrid actions', () => {

it('Test deleteGeometryFeature action creator', () => {
const retval = deleteGeometryFeature(features);
expect(retval).toExist();
expect(retval.features).toExist();
expect(retval.features.length).toBe(features.length);
expect(retval.type).toBe(DELETE_GEOMETRY_FEATURE);
});
it('Test deleteGeometry action creator', () => {
const retval = deleteGeometry();
expect(retval).toExist();
expect(retval.type).toBe(DELETE_GEOMETRY);
});
it('Test closeFeatureGridConfirmed action creator', () => {
const retval = closeFeatureGridConfirmed();
expect(retval).toExist();
expect(retval.type).toBe(FEATURE_GRID_CLOSE_CONFIRMED);
});
it('Test clearChangeConfirmed action creator', () => {
const retval = clearChangeConfirmed();
expect(retval).toExist();
expect(retval.type).toBe(CLEAR_CHANGES_CONFIRMED);
});
it('Test startDrawingFeature action creator', () => {
const retval = startDrawingFeature();
expect(retval).toExist();
expect(retval.type).toBe(START_DRAWING_FEATURE);
});
it('Test geometryChanged action creator', () => {
const retval = geometryChanged([feature]);
expect(retval).toExist();
expect(retval.type).toBe(GEOMETRY_CHANGED);
expect(retval.features).toExist();
expect(retval.features[0].id).toBe(idFeature);
expect(retval.features.length).toBe(1);
});
it('Test selectFeature action creator', () => {
const features = [1, 2];
const someFeatures = [1, 2];
const retval = selectFeatures(someFeatures);
expect(retval).toExist();
expect(retval.type).toBe(SELECT_FEATURES);
expect(retval.features).toExist();
expect(retval.features).toBe(someFeatures);
});
it('Test changePage action creator', () => {
const retval = changePage(1, 2);
expect(retval).toExist();
expect(retval.type).toBe(CHANGE_PAGE);
expect(retval.page).toBe(1);
expect(retval.size).toBe(2);
});
it('Test sort action creator', () => {
const retval = sort("attr", "ASC");
expect(retval).toExist();
expect(retval.type).toBe(SORT_BY);
expect(retval.sortBy).toBe("attr");
expect(retval.sortOrder).toBe("ASC");
});
it('Test startEditingFeature', () => {
const retval = startEditingFeature(feature, options);
expect(retval).toExist();
expect(retval.type).toBe(START_EDITING_FEATURE);
});
it('Test setSelectionOptions', () => {
const retval = setSelectionOptions({multiselect: true});
expect(retval).toExist();
expect(retval.type).toBe(SET_SELECTION_OPTIONS);
expect(retval.multiselect).toExist();
expect(retval.multiselect).toBeTruthy();
});
it('Test toggleEditMode AND toggleViewMode', () => {
let retval = toggleEditMode();
expect(retval).toExist();
expect(retval.type).toBe(TOGGLE_MODE);
expect(retval.mode).toExist();
expect(retval.mode).toBe(MODES.EDIT);

const retval = selectFeatures(features);
retval = toggleViewMode();
expect(retval).toExist();
expect(retval.type).toBe(TOGGLE_MODE);
expect(retval.mode).toExist();
expect(retval.mode).toBe(MODES.VIEW);
});

it('Test featureModified', () => {
const retval = featureModified([feature, feature], true);
expect(retval).toExist();
expect(retval.type).toBe(SELECT_FEATURES);
expect(retval.type).toBe(FEATURES_MODIFIED);
expect(retval.features).toExist();
expect(retval.features).toBe(features);
expect(retval.features.length).toBe(2);
expect(retval.updated).toBeTruthy();
});
it('Test createNewFeatures', () => {
const retval = createNewFeatures(features);
expect(retval).toExist();
expect(retval.type).toBe(CREATE_NEW_FEATURE);
expect(retval.features).toExist();
expect(retval.features.length).toBe(2);
});
it('Test saveChanges', () => {
const retval = saveChanges();
expect(retval).toExist();
expect(retval.type).toBe(SAVE_CHANGES);
});
it('Test saveSuccess', () => {
const retval = saveSuccess();
expect(retval).toExist();
expect(retval.type).toBe(SAVE_SUCCESS);
});
it('Test deleteFeatures', () => {
const retval = deleteFeatures();
expect(retval).toExist();
expect(retval.type).toBe(DELETE_SELECTED_FEATURES);
});
it('Test featureSaving', () => {
const retval = featureSaving();
expect(retval).toExist();
expect(retval.type).toBe(SAVING);
});
it('Test clearChanges', () => {
const retval = clearChanges();
expect(retval).toExist();
expect(retval.type).toBe(CLEAR_CHANGES);
});
it('Test deleteFeaturesConfirm', () => {
const retval = deleteFeaturesConfirm();
expect(retval).toExist();
expect(retval.type).toBe(DELETE_SELECTED_FEATURES_CONFIRM);
});
it('Test saveError', () => {
const retval = saveError();
expect(retval).toExist();
expect(retval.type).toBe(SAVE_ERROR);
});

});
22 changes: 15 additions & 7 deletions web/client/actions/__tests__/highlight-test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/**
* Copyright 2016, GeoSolutions Sas.
/*
* Copyright 2017, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
*/

const expect = require('expect');
const {
HIGHLIGHT_STATUS,
UPDATE_HIGHLIGHTED,
highlightStatus,
updateHighlighted
HIGHLIGHT_STATUS, highlightStatus,
UPDATE_HIGHLIGHTED, updateHighlighted,
SET_HIGHLIGHT_FEATURES_PATH, setHighlightFeaturesPath
} = require('../highlight');

describe('Test correctness of the highlight actions', () => {
Expand All @@ -25,6 +24,15 @@ describe('Test correctness of the highlight actions', () => {
expect(retval.type).toBe(HIGHLIGHT_STATUS);
expect(retval.status).toBe("enabled");
});
it('highlightStatus', () => {
let path = "my.path";

let retval = setHighlightFeaturesPath(path);

expect(retval).toExist();
expect(retval.type).toBe(SET_HIGHLIGHT_FEATURES_PATH);
expect(retval.featuresPath).toBe(path);
});

it('updateHighlighted', () => {
let features = ["One", "Two"];
Expand Down
Loading

0 comments on commit a981157

Please sign in to comment.