Commit 0e04c2bb authored by Patrik Meijer's avatar Patrik Meijer
Browse files

Store attr/regs setAttrs in cy nodes

parent f08de3fd
...@@ -12,7 +12,7 @@ const DEFAULT_STYLES = [ ...@@ -12,7 +12,7 @@ const DEFAULT_STYLES = [
{ {
selector: 'node.gme-node[hasChildren]', selector: 'node.gme-node[hasChildren]',
style: { style: {
content: 'data(label)', content: 'data(attributes.name)',
// http://js.cytoscape.org/#style/background-image // http://js.cytoscape.org/#style/background-image
'background-width': '20%', 'background-width': '20%',
'background-height': '20%', 'background-height': '20%',
...@@ -21,7 +21,7 @@ const DEFAULT_STYLES = [ ...@@ -21,7 +21,7 @@ const DEFAULT_STYLES = [
{ {
selector: 'node.gme-node[^hasChildren]', selector: 'node.gme-node[^hasChildren]',
style: { style: {
content: 'data(label)', content: 'data(attributes.name)',
// http://js.cytoscape.org/#style/background-image // http://js.cytoscape.org/#style/background-image
'background-width': '80%', 'background-width': '80%',
'background-height': '80%', 'background-height': '80%',
......
...@@ -232,11 +232,12 @@ export default class GraphEditor extends Component { ...@@ -232,11 +232,12 @@ export default class GraphEditor extends Component {
const edgeData = { const edgeData = {
data: { data: {
id, id,
label: childData.attributes.name, attributes: childData.attributes,
registries: childData.registries,
source: childData.pointers.src, source: childData.pointers.src,
target: childData.pointers.dst, target: childData.pointers.dst,
}, },
classes: `gme-connection ${childData.attributes.name}-gme-connection\ classes: `gme-connection ${childData.metaType}-gme-connection\
${activeSelection.includes(id) ? ' in-active-selection' : ''}`, ${activeSelection.includes(id) ? ' in-active-selection' : ''}`,
}; };
...@@ -255,16 +256,15 @@ ${activeSelection.includes(id) ? ' in-active-selection' : ''}`, ...@@ -255,16 +256,15 @@ ${activeSelection.includes(id) ? ' in-active-selection' : ''}`,
const cytoData = { const cytoData = {
data: { data: {
id, id,
name: childData.attributes.name, attributes: childData.attributes,
label: childData.attributes.label registries: childData.registries,
? `${childData.attributes.name}::${childData.attributes.label}`
: childData.attributes.name,
parent: childData.parent, parent: childData.parent,
metaType: childData.metaType, metaType: childData.metaType,
}, },
position: getPosition(id), position: getPosition(id),
grabbable: !readOnly, grabbable: !readOnly,
classes: `gme-node${activeSelection.includes(id) ? ' in-active-selection' : ''}`, classes: `gme-node ${childData.metaType}-gme-node \
${activeSelection.includes(id) ? 'in-active-selection' : ''}`,
}; };
result.elements.nodes.push(cytoData); result.elements.nodes.push(cytoData);
...@@ -308,7 +308,7 @@ ${activeSelection.includes(id) ? ' in-active-selection' : ''}`, ...@@ -308,7 +308,7 @@ ${activeSelection.includes(id) ? ' in-active-selection' : ''}`,
source: id, source: id,
target: setMemberData.id, target: setMemberData.id,
label: setName, label: setName,
memberAttrs: setMemberData.memberAttrs, setMemberAttributes: setMemberData.setMemberAttributes,
}, },
classes: `set-member ${setName}-set-member ${activeSelection.includes(edgeId) classes: `set-member ${setName}-set-member ${activeSelection.includes(edgeId)
? 'in-active-selection' : ''}`, ? 'in-active-selection' : ''}`,
......
...@@ -43,7 +43,7 @@ const DEFAULT_OPTIONS = { ...@@ -43,7 +43,7 @@ const DEFAULT_OPTIONS = {
setNames: null, setNames: null,
// Mapping from set name to set attribute name // Mapping from set name to set attribute name
setMemberAttributes: {}, setMemberAttributes: {},
// The depth of the territory, i.e. the number of levels of containment-hierarchy to display. // The depth of the territory, i.e. the number of levels of containment-hierarchy to load.
depth: 10, depth: 10,
}; };
...@@ -112,17 +112,13 @@ export default class SubTreeWatcher extends Component { ...@@ -112,17 +112,13 @@ export default class SubTreeWatcher extends Component {
result = nodeObj.getMemberIds(setName).map((id) => { result = nodeObj.getMemberIds(setName).map((id) => {
const entry = { const entry = {
id, id,
memberAttrs: [], setMemberAttributes: {},
}; };
if (options.setMemberAttributes[setName]) { if (options.setMemberAttributes[setName]) {
options.setMemberAttributes[setName] options.setMemberAttributes[setName]
.forEach((attrEntry) => { .forEach((name) => {
const value = nodeObj.getMemberAttribute(setName, id, attrEntry.name); entry.setMemberAttributes[name] = nodeObj.getMemberAttribute(setName, id, name) || '';
entry.memberAttrs.push({
name: attrEntry.name,
value,
});
}); });
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment