From 18608cb525b23ffb1f75a088a2e63dec23687e0c Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Wed, 12 Aug 2015 16:37:34 -0400
Subject: [PATCH] can't add parent as child

---
 js/cam/assemblers/Component.js                | 12 ++++++------
 js/menus/templates/EditComponentMenuView.html |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/js/cam/assemblers/Component.js b/js/cam/assemblers/Component.js
index 4579565a..a16e4181 100644
--- a/js/cam/assemblers/Component.js
+++ b/js/cam/assemblers/Component.js
@@ -157,17 +157,17 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
 
 
     Component.prototype.toJSON = function(){
-        var childIds = [];
+        var childIDs = [];
         _.each(this.children, function(child){
-            childIds.push(child.id);
+            childIDs.push(child.id);
         });
-        var parentName = "";
-        if (this.parent) parentName = this.parent.name;
+        var parentID = "";
+        if (this.parent) parentID = this.parent.id;
         return {
             id: this.id,
             name: this.name,
-            children: childIds,
-            parent: parentName,
+            children: childIDs,
+            parent: parentID,
             translation: this.object3D.position,
             scale: this.object3D.scale.x,
             rotation: this.object3D.rotation
diff --git a/js/menus/templates/EditComponentMenuView.html b/js/menus/templates/EditComponentMenuView.html
index 79c7232c..eac946ee 100644
--- a/js/menus/templates/EditComponentMenuView.html
+++ b/js/menus/templates/EditComponentMenuView.html
@@ -1,7 +1,7 @@
 Name: &nbsp;&nbsp;<input data-property="name" value="<%= components[editingComponent].name %>" placeholder="Enter Name" class="seventyFiveWidth form-control textInput component" type="text"><br/><br/>
 Parent: &nbsp;&nbsp;
     <div class="btn-group">
-        <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= components[editingComponent].parent || "No Parent Selected" %><span class="caret"></span></button>
+        <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= components[components[editingComponent].parent].name || "No Parent Selected" %><span class="caret"></span></button>
         <ul role="menu" class="dropdown-menu">
             <% _.each(components, function(component){ %>
                 <% if (component.id == editingComponent) return; %>
-- 
GitLab