From ce460b0026d6c6c2489f335fb8b3883671f2e8d1 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 | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/js/views/property.js b/src/js/views/property.js index e40e2e86..53061bc5 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 87f6ea6c..51cf7bce 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)propertyVisible: optional boolean for the property user-exposed in + * property view (default true) * * @class */ @@ -2311,6 +2313,27 @@ 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 to be shown in the property + * view, or it is undefined. + * false if the property is not to be shown in property + * view. + */ + propertyVisible: function (widgetType, property) { + var schema = BWidget.getPropertySchema(widgetType, property); + if (schema && typeof(schema.propertyVisible) == 'boolean') { + return schema.propertyVisible; + } else { + return true; + } + }, + /** * Gets the template for a given widget type. *