diagram.tpl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {% extends 'layout/layout_1_col.tpl'|get_template %}
  2. {% block content %}
  3. <script>
  4. mxBasePath = '{{ _p.web_lib }}mxgraph/src/';
  5. </script>
  6. <script type="text/javascript" src="{{ _p.web_lib }}mxgraph/src/js/mxClient.js"></script>
  7. <script>
  8. // Overridden to define per-shape connection points
  9. mxGraph.prototype.getAllConnectionConstraints = function(terminal, source) {
  10. if (terminal != null && terminal.shape != null) {
  11. if (terminal.shape.stencil != null) {
  12. if (terminal.shape.stencil != null) {
  13. return terminal.shape.stencil.constraints;
  14. }
  15. } else if (terminal.shape.constraints != null) {
  16. return terminal.shape.constraints;
  17. }
  18. }
  19. return null;
  20. };
  21. // Edges have no connection points
  22. mxPolyline.prototype.constraints = null;
  23. // Program starts here. Creates a sample graph in the
  24. // DOM node with the specified ID. This function is invoked
  25. // from the onLoad event handler of the document (see below).
  26. function main(container)
  27. {
  28. // Checks if the browser is supported
  29. if (!mxClient.isBrowserSupported())
  30. {
  31. // Displays an error message if the browser is not supported.
  32. mxUtils.error('Browser is not supported!', 200, false);
  33. }
  34. else
  35. {
  36. // Disables the built-in context menu
  37. mxEvent.disableContextMenu(container);
  38. // Creates the graph inside the given container
  39. var graph = new mxGraph(container);
  40. graph.setConnectable(true);
  41. graph.setHtmlLabels(true);
  42. // Blocks the selection of elements
  43. graph.setEnabled(false);
  44. // Enables connect preview for the default edge style
  45. graph.connectionHandler.createEdgeState = function(me)
  46. {
  47. var edge = graph.createEdge(null, null, null, null, null);
  48. return new mxCellState(this.graph.view, edge, this.graph.getCellStyle(edge));
  49. };
  50. // Specifies the default edge style
  51. graph.getStylesheet().getDefaultEdgeStyle()['edgeStyle'] = 'orthogonalEdgeStyle';
  52. // Enables rubberband selection
  53. new mxRubberband(graph);
  54. // Gets the default parent for inserting new cells. This
  55. // is normally the first child of the root (ie. layer 0).
  56. var parent = graph.getDefaultParent();
  57. // Adds cells to the model in a single step
  58. graph.getModel().beginUpdate();
  59. try {
  60. //var v1 = graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30);
  61. //var v2 = graph.insertVertex(parent, null, 'World!', 200, 150, 80, 30);
  62. //var e1 = graph.insertEdge(parent, null, '', v1, v2);
  63. {% for vertex in group_list %}
  64. {{ vertex }}
  65. {% endfor %}
  66. {% for vertex in subgroup_list %}
  67. {{ vertex }}
  68. {% endfor %}
  69. {% for vertex in vertex_list %}
  70. {{ vertex }}
  71. {% endfor %}
  72. {% for vertex in connections %}
  73. {{ vertex }}
  74. {% endfor %}
  75. } finally {
  76. // Updates the display
  77. graph.getModel().endUpdate();
  78. }
  79. }
  80. };
  81. $(document).ready(function () {
  82. main(document.getElementById('graphContainer'));
  83. });
  84. </script>
  85. {{ content }}
  86. {% endblock %}