Skip to content

Commit

Permalink
Add documentation for selectors and plugins (#1798)
Browse files Browse the repository at this point in the history
This is a porting of the documentation developed wrote durin the work on 3d.
* Search
* Zoom In
* ZoomOut 
* ScaleBox
* Locate
* CoordinateUtils.
  • Loading branch information
offtherailz authored May 9, 2017
1 parent c10dcf4 commit e34ad2a
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 17 deletions.
7 changes: 6 additions & 1 deletion docma-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
"web/client/epics/search.js",

"web/client/utils/index.jsdoc",
"web/client/utils/CoordinatesUtils.js",
"web/client/utils/PluginsUtils.js",
"web/client/utils/ShareUtils.js"
],
Expand All @@ -150,9 +151,13 @@
"web/client/plugins/MeasureResults.jsx",
"web/client/plugins/FullScreen.jsx",
"web/client/plugins/Identify.jsx",
"web/client/plugins/Locate.jsx",
"web/client/plugins/Login.jsx",
"web/client/plugins/ScaleBox.jsx",
"web/client/plugins/ScrollTop.jsx",
"web/client/plugins/Search.jsx"
"web/client/plugins/Search.jsx",
"web/client/plugins/ZoomIn.jsx",
"web/client/plugins/ZoomOut.jsx"
]
},
"./docs/**/*md",
Expand Down
5 changes: 5 additions & 0 deletions web/client/epics/index.jsdoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
* @see {@link https://redux-observable.js.org/docs/basics/Epics.html|the redux-observable documentation} for details
* @name epics
*/
/**
* @external Observable
* @description A RxJS Observable
* @see {@link http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html|Observable}
*/
2 changes: 1 addition & 1 deletion web/client/plugins/DrawerMenu.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
Expand Down
15 changes: 14 additions & 1 deletion web/client/plugins/Locate.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
Expand All @@ -16,6 +16,19 @@ const {Glyphicon} = require('react-bootstrap');

const assign = require('object-assign');

/**
* Locate Plugin. Provides button to locate the user's position on the map.
* By deafault it will follow the user until he moves the map. He can click again to
* restore the following mode.
* @class Locate
* @memberof plugins
* @static
*
* @prop {string} cfg.style CSS to apply to the button
* @prop {string} cfg.text The button text, if any
* @prop {string} cfg.className the class name for the button
*
*/
const LocatePlugin = connect((state) => ({
locate: state.locate && state.locate.state || 'DISABLED'
}), {
Expand Down
14 changes: 13 additions & 1 deletion web/client/plugins/ScaleBox.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
Expand Down Expand Up @@ -30,6 +30,18 @@ const selector = createSelector([mapSelector], (map) => ({

require('./scalebox/scalebox.css');

/**
* ScaleBox Plugin. Provides a selector for the scale of the map.
* @class ScaleBox
* @memberof plugins
* @static
*
* @prop {object} cfg.style CSS to apply to the scalebox
* @prop {Boolean} cfg.readOnly the selector is readonly
* @prop {string} cfg.label label for the selector
* @prop {Boolean} cfg.useRawInput set true if you want to use an normal html input object
*
*/
const ScaleBoxPlugin = React.createClass({
render() {
return (<HelpWrapper id="mapstore-scalebox-container"
Expand Down
10 changes: 10 additions & 0 deletions web/client/plugins/ZoomIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ const {changeZoomLevel} = require('../actions/map');

const Message = require('../components/I18N/Message');

/**
* ZoomIn Plugin. Provides button to zoom in
* @class ZoomIn
* @memberof plugins
* @static
*
* @prop {object} cfg.style CSS to apply to the button
* @prop {string} cfg.className the class name for the button
*
*/
const ZoomInButton = connect(selector, {
onZoom: changeZoomLevel
})(require('../components/buttons/ZoomButton'));
Expand Down
15 changes: 11 additions & 4 deletions web/client/plugins/ZoomOut.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/**
/*
* Copyright 2016, 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.
*/
/**
* Plugin for Zoom out
*/
const React = require('react');
const {connect} = require('react-redux');
const {createSelector} = require('reselect');
Expand All @@ -19,6 +16,16 @@ const {changeZoomLevel} = require('../actions/map');

const Message = require('../components/I18N/Message');

/**
* ZoomOut Plugin. Provides button to zoom out
* @class ZoomOut
* @memberof plugins
* @static
*
* @prop {object} cfg.style CSS to apply to the button
* @prop {string} cfg.className the class name for the button
*
*/
const ZoomOutButton = connect(selector, {
onZoom: changeZoomLevel
})(require('../components/buttons/ZoomButton'));
Expand Down
11 changes: 11 additions & 0 deletions web/client/selectors/index.jsdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* React/Redux selectors.
* @see {@link https://github.com/reactjs/reselect|Reselect} for details
* @name selectors
*
*/
/**
* @external selector
* @see {@link https://github.com/reactjs/reselect|Reselect} for details
* @description A function that computes the redux state or part of it allowing the redux store to be normalized and the react components to be re-rendered only if needed.
*/
17 changes: 15 additions & 2 deletions web/client/selectors/map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
Expand All @@ -10,11 +10,24 @@ const CoordinatesUtils = require('../utils/CoordinatesUtils');
const MapUtils = require('../utils/MapUtils');
const {createSelector} = require('reselect');

/**
* get the current map configuration from state
* @function
* @memberof selectors.map
* @param {object} state the state
* @return {object} the map configruation
*/
const mapSelector = (state) => (state.map && state.map.present) || (state.map) || (state.config && state.config.map) || null;

const projectionSelector = createSelector([mapSelector], (map) => map && map.projection);


/**
* Get the scales of the current map
* @function
* @memberof selectors.map
* @param {object} state the state
* @return {number[]} the scales of the map
*/
const scalesSelector = createSelector(
[projectionSelector],
(projection) => {
Expand Down
10 changes: 6 additions & 4 deletions web/client/utils/CoordinatesUtils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/**
/*
* Copyright 2015, 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 Proj4js = require('proj4');
const proj4 = Proj4js;
const assign = require('object-assign');
Expand Down Expand Up @@ -48,7 +49,10 @@ function determineCrs(crs) {
}
return crs;
}

/**
* Utilities for Coordinates conversion.
* @memberof utils
*/
const CoordinatesUtils = {
getUnits: function(projection) {
const proj = new Proj4js.Proj(projection);
Expand Down Expand Up @@ -126,11 +130,9 @@ const CoordinatesUtils = {
},
/**
* Reprojects a bounding box.
*
* @param bbox {array} [minx, miny, maxx, maxy]
* @param source {string} SRS of the given bbox
* @param dest {string} SRS of the returned bbox
*
* @return {array} [minx, miny, maxx, maxy]
*/
reprojectBbox: function(bbox, source, dest, normalize = true) {
Expand Down
1 change: 0 additions & 1 deletion web/client/utils/PluginsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ const defaultEpicWrapper = epic => (...args) =>
});
/**
* Utilities to manage plugins
* @class
* @memberof utils
*/
const PluginsUtils = {
Expand Down
3 changes: 1 addition & 2 deletions web/client/utils/ShareUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
const Url = require('url');

/**
* Utility functions for Share tools
* Utility functions for Share tools.
* @memberof utils
* @type {Object}
*/
var ShareUtils = {
/**
Expand Down

0 comments on commit e34ad2a

Please sign in to comment.