|
| 1 | +import { AfterViewInit, Component, TemplateRef, ViewChild } from "@angular/core"; |
| 2 | +import { Node } from "../tree-node.types"; |
| 3 | + |
| 4 | +@Component({ |
| 5 | + selector: "app-treeview-icon-component", |
| 6 | + template: ` |
| 7 | + <cds-tree-view |
| 8 | + label="Tree view" |
| 9 | + style="width: 18rem; display: block;" |
| 10 | + [tree]="tree"> |
| 11 | + </cds-tree-view> |
| 12 | +
|
| 13 | + <ng-template #document> |
| 14 | + <svg cdsIcon="document" class="cds--tree-node__icon" size="16"></svg> |
| 15 | + </ng-template> |
| 16 | + ` |
| 17 | +}) |
| 18 | +export class IconTreeviewDemoComponent implements AfterViewInit { |
| 19 | + |
| 20 | + tree: Node[] = []; |
| 21 | + |
| 22 | + @ViewChild("document") documentIcon: TemplateRef<any>; |
| 23 | + |
| 24 | + constructor() { } |
| 25 | + |
| 26 | + ngAfterViewInit() { |
| 27 | + // Wait for the view child to be picked up |
| 28 | + this.tree = [ |
| 29 | + { |
| 30 | + id: "1", |
| 31 | + value: "Artificial intelligence", |
| 32 | + label: "Artificial intelligence", |
| 33 | + icon: this.documentIcon |
| 34 | + }, |
| 35 | + { |
| 36 | + id: "2", |
| 37 | + value: "Blockchain", |
| 38 | + label: "Blockchain", |
| 39 | + icon: this.documentIcon |
| 40 | + }, |
| 41 | + { |
| 42 | + id: "3", |
| 43 | + value: "Business automation", |
| 44 | + label: "Business automation", |
| 45 | + children: [ |
| 46 | + { |
| 47 | + id: "3-1", |
| 48 | + value: "Business process automation", |
| 49 | + label: "Business process automation", |
| 50 | + icon: this.documentIcon |
| 51 | + }, |
| 52 | + { |
| 53 | + id: "3-2", |
| 54 | + value: "Business process mapping", |
| 55 | + label: "Business process mapping", |
| 56 | + icon: this.documentIcon |
| 57 | + } |
| 58 | + ], |
| 59 | + icon: "folder" |
| 60 | + }, |
| 61 | + { |
| 62 | + id: "4", |
| 63 | + value: "Business operations", |
| 64 | + label: "Business operations", |
| 65 | + icon: this.documentIcon |
| 66 | + }, |
| 67 | + { |
| 68 | + id: "5", |
| 69 | + value: "Cloud computing", |
| 70 | + label: "Cloud computing", |
| 71 | + "expanded": true, |
| 72 | + children: [ |
| 73 | + { |
| 74 | + id: "5-1", |
| 75 | + value: "Containers", |
| 76 | + label: "Containers", |
| 77 | + icon: this.documentIcon |
| 78 | + }, |
| 79 | + { |
| 80 | + id: "5-2", |
| 81 | + value: "Databases", |
| 82 | + label: "Databases", |
| 83 | + icon: this.documentIcon |
| 84 | + }, |
| 85 | + { |
| 86 | + id: "5-3", |
| 87 | + value: "DevOps", |
| 88 | + label: "DevOps", |
| 89 | + "expanded": true, |
| 90 | + children: [ |
| 91 | + { |
| 92 | + id: "5-4", |
| 93 | + value: "Solutions", |
| 94 | + label: "Solutions", |
| 95 | + icon: this.documentIcon |
| 96 | + }, |
| 97 | + { |
| 98 | + id: "5-5", |
| 99 | + value: "Case studies", |
| 100 | + label: "Case studies", |
| 101 | + "expanded": true, |
| 102 | + children: [ |
| 103 | + { |
| 104 | + id: "5-6", |
| 105 | + value: "Resources", |
| 106 | + label: "Resources", |
| 107 | + icon: this.documentIcon |
| 108 | + } |
| 109 | + ], |
| 110 | + icon: "folder" |
| 111 | + } |
| 112 | + ], |
| 113 | + icon: "folder" |
| 114 | + } |
| 115 | + ], |
| 116 | + icon: "folder" |
| 117 | + }, |
| 118 | + { |
| 119 | + id: "6", |
| 120 | + value: "Data & Analytics", |
| 121 | + label: "Data & Analytics", |
| 122 | + children: [ |
| 123 | + { |
| 124 | + id: "6-1", |
| 125 | + value: "Big data", |
| 126 | + label: "Big data", |
| 127 | + icon: this.documentIcon |
| 128 | + }, |
| 129 | + { |
| 130 | + id: "6-2", |
| 131 | + value: "Business intelligence", |
| 132 | + label: "Business intelligence", |
| 133 | + icon: this.documentIcon |
| 134 | + } |
| 135 | + ], |
| 136 | + icon: "folder" |
| 137 | + }, |
| 138 | + { |
| 139 | + id: "7", |
| 140 | + value: "IT infrastructure", |
| 141 | + label: "IT infrastructure", |
| 142 | + "expanded": true, |
| 143 | + "disabled": true, |
| 144 | + children: [ |
| 145 | + { |
| 146 | + id: "7-1", |
| 147 | + value: "Data storage", |
| 148 | + label: "Data storage", |
| 149 | + icon: this.documentIcon |
| 150 | + }, |
| 151 | + { |
| 152 | + id: "7-2", |
| 153 | + value: "Enterprise servers", |
| 154 | + label: "Enterprise servers", |
| 155 | + icon: this.documentIcon |
| 156 | + }, |
| 157 | + { |
| 158 | + id: "8", |
| 159 | + value: "Hybrid cloud infrastructure", |
| 160 | + label: "Hybrid cloud infrastructure", |
| 161 | + "expanded": true, |
| 162 | + children: [ |
| 163 | + { |
| 164 | + id: "8-1", |
| 165 | + value: "Insights", |
| 166 | + label: "Insights", |
| 167 | + icon: this.documentIcon |
| 168 | + }, |
| 169 | + { |
| 170 | + id: "8-2", |
| 171 | + value: "Benefits", |
| 172 | + label: "Benefits", |
| 173 | + icon: this.documentIcon |
| 174 | + } |
| 175 | + ], |
| 176 | + icon: "folder" |
| 177 | + } |
| 178 | + ], |
| 179 | + icon: "folder" |
| 180 | + } |
| 181 | + ]; |
| 182 | + } |
| 183 | +} |
0 commit comments