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