|
| 1 | +import React, { Component } from 'react'; |
| 2 | +import { OrgDiagram } from '../Diagrams'; |
| 3 | +import { Enabled, PageFitMode, GroupByType, OrgItemConfig, ChildrenPlacementType } from 'basicprimitives'; |
| 4 | + |
| 5 | +class Sample extends Component { |
| 6 | + constructor(props) { |
| 7 | + super(props); |
| 8 | + |
| 9 | + this.state = { |
| 10 | + alignBranches: false |
| 11 | + } |
| 12 | + } |
| 13 | + |
| 14 | + onAlignBranches(alignBranches) { |
| 15 | + this.setState({ alignBranches }); |
| 16 | + } |
| 17 | + |
| 18 | + render() { |
| 19 | + const { alignBranches } = this.state; |
| 20 | + const config = { |
| 21 | + alignBranches, |
| 22 | + hasSelectorCheckbox: Enabled.False, |
| 23 | + pageFitMode: PageFitMode.None, |
| 24 | + arrowsDirection: GroupByType.Children, |
| 25 | + defaultTemplateName: "info", |
| 26 | + templates: [{ |
| 27 | + name: "info", |
| 28 | + itemSize: { width: 80, height: 36 }, |
| 29 | + minimizedItemSize: { width: 3, height: 3 }, |
| 30 | + highlightPadding: { left: 4, top: 4, right: 4, bottom: 4 }, |
| 31 | + onItemRender: ({ context: itemConfig }) => { |
| 32 | + return <div className="InfoTemplate">{itemConfig.title}</div>; |
| 33 | + } |
| 34 | + }], |
| 35 | + items: [ |
| 36 | + new OrgItemConfig({ |
| 37 | + id: 1, |
| 38 | + parent: null, |
| 39 | + title: "Branch 1", |
| 40 | + childrenPlacementType: ChildrenPlacementType.Matrix, |
| 41 | + }), |
| 42 | + new OrgItemConfig({ |
| 43 | + id: 10, |
| 44 | + parent: 1, |
| 45 | + levelOffset: 0, |
| 46 | + title: "Child 1 at row 0", |
| 47 | + }), |
| 48 | + new OrgItemConfig({ |
| 49 | + id: 11, |
| 50 | + parent: 1, |
| 51 | + levelOffset: 0, |
| 52 | + title: "Child 2 at row 0", |
| 53 | + }), |
| 54 | + new OrgItemConfig({ |
| 55 | + id: 12, |
| 56 | + parent: 1, |
| 57 | + levelOffset: 1, |
| 58 | + title: "Child 3 at row 1", |
| 59 | + }), |
| 60 | + new OrgItemConfig({ |
| 61 | + id: 13, |
| 62 | + parent: 1, |
| 63 | + levelOffset: 1, |
| 64 | + title: "Child 4 at row 1", |
| 65 | + }), |
| 66 | + new OrgItemConfig({ |
| 67 | + id: 14, |
| 68 | + parent: 1, |
| 69 | + levelOffset: 1, |
| 70 | + title: "Child 5 at row 1", |
| 71 | + }), |
| 72 | + new OrgItemConfig({ |
| 73 | + id: 15, |
| 74 | + parent: 1, |
| 75 | + levelOffset: 1, |
| 76 | + title: "Child 6 at row 1", |
| 77 | + }), |
| 78 | + |
| 79 | + new OrgItemConfig({ id: 2, parent: 1, title: "Child 7" }), |
| 80 | + new OrgItemConfig({ id: 3, parent: 1, title: "Child 8" }), |
| 81 | + new OrgItemConfig({ id: 4, parent: 1, title: "Child 9" }), |
| 82 | + new OrgItemConfig({ id: 5, parent: 1, title: "Child 10" }), |
| 83 | + new OrgItemConfig({ id: 6, parent: 1, title: "Child 11" }), |
| 84 | + new OrgItemConfig({ id: 7, parent: 1, title: "Child 12" }), |
| 85 | + new OrgItemConfig({ id: 8, parent: 1, title: "Child 13" }), |
| 86 | + new OrgItemConfig({ id: 9, parent: 1, title: "Child 14" }), |
| 87 | + |
| 88 | + /* Branch 2 */ |
| 89 | + new OrgItemConfig({ |
| 90 | + id: 101, |
| 91 | + parent: null, |
| 92 | + title: "Branch 2", |
| 93 | + }), |
| 94 | + new OrgItemConfig({ |
| 95 | + id: 102, |
| 96 | + parent: 101, |
| 97 | + levelOffset: 1, |
| 98 | + title: "Child 1 at row 1", |
| 99 | + }), |
| 100 | + new OrgItemConfig({ |
| 101 | + id: 103, |
| 102 | + parent: 101, |
| 103 | + levelOffset: 1, |
| 104 | + title: "Child 2 at row 1", |
| 105 | + childrenPlacementType: ChildrenPlacementType.Vertical, |
| 106 | + }), |
| 107 | + new OrgItemConfig({ |
| 108 | + id: 104, |
| 109 | + parent: 103, |
| 110 | + title: "Sub Child 3", |
| 111 | + }), |
| 112 | + new OrgItemConfig({ |
| 113 | + id: 105, |
| 114 | + parent: 103, |
| 115 | + title: "Sub Child 4", |
| 116 | + }), |
| 117 | + new OrgItemConfig({ |
| 118 | + id: 106, |
| 119 | + parent: 101, |
| 120 | + title: "Child 3", |
| 121 | + }), |
| 122 | + new OrgItemConfig({ |
| 123 | + id: 107, |
| 124 | + parent: 101, |
| 125 | + title: "Child 4", |
| 126 | + }) |
| 127 | + ] |
| 128 | + }; |
| 129 | + |
| 130 | + return <> |
| 131 | + <p>Enable cross-branch children alignment: |
| 132 | + <br /> |
| 133 | + <label> |
| 134 | + <input |
| 135 | + onChange={() => this.onAlignBranches(true)} |
| 136 | + name="alignBranches" |
| 137 | + type="radio" |
| 138 | + value="1" |
| 139 | + checked={alignBranches === true ? 'checked' : ''} |
| 140 | + /> |
| 141 | + True |
| 142 | + </label> |
| 143 | + <br /> |
| 144 | + <label> |
| 145 | + <input |
| 146 | + onChange={() => this.onAlignBranches(false)} |
| 147 | + name="alignBranches" |
| 148 | + type="radio" |
| 149 | + value="0" |
| 150 | + checked={alignBranches === false ? 'checked' : ''} |
| 151 | + /> |
| 152 | + False |
| 153 | + </label> |
| 154 | + </p> |
| 155 | + <div className="placeholder"> |
| 156 | + <OrgDiagram centerOnCursor={true} config={config} /> |
| 157 | + </div> |
| 158 | + </> |
| 159 | + } |
| 160 | +} |
| 161 | + |
| 162 | +export default Sample; |
0 commit comments