From d3fad28f5dde100bc70cd3a53fa759694c3f59c4 Mon Sep 17 00:00:00 2001 From: Xuqing Kuang Date: Thu, 12 Jul 2012 16:49:21 +0800 Subject: [PATCH] [ADM] Implemented propertyVisible() for widget property exposed to user. The function will determine the property whether to show in property view. --- src/js/views/property.js | 3 +++ src/js/widgets.js | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/js/views/property.js b/src/js/views/property.js index 124ab42e..5cc27c78 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -130,6 +130,9 @@ options = node.getPropertyOptions(); // iterate property of node for (p in props) { + if (!BWidget.propertyVisible(node.getType(), p)) { + continue; + } labelVal = node.getPropertyDisplayName(p); valueId = p+'-value'; valueVal = props[p]; diff --git a/src/js/widgets.js b/src/js/widgets.js index d807309a..1f192e40 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -160,6 +160,8 @@ var BCommonProperties = { * 9) validIn: Parent widget in which this property is valid * * 10) invalidIn: Parent widget in which this property is not valid + * 11) visible: optional boolean for the property user-exposed in + * property view (default true) * * @class */ @@ -2300,6 +2302,26 @@ var BWidget = { return schema; }, + + /** + * Tests whether this property is visible to user, for example, property + * view can use it to decide if it will show this property. + * + * @param {String} widgetType The type of the widget. + * @param {String} property The name of the requested property. + * @return {Boolean} true if this property is visible to user, or it is + * undefined. + * false if this property is invisible to user. + */ + propertyVisible: function (widgetType, property) { + var schema = BWidget.getPropertySchema(widgetType, property); + if (schema && typeof(schema.visible) == 'boolean') { + return schema.visible; + } else { + return true; + } + }, + /** * Gets the template for a given widget type. *