1- import { Component , ViewChild } from '@angular/core' ;
1+ import { Component , DestroyRef , inject , TemplateRef , ViewChild , OnInit } from '@angular/core' ;
22import { FormsModule } from '@angular/forms' ;
33import {
44 IgxTimePickerComponent ,
@@ -13,22 +13,53 @@ import {
1313 IgxPrefixDirective ,
1414 IgxIconComponent ,
1515 IgxPickerClearComponent ,
16- IgxSuffixDirective
16+ IgxSuffixDirective ,
17+ IgxLabelDirective ,
18+ IgSizeDirective ,
19+ PickerInteractionMode ,
20+ IgxSwitchComponent
1721} from 'igniteui-angular' ;
22+ import {
23+ PropertyPanelConfig ,
24+ PropertyChangeService ,
25+ Properties ,
26+ } from '../properties-panel/property-change.service' ;
1827
1928@Component ( {
2029 selector : 'app-time-picker-sample' ,
2130 styleUrls : [ 'time-picker.sample.scss' ] ,
2231 templateUrl : 'time-picker.sample.html' ,
23- imports : [ IgxTimePickerComponent , FormsModule , IgxHintDirective , IgxButtonDirective , IgxPickerActionsDirective , IgxPickerToggleComponent , IgxPrefixDirective , IgxIconComponent , IgxPickerClearComponent , IgxSuffixDirective ]
32+ imports : [
33+ IgxTimePickerComponent ,
34+ FormsModule ,
35+ IgxHintDirective ,
36+ IgxButtonDirective ,
37+ IgxPickerActionsDirective ,
38+ IgxPickerToggleComponent ,
39+ IgxPrefixDirective ,
40+ IgxIconComponent ,
41+ IgxPickerClearComponent ,
42+ IgxSuffixDirective ,
43+ IgxLabelDirective ,
44+ IgSizeDirective ,
45+ IgxSwitchComponent
46+ ]
2447} )
25- export class TimePickerSampleComponent {
48+ export class TimePickerSampleComponent implements OnInit {
2649 @ViewChild ( 'tp' , { read : IgxTimePickerComponent , static : true } )
2750 public tp : IgxTimePickerComponent ;
2851
2952 @ViewChild ( 'target' )
3053 public target : IgxInputDirective ;
3154
55+ @ViewChild ( 'customControls' , { static : true } )
56+ public customControlsTemplate ! : TemplateRef < any > ;
57+
58+ public hasSuffix = false ;
59+ public hasPrefix = false ;
60+ public hasLabel = false ;
61+ public hasHint = false ;
62+
3263 public itemsDelta = { hours : 1 , minutes : 15 , seconds : 20 } ;
3364 public format = 'hh:mm:ss:SS a' ;
3465 public spinLoop = true ;
@@ -49,6 +80,91 @@ export class TimePickerSampleComponent {
4980 positionStrategy : new AutoPositionStrategy ( )
5081 } ;
5182
83+ public panelConfig : PropertyPanelConfig = {
84+ size : {
85+ control : {
86+ type : 'button-group' ,
87+ options : [ 'small' , 'medium' , 'large' ] ,
88+ defaultValue : 'medium' ,
89+ }
90+ } ,
91+ mode : {
92+ control : {
93+ type : 'button-group' ,
94+ options : [
95+ { label : 'dialog' , value : PickerInteractionMode . Dialog } ,
96+ { label : 'dropdown' , value : PickerInteractionMode . DropDown }
97+ ] ,
98+ defaultValue : 'dropdown'
99+ }
100+ } ,
101+ type : {
102+ control : {
103+ type : 'button-group' ,
104+ options : [ 'box' , 'border' , 'line' ] ,
105+ defaultValue : 'box'
106+ }
107+ } ,
108+ readonly : {
109+ control : {
110+ type : 'boolean' ,
111+ defaultValue : false
112+ }
113+ } ,
114+ disabled : {
115+ control : {
116+ type : 'boolean' ,
117+ defaultValue : false
118+ }
119+ } ,
120+ value : {
121+ control : {
122+ type : 'time'
123+ }
124+ } ,
125+ placeholder : {
126+ control : {
127+ type : 'text' ,
128+ defaultValue : 'hh:mm'
129+ }
130+ } ,
131+ displayFormat : {
132+ label : 'Display Format' ,
133+ control : {
134+ type : 'text'
135+ }
136+ } ,
137+ inputFormat : {
138+ label : 'Input Format' ,
139+ control : {
140+ type : 'text'
141+ }
142+ }
143+ }
144+
145+ public properties : Properties ;
146+ private propertyChangeService = inject ( PropertyChangeService ) ;
147+ private destroyRef = inject ( DestroyRef ) ;
148+
149+ constructor ( ) {
150+ this . propertyChangeService . setPanelConfig ( this . panelConfig ) ;
151+
152+ const propertyChange =
153+ this . propertyChangeService . propertyChanges . subscribe (
154+ ( properties ) => {
155+ this . properties = properties ;
156+ }
157+ ) ;
158+
159+ this . destroyRef . onDestroy ( ( ) => propertyChange . unsubscribe ( ) ) ;
160+ }
161+
162+ public ngOnInit ( ) {
163+ this . propertyChangeService . setCustomControls (
164+ this . customControlsTemplate
165+ ) ;
166+ }
167+
52168 public change ( ) {
53169 this . isRequired = ! this . isRequired ;
54170 }
0 commit comments