From 9274b3959384d21809c992f6f2e7860eb1682e06 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 5 Jun 2012 12:08:32 -0700 Subject: Binding Panel - Add getPropertyList and fix null currentObject --- js/controllers/objects-controller.js | 37 ++++++++++++++++++++-- .../binding/binding-item.reel/binding-item.js | 10 ++++-- 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'js') diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js index 2c9f2d66..32f24d5c 100644 --- a/js/controllers/objects-controller.js +++ b/js/controllers/objects-controller.js @@ -113,12 +113,38 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { /* ---- Bindable Properties ---- */ - getEnumerableProperties : { + getPropertyList : { value: function(object, excludeUnderscoreProperties) { + var object_i = object, + prototypes = [object_i]; + + ///// Collect prototypes + while(Object.getPrototypeOf(object_i)) { + object_i = Object.getPrototypeOf(object_i); + prototypes.push(object_i); + } + + return prototypes.map(function(proto) { + var metadata = proto._montage_metadata, + objectName = (metadata) ? metadata.objectName : "Object"; + + return { + category : objectName, + properties : this.getPropertiesFromObject(proto) + }; + }, this); + + } + }, + + getPropertiesFromObject : { + value: function (object, excludeUnderscoreProperties) { var properties = []; for(var key in object) { - properties.push(key); + if(object.hasOwnProperty(key)) { + properties.push(key); + } } if(excludeUnderscoreProperties) { @@ -146,7 +172,12 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { set: function(value) { if(value === this._currentObject) { return; } - this.currentObjectBindings = this.getObjectBindings(value); + if(value) { + this.currentObjectBindings = this.getObjectBindings(value); + console.log("Property list", this.getPropertyList(value, true)); + } else { + this.currentObjectBindings = []; + } this._currentObject = value; } diff --git a/js/panels/binding/binding-item.reel/binding-item.js b/js/panels/binding/binding-item.reel/binding-item.js index 294e8d35..55230fc3 100644 --- a/js/panels/binding/binding-item.reel/binding-item.js +++ b/js/panels/binding/binding-item.reel/binding-item.js @@ -20,8 +20,10 @@ exports.BindingItem = Montage.create(Component, { set: function(value) { if(value === this._sourceObject) { return; } - this.sourceObjectLabel = value.identifier; - + if(value && value.identifier) { + this.sourceObjectLabel = value.identifier; + } + this._sourceObject = value; } }, @@ -33,7 +35,9 @@ exports.BindingItem = Montage.create(Component, { set: function(value) { if(value === this._boundObject) { return; } - this.boundObjectLabel = value.identifier; + if(value && value.identifier) { + this.boundObjectLabel = value.identifier; + } this._boundObject = value; } -- cgit v1.2.3