|
1 | | -import { Component } from '@angular/core'; |
2 | | -import { DialogType } from 'office-ui-fabric-react/lib/Dialog'; |
| 1 | +import { ChangeDetectorRef, ViewEncapsulation, Component, ComponentFactoryResolver, Injector, Input, ComponentRef, TemplateRef, ViewChild, AfterViewInit } from '@angular/core'; |
| 2 | +import { DialogType, ITheme, IChoiceGroupProps, SpinnerSize, PersonaSize, PersonaPresence, PivotLinkSize, SelectableOptionMenuItemType, PanelType, ICommandBarItemProps, IBreadcrumbItem, IButtonProps, Button, MessageBarType, ShimmerElementType } from 'office-ui-fabric-react'; |
| 3 | +import { IExpandingCardOptions } from '@angular-react/fabric/src/components/hover-card'; |
| 4 | +import { ICommandBarItemOptions, FabCommandBarComponent } from '@angular-react/fabric/src/components/command-bar'; |
| 5 | + |
3 | 6 |
|
4 | 7 | @Component({ |
5 | 8 | selector: 'app-root', |
6 | 9 | templateUrl: './app.component.html', |
7 | | - styleUrls: ['./app.component.css'] |
| 10 | + styleUrls: ['./app.component.css'], |
| 11 | + encapsulation: ViewEncapsulation.None, |
8 | 12 | }) |
9 | 13 | export class AppComponent { |
10 | | - DialogType = DialogType; |
11 | 14 |
|
12 | | - dialogHidden = true; |
13 | | - counter = 0; |
| 15 | + @ViewChild(FabCommandBarComponent) commandBar: FabCommandBarComponent; |
| 16 | + @ViewChild('customRange') customRangeTemplate: TemplateRef<{ item: any, dismissMenu: (ev?: any, dismissAll?: boolean) => void }>; |
14 | 17 |
|
15 | | - toggleDialog() { |
16 | | - this.dialogHidden = !this.dialogHidden; |
17 | | - } |
| 18 | + commandBarItems: ReadonlyArray<ICommandBarItemOptions> = [ |
| 19 | + { |
| 20 | + key: 'run', |
| 21 | + text: 'Run', |
| 22 | + iconProps: { |
| 23 | + iconName: 'CaretRight', |
| 24 | + }, |
| 25 | + disabled: true, |
| 26 | + }, |
| 27 | + { |
| 28 | + key: 'new', |
| 29 | + text: 'New', |
| 30 | + iconProps: { |
| 31 | + iconName: 'Add', |
| 32 | + }, |
| 33 | + onClick: () => console.log('Add clicked'), |
| 34 | + }, |
| 35 | + { |
| 36 | + key: 'save', |
| 37 | + text: 'Save', |
| 38 | + iconProps: { |
| 39 | + iconName: 'Save' |
| 40 | + }, |
| 41 | + subMenuProps: { |
| 42 | + items: [ |
| 43 | + { |
| 44 | + key: 'save', |
| 45 | + text: 'Save', |
| 46 | + onClick: () => console.log('Save clicked'), |
| 47 | + }, |
| 48 | + { |
| 49 | + key: 'save-as', |
| 50 | + text: 'Save as', |
| 51 | + subMenuProps: { |
| 52 | + onItemClick: (ev, item) => { |
| 53 | + console.log(`${item.text} clicked`) |
| 54 | + return true; |
| 55 | + }, |
| 56 | + items: [ |
| 57 | + { |
| 58 | + key: 'save-as-1', |
| 59 | + text: 'Save as 1', |
| 60 | + }, |
| 61 | + { |
| 62 | + key: 'save-as-2', |
| 63 | + text: 'Save as 2', |
| 64 | + }, |
| 65 | + ], |
| 66 | + }, |
| 67 | + }, |
| 68 | + ], |
| 69 | + }, |
| 70 | + }, |
| 71 | + { |
| 72 | + key: 'copy', |
| 73 | + text: 'Copy', |
| 74 | + iconProps: { |
| 75 | + iconName: 'Copy' |
| 76 | + }, |
| 77 | + onClick: () => console.log('Copy clicked'), |
| 78 | + }, |
| 79 | + { |
| 80 | + key: 'date-picker', |
| 81 | + text: 'Last 30 days', |
| 82 | + iconProps: { |
| 83 | + iconName: 'Calendar', |
| 84 | + }, |
| 85 | + subMenuProps: { |
| 86 | + onItemClick: (ev, item) => { |
| 87 | + console.log(item.text, 'clicked'); |
| 88 | + |
| 89 | + this.commandBarItems.find(item => item.key === 'date-picker').text = item.text; |
| 90 | + this.commandBarItems = [...this.commandBarItems]; |
| 91 | + }, |
| 92 | + items: [ |
| 93 | + { |
| 94 | + key: '24h', |
| 95 | + text: 'Last 24 hours', |
| 96 | + |
| 97 | + }, |
| 98 | + { |
| 99 | + key: '7d', |
| 100 | + text: 'Last 7 days', |
| 101 | + }, |
| 102 | + { |
| 103 | + key: '30d', |
| 104 | + text: 'Last 30 days', |
| 105 | + }, |
| 106 | + { |
| 107 | + key: 'custom', |
| 108 | + text: 'Custom range...', |
| 109 | + onClick: () => { |
| 110 | + this.commandBarItems = [ |
| 111 | + ...this.commandBarItems, |
| 112 | + { |
| 113 | + key: 'custom-range-range', |
| 114 | + data: { |
| 115 | + earliestDateAllowed: new Date(2015, 2, 15), |
| 116 | + }, |
| 117 | + render: this.customRangeTemplate, |
| 118 | + onClick: () => { |
| 119 | + debugger; |
| 120 | + } |
| 121 | + }, |
| 122 | + ]; |
| 123 | + }, |
| 124 | + }, |
| 125 | + ] |
| 126 | + } |
| 127 | + }, |
| 128 | + { |
| 129 | + key: 'schedule-monitor', |
| 130 | + text: 'Schedule a monitor', |
| 131 | + iconProps: { |
| 132 | + iconName: 'ScheduleEventAction' |
| 133 | + }, |
| 134 | + onClick: () => { |
| 135 | + this.isPanelOpen = true; |
| 136 | + console.log('Schedule a monitor clicked'); |
| 137 | + } |
| 138 | + }, |
| 139 | + ]; |
| 140 | + |
| 141 | + commandBarFarItems: ReadonlyArray<ICommandBarItemOptions> = [ |
| 142 | + { |
| 143 | + key: 'help', |
| 144 | + text: 'Help', |
| 145 | + iconProps: { |
| 146 | + iconName: 'Help' |
| 147 | + }, |
| 148 | + onClick: () => console.log('Help clicked'), |
| 149 | + }, |
| 150 | + { |
| 151 | + key: 'full-screen', |
| 152 | + iconOnly: true, |
| 153 | + iconProps: { |
| 154 | + iconName: 'MiniExpand' |
| 155 | + }, |
| 156 | + onClick: () => console.log('Expand clicked'), |
| 157 | + } |
| 158 | + ]; |
| 159 | + |
| 160 | + isPanelOpen = false; |
18 | 161 |
|
19 | | - incrementCounter() { |
20 | | - this.counter += 1; |
| 162 | + toggleRun() { |
| 163 | + this.commandBarItems = this.commandBarItems.map(item => |
| 164 | + item.key === 'run' |
| 165 | + ? { ...item, disabled: !item.disabled } |
| 166 | + : item |
| 167 | + ); |
21 | 168 | } |
22 | 169 |
|
23 | 170 | } |
0 commit comments