Skip to content

Commit

Permalink
Group support on data level, refs #43
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Nov 5, 2013
1 parent 7c1a2fc commit efb5405
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
11 changes: 11 additions & 0 deletions the-graph-group/the-graph-group.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<polymer-element name="the-graph-group" attributes="name label nodes">

<script>
Polymer('the-graph-group', {
name: '',
label: '',
nodes: []
});
</script>

</polymer-element>
15 changes: 15 additions & 0 deletions the-graph-groups/the-graph-groups.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<link rel="import" href="../the-graph-group/the-graph-group.html">

<polymer-element name="the-graph-groups">
<template>
<content select="the-graph-group"></content>
</template>
<script>
Polymer('the-graph-groups', {
getGroups: function () {
return Array.prototype.slice.call(this.getElementsByTagName('the-graph-group'));
}
});
</script>

</polymer-element>
24 changes: 24 additions & 0 deletions the-graph/the-graph.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<link rel="import" href="../the-graph-exports/the-graph-exports.html">
<link rel="import" href="../the-graph-groups/the-graph-groups.html">
<link rel="import" href="../the-graph-nodes/the-graph-nodes.html">
<link rel="import" href="../the-graph-edges/the-graph-edges.html">
<link rel="import" href="../the-graph-initials/the-graph-initials.html">
Expand Down Expand Up @@ -27,6 +28,11 @@
<the-graph-export public="{{ export.public }}" private="{{ export.private }}"></the-graph-export>
</template>
</the-graph-exports>
<the-graph-groups id="groups">
<template repeat="{{ group in groups }}">
<the-graph-group name="{{ group.name }}" label="{{ group.metadata.label }}" nodes="{{ group.nodes }}"></the-graph-group>
</template>
</the-graph-groups>
</template>

<script type="text/javascript" src="../the-graph-util/the-graph-util.js"></script>
Expand Down Expand Up @@ -59,6 +65,7 @@
edges: [],
initials: [],
exports: [],
groups: [],
library: null,
ready: function () {
this._pan = { x: 0, y: 0 };
Expand Down Expand Up @@ -396,6 +403,7 @@
this.edges = [];
this.initials = [];
this.exports = [];
this.groups = [];
// Convert processes to an array
for (var index in this.graph.processes) {
var p = this.graph.processes[index];
Expand Down Expand Up @@ -429,6 +437,12 @@
this.graph.exports.forEach(function (exp) {
this.exports.push(exp);
}.bind(this));
if (!this.graph.groups) {
this.graph.groups = [];
}
this.graph.groups.forEach(function (group) {
this.groups.push(group);
}.bind(this));

this.calcMinMax();
},
Expand Down Expand Up @@ -534,6 +548,7 @@
var definition = {
properties: this.graph.properties,
exports: [],
groups: [],
processes: {},
connections: []
};
Expand Down Expand Up @@ -582,6 +597,15 @@
public: exp.public
});
});
this.$.groups.getGroups().forEach(function(group) {
definition.groups.push({
name: group.name,
nodes: group.nodes,
metadata: {
label: group.label
}
});
});
return definition;
}
});
Expand Down

0 comments on commit efb5405

Please sign in to comment.