Remove underscore library

This commit is contained in:
Paulo Gustavo Veiga 2021-12-05 08:14:15 -08:00
parent e07c13631c
commit aecf0864f5
30 changed files with 213 additions and 280 deletions

View File

@ -17,7 +17,6 @@
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import $ from '@libraries/jquery-2.1.0'; import $ from '@libraries/jquery-2.1.0';
import _ from '@libraries/underscore-min';
import Events from './Events'; import Events from './Events';
import Messages from './Messages'; import Messages from './Messages';
@ -146,7 +145,7 @@ class Designer extends Events {
screenManager.addEvent('update', () => { screenManager.addEvent('update', () => {
// Topic must be set to his original state. All editors must be closed. // Topic must be set to his original state. All editors must be closed.
const topics = me.getModel().getTopics(); const topics = me.getModel().getTopics();
_.each(topics, (object) => { topics.forEach((object) => {
object.closeEditors(); object.closeEditors();
}); });
@ -304,13 +303,13 @@ class Designer extends Events {
onObjectFocusEvent(currentObject, event) { onObjectFocusEvent(currentObject, event) {
// Close node editors .. // Close node editors ..
const topics = this.getModel().getTopics(); const topics = this.getModel().getTopics();
_.each(topics, (topic) => { topics.forEach((topic) => {
topic.closeEditors(); topic.closeEditors();
}); });
const model = this.getModel(); const model = this.getModel();
const objects = model.getEntities(); const objects = model.getEntities();
_.each(objects, (object) => { objects.forEach((object) => {
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed // Disable all nodes on focus but not the current if Ctrl key isn't being pressed
if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) { if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) {
if (object.isOnFocus() && object !== currentObject) { if (object.isOnFocus() && object !== currentObject) {
@ -324,7 +323,7 @@ class Designer extends Events {
selectAll() { selectAll() {
const model = this.getModel(); const model = this.getModel();
const objects = model.getEntities(); const objects = model.getEntities();
_.each(objects, (object) => { objects.forEach((object) => {
object.setOnFocus(true); object.setOnFocus(true);
}); });
} }
@ -332,7 +331,7 @@ class Designer extends Events {
/** removes focus from all model entities, i.e. relationships and topics */ /** removes focus from all model entities, i.e. relationships and topics */
deselectAll() { deselectAll() {
const objects = this.getModel().getEntities(); const objects = this.getModel().getEntities();
_.each(objects, (object) => { objects.forEach((object) => {
object.setOnFocus(false); object.setOnFocus(false);
}); });
} }

View File

@ -15,7 +15,6 @@
* 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 _ from '@libraries/underscore-min';
class Events { class Events {
constructor() { constructor() {
@ -38,15 +37,16 @@ class Events {
type = Events._removeOn(type); type = Events._removeOn(type);
const events = this.$events[type]; const events = this.$events[type];
if (!events) return this; if (!events) return this;
args = Array.isArray(args) ? args : [args]; args = Array.isArray(args) ? args : [args];
_.each( events.forEach(((fn) => {
events, if (delay) {
function (fn) { fn.delay(delay, this, args);
if (delay) fn.delay(delay, this, args); }
else fn.apply(this, args); else {
}, fn.apply(this, args);
this, }
); }).bind(this));
return this; return this;
} }

View File

@ -100,16 +100,14 @@ const IconGroup = new Class(
_findIconFromModel(iconModel) { _findIconFromModel(iconModel) {
let result = null; let result = null;
_.each(
this._icons, this._icons.forEach((icon) => {
(icon) => { const elModel = icon.getModel();
const elModel = icon.getModel();
if (elModel.getId() == iconModel.getId()) { if (elModel.getId() === iconModel.getId()) {
result = icon; result = icon;
} }
}, });
this,
);
if (result == null) { if (result == null) {
throw new Error(`Icon can no be found:${iconModel.getId()}, Icons:${this._icons}`); throw new Error(`Icon can no be found:${iconModel.getId()}, Icons:${this._icons}`);
@ -135,8 +133,9 @@ const IconGroup = new Class(
this._icons.erase(icon); this._icons.erase(icon);
this._resize(this._icons.length); this._resize(this._icons.length);
const me = this; const me = this;
// Add all again ... // Add all again ...
_.each(this._icons, (elem, i) => { this._icons.forEach((elem, i) => {
me._positionIcon(elem, i); me._positionIcon(elem, i);
}); });
}, },

View File

@ -70,7 +70,7 @@ class RelationshipPivot {
// Register focus events on all topics ... // Register focus events on all topics ...
const model = this._designer.getModel(); const model = this._designer.getModel();
const topics = model.getTopics(); const topics = model.getTopics();
_.each(topics, (topic) => { topics.forEach((topic) => {
topic.addEvent('ontfocus', this._onTopicClick); topic.addEvent('ontfocus', this._onTopicClick);
}); });
} }
@ -85,10 +85,10 @@ class RelationshipPivot {
const model = this._designer.getModel(); const model = this._designer.getModel();
const topics = model.getTopics(); const topics = model.getTopics();
const me = this;
_.each(topics, (topic) => { topics.forEach(((topic) => {
topic.removeEvent('ontfocus', me._onTopicClick); topic.removeEvent('ontfocus', this._onTopicClick);
}); }).bind(this));
workspace.removeChild(this._pivot); workspace.removeChild(this._pivot);
workspace.removeChild(this._startArrow); workspace.removeChild(this._startArrow);

View File

@ -56,7 +56,7 @@ class ScreenManager {
fireEvent(type, event) { fireEvent(type, event) {
if (type === 'click') { if (type === 'click') {
_.each(this._clickEvents, (listener) => { this._clickEvents.forEach((listener) => {
listener(type, event); listener(type, event);
}); });
} else { } else {

View File

@ -16,7 +16,6 @@
* limitations under the License. * limitations under the License.
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import { _ } from '@libraries/underscore-min';
import * as web2d from '@wisemapping/web2d'; import * as web2d from '@wisemapping/web2d';
import NodeGraph from './NodeGraph'; import NodeGraph from './NodeGraph';
@ -961,7 +960,7 @@ class Topic extends NodeGraph {
} }
_setRelationshipLinesVisibility(value) { _setRelationshipLinesVisibility(value) {
_.each(this._relationships, (relationship) => { this._relationships.forEach((relationship) => {
const sourceTopic = relationship.getSourceTopic(); const sourceTopic = relationship.getSourceTopic();
const targetTopic = relationship.getTargetTopic(); const targetTopic = relationship.getTargetTopic();

View File

@ -41,7 +41,7 @@ class AddTopicCommand extends Command {
*/ */
execute(commandContext) { execute(commandContext) {
const me = this; const me = this;
_.each(this._models, (model, index) => { this._models.forEach((model, index) => {
// Add a new topic ... // Add a new topic ...
const topic = commandContext.createTopic(model); const topic = commandContext.createTopic(model);
@ -73,12 +73,12 @@ class AddTopicCommand extends Command {
undoExecute(commandContext) { undoExecute(commandContext) {
// Delete disconnected the nodes. Create a copy of the topics ... // Delete disconnected the nodes. Create a copy of the topics ...
const clonedModel = []; const clonedModel = [];
_.each(this._models, (model) => { this._models.forEach((model) => {
clonedModel.push(model.clone()); clonedModel.push(model.clone());
}); });
// Finally, remove the nodes ... // Finally, remove the nodes ...
_.each(this._models, (model) => { this._models.forEach((model) => {
const topicId = model.getId(); const topicId = model.getId();
const topic = commandContext.findTopics(topicId)[0]; const topic = commandContext.findTopics(topicId)[0];
commandContext.deleteTopic(topic); commandContext.deleteTopic(topic);

View File

@ -44,7 +44,7 @@ class DeleteCommand extends Command {
const topics = this._filterChildren(this._topicIds, commandContext); const topics = this._filterChildren(this._topicIds, commandContext);
if (topics.length > 0) { if (topics.length > 0) {
_.each(topics, function (topic) { topics.forEach(((topic) => {
// In case that it's editing text node, force close without update ... // In case that it's editing text node, force close without update ...
topic.closeEditors(); topic.closeEditors();
@ -54,7 +54,7 @@ class DeleteCommand extends Command {
const relationships = this._collectInDepthRelationships(topic); const relationships = this._collectInDepthRelationships(topic);
this._deletedRelModel.append(relationships.map((rel) => rel.getModel().clone())); this._deletedRelModel.append(relationships.map((rel) => rel.getModel().clone()));
_.each(relationships, (relationship) => { relationships.forEach((relationship) => {
commandContext.deleteRelationship(relationship); commandContext.deleteRelationship(relationship);
}); });
@ -70,15 +70,15 @@ class DeleteCommand extends Command {
// Finally, delete the topic from the workspace... // Finally, delete the topic from the workspace...
commandContext.deleteTopic(topic); commandContext.deleteTopic(topic);
}, this); }));
} }
const rels = commandContext.findRelationships(this._relIds); const rels = commandContext.findRelationships(this._relIds);
if (rels.length > 0) { if (rels.length > 0) {
_.each(rels, function (rel) { rels.forEach(((rel) => {
this._deletedRelModel.push(rel.getModel().clone()); this._deletedRelModel.push(rel.getModel().clone());
commandContext.deleteRelationship(rel); commandContext.deleteRelationship(rel);
}, this); }).bind(this));
} }
} }
@ -88,12 +88,12 @@ class DeleteCommand extends Command {
*/ */
undoExecute(commandContext) { undoExecute(commandContext) {
// Add all the topics ... // Add all the topics ...
_.each(this._deletedTopicModels, (model) => { this._deletedTopicModels.forEach((model) => {
commandContext.createTopic(model); commandContext.createTopic(model);
}, this); });
// Do they need to be connected ? // Do they need to be connected ?
_.each(this._deletedTopicModels, function (topicModel, index) { this._deletedTopicModels.forEach(((topicModel, index) => {
const topics = commandContext.findTopics(topicModel.getId()); const topics = commandContext.findTopics(topicModel.getId());
const parentId = this._parentTopicIds[index]; const parentId = this._parentTopicIds[index];
@ -101,18 +101,18 @@ class DeleteCommand extends Command {
const parentTopics = commandContext.findTopics(parentId); const parentTopics = commandContext.findTopics(parentId);
commandContext.connect(topics[0], parentTopics[0]); commandContext.connect(topics[0], parentTopics[0]);
} }
}, this); }).bind(this));
// Add rebuild relationships ... // Add rebuild relationships ...
_.each(this._deletedRelModel, (model) => { this._deletedRelModel.forEach((model) => {
commandContext.addRelationship(model); commandContext.addRelationship(model);
}); });
// Finally display the topics ... // Finally display the topics ...
_.each(this._deletedTopicModels, (topicModel) => { this._deletedTopicModels.forEach((topicModel) => {
const topics = commandContext.findTopics(topicModel.getId()); const topics = commandContext.findTopics(topicModel.getId());
topics[0].setBranchVisibility(true); topics[0].setBranchVisibility(true);
}, this); });
// Focus on last recovered topic .. // Focus on last recovered topic ..
if (this._deletedTopicModels.length > 0) { if (this._deletedTopicModels.length > 0) {
@ -130,7 +130,7 @@ class DeleteCommand extends Command {
const topics = commandContext.findTopics(topicIds); const topics = commandContext.findTopics(topicIds);
const result = []; const result = [];
_.each(topics, (topic) => { topics.forEach((topic) => {
let parent = topic.getParent(); let parent = topic.getParent();
let found = false; let found = false;
while (parent != null && !found) { while (parent != null && !found) {
@ -172,7 +172,6 @@ class DeleteCommand extends Command {
} }
return result; return result;
} }
} }
export default DeleteCommand; export default DeleteCommand;

View File

@ -16,7 +16,6 @@
* limitations under the License. * limitations under the License.
*/ */
import { $defined, $assert } from '@wisemapping/core-js'; import { $defined, $assert } from '@wisemapping/core-js';
import _ from '@libraries/underscore-min';
import Command from '../Command'; import Command from '../Command';
class GenericFunctionCommand extends Command { class GenericFunctionCommand extends Command {
@ -62,14 +61,14 @@ class GenericFunctionCommand extends Command {
if (topics != null) { if (topics != null) {
const me = this; const me = this;
_.each(topics, (topic) => { topics.forEach((topic) => {
const oldValue = me._commandFunc(topic, me._value); const oldValue = me._commandFunc(topic, me._value);
me._oldValues.push(oldValue); me._oldValues.push(oldValue);
}); });
} }
this.applied = true; this.applied = true;
} else { } else {
throw 'Command can not be applied two times in a row.'; throw new Error('Command can not be applied two times in a row.');
} }
} }
@ -80,10 +79,10 @@ class GenericFunctionCommand extends Command {
undoExecute(commandContext) { undoExecute(commandContext) {
if (this.applied) { if (this.applied) {
const topics = commandContext.findTopics(this._topicsId); const topics = commandContext.findTopics(this._topicsId);
const me = this;
_.each(topics, (topic, index) => { topics.forEach( ((topic, index) => {
me._commandFunc(topic, me._oldValues[index]); this._commandFunc(topic, this._oldValues[index]);
}); }).bind(this));
this.applied = false; this.applied = false;
this._oldValues = []; this._oldValues = [];

View File

@ -15,7 +15,6 @@
* 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 _ from '@libraries/underscore-min';
import ChildrenSorterStrategy from './ChildrenSorterStrategy'; import ChildrenSorterStrategy from './ChildrenSorterStrategy';
/** /**
@ -50,13 +49,10 @@ const AbstractBasicSorter = new Class(
result = height; result = height;
} else { } else {
let childrenHeight = 0; let childrenHeight = 0;
_.each(
children, children.forEach(((child) => {
function (child) { childrenHeight += this._computeChildrenHeight(treeSet, child, heightCache);
childrenHeight += this._computeChildrenHeight(treeSet, child, heightCache); }));
},
this,
);
result = Math.max(height, childrenHeight); result = Math.max(height, childrenHeight);
} }

View File

@ -15,7 +15,6 @@
* 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 _ from '@libraries/underscore-min';
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import AbstractBasicSorter from './AbstractBasicSorter'; import AbstractBasicSorter from './AbstractBasicSorter';
@ -26,7 +25,7 @@ const BalancedSorter = new Class(
* @constructs * @constructs
* @extends mindplot.layout.AbstractBasicSorter * @extends mindplot.layout.AbstractBasicSorter
*/ */
initialize() {}, initialize() { },
/** /**
* @param {} graph * @param {} graph
@ -52,10 +51,10 @@ const BalancedSorter = new Class(
); );
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
@ -112,10 +111,10 @@ const BalancedSorter = new Class(
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,
}, },
]; ];
@ -125,7 +124,7 @@ const BalancedSorter = new Class(
let result = null; let result = null;
const last = children.getLast(); const last = children.getLast();
position = position || { x: last.getPosition().x, y: last.getPosition().y + 1 }; position = position || { x: last.getPosition().x, y: last.getPosition().y + 1 };
_.each(children, (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
@ -143,9 +142,9 @@ const BalancedSorter = new Class(
{ {
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,
}, },
]; ];
} }
@ -193,7 +192,7 @@ const BalancedSorter = new Class(
// Filter nodes on one side.. // Filter nodes on one side..
const children = this._getChildrenForOrder(parent, treeSet, node.getOrder()); const children = this._getChildrenForOrder(parent, treeSet, node.getOrder());
_.each(children, (child, index) => { children.forEach((child) => {
if (child.getOrder() > node.getOrder()) { if (child.getOrder() > node.getOrder()) {
child.setOrder(child.getOrder() - 2); child.setOrder(child.getOrder() - 2);
} }
@ -228,8 +227,8 @@ const BalancedSorter = new Class(
let totalPHeight = 0; let totalPHeight = 0;
let totalNHeight = 0; let totalNHeight = 0;
_.each(heights, (elem) => { heights.forEach((elem) => {
if (elem.order % 2 == 0) { if (elem.order % 2 === 0) {
totalPHeight += elem.height; totalPHeight += elem.height;
} else { } else {
totalNHeight += elem.height; totalNHeight += elem.height;
@ -254,9 +253,9 @@ const BalancedSorter = new Class(
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(!isNaN(xOffset), 'xOffset can not be null');
$assert(!isNaN(yOffset), 'yOffset can not be null'); $assert(!isNaN(yOffset), 'yOffset can not be null');
@ -282,12 +281,9 @@ const BalancedSorter = new Class(
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: ${ `Missing order elements. Missing order: ${i * factor
i * factor }. Parent:${node.getId()
}. Parent:${ },Node:${children[i].getId()}`,
node.getId()
},Node:${
children[i].getId()}`,
); );
} }
}, },

View File

@ -15,7 +15,6 @@
* 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 _ from '@libraries/underscore-min';
import $ from '@libraries/jquery-2.1.0'; import $ from '@libraries/jquery-2.1.0';
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import Events from '../Events'; import Events from '../Events';
@ -238,45 +237,37 @@ class LayoutManager extends Events {
} }
_flushEvents() { _flushEvents() {
_.each( this._events.forEach(((event) => {
this._events, this.fireEvent('change', event);
function (event) { }));
this.fireEvent('change', event);
},
this,
);
this._events = []; this._events = [];
} }
_collectChanges(nodes) { _collectChanges(nodes) {
if (!nodes) { if (!nodes) {
nodes = this._treeSet.getTreeRoots(); nodes = this._treeSet.getTreeRoots();
} }
_.each( nodes.forEach(((node) => {
nodes, if (node.hasOrderChanged() || node.hasPositionChanged()) {
function (node) { // Find or create a event ...
if (node.hasOrderChanged() || node.hasPositionChanged()) { const id = node.getId();
// Find or create a event ... let event = this._events.some((e) => e.id === id);
const id = node.getId(); if (!event) {
let event = this._events.some((event) => event.id == id); event = new ChangeEvent(id);
if (!event) {
event = new ChangeEvent(id);
}
// Update nodes ...
event.setOrder(node.getOrder());
event.setPosition(node.getPosition());
node.resetPositionState();
node.resetOrderState();
node.resetFreeState();
this._events.push(event);
} }
this._collectChanges(this._treeSet.getChildren(node));
}, // Update nodes ...
this, event.setOrder(node.getOrder());
); event.setPosition(node.getPosition());
node.resetPositionState();
node.resetOrderState();
node.resetFreeState();
this._events.push(event);
}
this._collectChanges(this._treeSet.getChildren(node));
}));
} }
} }

View File

@ -15,7 +15,6 @@
* 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 _ from '@libraries/underscore-min';
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import Node from './Node'; import Node from './Node';
import SymmetricSorter from './SymmetricSorter'; import SymmetricSorter from './SymmetricSorter';
@ -27,6 +26,7 @@ class OriginalLayout {
} }
/** */ /** */
// eslint-disable-next-line class-methods-use-this
createNode(id, size, position, type) { createNode(id, size, position, type) {
$assert($defined(id), 'id can not be null'); $assert($defined(id), 'id can not be null');
$assert(size, 'size can not be null'); $assert(size, 'size can not be null');
@ -77,20 +77,15 @@ class OriginalLayout {
/** */ /** */
layout() { layout() {
const roots = this._treeSet.getTreeRoots(); const roots = this._treeSet.getTreeRoots();
_.each( roots.each(((node) => {
roots, // Calculate all node heights ...
function (node) { const sorter = node.getSorter();
// Calculate all node heights ...
const sorter = node.getSorter();
const heightById = sorter.computeChildrenIdByHeights(this._treeSet, node); const heightById = sorter.computeChildrenIdByHeights(this._treeSet, node);
this._layoutChildren(node, heightById);
this._layoutChildren(node, heightById); this._fixOverlapping(node, heightById);
}));
this._fixOverlapping(node, heightById);
},
this,
);
} }
_layoutChildren(node, heightById) { _layoutChildren(node, heightById) {
@ -113,7 +108,8 @@ class OriginalLayout {
const offsetById = sorter.computeOffsets(this._treeSet, node); const offsetById = sorter.computeOffsets(this._treeSet, node);
const parentPosition = node.getPosition(); const parentPosition = node.getPosition();
const me = this; const me = this;
_.each(children, (child) => {
children.each((child) => {
const offset = offsetById[child.getId()]; const offset = offsetById[child.getId()];
const childFreeDisplacement = child.getFreeDisplacement(); const childFreeDisplacement = child.getFreeDisplacement();
@ -147,13 +143,9 @@ class OriginalLayout {
} }
// Continue reordering the children nodes ... // Continue reordering the children nodes ...
_.each( children.each(((child) => {
children, this._layoutChildren(child, heightById);
function (child) { }));
this._layoutChildren(child, heightById);
},
this,
);
} }
_calculateAlignOffset(node, child, heightById) { _calculateAlignOffset(node, child, heightById) {
@ -168,7 +160,7 @@ class OriginalLayout {
if ( if (
this._treeSet.isStartOfSubBranch(child) this._treeSet.isStartOfSubBranch(child)
&& this._branchIsTaller(child, heightById) && OriginalLayout._branchIsTaller(child, heightById)
) { ) {
if (this._treeSet.hasSinglePathToSingleLeaf(child)) { if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
offset = heightById[child.getId()] / 2 offset = heightById[child.getId()] / 2
@ -193,7 +185,7 @@ class OriginalLayout {
return offset; return offset;
} }
_branchIsTaller(node, heightById) { static _branchIsTaller(node, heightById) {
return ( return (
heightById[node.getId()] heightById[node.getId()]
> node.getSize().height + node.getSorter()._getVerticalPadding() * 2 > node.getSize().height + node.getSorter()._getVerticalPadding() * 2
@ -206,14 +198,9 @@ class OriginalLayout {
if (node.isFree()) { if (node.isFree()) {
this._shiftBranches(node, heightById); this._shiftBranches(node, heightById);
} }
children.each(((child) => {
_.each( this._fixOverlapping(child, heightById);
children, }));
function (child) {
this._fixOverlapping(child, heightById);
},
this,
);
} }
_shiftBranches(node, heightById) { _shiftBranches(node, heightById) {
@ -223,40 +210,31 @@ class OriginalLayout {
node, node,
node.getFreeDisplacement().y, node.getFreeDisplacement().y,
); );
let last = node;
_.each(
siblingsToShift,
function (sibling) {
const overlappingOccurs = shiftedBranches.some(function (shiftedBranch) {
return this._branchesOverlap(shiftedBranch, sibling, heightById);
}, this);
if (!sibling.isFree() || overlappingOccurs) { siblingsToShift.each(((sibling) => {
const sAmount = node.getFreeDisplacement().y; const overlappingOccurs = shiftedBranches.some(((shiftedBranch) =>{
this._treeSet.shiftBranchPosition(sibling, 0, sAmount); return OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById);
shiftedBranches.push(sibling); }).bind(this));
}
}, if (!sibling.isFree() || overlappingOccurs) {
this, const sAmount = node.getFreeDisplacement().y;
); this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
shiftedBranches.push(sibling);
}
}).bind(this));
const branchesToShift = this._treeSet const branchesToShift = this._treeSet
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y) .getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
.filter((branch) => !shiftedBranches.contains(branch)); .filter((branch) => !shiftedBranches.contains(branch));
_.each( branchesToShift.each(((branch) =>{
branchesToShift, const bAmount = node.getFreeDisplacement().y;
function (branch) { this._treeSet.shiftBranchPosition(branch, 0, bAmount);
const bAmount = node.getFreeDisplacement().y; shiftedBranches.push(branch);
this._treeSet.shiftBranchPosition(branch, 0, bAmount); }).bind(this));
shiftedBranches.push(branch);
last = branch;
},
this,
);
} }
_branchesOverlap(branchA, branchB, heightById) { static _branchesOverlap(branchA, branchB, heightById) {
// a branch doesn't really overlap with itself // a branch doesn't really overlap with itself
if (branchA === branchB) { if (branchA === branchB) {
return false; return false;

View File

@ -15,7 +15,6 @@
* 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 _ from '@libraries/underscore-min';
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
const RootedTreeSet = new Class( const RootedTreeSet = new Class(
@ -376,7 +375,7 @@ const RootedTreeSet = new Class(
const children = this.getChildren(node); const children = this.getChildren(node);
const me = this; const me = this;
_.each(children, (child) => { children.forEach( (child) => {
me.shiftBranchPosition(child, xOffset, yOffset); me.shiftBranchPosition(child, xOffset, yOffset);
}); });
}, },
@ -392,7 +391,7 @@ const RootedTreeSet = new Class(
const children = this.getChildren(node); const children = this.getChildren(node);
const me = this; const me = this;
_.each(children, (child) => { children.forEach((child) => {
me.shiftBranchPosition(child, xOffset, yOffset); me.shiftBranchPosition(child, xOffset, yOffset);
}); });
}, },

View File

@ -15,7 +15,6 @@
* 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 _ from '@libraries/underscore-min';
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import AbstractBasicSorter from './AbstractBasicSorter'; import AbstractBasicSorter from './AbstractBasicSorter';
@ -248,7 +247,7 @@ const SymmetricSorter = new Class(
// Compute the center of the branch ... // Compute the center of the branch ...
let totalHeight = 0; let totalHeight = 0;
_.each(heights, (elem) => { heights.forEach((elem) => {
totalHeight += elem.height; totalHeight += elem.height;
}); });
let ysum = totalHeight / 2; let ysum = totalHeight / 2;

View File

@ -12,10 +12,10 @@ class BootstrapDialogRequest extends BootstrapDialog {
console.log(xhr); console.log(xhr);
}; };
this.requestOptions.success = function () { this.requestOptions.success = function success() {
// Intercept form requests ... // Intercept form requests ...
const forms = me._native.find('form'); const forms = me._native.find('form');
_.each(forms, (form) => { forms.forEach((form) => {
$(form).on('submit', (event) => { $(form).on('submit', (event) => {
// Intercept form ... // Intercept form ...
me.requestOptions.url = form.action; me.requestOptions.url = form.action;

View File

@ -163,7 +163,7 @@ class IMindmap {
// Then the rest of the branches ... // Then the rest of the branches ...
const sbranchs = source.getBranches(); const sbranchs = source.getBranches();
_.each(sbranchs, (snode) => { sbranchs.forEach((snode) => {
const tnode = target.createNode(snode.getType(), snode.getId()); const tnode = target.createNode(snode.getType(), snode.getId());
snode.copyTo(tnode); snode.copyTo(tnode);
target.addBranch(tnode); target.addBranch(tnode);

View File

@ -17,7 +17,6 @@
* limitations under the License. * limitations under the License.
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import _ from '../../../../../libraries/underscore-min';
class INodeModel { class INodeModel {
constructor(mindmap) { constructor(mindmap) {
@ -273,7 +272,7 @@ class INodeModel {
const source = this; const source = this;
// Copy properties ... // Copy properties ...
const keys = source.getPropertiesKeys(); const keys = source.getPropertiesKeys();
_.each(keys, (key) => { keys.forEach((key) => {
const value = source.getProperty(key); const value = source.getProperty(key);
target.putProperty(key, value); target.putProperty(key, value);
}); });
@ -282,7 +281,7 @@ class INodeModel {
const children = this.getChildren(); const children = this.getChildren();
const tmindmap = target.getMindmap(); const tmindmap = target.getMindmap();
_.each((children, snode) => { children.forEach((snode) => {
const tnode = tmindmap.createNode(snode.getType(), snode.getId()); const tnode = tmindmap.createNode(snode.getType(), snode.getId());
snode.copyTo(tnode); snode.copyTo(tnode);
target.append(tnode); target.append(tnode);
@ -347,10 +346,10 @@ class INodeModel {
const children = this.getChildren(); const children = this.getChildren();
if (children.length > 0) { if (children.length > 0) {
result = `${result}, children: {(size:${children.length}`; result = `${result}, children: {(size:${children.length}`;
_.each(children, (node) => { children.forEach((node) => {
result = `${result}=> (`; result = `${result}=> (`;
const keys = node.getPropertiesKeys(); const keys = node.getPropertiesKeys();
_.each(keys, (key) => { keys.forEach((key) => {
const value = node.getProperty(key); const value = node.getProperty(key);
result = `${result + key}:${value},`; result = `${result + key}:${value},`;
}); });

View File

@ -36,7 +36,7 @@ class Beta2PelaMigrator {
// Beta does not set position on second level nodes ... // Beta does not set position on second level nodes ...
const branches = mindmap.getBranches(); const branches = mindmap.getBranches();
const me = this; const me = this;
_.each(branches, (model) => { branches.forEach((model) => {
me._fixPosition(model); me._fixPosition(model);
}); });
@ -47,7 +47,7 @@ class Beta2PelaMigrator {
const parentPos = parentModel.getPosition(); const parentPos = parentModel.getPosition();
const isRight = parentPos.x > 0; const isRight = parentPos.x > 0;
const me = this; const me = this;
_.each(parentModel.getChildren(), (child) => { parentModel.getChildren().forEach((child) => {
if (!child.getPosition()) { if (!child.getPosition()) {
child.setPosition(parentPos.x + (50 * isRight ? 1 : -1), parentPos.y); child.setPosition(parentPos.x + (50 * isRight ? 1 : -1), parentPos.y);
} }

View File

@ -15,7 +15,6 @@
* 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 _ from '@libraries/underscore-min';
// FIXME: this Class should be reimplemented // FIXME: this Class should be reimplemented
import Events from '../Events'; import Events from '../Events';
@ -36,7 +35,7 @@ const FadeEffect = new Class(/** @lends FadeEffect */{
/** */ /** */
start() { start() {
const visible = this._isVisible; const visible = this._isVisible;
_.each(this._element, (elem) => { this._element.forEach((elem) => {
if (elem) { if (elem) {
elem.setVisibility(visible); elem.setVisibility(visible);
} }

View File

@ -16,7 +16,6 @@
* limitations under the License. * limitations under the License.
*/ */
import $ from '@libraries/jquery-2.1.0'; import $ from '@libraries/jquery-2.1.0';
import _ from '@libraries/underscore-min';
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import ToolbarPaneItem from './ToolbarPaneItem'; import ToolbarPaneItem from './ToolbarPaneItem';
@ -65,7 +64,7 @@ class ColorPalettePanel extends ToolbarPaneItem {
const colorCells = content.find('div[class=palette-colorswatch]'); const colorCells = content.find('div[class=palette-colorswatch]');
const model = this.getModel(); const model = this.getModel();
const me = this; const me = this;
_.each(colorCells, (elem) => { colorCells.each((elem) => {
$(elem).on('click', () => { $(elem).on('click', () => {
const color = $(elem).css('background-color'); const color = $(elem).css('background-color');
model.setValue(color); model.setValue(color);
@ -88,7 +87,7 @@ class ColorPalettePanel extends ToolbarPaneItem {
const colorCells = panelElem.find('div[class=palette-colorswatch]'); const colorCells = panelElem.find('div[class=palette-colorswatch]');
const model = this.getModel(); const model = this.getModel();
let modelValue = model.getValue(); let modelValue = model.getValue();
_.each(colorCells, (elem) => { colorCells.forEach((elem) => {
const color = $(elem).css('background-color').rgbToHex(); const color = $(elem).css('background-color').rgbToHex();
if (modelValue != null && modelValue[0] === 'r') { if (modelValue != null && modelValue[0] === 'r') {
modelValue = modelValue.rgbToHex(); modelValue = modelValue.rgbToHex();

View File

@ -37,7 +37,7 @@ class IMenu {
} }
clear() { clear() {
_.each(this._toolbarElems, (item) => { this._toolbarElems.forEach((item) => {
item.hide(); item.hide();
}); });
} }

View File

@ -26,7 +26,7 @@ class ListToolbarPanel extends ToolbarPaneItem {
_initPanel() { _initPanel() {
// Register on toolbar elements ... // Register on toolbar elements ...
const me = this; const me = this;
this.getPanelElem().children('div').bind('click', function (event) { this.getPanelElem().children('div').bind('click', function click(event) {
event.stopPropagation(); event.stopPropagation();
me.hide(); me.hide();
const value = $defined($(this).attr('model')) ? $(this).attr('model') : $(this).attr('id'); const value = $defined($(this).attr('model')) ? $(this).attr('model') : $(this).attr('id');
@ -38,7 +38,7 @@ class ListToolbarPanel extends ToolbarPaneItem {
const panelElem = this.getPanelElem(); const panelElem = this.getPanelElem();
const menuElems = panelElem.find('div'); const menuElems = panelElem.find('div');
const value = this.getModel().getValue(); const value = this.getModel().getValue();
_.each(menuElems, (elem) => { menuElems.forEach((elem) => {
const elemValue = $defined($(elem).attr('model')) ? $(elem).attr('model') : $(elem).attr('id'); const elemValue = $defined($(elem).attr('model')) ? $(elem).attr('model') : $(elem).attr('id');
$assert(elemValue, 'elemValue can not be null'); $assert(elemValue, 'elemValue can not be null');
if (elemValue === value) $(elem).attr('class', 'toolbarPanelLinkSelectedLink'); if (elemValue === value) $(elem).attr('class', 'toolbarPanelLinkSelectedLink');

View File

@ -16,7 +16,6 @@
* limitations under the License. * limitations under the License.
*/ */
import $ from '@libraries/jquery-2.1.0'; import $ from '@libraries/jquery-2.1.0';
import _ from '@libraries/underscore-min';
import { $defined } from '@wisemapping/core-js'; import { $defined } from '@wisemapping/core-js';
import BootstrapDialogRequest from "../libraries/bootstrap/BootstrapDialogRequest"; import BootstrapDialogRequest from "../libraries/bootstrap/BootstrapDialogRequest";
@ -412,7 +411,7 @@ class Menu extends IMenu {
_registerEvents(designer) { _registerEvents(designer) {
const me = this; const me = this;
// Register on close events ... // Register on close events ...
_.each(this._toolbarElems, (elem) => { this._toolbarElems.forEach((elem) => {
elem.addEvent('show', () => { elem.addEvent('show', () => {
me.clear(); me.clear();
}); });
@ -422,12 +421,12 @@ class Menu extends IMenu {
const topics = designer.getModel().filterSelectedTopics(); const topics = designer.getModel().filterSelectedTopics();
const rels = designer.getModel().filterSelectedRelationships(); const rels = designer.getModel().filterSelectedRelationships();
_.each(me._toolbarElems, (button) => { me._toolbarElems.forEach((button) => {
const isTopicAction = button.isTopicAction(); const isTopicAction = button.isTopicAction();
const isRelAction = button.isRelAction(); const isRelAction = button.isRelAction();
if (isTopicAction || isRelAction) { if (isTopicAction || isRelAction) {
if ((isTopicAction && topics.length != 0) || (isRelAction && rels.length != 0)) { if ((isTopicAction && topics.length !== 0) || (isRelAction && rels.length !== 0)) {
button.enable(); button.enable();
} else { } else {
button.disable(); button.disable();
@ -440,7 +439,7 @@ class Menu extends IMenu {
const topics = designer.getModel().filterSelectedTopics(); const topics = designer.getModel().filterSelectedTopics();
const rels = designer.getModel().filterSelectedRelationships(); const rels = designer.getModel().filterSelectedRelationships();
_.each(me._toolbarElems, (button) => { me._toolbarElems.forEach((button) => {
const isTopicAction = button.isTopicAction(); const isTopicAction = button.isTopicAction();
const isRelAction = button.isRelAction(); const isRelAction = button.isRelAction();

View File

@ -17,13 +17,12 @@
*/ */
import TestSuite from './TestSuite'; import TestSuite from './TestSuite';
import LayoutManager from '../../../src/components/layout/LayoutManager'; import LayoutManager from '../../../src/components/layout/LayoutManager';
import OriginalLayout from '../../../src/components/layout/OriginalLayout';
const FreeTestSuite = new Class({ class FreeTestSuite extends TestSuite {
Extends: TestSuite, constructor() {
initialize() {
$('#freeTest').css('display', 'block'); $('#freeTest').css('display', 'block');
super();
this.testFreePosition(); this.testFreePosition();
this.testFreePredict(); this.testFreePredict();
this.testReconnectFreeNode(); this.testReconnectFreeNode();
@ -32,7 +31,7 @@ const FreeTestSuite = new Class({
this.testBalancedFreePredict(); this.testBalancedFreePredict();
this.testFreeReorder(); this.testFreeReorder();
this.testFreeOverlap(); this.testFreeOverlap();
}, }
testFreePosition() { testFreePosition() {
console.log('testFreePosition:'); console.log('testFreePosition:');
@ -142,7 +141,7 @@ const FreeTestSuite = new Class({
this._assertFreePosition(manager, null, null); this._assertFreePosition(manager, null, null);
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testFreePredict() { testFreePredict() {
console.log('testFreePredict:'); console.log('testFreePredict:');
@ -212,7 +211,7 @@ const FreeTestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testReconnectFreeNode() { testReconnectFreeNode() {
console.log('testReconnectFreeNode:'); console.log('testReconnectFreeNode:');
@ -302,7 +301,7 @@ const FreeTestSuite = new Class({
this._assertFreePosition(manager, 8, { x: 370, y: 30 }); this._assertFreePosition(manager, 8, { x: 370, y: 30 });
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testSiblingOverlapping() { testSiblingOverlapping() {
console.log('testSiblingOverlapping:'); console.log('testSiblingOverlapping:');
@ -335,7 +334,7 @@ const FreeTestSuite = new Class({
this._assertFreePosition(manager, 7, { x: 250, y: 100 }); this._assertFreePosition(manager, 7, { x: 250, y: 100 });
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testRootNodeChildrenPositioning() { testRootNodeChildrenPositioning() {
console.log('testRootNodeChildrenPositioning:'); console.log('testRootNodeChildrenPositioning:');
@ -378,7 +377,7 @@ const FreeTestSuite = new Class({
// this._assertFreePosition(manager, 6, {x:-150, y:-50}); // this._assertFreePosition(manager, 6, {x:-150, y:-50});
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testBalancedFreePredict() { testBalancedFreePredict() {
console.log('testBalancedFreePredict:'); console.log('testBalancedFreePredict:');
@ -398,7 +397,7 @@ const FreeTestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testFreeReorder() { testFreeReorder() {
console.log('testFreeReorder:'); console.log('testFreeReorder:');
@ -435,7 +434,7 @@ const FreeTestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testFreeOverlap() { testFreeOverlap() {
console.log('testFreeOverlap:'); console.log('testFreeOverlap:');
@ -474,7 +473,7 @@ const FreeTestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
_assertFreePosition(manager, id, position) { _assertFreePosition(manager, id, position) {
if (id != null && position.x != null && position.y != null) { if (id != null && position.x != null && position.y != null) {
@ -492,49 +491,35 @@ const FreeTestSuite = new Class({
} }
const treeSet = manager._treeSet; const treeSet = manager._treeSet;
_.each( treeSet._rootNodes.forEach(((rootNode) => {
treeSet._rootNodes, const heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode);
function (rootNode) { this._assertBranchCollision(treeSet, rootNode, heightById);
const heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode); }));
this._assertBranchCollision(treeSet, rootNode, heightById); }
},
this,
);
},
_assertBranchCollision(treeSet, node, heightById) { _assertBranchCollision(treeSet, node, heightById) {
const children = treeSet.getChildren(node); const children = treeSet.getChildren(node);
const childOfRootNode = treeSet._rootNodes.contains(node); const childOfRootNode = treeSet._rootNodes.contains(node);
_.each( children.forEach((child) => {
children, const height = heightById[child.getId()];
function (child) { let siblings = treeSet.getSiblings(child);
const height = heightById[child.getId()]; if (childOfRootNode) {
let siblings = treeSet.getSiblings(child); siblings = siblings.filter((sibling) => child.getOrder() % 2 == sibling.getOrder() % 2);
if (childOfRootNode) { }
siblings = siblings.filter((sibling) => child.getOrder() % 2 == sibling.getOrder() % 2);
}
_.each(
siblings,
function (sibling) {
this._branchesOverlap(child, sibling, heightById);
},
this,
);
},
this,
);
_.each( siblings.forEach((sibling) => {
children, this._branchesOverlap(child, sibling, heightById);
function (child) { });
this._assertBranchCollision(treeSet, child, heightById);
},
this,
);
},
_branchesOverlap(branchA, branchB, heightById) { });
children.forEach(((child) => {
OriginalLayout._assertBranchCollision(treeSet, child, heightById);
}).bind(this));
}
static _branchesOverlap(branchA, branchB, heightById) {
const topA = branchA.getPosition().y - heightById[branchA.getId()] / 2; const topA = branchA.getPosition().y - heightById[branchA.getId()] / 2;
const bottomA = branchA.getPosition().y + heightById[branchA.getId()] / 2; const bottomA = branchA.getPosition().y + heightById[branchA.getId()] / 2;
const topB = branchB.getPosition().y - heightById[branchB.getId()] / 2; const topB = branchB.getPosition().y - heightById[branchB.getId()] / 2;
@ -544,7 +529,7 @@ const FreeTestSuite = new Class({
topA >= bottomB || bottomA <= topB, topA >= bottomB || bottomA <= topB,
`Branches ${branchA.getId()} and ${branchB.getId()} overlap`, `Branches ${branchA.getId()} and ${branchB.getId()} overlap`,
); );
}, }
}); }
export default FreeTestSuite; export default FreeTestSuite;

View File

@ -14,7 +14,6 @@
<script type='text/javascript' src='js/jquery.js'></script> <script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/jquery-mousewheel.js'></script> <script type='text/javascript' src='js/jquery-mousewheel.js'></script>
<script type='text/javascript' src='js/hotkeys.js'></script> <script type='text/javascript' src='js/hotkeys.js'></script>
<script type='text/javascript' src='js/underscorejs.js'></script>
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.js"></script> <script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.js"></script>
<script src="js/less.js" type="text/javascript"></script> <script src="js/less.js" type="text/javascript"></script>

View File

@ -12,7 +12,6 @@
<script type='text/javascript' src='js/jquery.js'></script> <script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/bootstrap.js'></script> <script type='text/javascript' src='js/bootstrap.js'></script>
<script type='text/javascript' src='js/underscore.js'></script>
<script type='text/javascript' src='js/mootools-core.js'></script> <script type='text/javascript' src='js/mootools-core.js'></script>
<script type='text/javascript' src='js/core.js'></script> <script type='text/javascript' src='js/core.js'></script>
<script type='text/javascript' src='js/less.js'></script> <script type='text/javascript' src='js/less.js'></script>

View File

@ -1,5 +1,5 @@
describe('Free Test Suite', () => { describe('Free Test Suite', () => {
beforeEach(function () { beforeEach(function beforeEach() {
this.addMatchers({ this.addMatchers({
toNotBeBranchesOverlap(expected) { toNotBeBranchesOverlap(expected) {
const a = this.actual; const a = this.actual;
@ -13,19 +13,21 @@ describe('Free Test Suite', () => {
const children = treeSet.getChildren(node); const children = treeSet.getChildren(node);
const childOfRootNode = treeSet._rootNodes.contains(node); const childOfRootNode = treeSet._rootNodes.contains(node);
_.each(children, function (child) { children.foeEach(((child) => {
let siblings = treeSet.getSiblings(child); let siblings = treeSet.getSiblings(child);
if (childOfRootNode) { if (childOfRootNode) {
siblings = siblings.filter((sibling) => (child.getOrder() % 2) == (sibling.getOrder() % 2)); siblings = siblings.filter((sibling) => (child.getOrder() % 2) == (sibling.getOrder() % 2));
} }
_.each(siblings, (sibling) => {
branchesOverlap(child, sibling, heightById);
}, this);
}, this);
_.each(children, (child) => { siblings.foeEach(((sibling) => {
branchesOverlap(child, sibling, heightById);
}).bind(this));
}).bind(this));
children.foeEach((child) => {
branchCollision(treeSet, child, heightById); branchCollision(treeSet, child, heightById);
}, this); }).bind((this));
} }
function branchesOverlap(branchA, branchB, heightById) { function branchesOverlap(branchA, branchB, heightById) {
@ -36,7 +38,7 @@ describe('Free Test Suite', () => {
expect([bottomA, topA]).toNotBeBranchesOverlap([bottomB, topB]); expect([bottomA, topA]).toNotBeBranchesOverlap([bottomB, topB]);
} }
it('avoidCollisionTree1Test', function () { it('avoidCollisionTree1Test', function avoidCollisionTree1Test() {
const position = { x: 0, y: 0 }; const position = { x: 0, y: 0 };
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE); const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
@ -82,14 +84,14 @@ describe('Free Test Suite', () => {
manager.layout(true); manager.layout(true);
const treeSet = manager._treeSet; const treeSet = manager._treeSet;
_.each(treeSet._rootNodes, (rootNode) => { treeSet._rootNodes.beforeEach(((rootNode) => {
const heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode); const heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode);
branchCollision(treeSet, rootNode, heightById); branchCollision(treeSet, rootNode, heightById);
}, this); }).bind(this));
}); });
// FIXME: This is broken in master. This configuration has two topics overlapping. // FIXME: This is broken in master. This configuration has two topics overlapping.
it('avoidCollisionTree2Test - FAILING, commented test', function () { it('avoidCollisionTree2Test - FAILING, commented test', function avoidCollisionTree2Test() {
const position = { x: 0, y: 0 }; const position = { x: 0, y: 0 };
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE); const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
@ -130,10 +132,10 @@ describe('Free Test Suite', () => {
manager.layout(true); manager.layout(true);
const treeSet = manager._treeSet; const treeSet = manager._treeSet;
_.each(treeSet._rootNodes, (rootNode) => { treeSet._rootNodes.foeEach(((rootNode) => {
const heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode); const heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode);
// FIXME: uncoment this line when bug is fixed, branchCollision(treeSet, rootNode, heightById); // FIXME: uncoment this line when bug is fixed, branchCollision(treeSet, rootNode, heightById);
}, this); }).bind(this));
}); });
it('predictTest', () => { it('predictTest', () => {

View File

@ -18,7 +18,6 @@ module.exports = {
test: /.(js)$/, test: /.(js)$/,
exclude: [ exclude: [
/node_modules/, /node_modules/,
path.resolve(__dirname, '../../libraries/underscore-min'),
], ],
}, },
], ],

View File

@ -35,7 +35,6 @@ module.exports = {
test: /.js$/, test: /.js$/,
exclude: [ exclude: [
/node_modules/, /node_modules/,
path.resolve(__dirname, '../../libraries/underscore-min'),
], ],
}, },
], ],