-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathselect.sample.ts
More file actions
165 lines (139 loc) · 5.55 KB
/
select.sample.ts
File metadata and controls
165 lines (139 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import { Component, OnInit, ViewChildren, QueryList, ViewChild } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { IgxButtonDirective, IgxSelectComponent, IgxLabelDirective, IgxPrefixDirective, IgxIconComponent, IgxSelectItemComponent, IgxSelectHeaderDirective, IgxSelectFooterDirective, IgxSuffixDirective, IgxHintDirective, IgxSelectGroupComponent, IgxSwitchComponent, ISelectionEventArgs, CancelableEventArgs, HorizontalAlignment, VerticalAlignment, ConnectedPositioningStrategy, AbsoluteScrollStrategy } from 'igniteui-angular';
import { scaleInTop, scaleOutBottom } from 'igniteui-angular/animations';
import { SizeSelectorComponent } from '../size-selector/size-selector.component';
@Component({
selector: 'app-select-sample',
styleUrls: ['./select.sample.scss'],
templateUrl: './select.sample.html',
imports: [
IgxButtonDirective,
IgxSelectComponent,
FormsModule,
IgxLabelDirective,
IgxPrefixDirective,
IgxIconComponent,
IgxSelectItemComponent,
IgxSelectHeaderDirective,
IgxSelectFooterDirective,
IgxSuffixDirective,
IgxHintDirective,
IgxSelectGroupComponent,
ReactiveFormsModule,
IgxSwitchComponent,
SizeSelectorComponent
]
})
export class SelectSampleComponent implements OnInit {
@ViewChild('selectReactive', { read: IgxSelectComponent, static: true })
public select: IgxSelectComponent;
@ViewChild('model', { read: IgxSelectComponent, static: true })
public selectFruits: IgxSelectComponent;
@ViewChild('sizeSelect', { read: IgxSelectComponent, static: true })
public sizeSelect: IgxSelectComponent;
@ViewChildren(IgxSelectComponent) private selectComponents: QueryList<IgxSelectComponent>;
public isDisabled = false;
public items: any[] = [];
public value: 'opt1';
public disabledItemValue: 'InsideGroup1';
public fruits: string[] = ['Orange', 'Apple', 'Banana', 'Mango', 'Pear', 'Lemon', 'Peach', 'Apricot', 'Grapes', 'Cactus'];
public selected: string;
public selectRequired = true;
//Test data for nested @if/@else issue
public testItems: string[] = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight'];
public reactiveForm: UntypedFormGroup;
public cities: string[] = [
'Sofia',
'Varna',
'Sozopol',
'Plovdiv',
'Ruse',
'Stara Zagora'
];
public validationType = {
citiesSelect: [Validators.required]
};
constructor(fb: UntypedFormBuilder) {
this.reactiveForm = fb.group({
citiesSelect: ['', Validators.required]
});
}
public ngOnInit() {
for (let i = 1; i < 10; i++) {
const item = { field: 'opt' + i };
this.items.push(item);
}
}
public onSubmitReactive() { }
public selectBanana() {
this.selectFruits.setSelectedItem(3);
}
public setToNull() {
this.selectFruits.value = null;
this.selected = null;
}
public testOnSelection(evt: ISelectionEventArgs) {
console.log('testOnSelection.....................' + evt.cancel);
}
public testOnOpening(evt: CancelableEventArgs) {
console.log('testOnOpening.....................: ' + evt.cancel);
}
public testOnOpened() {
// console.log('testOnOpened.....................: ');
}
public testOnClosing(evt: CancelableEventArgs) {
console.log('testOnClosing.....................: ' + evt.cancel);
}
public testOnClosed() {
// console.log('testOnClosed.....................: ');
}
public handleToggle() {
// console.log('handleToggle.....................: ');
this.selectComponents.first.toggle();
}
public handleOpen() {
if (this.selectComponents.first.collapsed) {
const customCloseOnOutsideClick = {
closeOnOutsideClick: false
};
console.log('onOpen.....................:');
this.selectComponents.first.open(customCloseOnOutsideClick);
}
}
public handleClose() {
if (!this.selectComponents.first.collapsed) {
// console.log('onClose.....................: ');
this.selectComponents.first.close();
}
}
public openCustomOverlaySettings() {
if (this.selectComponents.first.collapsed) {
const positionSettings = {
target: this.selectComponents.first.inputGroup.element.nativeElement,
horizontalDirection: HorizontalAlignment.Right,
verticalDirection: VerticalAlignment.Bottom,
horizontalStartPoint: HorizontalAlignment.Left,
verticalStartPoint: VerticalAlignment.Bottom,
openAnimation: scaleInTop,
closeAnimation: scaleOutBottom
};
const customOverlaySettings = {
modal: true,
closeOnOutsideClick: false,
positionStrategy: new ConnectedPositioningStrategy(
positionSettings
),
scrollStrategy: new AbsoluteScrollStrategy()
};
console.log('onOpenCustomOverlaySettings.....................: customOverlaySettings');
this.selectComponents.first.open(customOverlaySettings);
}
}
public btnClick() {
// console.log('clicked');
}
public headerFootedClick(event) {
console.log('Header/Footer clicked', event);
}
}