Permalink
Browse files

improved handling of components in tree

  • Loading branch information...
1 parent 8bf7400 commit bf9edfd70440e31c4392260a9c0e004213c0d860 @amorgner amorgner committed Jul 20, 2012
@@ -326,6 +326,7 @@ public static void reorderRels(final List<AbstractRelationship> rels, final Stri
if ((pageId == null) || (parentNode instanceof Group) || (parentNode instanceof Folder)) {
nodesWithChildren.add(parentId);
+ continue;
}
@@ -118,7 +118,7 @@
public enum UiKey implements PropertyKey {
- name, tag, content, contentType, size, type, paths
+ name, tag, content, contentType, size, type, paths, dataKey
}
@@ -280,9 +280,12 @@ public Object execute() throws FrameworkException {
// create new content node with content from property set
contentTemplateProperties.clear();
- contentTemplateProperties.put(AbstractNode.Key.type.name(), "Content");
+ contentTemplateProperties.put(AbstractNode.Key.type.name(), Content.class.getSimpleName());
contentTemplateProperties.put("data-key", dataKey);
- contentTemplateProperties.put("content", propertySet.get(dataKey));
+ contentTemplateProperties.put(Content.UiKey.content.name(), propertySet.get(dataKey));
+
+ contentTemplateProperties.put(AbstractNode.Key.visibleToPublicUsers.name(), propertySet.get(AbstractNode.Key.visibleToAuthenticatedUsers.name()));
+ contentTemplateProperties.put(AbstractNode.Key.visibleToAuthenticatedUsers.name(), propertySet.get(AbstractNode.Key.visibleToAuthenticatedUsers.name()));
Content newContent = (Content) createNodeCommand.execute(contentTemplateProperties);
@@ -50,15 +50,15 @@
@Override
public void processMessage(WebSocketMessage webSocketData) {
- String pageId = (String) webSocketData.getNodeData().get("pageId");
- String componentId = (String) webSocketData.getNodeData().get("componentId");
- AbstractNode node = getNode(webSocketData.getId());
+ AbstractNode node = getNode(webSocketData.getId());
- if (node == null || pageId == null) {
+ if (node == null) {
return;
}
+ String pageId = (String) webSocketData.getNodeData().get("pageId");
+ String componentId = (String) webSocketData.getNodeData().get("componentId");
List<AbstractRelationship> rels = node.getOutgoingRelationships(RelType.CONTAINS);
Map<Long, GraphObject> sortMap = new TreeMap<Long, GraphObject>();
Set<String> nodesWithChildren = new HashSet<String>();
@@ -82,6 +82,11 @@ public void processMessage(WebSocketMessage webSocketData) {
}
+ if (pageId == null) {
+
+ return;
+ }
+
Long pos = null;
if (rel.getLongProperty(pageId) != null) {
@@ -93,20 +98,16 @@ public void processMessage(WebSocketMessage webSocketData) {
pos = rel.getLongProperty("*");
}
- String relCompId = rel.getStringProperty("componentId");
- boolean isComponent = endNode instanceof Component;
+ String relCompId = rel.getStringProperty("componentId");
+ boolean isComponentOrContent = ((endNode instanceof Component) || (endNode instanceof Content));
- if (pos == null || (isComponent && relCompId != null && !relCompId.equals(componentId))) {
+ if (pos == null || (isComponentOrContent && relCompId != null && !relCompId.equals(componentId))) {
continue;
}
- if ((componentId == null || !isComponent || (relCompId != null && relCompId.equals(componentId)))) {
-
- nodesWithChildren.addAll(RelationshipHelper.getChildrenInPage(endNode, pageId));
- sortMap.put(pos, endNode);
-
- }
+ nodesWithChildren.addAll(RelationshipHelper.getChildrenInPage(endNode, pageId));
+ sortMap.put(pos, endNode);
}
@@ -179,11 +179,10 @@ var _Elements = {
appendElementElement : function(entity, parentId, componentId, pageId, removeExisting, hasChildren, treeAddress) {
if (debug) console.log('_Elements.appendElementElement', entity, parentId, componentId, pageId, removeExisting, hasChildren, treeAddress);
-
+ console.log(entity.id);
var parent;
if (treeAddress) {
- if (debug) console.log('tree address', treeAddress);
parent = $('#_' + treeAddress);
} else {
parent = Structr.findParent(parentId, componentId, pageId, elements);
@@ -199,14 +198,13 @@ var _Elements = {
if (debug) console.log(id);
parent.append('<div id="_' + id + '" class="node element ' + entity.id + '_"></div>');
+ console.log('Element appended (div, parent)', div, parent);
//var div = Structr.node(entity.id, parentId, componentId, pageId, pos);
var div = $('#_' + id);
if (!div) return;
- if (debug) console.log('Element appended', div);
-
entity.pageId = pageId;
div.append('<img class="typeIcon" src="'+ _Elements.icon + '">'
@@ -90,7 +90,7 @@ var _Entities = {
appendObj : function(entity, parentId, componentId, pageId, removeExisting, hasChildren, treeAddress) {
- if (debug) console.log('_Entities.appendObj: ', entity, parentId, componentId, pageId, removeExisting, hasChildren, treeAddress);
+ console.log('_Entities.appendObj: ', entity, parentId, componentId, pageId, removeExisting, hasChildren, treeAddress);
var lastAppendedObj;
@@ -283,11 +283,13 @@ function connect() {
$(result).each(function(i, entity) {
- console.log(command, entity, parentId, componentId, pageId, command == 'ADD', isIn(entity.id, data.nodesWithChildren), treeAddress);
+ console.log(command, entity, parentId, componentId, pageId, command == 'ADD', isIn(entity.id, data.nodesWithChildren), treeAddress);
var el = Structr.node(entity.id, parentId, componentId, pageId);
if (el) el.remove();
+ //alert(entity.id);
+
_Entities.appendObj(entity, parentId, componentId, pageId, command == 'ADD', isIn(entity.id, data.nodesWithChildren), treeAddress);
});
@@ -298,6 +300,8 @@ function connect() {
} else if (command == 'UPDATE') { /*********************** UPDATE ************************/
+ console.log('UPDATE');
+
var relData = data.relData;
if (debug) console.log('relData', relData);
@@ -354,7 +358,7 @@ function connect() {
var el = Structr.node(id, parentId, componentId, newPageId);
if (debug) console.log('node already exists?', el);
- if (!el || !el.length) {
+ if (id && (!el || !el.length)) {
//el.remove();
//_Entities.resetMouseOverState(el);

0 comments on commit bf9edfd

Please sign in to comment.