Revision 08af4f8a
Added by Cherian Mathew almost 9 years ago
src/main/resources/eu/etaxonomy/cdm/vaadin/jscomponent/lib/d3.conceptrelationshiptree_connector.js | ||
---|---|---|
22 | 22 |
.attr("height", height + margin.top + margin.bottom) |
23 | 23 |
.append("g") |
24 | 24 |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); |
25 |
|
|
26 |
|
|
25 |
|
|
26 |
var selectedNode; |
|
27 | 27 |
this.onStateChange = function() { |
28 | 28 |
crTree = this.getState().conceptRelationshipTree; |
29 |
|
|
29 |
|
|
30 | 30 |
if(crTree) { |
31 | 31 |
root = JSON.parse(connector.getState().conceptRelationshipTree); |
32 |
|
|
32 |
|
|
33 | 33 |
root.x0 = height / 2; |
34 | 34 |
root.y0 = 0; |
35 | 35 |
|
... | ... | |
41 | 41 |
} |
42 | 42 |
} |
43 | 43 |
|
44 |
root.children.forEach(collapse); |
|
44 |
//root.children.forEach(collapse);
|
|
45 | 45 |
update(root); |
46 | 46 |
|
47 | 47 |
|
48 | 48 |
d3.select(self.frameElement).style("height", "800px"); |
49 | 49 |
} |
50 | 50 |
} |
51 |
|
|
51 |
|
|
52 | 52 |
function update(source) { |
53 | 53 |
|
54 | 54 |
// Compute the new tree layout. |
... | ... | |
70 | 70 |
.on("click", click); |
71 | 71 |
|
72 | 72 |
nodeEnter.append("circle") |
73 |
.attr("r", 5)
|
|
74 |
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
|
|
73 |
.attr("r", function(d) { return d.type === "taxon" ? 5 : 10; })
|
|
74 |
.style("fill", function(d) { return d === source && d.type === "conceptr" ? "#DF7401" : "#fff"; });
|
|
75 | 75 |
|
76 | 76 |
nodeEnter.append("text") |
77 |
.attr("x", function(d) { return d.children || d._children ? 5 : 10; }) |
|
78 |
.attr("y", "-15") |
|
77 |
.attr("x", function(d) { |
|
78 |
if(d.type === "conceptr") { |
|
79 |
return 50; |
|
80 |
} else { |
|
81 |
return d.children || d._children ? -10 : 10; |
|
82 |
} |
|
83 |
}) |
|
84 |
.attr("y", function(d) { return d.type === "conceptr" ? -20 : 0; }) |
|
79 | 85 |
.attr("dy", ".35em") |
80 | 86 |
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; }) |
81 | 87 |
.text(function(d) { return d.name; }) |
... | ... | |
87 | 93 |
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; }); |
88 | 94 |
|
89 | 95 |
nodeUpdate.select("circle") |
90 |
.attr("r", 5)
|
|
91 |
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
|
|
96 |
.attr("r", function(d) { return d.type === "taxon" ? 5 : 10; })
|
|
97 |
.style("fill", function(d) { return d === selectedNode && d.type === "conceptr" ? "#DF7401" : "#fff"; });
|
|
92 | 98 |
|
93 | 99 |
nodeUpdate.select("text") |
94 | 100 |
.style("fill-opacity", 1); |
... | ... | |
136 | 142 |
d.x0 = d.x; |
137 | 143 |
d.y0 = d.y; |
138 | 144 |
}); |
139 |
|
|
145 |
|
|
140 | 146 |
} |
141 | 147 |
|
142 | 148 |
// Toggle children on click. |
143 | 149 |
function click(d) { |
144 | 150 |
//root.children.forEach(collapse); |
145 |
|
|
146 |
connector.test(d.uuid); |
|
147 |
if (d.children) { |
|
148 |
d._children = d.children; |
|
149 |
d.children = null; |
|
150 |
} else { |
|
151 |
d.children = d._children; |
|
152 |
d._children = null; |
|
151 |
|
|
152 |
if(d.type === "conceptr") { |
|
153 |
connector.select(d.uuid); |
|
153 | 154 |
} |
155 |
|
|
156 |
selectedNode = d; |
|
154 | 157 |
update(d); |
155 | 158 |
} |
156 | 159 |
} |
Also available in: Unified diff
ConceptRelationshipComposite: added enabling / disabling of edit / delete buttons and firing event when edit concept relationship dialog is opened
EditConceptRelationshipComposite : fixed problems with async calls , adapted to updated operation class, added show in dialog method
NewTaxonBaseComposite : adapted to updated operation class
StatusComposite : added methods to update taxa table ui
D3ConceptRelationshipTree : added possibility to display one to one relationships
EditConceptRelationshipPresenter, EditConceptRelationshipPresenterTest : added method to get data to setup composite
CdmBaseUI, CdmVaadinSessionUtilities : using new basic events
CdmSpringContextHelper : fixed connection bug by closing connection after getting database metadata
CdmVaadinOperation : fixed problems with async calls
ConceptRelationshipView : setup ui changes for status composite depending on whether it is a primary of secondary composite
d3.conceptrelationshiptree_connector.js : added selected node capability