Skip to content
This repository was archived by the owner on Mar 14, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions src/js/views/outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,28 @@

_modelUpdatedHandler: function(event, widget) {
widget = widget || this;
switch (event.type) {
case "nodeAdded":
widget.addNode(event.node);
break;
case "nodeRemoved":
widget.removeNode(event.node, event.parent);
break;
case "nodeMoved":
widget.moveNode(event.node, event.oldParent);
break;
case "propertyChanged":
widget.removeNode(event.node);
widget.addNode(event.node);
widget.setSelected(widget._getSelected());
break;
default:
console.warning('Unknown type of modelUpdated event:'
if (event.node &&
BWidget.isShownInOutline(event.node.getType())) {
switch (event.type) {
case "nodeAdded":
widget.addNode(event.node);
break;
case "nodeRemoved":
widget.removeNode(event.node, event.parent);
break;
case "nodeMoved":
widget.moveNode(event.node, event.oldParent);
break;
case "propertyChanged":
widget.removeNode(event.node);
widget.addNode(event.node);
widget.setSelected(widget._getSelected());
break;
default:
console.warning('Unknown type of modelUpdated event:'
+ event.type);
break;
break;
}
}
},
_getParent: function (node) {
Expand All @@ -136,8 +139,7 @@
}

type = admNode.getType();
showInOutline = BWidget.isPaletteWidget(type) ||
(type === "Page");
showInOutline = BWidget.isShownInOutline(type);
label = BWidget.getDisplayLabel(type);
if (showInOutline) {
treeNode[label] = childNodes;
Expand Down
3 changes: 2 additions & 1 deletion src/js/views/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
var node;
widget = widget || this;
if (event) {
if (event.node && !(event.name === "modelUpdated" &&
if (event.node && BWidget.isShownInProperty(event.node.getType())
&& !(event.name === "modelUpdated" &&
event.type === "nodeRemoved")) {
widget._showProperties(event.node);
} else {
Expand Down
42 changes: 42 additions & 0 deletions src/js/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ var BCommonProperties = {
* a required property name (see #3 above). Existance of
* this object implies the textContent node of the
* resulting DOM element is editable in-line
* 16) showInProperty: boolean, whether widget is shown in property view (
* default: true)
* 17) showInOutline: boolean, whether widget is shown in outline view (
* default: true)
*
* Each zone description in the array should be an object with:
* 1) name identifying the zone point
Expand Down Expand Up @@ -194,6 +198,8 @@ var BWidgetRegistry = {
parent: "Base",
allowIn: [],
showInPalette: false,
showInProperty: false,
showInOutline: false,
selectable: false,
moveable: false,
properties: {
Expand Down Expand Up @@ -427,6 +433,8 @@ var BWidgetRegistry = {
parent: "Base",
allowIn: "Page",
showInPalette: false,
showInProperty: false,
showInOutline: false,
selectable: false,
moveable: false,
template: '<div data-role="content"></div>',
Expand Down Expand Up @@ -1043,6 +1051,8 @@ var BWidgetRegistry = {
parent: "Base",
allowIn: "SelectMenu",
showInPalette: false,
showInProperty: false,
showInOutline: false,
selectable: false,
moveable: false,
properties: {
Expand Down Expand Up @@ -1580,6 +1590,8 @@ var BWidgetRegistry = {
Block: {
parent: "Base",
showInPalette: false,
showInProperty: false,
showInOutline: false,
selectable: false,
outlineLabel: function (node) {
var columns, row, col, children, map;
Expand Down Expand Up @@ -1915,6 +1927,36 @@ var BWidget = {
return false;
},

/**
* Tests whether this widget type should be shown in the property view
*
* @param {String} widgetType The type of the widget.
* @return {Boolean} true if this widget is to be shown in the property view,
* false if not or it is undefined.
*/
isShownInProperty: function (widgetType) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"showInProperty" might be a better name than "isShownInProperty", which mean's it has already be shown in property. showInProperty means it should be shown in property

var widget = BWidgetRegistry[widgetType];
if (typeof widget === "object" && widget.showInProperty !== false) {
return true;
}
return false;
},

/**
* Tests whether this widget type should be shown in the outline view
*
* @param {String} widgetType The type of the widget.
* @return {Boolean} true if this widget is to be shown in the outline view,
* false if not or it is undefined.
*/
isShownInOutline: function (widgetType) {
var widget = BWidgetRegistry[widgetType];
if (typeof widget === "object" && widget.showInOutline !== false) {
return true;
}
return false;
},

/**
* Tests whether this widget type should be shown with a drag header bar.
*
Expand Down