From d2e9d8703758b553b541d6c159325a765057e7c2 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 28 Jan 2015 21:04:00 -0500 Subject: [PATCH] when a topic was deleted, renderEdgeArrows was trying to call on a topic that was no longer existent to draw synapse direction, breaking the graph render --- app/assets/javascripts/src/Metamaps.JIT.js | 4 +++- app/assets/javascripts/src/Metamaps.js | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index 51240234..bef4ad59 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -1758,7 +1758,9 @@ Metamaps.JIT = { var posChild = adj.nodeTo.pos.getc(true); //plot arrow edge - if (directionCat == "none") { + if (!direction) { + // render nothing for this arrow if the direction couldn't be retrieved + } else if (directionCat == "none") { edgeHelper.line.render({ x: pos.x, y: pos.y diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js index 95a76745..44df0d4c 100644 --- a/app/assets/javascripts/src/Metamaps.js +++ b/app/assets/javascripts/src/Metamaps.js @@ -356,10 +356,13 @@ Metamaps.Backbone.init = function () { return Metamaps.Topics.get(this.get('node2_id')); }, getDirection: function () { - return [ - this.getTopic1().get('node').id, - this.getTopic2().get('node').id - ]; + var t1 = this.getTopic1(), + t2 = this.getTopic2(); + + return t1 && t2 ? [ + t1.get('node').id, + t2.get('node').id + ] : false; }, getMapping: function () {