|
| 1 | +/* tslint:disable:max-line-length */ |
| 2 | + |
| 3 | + |
| 4 | +import { |
| 5 | + Component, |
| 6 | + NgModule, |
| 7 | + Host, |
| 8 | + ElementRef, |
| 9 | + Renderer2, |
| 10 | + Inject, |
| 11 | + AfterViewInit, |
| 12 | + SkipSelf, |
| 13 | + Input |
| 14 | +} from '@angular/core'; |
| 15 | + |
| 16 | +import { DOCUMENT } from '@angular/common'; |
| 17 | + |
| 18 | + |
| 19 | +import { LocateInMenuMode, ShowTextMode } from 'devextreme/ui/toolbar'; |
| 20 | +import { ToolbarItemLocation, ToolbarItemComponent, ButtonType } from 'devextreme/common'; |
| 21 | +import { SchedulerPredefinedToolbarItem, DateNavigatorItemProperties } from 'devextreme/ui/scheduler'; |
| 22 | + |
| 23 | +import { |
| 24 | + DxIntegrationModule, |
| 25 | + NestedOptionHost, |
| 26 | + extractTemplate, |
| 27 | + DxTemplateDirective, |
| 28 | + IDxTemplateHost, |
| 29 | + DxTemplateHost |
| 30 | +} from 'devextreme-angular/core'; |
| 31 | +import { CollectionNestedOption } from 'devextreme-angular/core'; |
| 32 | + |
| 33 | + |
| 34 | +@Component({ |
| 35 | + selector: 'dxi-scheduler-item', |
| 36 | + standalone: true, |
| 37 | + template: '<ng-content></ng-content>', |
| 38 | + styles: [':host { display: block; }'], |
| 39 | + imports: [ DxIntegrationModule ], |
| 40 | + providers: [NestedOptionHost, DxTemplateHost] |
| 41 | +}) |
| 42 | +export class DxiSchedulerItemComponent extends CollectionNestedOption implements AfterViewInit, |
| 43 | + IDxTemplateHost { |
| 44 | + @Input() |
| 45 | + get cssClass(): string | undefined { |
| 46 | + return this._getOption('cssClass'); |
| 47 | + } |
| 48 | + set cssClass(value: string | undefined) { |
| 49 | + this._setOption('cssClass', value); |
| 50 | + } |
| 51 | + |
| 52 | + @Input() |
| 53 | + get disabled(): boolean { |
| 54 | + return this._getOption('disabled'); |
| 55 | + } |
| 56 | + set disabled(value: boolean) { |
| 57 | + this._setOption('disabled', value); |
| 58 | + } |
| 59 | + |
| 60 | + @Input() |
| 61 | + get html(): string { |
| 62 | + return this._getOption('html'); |
| 63 | + } |
| 64 | + set html(value: string) { |
| 65 | + this._setOption('html', value); |
| 66 | + } |
| 67 | + |
| 68 | + @Input() |
| 69 | + get locateInMenu(): LocateInMenuMode { |
| 70 | + return this._getOption('locateInMenu'); |
| 71 | + } |
| 72 | + set locateInMenu(value: LocateInMenuMode) { |
| 73 | + this._setOption('locateInMenu', value); |
| 74 | + } |
| 75 | + |
| 76 | + @Input() |
| 77 | + get location(): ToolbarItemLocation { |
| 78 | + return this._getOption('location'); |
| 79 | + } |
| 80 | + set location(value: ToolbarItemLocation) { |
| 81 | + this._setOption('location', value); |
| 82 | + } |
| 83 | + |
| 84 | + @Input() |
| 85 | + get menuItemTemplate(): any { |
| 86 | + return this._getOption('menuItemTemplate'); |
| 87 | + } |
| 88 | + set menuItemTemplate(value: any) { |
| 89 | + this._setOption('menuItemTemplate', value); |
| 90 | + } |
| 91 | + |
| 92 | + @Input() |
| 93 | + get name(): SchedulerPredefinedToolbarItem { |
| 94 | + return this._getOption('name'); |
| 95 | + } |
| 96 | + set name(value: SchedulerPredefinedToolbarItem) { |
| 97 | + this._setOption('name', value); |
| 98 | + } |
| 99 | + |
| 100 | + @Input() |
| 101 | + get options(): DateNavigatorItemProperties | Record<string, any> { |
| 102 | + return this._getOption('options'); |
| 103 | + } |
| 104 | + set options(value: DateNavigatorItemProperties | Record<string, any>) { |
| 105 | + this._setOption('options', value); |
| 106 | + } |
| 107 | + |
| 108 | + @Input() |
| 109 | + get showText(): ShowTextMode { |
| 110 | + return this._getOption('showText'); |
| 111 | + } |
| 112 | + set showText(value: ShowTextMode) { |
| 113 | + this._setOption('showText', value); |
| 114 | + } |
| 115 | + |
| 116 | + @Input() |
| 117 | + get template(): any { |
| 118 | + return this._getOption('template'); |
| 119 | + } |
| 120 | + set template(value: any) { |
| 121 | + this._setOption('template', value); |
| 122 | + } |
| 123 | + |
| 124 | + @Input() |
| 125 | + get text(): string { |
| 126 | + return this._getOption('text'); |
| 127 | + } |
| 128 | + set text(value: string) { |
| 129 | + this._setOption('text', value); |
| 130 | + } |
| 131 | + |
| 132 | + @Input() |
| 133 | + get visible(): boolean { |
| 134 | + return this._getOption('visible'); |
| 135 | + } |
| 136 | + set visible(value: boolean) { |
| 137 | + this._setOption('visible', value); |
| 138 | + } |
| 139 | + |
| 140 | + @Input() |
| 141 | + get widget(): ToolbarItemComponent { |
| 142 | + return this._getOption('widget'); |
| 143 | + } |
| 144 | + set widget(value: ToolbarItemComponent) { |
| 145 | + this._setOption('widget', value); |
| 146 | + } |
| 147 | + |
| 148 | + @Input() |
| 149 | + get elementAttr(): Record<string, any> { |
| 150 | + return this._getOption('elementAttr'); |
| 151 | + } |
| 152 | + set elementAttr(value: Record<string, any>) { |
| 153 | + this._setOption('elementAttr', value); |
| 154 | + } |
| 155 | + |
| 156 | + @Input() |
| 157 | + get hint(): string { |
| 158 | + return this._getOption('hint'); |
| 159 | + } |
| 160 | + set hint(value: string) { |
| 161 | + this._setOption('hint', value); |
| 162 | + } |
| 163 | + |
| 164 | + @Input() |
| 165 | + get icon(): string { |
| 166 | + return this._getOption('icon'); |
| 167 | + } |
| 168 | + set icon(value: string) { |
| 169 | + this._setOption('icon', value); |
| 170 | + } |
| 171 | + |
| 172 | + @Input() |
| 173 | + get type(): ButtonType | string { |
| 174 | + return this._getOption('type'); |
| 175 | + } |
| 176 | + set type(value: ButtonType | string) { |
| 177 | + this._setOption('type', value); |
| 178 | + } |
| 179 | + |
| 180 | + |
| 181 | + protected get _optionPath() { |
| 182 | + return 'items'; |
| 183 | + } |
| 184 | + |
| 185 | + |
| 186 | + constructor(@SkipSelf() @Host() parentOptionHost: NestedOptionHost, |
| 187 | + @Host() optionHost: NestedOptionHost, |
| 188 | + private renderer: Renderer2, |
| 189 | + @Inject(DOCUMENT) private document: any, |
| 190 | + @Host() templateHost: DxTemplateHost, |
| 191 | + private element: ElementRef) { |
| 192 | + super(); |
| 193 | + parentOptionHost.setNestedOption(this); |
| 194 | + optionHost.setHost(this, this._fullOptionPath.bind(this)); |
| 195 | + templateHost.setHost(this); |
| 196 | + } |
| 197 | + |
| 198 | + setTemplate(template: DxTemplateDirective) { |
| 199 | + this.template = template; |
| 200 | + } |
| 201 | + ngAfterViewInit() { |
| 202 | + extractTemplate(this, this.element, this.renderer, this.document); |
| 203 | + } |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + ngOnDestroy() { |
| 208 | + this._deleteRemovedOptions(this._fullOptionPath()); |
| 209 | + } |
| 210 | + |
| 211 | +} |
| 212 | + |
| 213 | +@NgModule({ |
| 214 | + imports: [ |
| 215 | + DxiSchedulerItemComponent |
| 216 | + ], |
| 217 | + exports: [ |
| 218 | + DxiSchedulerItemComponent |
| 219 | + ], |
| 220 | +}) |
| 221 | +export class DxiSchedulerItemModule { } |
0 commit comments