1
- import { Component , ViewChild } from '@angular/core' ;
1
+ import { Component , CUSTOM_ELEMENTS_SCHEMA , DestroyRef , ViewChild } from '@angular/core' ;
2
2
import { JsonPipe } from '@angular/common' ;
3
3
import { UntypedFormGroup , UntypedFormBuilder , Validators , UntypedFormControl , ValidatorFn , AbstractControl , FormsModule , ReactiveFormsModule } from '@angular/forms' ;
4
+ import { DateRange , IgxButtonDirective , IgxDateRangePickerComponent , IgxDateTimeEditorDirective , IgxInputDirective , IgxLabelDirective , IgxRadioComponent , IgxRippleDirective , IGX_INPUT_GROUP_TYPE , IChangeCheckboxEventArgs , IGX_DATE_RANGE_PICKER_DIRECTIVES , IgxIconComponent , IgSizeDirective } from 'igniteui-angular' ;
4
5
import { DateRangeType } from 'igniteui-angular/src/lib/calendar/common/types' ;
6
+ import { defineComponents , IgcButtonComponent , IgcDateRangePickerComponent , IgcDateTimeInputComponent , IgcIconComponent } from 'igniteui-webcomponents' ;
7
+ import { Properties , PropertyChangeService , PropertyPanelConfig } from '../properties-panel/property-change.service' ;
5
8
9
+ defineComponents ( IgcDateRangePickerComponent , IgcButtonComponent , IgcIconComponent , IgcDateTimeInputComponent ) ;
6
10
7
11
@Component ( {
8
12
selector : 'app-date-range' ,
9
13
templateUrl : './date-range.sample.html' ,
10
14
styleUrls : [ './date-range.sample.scss' ] ,
15
+ schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
11
16
providers : [
12
17
{
13
18
provide : IGX_INPUT_GROUP_TYPE ,
14
19
useValue : 'border'
15
20
}
16
21
] ,
17
- imports : [ IgxButtonDirective , IgxRippleDirective , IgxDateRangePickerComponent , IgxPickerToggleComponent , IgxSuffixDirective , IgxIconComponent , IgxDateRangeStartComponent , IgxInputDirective , IgxDateTimeEditorDirective , IgxPrefixDirective , IgxDateRangeEndComponent , FormsModule , IgxLabelDirective , IgxRadioComponent , ReactiveFormsModule , JsonPipe ]
22
+ imports : [
23
+ IgxButtonDirective ,
24
+ IgxRippleDirective ,
25
+ FormsModule ,
26
+ IgxLabelDirective ,
27
+ IgxRadioComponent ,
28
+ ReactiveFormsModule ,
29
+ JsonPipe ,
30
+ IGX_DATE_RANGE_PICKER_DIRECTIVES ,
31
+ IgxInputDirective ,
32
+ IgxDateTimeEditorDirective ,
33
+ IgxIconComponent ,
34
+ IgSizeDirective
35
+ ]
18
36
} )
19
37
export class DateRangeSampleComponent {
20
38
@ViewChild ( 'dr1' , { static : true } )
@@ -29,22 +47,155 @@ export class DateRangeSampleComponent {
29
47
public range6Start = null ;
30
48
public range6End = null ;
31
49
public range6 : DateRange = { start : this . range6Start , end : this . range6End } ;
32
- public minDate : Date = new Date ( ) ;
50
+ public minDate : Date = new Date ( new Date ( ) . setDate ( new Date ( ) . getDate ( ) - 20 ) ) ;
33
51
public maxDate : Date = new Date ( new Date ( ) . setDate ( new Date ( ) . getDate ( ) + 25 ) ) ;
34
52
35
53
public reactiveForm : UntypedFormGroup ;
54
+ public DateRangeType = DateRangeType ;
36
55
37
56
public updateOnOptions : string [ ] = [ 'change' , 'blur' , 'submit' ] ;
38
57
public updateOn = 'blur' ;
39
58
59
+
60
+ public specialDates = [ {
61
+ type : DateRangeType . Between , dateRange : [
62
+ new Date ( new Date ( ) . getFullYear ( ) , new Date ( ) . getMonth ( ) , 3 ) ,
63
+ new Date ( new Date ( ) . getFullYear ( ) , new Date ( ) . getMonth ( ) , 8 )
64
+ ]
65
+ } ] ;
66
+
40
67
public disabledDates = [ {
41
68
type : DateRangeType . Between , dateRange : [
42
69
new Date ( new Date ( ) . getFullYear ( ) , new Date ( ) . getMonth ( ) , 20 ) ,
43
70
new Date ( new Date ( ) . getFullYear ( ) , new Date ( ) . getMonth ( ) , 25 )
44
71
]
45
72
} ] ;
46
73
47
- constructor ( fb : UntypedFormBuilder ) {
74
+ public panelConfig : PropertyPanelConfig = {
75
+ size : {
76
+ control : {
77
+ type : 'button-group' ,
78
+ options : [ 'small' , 'medium' , 'large' ] ,
79
+ defaultValue : 'medium' ,
80
+ }
81
+ } ,
82
+ mode : {
83
+ control : {
84
+ type : 'button-group' ,
85
+ options : [ 'dropdown' , 'dialog' ] ,
86
+ defaultValue : 'dropdown'
87
+ }
88
+ } ,
89
+ value : {
90
+ control : {
91
+ type : 'date-range' ,
92
+ defaultValue : this . range3
93
+ }
94
+ } ,
95
+ minValue : {
96
+ label : 'Min Value' ,
97
+ control : {
98
+ type : 'date' ,
99
+ defaultValue : this . minDate
100
+ }
101
+ } ,
102
+ maxValue : {
103
+ label : 'Max Value' ,
104
+ control : {
105
+ type : 'date' ,
106
+ defaultValue : this . maxDate
107
+ }
108
+ } ,
109
+ required : {
110
+ control : {
111
+ type : 'boolean' ,
112
+ defaultValue : false
113
+ }
114
+ } ,
115
+ disabled : {
116
+ control : {
117
+ type : 'boolean' ,
118
+ defaultValue : false
119
+ }
120
+ } ,
121
+ placeholder : {
122
+ control : {
123
+ type : 'text' ,
124
+ defaultValue : 'MM/dd/yyyy'
125
+ }
126
+ } ,
127
+ displayFormat : {
128
+ label : 'Display Format' ,
129
+ control : {
130
+ type : 'text'
131
+ }
132
+ } ,
133
+ inputFormat : {
134
+ label : 'Input Format' ,
135
+ control : {
136
+ type : 'text'
137
+ }
138
+ } ,
139
+ hasHeader : {
140
+ label : 'Has Header (for dialog mode)' ,
141
+ control : {
142
+ type : 'boolean' ,
143
+ defaultValue : true
144
+ }
145
+ } ,
146
+ orientation : {
147
+ label : 'Orientation' ,
148
+ control : {
149
+ type : 'button-group' ,
150
+ options : [ 'horizontal' , 'vertical' ] ,
151
+ defaultValue : 'horizontal'
152
+ }
153
+ } ,
154
+ headerOrientation : {
155
+ label : 'Header Orientation (dialog mode)' ,
156
+ control : {
157
+ type : 'button-group' ,
158
+ options : [ 'horizontal' , 'vertical' ] ,
159
+ defaultValue : 'horizontal'
160
+ }
161
+ } ,
162
+ headerTemplate : {
163
+ label : 'Show Header Template (dialog)' ,
164
+ control : {
165
+ type : 'boolean' ,
166
+ defaultValue : false
167
+ }
168
+ } ,
169
+ calendarTitle : {
170
+ label : 'Show Calendar Title (dialog)' ,
171
+ control : {
172
+ type : 'boolean' ,
173
+ defaultValue : false
174
+ }
175
+ } ,
176
+ separator : {
177
+ label : 'Separator text' ,
178
+ control : {
179
+ type : 'text' ,
180
+ defaultValue : 'to'
181
+ }
182
+ } ,
183
+ visibleMonths : {
184
+ label : 'Visible Months' ,
185
+ control : {
186
+ type : 'number' ,
187
+ defaultValue : 2 ,
188
+ }
189
+ } ,
190
+ } ;
191
+
192
+ public properties : Properties ;
193
+
194
+ constructor (
195
+ fb : UntypedFormBuilder ,
196
+ private propertyChangeService : PropertyChangeService ,
197
+ private destroyRef : DestroyRef
198
+ ) {
48
199
const today = new Date ( ) ;
49
200
const in5days = new Date ( ) ;
50
201
in5days . setDate ( today . getDate ( ) + 5 ) ;
@@ -60,6 +211,17 @@ export class DateRangeSampleComponent {
60
211
start6 : [ '' , { validators : Validators . required , updateOn : this . updateOn } ] ,
61
212
end6 : [ '' , { validators : Validators . required , updateOn : this . updateOn } ] ,
62
213
} ) ;
214
+
215
+ this . propertyChangeService . setPanelConfig ( this . panelConfig ) ;
216
+
217
+ const propertyChange =
218
+ this . propertyChangeService . propertyChanges . subscribe (
219
+ ( properties ) => {
220
+ this . properties = properties ;
221
+ }
222
+ ) ;
223
+
224
+ this . destroyRef . onDestroy ( ( ) => propertyChange . unsubscribe ( ) ) ;
63
225
}
64
226
65
227
public updateOnChange ( e : IChangeCheckboxEventArgs ) {
0 commit comments