From b1093a8f4ab464da63ef8e1399cfaea8d2643eee Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 6 Jun 2012 18:01:54 -0700 Subject: Objects Controller - Get serializable properties --- js/controllers/objects-controller.js | 59 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js index 32f24d5c..14213d56 100644 --- a/js/controllers/objects-controller.js +++ b/js/controllers/objects-controller.js @@ -113,45 +113,46 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { /* ---- Bindable Properties ---- */ - getPropertyList : { - value: function(object, excludeUnderscoreProperties) { + getPropertiesList : { + value: function(object, groupByPrototype) { var object_i = object, - prototypes = [object_i]; + prototypes = [object_i], + list; + + if(groupByPrototype) { + ///// Collect prototypes + while(Object.getPrototypeOf(object_i)) { + object_i = Object.getPrototypeOf(object_i); + prototypes.push(object_i); + } + + list = prototypes.map(function(proto) { + var metadata = proto._montage_metadata, + objectName = (metadata) ? metadata.objectName : "Object"; - ///// Collect prototypes - while(Object.getPrototypeOf(object_i)) { - object_i = Object.getPrototypeOf(object_i); - prototypes.push(object_i); + return { + category : objectName, + properties : Montage.getSerializablePropertyNames(proto) + }; + }, this); + } else { + list = Montage.getSerializablePropertyNames(object); } - return prototypes.map(function(proto) { - var metadata = proto._montage_metadata, - objectName = (metadata) ? metadata.objectName : "Object"; - return { - category : objectName, - properties : this.getPropertiesFromObject(proto) - }; - }, this); + return list; } }, - getPropertiesFromObject : { - value: function (object, excludeUnderscoreProperties) { - var properties = []; + getBindablePropertiesFromObject : { + value: function (object) { + var serializableProperties = Montage.getSerializablePropertyNames(object), + properties; - for(var key in object) { - if(object.hasOwnProperty(key)) { - properties.push(key); - } - } - - if(excludeUnderscoreProperties) { - properties = properties.filter(function(property) { - return property[0] !== '_'; - }, this); - } + properties = serializableProperties.filter(function(prop) { + return object.hasOwnProperty(prop); + }, this); return properties.sort(); } -- cgit v1.2.3