mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 14:47:56 +01:00
Fix eslint errors
This commit is contained in:
parent
5e8be48916
commit
c502a2f669
@ -13,6 +13,7 @@
|
|||||||
"no-underscore-dangle": "off",
|
"no-underscore-dangle": "off",
|
||||||
"no-plusplus": "off",
|
"no-plusplus": "off",
|
||||||
"no-param-reassign": "off",
|
"no-param-reassign": "off",
|
||||||
|
"max-len": [1,250],
|
||||||
"class-methods-use-this": "off",
|
"class-methods-use-this": "off",
|
||||||
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["!cypress/**/*.js"]}]
|
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["!cypress/**/*.js"]}]
|
||||||
},
|
},
|
||||||
|
@ -90,8 +90,6 @@ class Relationship extends ConnectionLine {
|
|||||||
targetPosition = Shape.workoutIncomingConnectionPoint(targetTopic, sourcePosition);
|
targetPosition = Shape.workoutIncomingConnectionPoint(targetTopic, sourcePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sPos;
|
|
||||||
let tPos;
|
|
||||||
this._line2d.setStroke(2);
|
this._line2d.setStroke(2);
|
||||||
const ctrlPoints = this._line2d.getControlPoints();
|
const ctrlPoints = this._line2d.getControlPoints();
|
||||||
if (!this._line2d.isDestControlPointCustom() && !this._line2d.isSrcControlPointCustom()) {
|
if (!this._line2d.isDestControlPointCustom() && !this._line2d.isSrcControlPointCustom()) {
|
||||||
@ -114,8 +112,8 @@ class Relationship extends ConnectionLine {
|
|||||||
tpoint.x = parseInt(ctrlPoints[1].x, 10) + parseInt(targetPosition.x, 10);
|
tpoint.x = parseInt(ctrlPoints[1].x, 10) + parseInt(targetPosition.x, 10);
|
||||||
tpoint.y = parseInt(ctrlPoints[1].y, 10) + parseInt(targetPosition.y, 10);
|
tpoint.y = parseInt(ctrlPoints[1].y, 10) + parseInt(targetPosition.y, 10);
|
||||||
|
|
||||||
sPos = Shape.calculateRelationShipPointCoordinates(sourceTopic, spoint);
|
const sPos = Shape.calculateRelationShipPointCoordinates(sourceTopic, spoint);
|
||||||
tPos = Shape.calculateRelationShipPointCoordinates(targetTopic, tpoint);
|
const tPos = Shape.calculateRelationShipPointCoordinates(targetTopic, tpoint);
|
||||||
|
|
||||||
line2d.setFrom(sPos.x, sPos.y);
|
line2d.setFrom(sPos.x, sPos.y);
|
||||||
line2d.setTo(tPos.x, tPos.y);
|
line2d.setTo(tPos.x, tPos.y);
|
||||||
|
@ -27,7 +27,6 @@ import DragTopicCommand from './commands/DragTopicCommand';
|
|||||||
import GenericFunctionCommand from './commands/GenericFunctionCommand';
|
import GenericFunctionCommand from './commands/GenericFunctionCommand';
|
||||||
import MoveControlPointCommand from './commands/MoveControlPointCommand';
|
import MoveControlPointCommand from './commands/MoveControlPointCommand';
|
||||||
import ChangeFeatureToTopicCommand from './commands/ChangeFeatureToTopicCommand';
|
import ChangeFeatureToTopicCommand from './commands/ChangeFeatureToTopicCommand';
|
||||||
import NodeModel from './model/NodeModel';
|
|
||||||
import EventBus from './layout/EventBus';
|
import EventBus from './layout/EventBus';
|
||||||
|
|
||||||
class StandaloneActionDispatcher extends ActionDispatcher {
|
class StandaloneActionDispatcher extends ActionDispatcher {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { $assert, $defined } from '@wisemapping/core-js';
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import Command from '../Command';
|
import Command from '../Command';
|
||||||
|
|
||||||
class AddRelationshipCommand extends Command {
|
class AddRelationshipCommand extends Command {
|
||||||
|
@ -30,7 +30,7 @@ class AddTopicCommand extends Command {
|
|||||||
*/
|
*/
|
||||||
constructor(models, parentTopicsId) {
|
constructor(models, parentTopicsId) {
|
||||||
$assert(models, 'models can not be null');
|
$assert(models, 'models can not be null');
|
||||||
$assert(parentTopicsId == null || parentTopicsId.length == models.length, 'parents and models must have the same size');
|
$assert(parentTopicsId == null || parentTopicsId.length === models.length, 'parents and models must have the same size');
|
||||||
|
|
||||||
super();
|
super();
|
||||||
this._models = models;
|
this._models = models;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable class-methods-use-this */
|
/* eslint-disable no-nested-ternary */
|
||||||
|
/* eslint-disable max-len */
|
||||||
/*
|
/*
|
||||||
* Copyright [2015] [wisemapping]
|
* Copyright [2015] [wisemapping]
|
||||||
*
|
*
|
||||||
@ -36,10 +37,10 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const limitXPos = parent.getPosition().x
|
const limitXPos = parent.getPosition().x
|
||||||
+ direction
|
+ direction
|
||||||
* (parent.getSize().width / 2
|
* (parent.getSize().width / 2
|
||||||
+ node.getSize().width / 2
|
+ node.getSize().width / 2
|
||||||
+ BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
|
+ BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
const xPos = direction > 0
|
const xPos = direction > 0
|
||||||
? position.x >= limitXPos
|
? position.x >= limitXPos
|
||||||
@ -67,8 +68,8 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
);
|
);
|
||||||
const siblings = graph.getSiblings(node);
|
const siblings = graph.getSiblings(node);
|
||||||
|
|
||||||
const sameParent = parent == graph.getParent(node);
|
const sameParent = parent === graph.getParent(node);
|
||||||
if (siblings.length == 0 && nodeDirection == positionDirection && sameParent) {
|
if (siblings.length === 0 && nodeDirection === positionDirection && sameParent) {
|
||||||
return [node.getOrder(), node.getPosition()];
|
return [node.getOrder(), node.getPosition()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,21 +87,21 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
: right.length - left.length > 0
|
: right.length - left.length > 0
|
||||||
? 1
|
? 1
|
||||||
: 0;
|
: 0;
|
||||||
const direction = order % 2 == 0 ? 1 : -1;
|
const direction = order % 2 === 0 ? 1 : -1;
|
||||||
|
|
||||||
// Exclude the dragged node (if set)
|
// Exclude the dragged node (if set)
|
||||||
const children = this._getChildrenForOrder(parent, graph, order).filter((child) => child !== node);
|
const children = this._getChildrenForOrder(parent, graph, order).filter((child) => child !== node);
|
||||||
|
|
||||||
// No children?
|
// No children?
|
||||||
if (children.length == 0) {
|
if (children.length === 0) {
|
||||||
return [
|
return [
|
||||||
order,
|
order,
|
||||||
{
|
{
|
||||||
x:
|
x:
|
||||||
parent.getPosition().x
|
parent.getPosition().x
|
||||||
+ direction
|
+ direction
|
||||||
* (parent.getSize().width / 2
|
* (parent.getSize().width / 2
|
||||||
+ BalancedSorter.INTERNODE_HORIZONTAL_PADDING * 2),
|
+ BalancedSorter.INTERNODE_HORIZONTAL_PADDING * 2),
|
||||||
y: parent.getPosition().y,
|
y: parent.getPosition().y,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -113,7 +114,7 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
children.forEach((child, index) => {
|
children.forEach((child, index) => {
|
||||||
const cpos = child.getPosition();
|
const cpos = child.getPosition();
|
||||||
if (position.y > cpos.y) {
|
if (position.y > cpos.y) {
|
||||||
const yOffset = child == last
|
const yOffset = child === last
|
||||||
? child.getSize().height + BalancedSorter.INTERNODE_VERTICAL_PADDING * 2
|
? child.getSize().height + BalancedSorter.INTERNODE_VERTICAL_PADDING * 2
|
||||||
: (children[index + 1].getPosition().y - child.getPosition().y) / 2;
|
: (children[index + 1].getPosition().y - child.getPosition().y) / 2;
|
||||||
result = [child.getOrder() + 2, { x: cpos.x, y: cpos.y + yOffset }];
|
result = [child.getOrder() + 2, { x: cpos.x, y: cpos.y + yOffset }];
|
||||||
@ -128,9 +129,9 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
{
|
{
|
||||||
x: first.getPosition().x,
|
x: first.getPosition().x,
|
||||||
y:
|
y:
|
||||||
first.getPosition().y
|
first.getPosition().y
|
||||||
- first.getSize().height
|
- first.getSize().height
|
||||||
- BalancedSorter.INTERNODE_VERTICAL_PADDING * 2,
|
- BalancedSorter.INTERNODE_VERTICAL_PADDING * 2,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -148,7 +149,7 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
const children = this._getChildrenForOrder(parent, treeSet, order);
|
const children = this._getChildrenForOrder(parent, treeSet, order);
|
||||||
|
|
||||||
// If no children, return 0 or 1 depending on the side
|
// If no children, return 0 or 1 depending on the side
|
||||||
if (children.length == 0) {
|
if (children.length === 0) {
|
||||||
child.setOrder(order % 2);
|
child.setOrder(order % 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -183,7 +184,7 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
child.setOrder(child.getOrder() - 2);
|
child.setOrder(child.getOrder() - 2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
node.setOrder(node.getOrder() % 2 == 0 ? 0 : 1);
|
node.setOrder(node.getOrder() % 2 === 0 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,15 +200,12 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
|
|
||||||
// Compute heights ...
|
// Compute heights ...
|
||||||
const heights = children
|
const heights = children
|
||||||
.map(function (child) {
|
.map((child) => ({
|
||||||
return {
|
id: child.getId(),
|
||||||
id: child.getId(),
|
order: child.getOrder(),
|
||||||
order: child.getOrder(),
|
width: child.getSize().width,
|
||||||
width: child.getSize().width,
|
height: this._computeChildrenHeight(treeSet, child),
|
||||||
height: this._computeChildrenHeight(treeSet, child),
|
})).reverse();
|
||||||
};
|
|
||||||
}, this)
|
|
||||||
.reverse();
|
|
||||||
|
|
||||||
// Compute the center of the branch ...
|
// Compute the center of the branch ...
|
||||||
let totalPHeight = 0;
|
let totalPHeight = 0;
|
||||||
@ -239,12 +237,12 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
|
|
||||||
const yOffset = ysum + heights[i].height / 2;
|
const yOffset = ysum + heights[i].height / 2;
|
||||||
const xOffset = direction
|
const xOffset = direction
|
||||||
* (node.getSize().width / 2
|
* (node.getSize().width / 2
|
||||||
+ heights[i].width / 2
|
+ heights[i].width / 2
|
||||||
+ +BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
|
+ +BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
$assert(!isNaN(xOffset), 'xOffset can not be null');
|
$assert(!Number.isNaN(xOffset), 'xOffset can not be null');
|
||||||
$assert(!isNaN(yOffset), 'yOffset can not be null');
|
$assert(!Number.isNaN(yOffset), 'yOffset can not be null');
|
||||||
|
|
||||||
result[heights[i].id] = { x: xOffset, y: yOffset };
|
result[heights[i].id] = { x: xOffset, y: yOffset };
|
||||||
}
|
}
|
||||||
@ -262,11 +260,11 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
|
|
||||||
// All odd ordered nodes should be "continuous" by themselves
|
// All odd ordered nodes should be "continuous" by themselves
|
||||||
// All even numbered nodes should be "continuous" by themselves
|
// All even numbered nodes should be "continuous" by themselves
|
||||||
const factor = node.getOrder() % 2 == 0 ? 2 : 1;
|
const factor = node.getOrder() % 2 === 0 ? 2 : 1;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const order = i == 0 && factor == 1 ? 1 : factor * i;
|
const order = i === 0 && factor === 1 ? 1 : factor * i;
|
||||||
$assert(
|
$assert(
|
||||||
children[i].getOrder() == order,
|
children[i].getOrder() === order,
|
||||||
`Missing order elements. Missing order: ${i * factor
|
`Missing order elements. Missing order: ${i * factor
|
||||||
}. Parent:${node.getId()
|
}. Parent:${node.getId()
|
||||||
},Node:${children[i].getId()}`,
|
},Node:${children[i].getId()}`,
|
||||||
@ -280,7 +278,7 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
* @return the direction of the child within the treeSet
|
* @return the direction of the child within the treeSet
|
||||||
*/
|
*/
|
||||||
getChildDirection(treeSet, child) {
|
getChildDirection(treeSet, child) {
|
||||||
return child.getOrder() % 2 == 0 ? 1 : -1;
|
return child.getOrder() % 2 === 0 ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-unused-vars */
|
||||||
/* eslint-disable class-methods-use-this */
|
/* eslint-disable class-methods-use-this */
|
||||||
/*
|
/*
|
||||||
* Copyright [2015] [wisemapping]
|
* Copyright [2015] [wisemapping]
|
||||||
@ -16,11 +17,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
class ChildrenSorterStrategy {/** @lends ChildrenSorterStrategy */
|
class ChildrenSorterStrategy {
|
||||||
/**
|
|
||||||
* @constructs
|
|
||||||
*/
|
|
||||||
/** @abstract */
|
|
||||||
computeChildrenIdByHeights(treeSet, node) {
|
computeChildrenIdByHeights(treeSet, node) {
|
||||||
throw new Error('Method must be implemented');
|
throw new Error('Method must be implemented');
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class EventBusDispatcher {
|
|||||||
|
|
||||||
_nodeAdded(node) {
|
_nodeAdded(node) {
|
||||||
// Central topic must not be added twice ...
|
// Central topic must not be added twice ...
|
||||||
if (node.getId() != 0) {
|
if (node.getId() !== 0) {
|
||||||
this._layoutManager.addNode(node.getId(), { width: 10, height: 10 }, node.getPosition());
|
this._layoutManager.addNode(node.getId(), { width: 10, height: 10 }, node.getPosition());
|
||||||
this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken());
|
this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken());
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ class SymmetricSorter extends AbstractBasicSorter {
|
|||||||
+ node.getSize().width / 2
|
+ node.getSize().width / 2
|
||||||
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-nested-ternary
|
||||||
const xPos = direction > 0
|
const xPos = direction > 0
|
||||||
? position.x >= limitXPos
|
? position.x >= limitXPos
|
||||||
? position.x
|
? position.x
|
||||||
@ -88,7 +89,7 @@ class SymmetricSorter extends AbstractBasicSorter {
|
|||||||
|
|
||||||
// node has no siblings and its trying to reconnect to its own parent
|
// node has no siblings and its trying to reconnect to its own parent
|
||||||
const sameParent = parent === graph.getParent(node);
|
const sameParent = parent === graph.getParent(node);
|
||||||
if (siblings.length == 0 && nodeDirection == positionDirection && sameParent) {
|
if (siblings.length === 0 && nodeDirection === positionDirection && sameParent) {
|
||||||
return [node.getOrder(), node.getPosition()];
|
return [node.getOrder(), node.getPosition()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +270,7 @@ class SymmetricSorter extends AbstractBasicSorter {
|
|||||||
const children = this._getSortedChildren(treeSet, node);
|
const children = this._getSortedChildren(treeSet, node);
|
||||||
|
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
$assert(children[i].getOrder() == i, 'missing order elements');
|
$assert(children[i].getOrder() === i, 'missing order elements');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +284,7 @@ class SymmetricSorter extends AbstractBasicSorter {
|
|||||||
|
|
||||||
let result;
|
let result;
|
||||||
const rootNode = treeSet.getRootNode(child);
|
const rootNode = treeSet.getRootNode(child);
|
||||||
if (treeSet.getParent(child) == rootNode) {
|
if (treeSet.getParent(child) === rootNode) {
|
||||||
// This is the case of a isolated child ... In this case, the directions is based on the root.
|
// This is the case of a isolated child ... In this case, the directions is based on the root.
|
||||||
result = Math.sign(rootNode.getPosition().x);
|
result = Math.sign(rootNode.getPosition().x);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user