Revize d276ae6c
Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)
sources/src/main/webapp/js/components/group.js | ||
---|---|---|
12 | 12 |
this.symbol = app.markSymbol.getMarkSymbol(); |
13 | 13 |
|
14 | 14 |
var rootElement; |
15 |
var vertexListComponent; |
|
15 | 16 |
|
16 | 17 |
var position = new Coordinates(0, 0); |
17 | 18 |
var size = { |
... | ... | |
82 | 83 |
|
83 | 84 |
app.viewportComponent.removeVertex(vertex); |
84 | 85 |
|
86 |
if (vertexListComponent) { |
|
87 |
vertexListComponent.appendChild(vertex); |
|
88 |
} |
|
89 |
|
|
85 | 90 |
vertexList.push(vertex); |
86 | 91 |
if(isIconShown) showIconClick.bind(this)(null); |
87 | 92 |
}; |
... | ... | |
112 | 117 |
|
113 | 118 |
app.viewportComponent.addVertex(vertex); |
114 | 119 |
|
120 |
if (vertexListComponent) { |
|
121 |
vertexListComponent.removeChild(vertex); |
|
122 |
} |
|
123 |
|
|
115 | 124 |
vertexList.splice(vertexList.indexOf(vertex), 1); |
116 | 125 |
}; |
117 | 126 |
|
... | ... | |
638 | 647 |
nameText.addEventListener('click', nameClick.bind(this)); |
639 | 648 |
rootElement.appendChild(nameText); |
640 | 649 |
|
650 |
// vertex list |
|
651 |
vertexListComponent = new GroupVertexList(this); |
|
652 |
rootElement.appendChild(vertexListComponent.render()); |
|
653 |
|
|
654 |
vertexList.forEach(function(vertex) { |
|
655 |
vertexListComponent.appendChild(vertex); |
|
656 |
}, this); |
|
657 |
|
|
641 | 658 |
// buttons |
642 | 659 |
var buttonGroup = app.utils.createHtmlElement('div', { |
643 | 660 |
'class': 'button-group', |
sources/src/main/webapp/js/components/groupVertexList.js | ||
---|---|---|
1 |
/** |
|
2 |
* Class representing a list of vertices added to a group. |
|
3 |
* @see Group |
|
4 |
* @constructor |
|
5 |
* @param {Group} parentalGroup Group this vertex list is bound to. |
|
6 |
*/ |
|
7 |
function GroupVertexList(parentalGroup) { |
|
8 |
const lineHeight = 18; |
|
9 |
|
|
10 |
var rootElement; |
|
11 |
var listItemCounter = 0; |
|
12 |
|
|
13 |
/** |
|
14 |
* Adds a new vertex to the list. Binds user interactions to local handler functions. |
|
15 |
* @param {vertex} vertex Vertex to be added to this list. |
|
16 |
*/ |
|
17 |
this.appendChild = function(vertex) { |
|
18 |
var listItemElement; |
|
19 |
if (parentalGroup.isExcluded()) { |
|
20 |
listItemElement = app.utils.createHtmlElement('li', {}); |
|
21 |
} else { |
|
22 |
listItemElement = app.utils.createSvgElement('text', { |
|
23 |
'y': listItemCounter * lineHeight, |
|
24 |
}); |
|
25 |
} |
|
26 |
|
|
27 |
listItemElement.setAttribute('data-id', vertex.id); |
|
28 |
listItemElement.appendChild(document.createTextNode(vertex.name)); |
|
29 |
listItemElement.addEventListener('click', listItemClick.bind(vertex)); |
|
30 |
|
|
31 |
rootElement.appendChild(listItemElement); |
|
32 |
|
|
33 |
listItemCounter++; |
|
34 |
}; |
|
35 |
|
|
36 |
/** |
|
37 |
* Removes a vertex from the list. |
|
38 |
* @param {Vertex} vertex Vertex to be removed from this list. |
|
39 |
*/ |
|
40 |
this.removeChild = function(vertex) { |
|
41 |
var listItemElement = rootElement.querySelector('[data-id="' + vertex.id + '"]'); |
|
42 |
|
|
43 |
listItemElement.remove(); |
|
44 |
}; |
|
45 |
|
|
46 |
/** |
|
47 |
* Creates a new DOM element representing the list in memory. |
|
48 |
* @returns {Element} HTML or SVG DOM element depending on whether the group is excluded. |
|
49 |
*/ |
|
50 |
this.render = function() { |
|
51 |
if (parentalGroup.isExcluded()) { |
|
52 |
rootElement = app.utils.createHtmlElement('ul', {}); |
|
53 |
} else { |
|
54 |
rootElement = app.utils.createSvgElement('g', { |
|
55 |
'transform': 'translate(70, 30)', |
|
56 |
}); |
|
57 |
} |
|
58 |
|
|
59 |
rootElement.setAttribute('class', 'group-vertex-list'); |
|
60 |
|
|
61 |
return rootElement; |
|
62 |
}; |
|
63 |
|
|
64 |
/** |
|
65 |
* Vertex list item click interaction. |
|
66 |
* @param {Event} e Click event. |
|
67 |
*/ |
|
68 |
function listItemClick(e) { |
|
69 |
e.stopPropagation(); |
|
70 |
|
|
71 |
console.log('TODO: highlight vertex on click'); |
|
72 |
} |
|
73 |
} |
sources/src/main/webapp/showGraph.jsp | ||
---|---|---|
26 | 26 |
<script src="js/components/edgePopover.js"></script> |
27 | 27 |
<script src="js/components/floatingPoint.js"></script> |
28 | 28 |
<script src="js/components/group.js"></script> |
29 |
<script src="js/components/groupVertexList.js"></script> |
|
29 | 30 |
<script src="js/components/minimap.js"></script> |
30 | 31 |
<script src="js/components/modalWindow.js"></script> |
31 | 32 |
<script src="js/components/sidebar.js"></script> |
Také k dispozici: Unified diff
added back list of vertices in a Group