Skip to content

Commit

Permalink
Documentation for controls actions and reducers. Doc for Login plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Mar 22, 2017
1 parent 19a0656 commit 0fe9df8
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
5 changes: 4 additions & 1 deletion docma-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@

"web/client/actions/index.jsdoc",
"web/client/actions/search.js",
"web/client/actions/controls.js",

"web/client/reducers/index.jsdoc",
"web/client/reducers/search.js",
"web/client/reducers/controls.js",

"web/client/epics/index.jsdoc",
"web/client/epics/search.js",
Expand All @@ -128,7 +130,8 @@
"web/client/plugins/Search.jsx",
"web/client/plugins/BackgroundSwitcher.jsx",
"web/client/plugins/Map.jsx",
"web/client/plugins/Identify.jsx"
"web/client/plugins/Identify.jsx",
"web/client/plugins/Login.jsx"
]
},
"./docs/**/*md",
Expand Down
29 changes: 27 additions & 2 deletions web/client/actions/controls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
Expand All @@ -9,6 +9,13 @@ const TOGGLE_CONTROL = 'TOGGLE_CONTROL';
const SET_CONTROL_PROPERTY = 'SET_CONTROL_PROPERTY';
const RESET_CONTROLS = 'RESET_CONTROLS';

/**
* Toggle a control property
* @memberof actions.controls
* @param {string} control the name of the control
* @param {boolean|number|string|object} [property] the property to override
* @return {object} action of type `TOGGLE_CONTROL`, control, and property
*/
function toggleControl(control, property) {
return {
type: TOGGLE_CONTROL,
Expand All @@ -17,6 +24,15 @@ function toggleControl(control, property) {
};
}

/**
* Sets a property in a more detailed way
* @memberof actions.controls
* @param {string} control control name
* @param {string} property the property to set
* @param {string|number|boolean|object} value the value to set or to check for toggling
* @param {boolean} [toggle] if true, the reducer will toggle the property of the control only if is equal to the value parameter
* @return {object} of type `SET_CONTROL_PROPERTY` with control, property, value and toggle params
*/
function setControlProperty(control, property, value, toggle) {
return {
type: SET_CONTROL_PROPERTY,
Expand All @@ -27,11 +43,20 @@ function setControlProperty(control, property, value, toggle) {
};
}

/**
* reset all the controls
* @memberof actions.controls
* @return {object} action of type `RESET_CONTROLS`
*/
function resetControls() {
return {
type: RESET_CONTROLS
};
}

/**
* Actions for controls. Provide a simple generic functionality to toggle a generic
* control property.
* @name actions.controls
*/
module.exports = {TOGGLE_CONTROL, SET_CONTROL_PROPERTY, RESET_CONTROLS,
toggleControl, setControlProperty, resetControls};
17 changes: 15 additions & 2 deletions web/client/plugins/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
Expand All @@ -11,7 +11,20 @@ const assign = require('object-assign');
const {UserDetails, PasswordReset, UserMenu, Login, LoginNav } = require('./login/index');

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

/**
* Login Plugin. Allow to login/logout or show user info and reset password tools
* @class Login
* @memberof plugins
* @static
*
* @prop {string} cfg.id identifier of the Plugin, by default `"mapstore-login-menu"`
* @prop {object} cfg.menuStyle inline style for the menu, by defualt:
* ```
* menuStyle: {
* zIndex: 30
* }
*```
*/
const LoginTool = React.createClass({
propTypes: {
id: React.PropTypes.string,
Expand Down
40 changes: 38 additions & 2 deletions web/client/reducers/controls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
Expand All @@ -8,7 +8,43 @@

const {TOGGLE_CONTROL, SET_CONTROL_PROPERTY, RESET_CONTROLS} = require('../actions/controls');
const assign = require('object-assign');

/**
* Manages the state the controls in MapStore2
* The root elements of the state returned by this reducers ar variable, but they have
* this shape
* ```
* {
* [action.control]: {
* [action.property]: action.value
* }
* }
* }
* ```
* where:
* @prop {string} action.control identifier, used as key
* @prop {string} action.property the proeprty to set, by default enabled
* @prop {boolean|string|number|object} action.value the value of the action. If not present is a boolean that toggles
* @example
* {
* controls: {
* help: {
* enabled: false
* },
* print: {
* enabled: false
* },
* toolbar: {
* active: null,
* expanded: false
* },
* drawer: {
* enabled: false,
* menu: '1'
* }
* }
* }
* @memberof reducers
*/
function controls(state = {}, action) {
switch (action.type) {
case TOGGLE_CONTROL:
Expand Down
3 changes: 2 additions & 1 deletion web/client/reducers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function search(state = null, action) {
return assign({}, state, { results: null, error: null});
case TEXT_SEARCH_ADD_MARKER:
return assign({}, state, { markerPosition: action.markerPosition });
case TEXT_SEARCH_RESET: case RESET_CONTROLS:
case TEXT_SEARCH_RESET:
case RESET_CONTROLS:
return null;
case TEXT_SEARCH_NESTED_SERVICES_SELECTED:
return assign({}, state, {
Expand Down

0 comments on commit 0fe9df8

Please sign in to comment.