Skip to content

Commit 4a5daf7

Browse files
authored
Merge branch '20.1.x' into iminchev/default-merge-strategy-elements
2 parents 3784e04 + 52e4e9c commit 4a5daf7

File tree

3 files changed

+180
-8
lines changed

3 files changed

+180
-8
lines changed

src/app/time-picker/time-picker.sample.html

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,34 @@
22
<article class="timepicker-column">
33
<h4 class="sample-title">Time Picker with Date value binding</h4>
44
<p class="sample-description">{{showDate(date)}}</p>
5-
<div class="preview">
6-
<igx-time-picker #tp [value]="date" [minValue]="min" [maxValue]="max" [spinLoop]="spinLoop" locale="FR"
7-
[itemsDelta]="itemsDelta" [inputFormat]="format" displayFormat="longDate" (valueChange)="valueChanged($event)"
8-
(validationFailed)="validationFailed($event)">
5+
<div class="preview" [igSize]="properties.size">
6+
<igx-time-picker
7+
#tp
8+
[mode]="properties.mode"
9+
[type]="properties.type"
10+
[value]="properties.value"
11+
[minValue]="min"
12+
[maxValue]="max"
13+
[spinLoop]="spinLoop"
14+
locale="FR"
15+
[itemsDelta]="itemsDelta"
16+
[inputFormat]="properties.inputFormat"
17+
[displayFormat]="properties.displayFormat"
18+
[readOnly]="properties.readonly"
19+
[disabled]="properties.disabled"
20+
[placeholder]="properties.placeholder"
21+
(valueChange)="valueChanged($event)"
22+
(validationFailed)="validationFailed($event)"
23+
>
24+
@if (hasLabel) {
25+
<label igxLabel>It's a Label</label>
26+
} @if (hasPrefix) {
27+
<igx-icon igxPrefix>face</igx-icon>
28+
} @if (hasSuffix) {
29+
<igx-icon igxSuffix>face</igx-icon>
30+
} @if (hasHint) {
31+
<span igxHint>It's a hint</span>
32+
}
933
</igx-time-picker>
1034
</div>
1135
</article>
@@ -77,4 +101,24 @@ <h4 class="sample-title">Time Picker with custom spin buttons</h4>
77101
</igx-time-picker>
78102
</div>
79103
</article>
104+
105+
<ng-template #customControls>
106+
<div class="custom-controls">
107+
<igx-switch id="addPrefix" [(ngModel)]="hasPrefix">
108+
<label for="addPrefix">Add prefix</label>
109+
</igx-switch>
110+
111+
<igx-switch id="addSuffix" [(ngModel)]="hasSuffix">
112+
<label for="addSuffix">Add suffix</label>
113+
</igx-switch>
114+
115+
<igx-switch id="addLabel" [(ngModel)]="hasLabel">
116+
<label for="addLabel">Add Label</label>
117+
</igx-switch>
118+
119+
<igx-switch id="addHint" [(ngModel)]="hasHint">
120+
<label for="addHint">Add Hint</label>
121+
</igx-switch>
122+
</div>
123+
</ng-template>
80124
</div>

src/app/time-picker/time-picker.sample.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,15 @@
1414
justify-content: center;
1515
padding: 8px;
1616
}
17+
18+
.custom-controls {
19+
igx-switch {
20+
display: flex;
21+
align-items: center;
22+
margin-bottom: 16px;
23+
24+
label {
25+
margin: 0;
26+
}
27+
}
28+
}

src/app/time-picker/time-picker.sample.ts

Lines changed: 120 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild } from '@angular/core';
1+
import { Component, DestroyRef, inject, TemplateRef, ViewChild, OnInit } from '@angular/core';
22
import { FormsModule } from '@angular/forms';
33
import {
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

Comments
 (0)