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

Implemented Feature Editor Plugin #2064

Merged
merged 14 commits into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
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
4 changes: 4 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 @@ -131,6 +132,7 @@
"react-container-dimensions": "1.3.2",
"react-copy-to-clipboard": "5.0.0",
"react-data-grid": "2.0.41",
"react-data-grid-addons": "^2.0.49",
"react-dnd": "2.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ^

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove react-data-grid-addons at all. It is not used anymore.

"react-dnd-html5-backend": "2.4.1",
"react-dock": "0.2.4",
Expand Down Expand Up @@ -160,6 +162,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 +191,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,
clearAndClose, CLEAR_AND_CLOSE,
deleteFeaturesConfirm, DELETE_SELECTED_FEATURES_CONFIRM,
closeDialogAndDrawer, CLOSE_DIALOG_AND_DRAWER
} = 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 closeDialogAndDrawer action creator', () => {
const retval = closeDialogAndDrawer();
expect(retval).toExist();
expect(retval.type).toBe(CLOSE_DIALOG_AND_DRAWER);
});
it('Test clearAndClose action creator', () => {
const retval = clearAndClose();
expect(retval).toExist();
expect(retval.type).toBe(CLEAR_AND_CLOSE);
});
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);
});

});
104 changes: 104 additions & 0 deletions web/client/actions/__tests__/wfsquery-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* 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.
*/

var expect = require('expect');
var {
LAYER_SELECTED_FOR_SEARCH,
FEATURE_TYPE_SELECTED,
FEATURE_TYPE_ERROR,
FEATURE_LOADING,
FEATURE_LOADED,
FEATURE_ERROR,
QUERY_RESULT,
QUERY_ERROR,
QUERY_CREATE,
QUERY,
RESET_QUERY,
FEATURE_CLOSE,
layerSelectedForSearch,
featureTypeSelected,
featureTypeError,
featureLoading,
featureLoaded,
featureError,
querySearchResponse,
queryError,
createQuery,
query,
resetQuery,
featureClose
} = require('../wfsquery');

describe('wfsquery actions', () => {
it('layerSelectedForSearch', () => {
let {type, id} = layerSelectedForSearch(1);
expect(type).toBe(LAYER_SELECTED_FOR_SEARCH);
expect(id).toBe(1);
});
it('featureTypeSelected', () => {
let {type, url, typeName} = featureTypeSelected("/geoserver/", "topp:states");
expect(type).toBe(FEATURE_TYPE_SELECTED);
expect(url).toBe("/geoserver/");
expect(typeName).toBe("topp:states");
});
it('featureTypeError', () => {
let {type, error, typeName} = featureTypeError("topp:states", "ERROR");
expect(type).toBe(FEATURE_TYPE_ERROR);
expect(error).toBe("ERROR");
expect(typeName).toBe("topp:states");
});
it('featureLoading', () => {
let {type, isLoading} = featureLoading(true);
expect(type).toBe(FEATURE_LOADING);
expect(isLoading).toBe(true);
});
it('featureLoaded', () => {
let {type, typeName, feature} = featureLoaded("topp:states", "feature");
expect(type).toBe(FEATURE_LOADED);
expect(typeName).toBe("topp:states");
expect(feature).toBe(feature);
});
it('featureError', () => {
let {type, typeName, error} = featureError("topp:states", "ERROR");
expect(type).toBe(FEATURE_ERROR);
expect(typeName).toBe("topp:states");
expect(error).toBe("ERROR");
});
it('querySearchResponse', () => {
let {type, result, searchUrl, filterObj} = querySearchResponse("result", "searchUrl", "filterObj");
expect(type).toBe(QUERY_RESULT);
expect(result).toBe("result");
expect(searchUrl).toBe("searchUrl");
expect(filterObj).toBe("filterObj");
});
it('queryError', () => {
let {type, error} = queryError("ERROR");
expect(type).toBe(QUERY_ERROR);
expect(error).toBe("ERROR");
});
it('createQuery', () => {
let {type, searchUrl, filterObj} = createQuery("searchUrl", "filterObj");
expect(type).toBe(QUERY_CREATE);
expect(searchUrl).toBe("searchUrl");
expect(filterObj).toBe("filterObj");
});
it('query', () => {
let {type, searchUrl, filterObj} = query("searchUrl", "filterObj");
expect(type).toBe(QUERY);
expect(searchUrl).toBe("searchUrl");
expect(filterObj).toBe("filterObj");
});
it('resetQuery', () => {
let {type} = resetQuery();
expect(type).toBe(RESET_QUERY);
});
it('featureClose', () => {
let {type} = featureClose();
expect(type).toBe(FEATURE_CLOSE);
});
});
Loading