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

Added infinite nesting to TOC #1388

Merged
merged 5 commits into from
Jan 24, 2017
Merged

Conversation

kappu72
Copy link
Contributor

@kappu72 kappu72 commented Jan 19, 2017

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 80.338% when pulling b760841 on kappu72:nestedGroup into a56dc1a on geosolutions-it:master.

Copy link
Contributor

@mbarto mbarto left a comment

Choose a reason for hiding this comment

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

How do we handle group id assignment?
Is it working for current configurations?

let getGroupVisibility = (nodes) => {
let visibility = true;
let visibility = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this refactor is correct. The group visibility is true only if every node is visible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -9,21 +9,41 @@
const assign = require('object-assign');
const {isObject, isArray} = require('lodash');

const getGroup = (groupId, groups) => {
return groups.filter((subGroup) => isObject(subGroup) && subGroup.id === groupId).pop();
Copy link
Contributor

Choose a reason for hiding this comment

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

use lodash head to get first element of array, not pop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The id is autogenerated and is the same then before, are name and title that change.

@@ -204,7 +149,29 @@ function layers(state = [], action) {
});
let originalNode = head(flatLayers.filter((layer) => { return (layer[selector] === action.node || layer[selector].indexOf(action.node + '.') === 0); }));
if (!sameGroup && originalNode ) {
let newGroups = moveNode(state.groups, action.node, (action.options.group || 'Default'));
// Remove layers from old group
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove moveNode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 80.323% when pulling b4f5bd2 on kappu72:nestedGroup into a56dc1a on geosolutions-it:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 80.413% when pulling b4f5bd2 on kappu72:nestedGroup into a56dc1a on geosolutions-it:master.

@@ -0,0 +1,25 @@
/**
* Copyright 2016, GeoSolutions Sas.
Copy link
Member

Choose a reason for hiding this comment

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

2017

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -31,7 +31,7 @@ const GroupTitle = React.createClass({
let expanded = (this.props.node.expanded !== undefined) ? this.props.node.expanded : true;
let groupTitle = this.props.node && this.props.node.title || 'Default';
return (
<div className="toc-group-title" onClick={() => this.props.onClick(this.props.node.name, expanded)} style={this.props.style}>
<div className="toc-group-title" onClick={() => this.props.onClick(this.props.node.id, expanded)} style={this.props.style}>
Copy link
Member

Choose a reason for hiding this comment

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

Is the id mandatory now?

Copy link
Contributor Author

@kappu72 kappu72 Jan 23, 2017

Choose a reason for hiding this comment

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

Yes, group id is mandatory, but is autogenerated in LayersUtils.getLayersByGroup

const getNode = (nodes, name) => {
if (nodes && isArray(nodes)) {
return nodes.reduce((previous, node) => {
if (previous) {
return previous;
}
if (node && node.name === name) {
if (node && (node.name === name || node.id === name)) {
Copy link
Member

Choose a reason for hiding this comment

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

rename name parameter as id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

group = head(LayersUtils.getLayersByGroup([getNode(newLayers, node)]));
// check for parent group if exist
const parentGroup = groupId.split('.').reduce((tree, gName, idx) => {
const gId = groupId.split(".", idx + 1).join('.');
Copy link
Member

@offtherailz offtherailz Jan 20, 2017

Choose a reason for hiding this comment

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

parentId is more meaningful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

parentGroup is the object parentGroup.id is the parentId

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 80.427% when pulling 074a5c8 on kappu72:nestedGroup into a56dc1a on geosolutions-it:master.

@offtherailz
Copy link
Member

Should we use / instead of . as a separator for groups? Does it make sense?
As a plus we should allow to escape the group separator somehow

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 80.545% when pulling 84732ae on kappu72:nestedGroup into a56dc1a on geosolutions-it:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 80.538% when pulling 3b8d584 on kappu72:nestedGroup into a56dc1a on geosolutions-it:master.

@mbarto mbarto merged commit d92f27e into geosolutions-it:master Jan 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants