Revize 5022c089
Přidáno uživatelem Pavel Fidranský před asi 6 roky(ů)
sources/imiger-core/src/main/webapp/js/components/group.js | ||
---|---|---|
200 | 200 |
*/ |
201 | 201 |
_renderIncluded() { |
202 | 202 |
// root |
203 |
this._rootElement = DOM.s('svg', {
|
|
203 |
this._rootElement = DOM.s('g', { |
|
204 | 204 |
class: 'node group', |
205 |
x: this.position.x, |
|
206 |
y: this.position.y, |
|
205 |
transform: `translate(${this.position.x}, ${this.position.y})`, |
|
207 | 206 |
'data-id': this.id, |
208 | 207 |
onClick: this._onNodeClick.bind(this), |
209 | 208 |
onMouseDown: this._onNodeMouseDown.bind(this), |
sources/imiger-core/src/main/webapp/js/components/node.js | ||
---|---|---|
117 | 117 |
throw new TypeError(coords.toString() + ' is not an instance of Coordinates'); |
118 | 118 |
} |
119 | 119 |
|
120 |
this._rootElement.setAttribute('x', coords.x); |
|
121 |
this._rootElement.setAttribute('y', coords.y); |
|
120 |
this._rootElement.setAttribute('transform', `translate(${coords.x}, ${coords.y})`); |
|
122 | 121 |
|
123 | 122 |
let inEdgeList = this.inEdgeList; |
124 | 123 |
inEdgeList.forEach(edge => { |
... | ... | |
452 | 451 |
* @param {Event} e Mouse up event. |
453 | 452 |
*/ |
454 | 453 |
function mouseUp() { |
455 |
that.position = new Coordinates( |
|
456 |
+that._rootElement.getAttribute('x'), |
|
457 |
+that._rootElement.getAttribute('y'), |
|
458 |
); |
|
454 |
const match = Constants.transformAttributeRegex.exec(that._rootElement.getAttribute('transform')); |
|
455 |
|
|
456 |
that.position = new Coordinates(+match.groups.x, +match.groups.y); |
|
459 | 457 |
|
460 | 458 |
that._rootElement.classList.remove('node--dragged'); |
461 | 459 |
|
sources/imiger-core/src/main/webapp/js/components/vertex.js | ||
---|---|---|
214 | 214 |
*/ |
215 | 215 |
_renderIncluded() { |
216 | 216 |
// root |
217 |
this._rootElement = DOM.s('svg', {
|
|
217 |
this._rootElement = DOM.s('g', { |
|
218 | 218 |
class: 'node vertex', |
219 |
x: this.position.x, |
|
220 |
y: this.position.y, |
|
219 |
transform: `translate(${this.position.x}, ${this.position.y})`, |
|
221 | 220 |
'data-id': this.id, |
222 | 221 |
'data-name': this.name, |
223 | 222 |
onClick: this._onNodeClick.bind(this), |
sources/imiger-core/src/main/webapp/js/constants.js | ||
---|---|---|
18 | 18 |
removeDiagram: 'api/remove-diagram', |
19 | 19 |
getPrivateDiagrams: 'api/get-private-diagrams', |
20 | 20 |
}; |
21 |
|
|
22 |
/** @static @prop {object} Regular expression for extracting coordinates from SVG transform attribute. */ |
|
23 |
Constants.transformAttributeRegex = /translate\((?<x>[0-9\.-]+), (?<y>[0-9\.-]+)\)/; |
sources/imiger-core/src/main/webapp/tests/common.robot | ||
---|---|---|
3 | 3 |
|
4 | 4 |
Library Selenium2Library |
5 | 5 |
Library OperatingSystem |
6 |
Library String |
|
6 | 7 |
|
7 | 8 |
|
8 | 9 |
*** Variables *** |
... | ... | |
53 | 54 |
|
54 | 55 |
Element Should Have Class |
55 | 56 |
[Arguments] ${element} ${className} |
56 |
Page Should Contain Element ${element}[contains(@class, "${className}")] |
|
57 |
${element}= Catenate SEPARATOR= ${element} [contains(@class," ${className} ")] |
|
58 |
Page Should Contain Element ${element} |
|
57 | 59 |
|
58 | 60 |
|
59 | 61 |
Element Should Not Have Class |
60 | 62 |
[Arguments] ${element} ${className} |
61 |
Page Should Not Contain Element ${element}[contains(@class, "${className}")] |
|
63 |
${element}= Catenate SEPARATOR= ${element} [contains(@class," ${className} ")] |
|
64 |
Page Should Not Contain Element ${element} |
|
62 | 65 |
|
63 | 66 |
|
64 | 67 |
Element Should Have Attribute |
65 | 68 |
[Arguments] ${element} ${attributeName} |
66 |
Page Should Contain Element ${element}[@${attributeName}] |
|
69 |
${element}= Catenate SEPARATOR= ${element} [@ ${attributeName} ] |
|
70 |
Page Should Contain Element ${element} |
|
67 | 71 |
|
68 | 72 |
|
69 | 73 |
Element Should Not Have Attribute |
70 | 74 |
[Arguments] ${element} ${attributeName} |
71 |
Page Should Not Contain Element ${element}[@${attributeName}] |
|
75 |
Element Attribute Value Should Be ${element} ${attributeName} ${None} |
|
76 |
|
|
77 |
|
|
78 |
Get Element Coordinates |
|
79 |
[Arguments] ${element} |
|
80 |
${transformAttributeValue}= Get Element Attribute ${element} transform |
|
81 |
${matches}= Get Regexp Matches ${transformAttributeValue} ([0-9\.-]+) |
|
82 |
[Return] ${matches} |
sources/imiger-core/src/main/webapp/tests/edge.robot | ||
---|---|---|
11 | 11 |
*** Variables *** |
12 | 12 |
${edge38} //*[name()="g"][contains(@class, "edge")][@data-id="38"] |
13 | 13 |
|
14 |
${vertex4} //*[name()="svg"][contains(@class, "vertex")][@data-id="4"]
|
|
15 |
${vertex2014} //*[name()="svg"][contains(@class, "vertex")][@data-id="2014"]
|
|
14 |
${vertex4} //*[name()="g"][contains(@class, "vertex")][@data-id="4"] |
|
15 |
${vertex2014} //*[name()="g"][contains(@class, "vertex")][@data-id="2014"] |
|
16 | 16 |
|
17 | 17 |
${edgeArrow} /*[name()="g"][contains(@class, "arrow")] |
18 | 18 |
|
sources/imiger-core/src/main/webapp/tests/filter.robot | ||
---|---|---|
31 | 31 |
${applyButton} ${filterModalWindow}//button[@type="submit"] |
32 | 32 |
${resetButton} ${filterModalWindow}//button[@type="reset"] |
33 | 33 |
|
34 |
${foundNodes} //*[name()="svg"][contains(@class, "node--found")]
|
|
34 |
${foundNodes} //*[contains(@class, "node")][@filter="url(#node--found)"]
|
|
35 | 35 |
|
36 | 36 |
|
37 | 37 |
*** Test Cases *** |
sources/imiger-core/src/main/webapp/tests/graph.robot | ||
---|---|---|
12 | 12 |
${unconnectedNodeList} //div[@id="unconnectedNodeListComponent"] |
13 | 13 |
${componentCounter} //span[@class="component-counter"] |
14 | 14 |
|
15 |
${vertex2} //*[name()="svg"][contains(@class, "vertex")][@data-id="2"]
|
|
16 |
${vertex4} //*[name()="svg"][contains(@class, "vertex")][@data-id="4"]
|
|
17 |
${vertex291} //*[name()="svg"][contains(@class, "vertex")][@data-id="291"]
|
|
18 |
${vertex303} //*[name()="svg"][contains(@class, "vertex")][@data-id="303"]
|
|
15 |
${vertex2} //*[name()="g"][contains(@class, "vertex")][@data-id="2"] |
|
16 |
${vertex4} //*[name()="g"][contains(@class, "vertex")][@data-id="4"] |
|
17 |
${vertex291} //*[name()="g"][contains(@class, "vertex")][@data-id="291"] |
|
18 |
${vertex303} //*[name()="g"][contains(@class, "vertex")][@data-id="303"] |
|
19 | 19 |
|
20 | 20 |
${vertex0} //*[name()="li"][contains(@class, "vertex")][@data-id="0"] |
21 | 21 |
${vertex6} //*[name()="li"][contains(@class, "vertex")][@data-id="6"] |
sources/imiger-core/src/main/webapp/tests/group.robot | ||
---|---|---|
12 | 12 |
*** Variables *** |
13 | 13 |
${zoomInButton} //button[@id="zoomIn"] |
14 | 14 |
|
15 |
${vertex2014} //*[name()="svg"][contains(@class, "vertex")][@data-id="2014"]
|
|
16 |
${vertex2019} //*[name()="svg"][contains(@class, "vertex")][@data-id="2019"]
|
|
15 |
${vertex2014} //*[name()="g"][contains(@class, "vertex")][@data-id="2014"] |
|
16 |
${vertex2019} //*[name()="g"][contains(@class, "vertex")][@data-id="2019"] |
|
17 | 17 |
|
18 |
${group1} //*[name()="svg"][contains(@class, "group")][@data-id="1"]
|
|
18 |
${group1} //*[name()="g"][contains(@class, "group")][@data-id="1"] |
|
19 | 19 |
|
20 | 20 |
${groupName} //span[@class="group-name"] |
21 | 21 |
|
... | ... | |
35 | 35 |
Click Element ${zoomInButton} |
36 | 36 |
Click Element ${zoomInButton} |
37 | 37 |
# get old group coordinates |
38 |
${oldX}= Get Element Attribute ${group1} x |
|
39 |
${oldX}= Convert To Number ${oldX} 2 |
|
40 |
${oldY}= Get Element Attribute ${group1} y |
|
41 |
${oldY}= Convert To Number ${oldY} 2 |
|
38 |
${oldCoords}= Get Element Coordinates ${group1} |
|
39 |
${oldX}= Convert To Number ${oldCoords}[0] 2 |
|
40 |
${oldY}= Convert To Number ${oldCoords}[1] 2 |
|
42 | 41 |
# move vertex by 10 pixels in both directions |
43 | 42 |
Drag And Drop By Offset ${group1} 10 10 |
44 | 43 |
# get new group coordinates |
45 |
${newX}= Get Element Attribute ${group1} x |
|
46 |
${newX}= Convert To Number ${newX} 2 |
|
47 |
${newY}= Get Element Attribute ${group1} y |
|
48 |
${newY}= Convert To Number ${newY} 2 |
|
44 |
${newCoords}= Get Element Coordinates ${group1} |
|
45 |
${newX}= Convert To Number ${newCoords}[0] 2 |
|
46 |
${newY}= Convert To Number ${newCoords}[1] 2 |
|
49 | 47 |
# check that offset matches |
50 | 48 |
Should Be Equal As Numbers ${oldX + 10} ${newX} |
51 | 49 |
Should Be Equal As Numbers ${oldY + 10} ${newY} |
sources/imiger-core/src/main/webapp/tests/navbar.robot | ||
---|---|---|
18 | 18 |
|
19 | 19 |
${excludedNodeList} //div[@id="excludedNodeListComponent"] |
20 | 20 |
|
21 |
${group1} //*[name()="svg"][contains(@class, "group")][@data-id="1"]
|
|
22 |
${vertex2044} //*[name()="svg"][contains(@class, "vertex")][@data-id="2044"]
|
|
21 |
${group1} //*[name()="g"][contains(@class, "group")][@data-id="1"] |
|
22 |
${vertex2044} //*[name()="g"][contains(@class, "vertex")][@data-id="2044"] |
|
23 | 23 |
${excludedVertex2044} //li[contains(@class, "vertex")][@data-id="2044"] |
24 | 24 |
|
25 | 25 |
|
sources/imiger-core/src/main/webapp/tests/node-excluding.robot | ||
---|---|---|
16 | 16 |
|
17 | 17 |
${includeAllButton} //button[contains(@class, "include-all-button")] |
18 | 18 |
|
19 |
${vertex2013} //*[name()="svg"][contains(@class, "vertex")][@data-id="2013"]
|
|
19 |
${vertex2013} //*[name()="g"][contains(@class, "vertex")][@data-id="2013"] |
|
20 | 20 |
${excludedVertex2013} //li[contains(@class, "vertex")][@data-id="2013"] |
21 |
${vertex2014} //*[name()="svg"][contains(@class, "vertex")][@data-id="2014"]
|
|
21 |
${vertex2014} //*[name()="g"][contains(@class, "vertex")][@data-id="2014"] |
|
22 | 22 |
${excludedVertex2014} //li[contains(@class, "vertex")][@data-id="2014"] |
23 | 23 |
|
24 |
${group1} //*[name()="svg"][contains(@class, "group")][@data-id="1"]
|
|
24 |
${group1} //*[name()="g"][contains(@class, "group")][@data-id="1"] |
|
25 | 25 |
${excludedGroup1} //li[contains(@class, "group")][@data-id="1"] |
26 | 26 |
|
27 | 27 |
|
sources/imiger-core/src/main/webapp/tests/search.robot | ||
---|---|---|
13 | 13 |
${searchButton} //button[@id="searchButton"] |
14 | 14 |
${searchCounter} //span[@id="searchCount"] |
15 | 15 |
|
16 |
${vertex2015} //*[name()="svg"][@data-id="2015"]
|
|
17 |
${vertex2039} //*[name()="svg"][@data-id="2039"]
|
|
16 |
${vertex2015} //*[contains(@class, "vertex")][@data-id="2015"]
|
|
17 |
${vertex2039} //*[contains(@class, "vertex")][@data-id="2039"]
|
|
18 | 18 |
|
19 | 19 |
|
20 | 20 |
*** Test Cases *** |
sources/imiger-core/src/main/webapp/tests/sidebar.robot | ||
---|---|---|
15 | 15 |
${includeAllButton} //button[contains(@class, "include-all-button")] |
16 | 16 |
${excludeAllButton} //button[contains(@class, "exclude-all-button")] |
17 | 17 |
|
18 |
${vertex2030} //*[name()="svg"][contains(@class, "vertex")][@data-id="2030"]
|
|
18 |
${vertex2030} //*[name()="g"][contains(@class, "vertex")][@data-id="2030"] |
|
19 | 19 |
${excludedVertex2030} //li[contains(@class, "vertex")][@data-id="2030"] |
20 | 20 |
|
21 | 21 |
|
sources/imiger-core/src/main/webapp/tests/vertex.robot | ||
---|---|---|
10 | 10 |
*** Variables *** |
11 | 11 |
${zoomInButton} //button[@id="zoomIn"] |
12 | 12 |
|
13 |
${vertex9} //*[name()="svg"][contains(@class, "vertex")][@data-id="9"]
|
|
14 |
${vertex58} //*[name()="svg"][contains(@class, "vertex")][@data-id="58"]
|
|
15 |
${vertex2014} //*[name()="svg"][contains(@class, "vertex")][@data-id="2014"]
|
|
13 |
${vertex9} //*[name()="g"][contains(@class, "vertex")][@data-id="9"] |
|
14 |
${vertex58} //*[name()="g"][contains(@class, "vertex")][@data-id="58"] |
|
15 |
${vertex2014} //*[name()="g"][contains(@class, "vertex")][@data-id="2014"] |
|
16 | 16 |
|
17 | 17 |
${vertexArchetypeIcon} /*[name()="use"][@class="archetype-icon"] |
18 | 18 |
|
... | ... | |
46 | 46 |
Click Element ${zoomInButton} |
47 | 47 |
Click Element ${zoomInButton} |
48 | 48 |
# get old vertex coordinates |
49 |
${oldX}= Get Element Attribute ${vertex2014} x |
|
50 |
${oldX}= Convert To Number ${oldX} 2 |
|
51 |
${oldY}= Get Element Attribute ${vertex2014} y |
|
52 |
${oldY}= Convert To Number ${oldY} 2 |
|
49 |
${oldCoords}= Get Element Coordinates ${vertex2014} |
|
50 |
${oldX}= Convert To Number ${oldCoords}[0] 2 |
|
51 |
${oldY}= Convert To Number ${oldCoords}[1] 2 |
|
53 | 52 |
# move vertex by 10 pixels in both directions |
54 | 53 |
Drag And Drop By Offset ${vertex2014} 10 10 |
55 | 54 |
# get new vertex coordinates |
56 |
${newX}= Get Element Attribute ${vertex2014} x |
|
57 |
${newX}= Convert To Number ${newX} 2 |
|
58 |
${newY}= Get Element Attribute ${vertex2014} y |
|
59 |
${newY}= Convert To Number ${newY} 2 |
|
55 |
${newCoords}= Get Element Coordinates ${vertex2014} |
|
56 |
${newX}= Convert To Number ${newCoords}[0] 2 |
|
57 |
${newY}= Convert To Number ${newCoords}[1] 2 |
|
60 | 58 |
# check that offset matches |
61 | 59 |
Should Be Equal As Numbers ${oldX + 10} ${newX} |
62 | 60 |
Should Be Equal As Numbers ${oldY + 10} ${newY} |
Také k dispozici: Unified diff
re #16: change node SVG element from <svg> to <g>