Skip to content

Commit

Permalink
fix lint and test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
slhh committed Dec 11, 2016
1 parent 0592645 commit f4255c6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions modules/modes/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export function modeSelect(context, selectedIDs) {

if (!selectedIDs || selectedIDs.length < 1) return null;

var relatedParentEntity;
var relatedParentEntity,
member,
index;
if (relatedParent) relatedParentEntity = context.hasEntity(relatedParent.id);
// if the entity does no longer exist, related parent will be cleared
if (!relatedParentEntity) relatedParent = null;
Expand Down Expand Up @@ -167,7 +169,7 @@ export function modeSelect(context, selectedIDs) {
if (relatedParent.id[0] === 'r') {
// Keep the related parent relation if the first selected entity is member of the relation
if (selectedIDs[0] === relatedParentEntity.members[relatedParent.index].id) return relatedParent;
let member = relatedParentEntity.memberById(selectedIDs[0]);
member = relatedParentEntity.memberById(selectedIDs[0]);
if (member) return {id: relatedParent.id, index: member.index};
} else {
// When we visit a vertex with multiple parents, we want to remember which parent line we started on.
Expand All @@ -182,12 +184,12 @@ export function modeSelect(context, selectedIDs) {
}

if (previousSelectedIDs && previousSelectedIDs.length === 1) {
let id = previousSelectedIDs[0];
let entity = context.hasEntity(id); // check if entity does still exist.
var id = previousSelectedIDs[0];
var entity = context.hasEntity(id); // check if entity does still exist.
if (entity) {
if (id[0] === 'r' & selectedIDs.length === 1) {
// When we visit a relation and one of its members afterward, we want to use this way as the related parent.
let member = entity.memberById(selectedIDs[0]);
member = entity.memberById(selectedIDs[0]);
if (member) {
mode.follow(true);
return {id: id, index: member.index }; // prefer the previously selected entity as parent
Expand All @@ -198,7 +200,7 @@ export function modeSelect(context, selectedIDs) {
if (selectedIDs.length > 1) {
return {id: id, index:null};
} else {
let index = entity.nodes.indexOf(selectedIDs[0]);
index = entity.nodes.indexOf(selectedIDs[0]);
if (index !== -1) {
mode.follow(true);
return {id: id, index: index }; // prefer the previously selected entity as parent
Expand Down Expand Up @@ -637,8 +639,7 @@ export function modeSelect(context, selectedIDs) {
closeMenu();
radialMenu = undefined;

// storeSelectedIDs();
previousSelectedIDs = selectedIDs.slice();
if (Array.isArray(selectedIDs)) previousSelectedIDs = selectedIDs.slice();

context.history()
.on('undone.select', null)
Expand Down

0 comments on commit f4255c6

Please sign in to comment.