Skip to content

Commit aa13a72

Browse files
authored
Merge pull request #273 from IgniteUI/dkamburov/timepicker
Add TimePickerComponent
2 parents 2e46a39 + 44408d6 commit aa13a72

File tree

7 files changed

+173
-7
lines changed

7 files changed

+173
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@types/node": "^6.0.46",
4545
"@types/jasmine": "^2.5.36",
4646
"@types/reflect-metadata": "^0.0.5",
47-
"@types/ignite-ui": "^0.0.4",
47+
"@types/ignite-ui": "^18.1.1",
4848
"@types/jquery": "2.0.47",
4949
"rollup": "^0.52.1",
5050
"rollup-plugin-node-resolve": "^3.0.0",

samples/igEditors/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, NgModule } from '@angular/core';
22
import { IgCurrencyEditorComponent, IgDateEditorComponent, IgMaskEditorComponent, IgNumericEditorComponent,
3-
IgPercentEditorComponent, IgTextEditorComponent, IgDatePickerComponent } from "../../src/igniteui.angular2";
3+
IgPercentEditorComponent, IgTextEditorComponent, IgDatePickerComponent, IgTimePickerComponent } from "../../src/igniteui.angular2";
44
import { FormsModule } from '@angular/forms';
55
import { BrowserModule } from '@angular/platform-browser';
66
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
@@ -22,14 +22,14 @@ export class AppComponent {
2222
numeric: 123,
2323
percent: 0.12,
2424
text: 'Ignite UI'
25-
};
25+
};
2626
}
2727
}
2828

2929
@NgModule({
3030
imports: [ BrowserModule, FormsModule ],
3131
declarations: [ AppComponent, IgCurrencyEditorComponent, IgDateEditorComponent, IgMaskEditorComponent, IgNumericEditorComponent,
32-
IgPercentEditorComponent, IgTextEditorComponent, IgDatePickerComponent ],
32+
IgPercentEditorComponent, IgTextEditorComponent, IgDatePickerComponent, IgTimePickerComponent ],
3333
bootstrap: [ AppComponent ]
3434
})
3535
export class AppModule {}

samples/igEditors/igEditorsTemplate.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
<td>igDatePicker</td>
4242
<td><input class="form-control" type="text" id="datePicker11" [(ngModel)]="editors.date" /></td>
4343
<td><ig-date-picker widgetId="datePicker1" [(ngModel)]="editors.date" [options]="{width:'100%'}"></ig-date-picker></td>
44+
</tr>
45+
<tr>
46+
<td>igTimePicker</td>
47+
<td><input class="form-control" type="text" id="timePicker11" [(ngModel)]="editors.date" /></td>
48+
<td><ig-time-picker widgetId="timePicker1" [(ngModel)]="editors.date" [options]="{width:'100%',isLimitedToListValues:false}"></ig-time-picker></td>
4449
</tr>
4550
</tbody>
4651
</table>

src/igcontrolbase/igcontrolbase.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var NODES = {
88
"ig-percent-editor": "input",
99
"ig-mask-editor": "input",
1010
"ig-date-picker": "input",
11+
"ig-time-picker": "input",
1112
"ig-date-editor": "input",
1213
"ig-currency-editor": "input",
1314
"ig-checkbox-editor": "input",
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { Component, ElementRef, Renderer, IterableDiffers, Optional, KeyValueDiffers, ChangeDetectorRef } from "@angular/core";
2+
import { IgEditorBase } from "./igeditorbase";
3+
import { NgModel } from "@angular/forms";
4+
5+
6+
@Component({
7+
selector: "ig-time-picker",
8+
template: "<ng-content></ng-content>",
9+
inputs: ["widgetId", "options", "disabled", "create", "locale", "language", "regional", "width", "height", "value", "tabIndex", "allowNullValue", "nullValue", "inputName", "readOnly", "validatorOptions", "buttonType", "listItems", "listWidth", "listItemHoverDuration", "dropDownAttachedToBody", "dropDownAnimationDuration", "visibleItemsCount", "includeKeys", "excludeKeys", "textAlign", "placeHolder", "selectionOnFocus", "textMode", "spinWrapAround", "isLimitedToListValues", "revertIfNotValid", "preventSubmitOnEnter", "dropDownOrientation", "maxLength", "dropDownOnReadOnly", "toUpper", "toLower", "suppressNotifications", "suppressKeyboard", "inputMask", "dataMode", "unfilledCharsPrompt", "padChar", "emptyChar", "minValue", "maxValue", "dateDisplayFormat", "dateInputFormat", "displayTimeOffset", "spinDelta", "limitSpinToCurrentField", "enableUTCDates", "centuryThreshold", "yearShift", "itemsDelta", "timeInputFormat", "timeDisplayFormat"],
10+
outputs: ["rendering", "rendered", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout", "blur", "focus", "keydown", "keypress", "keyup", "valueChanging", "valueChanged", "dropDownListOpening", "dropDownListOpened", "dropDownListClosing", "dropDownListClosed", "dropDownItemSelecting", "dropDownItemSelected", "textChanged"]
11+
})
12+
export class IgTimePickerComponent extends IgEditorBase<IgTimePicker> {
13+
constructor(el: ElementRef, renderer: Renderer, differs: IterableDiffers, kvalDiffers: KeyValueDiffers, cdr: ChangeDetectorRef, @Optional() public model: NgModel) { super(el, renderer, differs, kvalDiffers, cdr, model); }
14+
/**
15+
* Gets the selected list item.
16+
*/
17+
public getSelectedListItem(): string { return; };
18+
19+
/**
20+
* Returns the visibility state of the calendar.
21+
*/
22+
public dropDownVisible(): boolean { return; };
23+
24+
/**
25+
* Returns a reference to the drop-down button UI element of the editor.
26+
*/
27+
public dropDownButton(): string { return; };
28+
29+
/**
30+
* Gets reference to jquery object which is used as container of drop-down list.
31+
*/
32+
public dropDownContainer(): string { return; };
33+
34+
/**
35+
* Finds index of list item by text that matches with the search parameters.
36+
*
37+
* @param text The text to search for in the drop down list.
38+
* @param matchType The rule that is applied for searching the text.
39+
*/
40+
public findListItemIndex(text: string, matchType?: Object): number { return; };
41+
42+
/**
43+
* Gets the index of the selected list item. Sets selected item by index.
44+
*
45+
* @param index The index of the item that needs to be selected.
46+
*/
47+
public selectedListIndex(index?: number): number { return; };
48+
public value(newValue: Object): void { return; };
49+
public selectDate(): void { return; };
50+
51+
/**
52+
* Changes the the regional settings of widget element to the language specified in [options.regional](ui.igdateeditor#options:regional)
53+
* Note that this method is for rare scenarios, use [regional](ui.igdateeditor#options:regional) option setter
54+
*/
55+
public changeRegional(): void { return; };
56+
57+
/**
58+
* Gets selected date as a date object. This method can be used when dataMode is set as either displayModeText or editModeText.
59+
* In such cases the value() method will not return date object and getSelectedDate() can be used to replace that functionality.
60+
*/
61+
public getSelectedDate(): Date { return; };
62+
63+
/**
64+
* Increases the date or time period, depending on the current cursor position.
65+
*
66+
* @param delta The increase delta.
67+
*/
68+
public spinUp(delta?: number): void { return; };
69+
70+
/**
71+
* Decreases the date or time period, depending on the current cursor position.
72+
*
73+
* @param delta The decrease delta.
74+
*/
75+
public spinDown(delta?: number): void { return; };
76+
77+
/**
78+
* Returns a reference to the spin up UI element of the editor.
79+
*/
80+
public spinUpButton(): string { return; };
81+
82+
/**
83+
* Returns a reference to the spin down UI element of the editor.
84+
*/
85+
public spinDownButton(): string { return; };
86+
87+
/**
88+
* Checks if the value in the editor is valid. Note: This function will not trigger automatic notifications.
89+
*/
90+
public isValid(): boolean { return; };
91+
}

src/igniteui.angular2.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { IgCheckboxEditorComponent } from './igeditors/igcheckboxeditor.componen
2626
import { IgCurrencyEditorComponent } from './igeditors/igcurrencyeditor.component';
2727
import { IgDateEditorComponent } from './igeditors/igdateeditor.component';
2828
import { IgDatePickerComponent } from './igeditors/igdatepicker.component';
29+
import { IgTimePickerComponent } from './igeditors/igtimepicker.component';
2930
import { IgMaskEditorComponent } from './igeditors/igmaskeditor.component';
3031
import { IgNumericEditorComponent } from './igeditors/ignumericeditor.component';
3132
import { IgPercentEditorComponent } from './igeditors/igpercenteditor.component';
@@ -87,6 +88,7 @@ export { IgCheckboxEditorComponent };
8788
export { IgCurrencyEditorComponent };
8889
export { IgDateEditorComponent };
8990
export { IgDatePickerComponent };
91+
export { IgTimePickerComponent };
9092
export { IgMaskEditorComponent };
9193
export { IgNumericEditorComponent };
9294
export { IgPercentEditorComponent };
@@ -122,7 +124,7 @@ export { IgSpreadsheetComponent };
122124
export { IgSchedulerComponent };
123125

124126
@NgModule({
125-
declarations: [Column,IgGridMultiColumnHeadersFeature,IgGridSortingFeature,IgGridFilteringFeature,IgGridPagingFeature,IgGridUpdatingFeature,IgGridGroupByFeature,IgGridColumnMovingFeature,IgGridHidingFeature,IgGridCellMergingFeature,IgGridResponsiveFeature,IgGridResizingFeature,IgGridSelectionFeature,IgGridRowSelectorsFeature,IgGridSummariesFeature,IgGridColumnFixingFeature,IgGridTooltipsFeature,IgGridAppendRowsOnDemandFeature,Features,IgGridComponent,IgTreeGridComponent,IgHierarchicalGridComponent,IgComboComponent,IgCheckboxEditorComponent,IgCurrencyEditorComponent,IgDateEditorComponent,IgDatePickerComponent,IgMaskEditorComponent,IgNumericEditorComponent,IgPercentEditorComponent,IgTextEditorComponent,IgTreeComponent,IgDialogComponent,IgSplitterComponent,IgLayoutManagerComponent,IgTileManagerComponent,IgHtmlEditorComponent,IgValidatorComponent,IgPivotDataSelectorComponent,IgPivotGridComponent,IgDataChartComponent,IgPieChartComponent,IgDoughnutChartComponent,IgFunnelChartComponent,IgRadialGaugeComponent,IgZoombarComponent,IgMapComponent,IgSparklineComponent,IgBulletGraphComponent,IgLinearGaugeComponent,IgQRCodeBarcodeComponent,IgUploadComponent,IgPopoverComponent,IgNotifierComponent,IgRatingComponent,IgVideoPlayerComponent,IgRadialMenuComponent,IgSplitButtonComponent, IgSpreadsheetComponent, IgSchedulerComponent],
126-
exports: [Column, IgGridMultiColumnHeadersFeature, IgGridSortingFeature,IgGridFilteringFeature,IgGridPagingFeature,IgGridUpdatingFeature,IgGridGroupByFeature,IgGridColumnMovingFeature,IgGridHidingFeature,IgGridCellMergingFeature,IgGridResponsiveFeature,IgGridResizingFeature,IgGridSelectionFeature,IgGridRowSelectorsFeature,IgGridSummariesFeature,IgGridColumnFixingFeature,IgGridTooltipsFeature,IgGridAppendRowsOnDemandFeature,Features,IgGridComponent,IgTreeGridComponent,IgHierarchicalGridComponent,IgComboComponent,IgCheckboxEditorComponent,IgCurrencyEditorComponent,IgDateEditorComponent,IgDatePickerComponent,IgMaskEditorComponent,IgNumericEditorComponent,IgPercentEditorComponent,IgTextEditorComponent,IgTreeComponent,IgDialogComponent,IgSplitterComponent,IgLayoutManagerComponent,IgTileManagerComponent,IgHtmlEditorComponent,IgValidatorComponent,IgPivotDataSelectorComponent,IgPivotGridComponent,IgDataChartComponent,IgPieChartComponent,IgDoughnutChartComponent,IgFunnelChartComponent,IgRadialGaugeComponent,IgZoombarComponent,IgMapComponent,IgSparklineComponent,IgBulletGraphComponent,IgLinearGaugeComponent,IgQRCodeBarcodeComponent,IgUploadComponent,IgPopoverComponent,IgNotifierComponent,IgRatingComponent,IgVideoPlayerComponent,IgRadialMenuComponent,IgSplitButtonComponent, IgSpreadsheetComponent, IgSchedulerComponent]
127+
declarations: [Column,IgGridMultiColumnHeadersFeature,IgGridSortingFeature,IgGridFilteringFeature,IgGridPagingFeature,IgGridUpdatingFeature,IgGridGroupByFeature,IgGridColumnMovingFeature,IgGridHidingFeature,IgGridCellMergingFeature,IgGridResponsiveFeature,IgGridResizingFeature,IgGridSelectionFeature,IgGridRowSelectorsFeature,IgGridSummariesFeature,IgGridColumnFixingFeature,IgGridTooltipsFeature,IgGridAppendRowsOnDemandFeature,Features,IgGridComponent,IgTreeGridComponent,IgHierarchicalGridComponent,IgComboComponent,IgCheckboxEditorComponent,IgCurrencyEditorComponent,IgDateEditorComponent,IgDatePickerComponent,IgDatePickerComponent,IgMaskEditorComponent,IgNumericEditorComponent,IgPercentEditorComponent,IgTextEditorComponent,IgTreeComponent,IgDialogComponent,IgSplitterComponent,IgLayoutManagerComponent,IgTileManagerComponent,IgHtmlEditorComponent,IgValidatorComponent,IgPivotDataSelectorComponent,IgPivotGridComponent,IgDataChartComponent,IgPieChartComponent,IgDoughnutChartComponent,IgFunnelChartComponent,IgRadialGaugeComponent,IgZoombarComponent,IgMapComponent,IgSparklineComponent,IgBulletGraphComponent,IgLinearGaugeComponent,IgQRCodeBarcodeComponent,IgUploadComponent,IgPopoverComponent,IgNotifierComponent,IgRatingComponent,IgVideoPlayerComponent,IgRadialMenuComponent,IgSplitButtonComponent, IgSpreadsheetComponent, IgSchedulerComponent],
128+
exports: [Column, IgGridMultiColumnHeadersFeature, IgGridSortingFeature,IgGridFilteringFeature,IgGridPagingFeature,IgGridUpdatingFeature,IgGridGroupByFeature,IgGridColumnMovingFeature,IgGridHidingFeature,IgGridCellMergingFeature,IgGridResponsiveFeature,IgGridResizingFeature,IgGridSelectionFeature,IgGridRowSelectorsFeature,IgGridSummariesFeature,IgGridColumnFixingFeature,IgGridTooltipsFeature,IgGridAppendRowsOnDemandFeature,Features,IgGridComponent,IgTreeGridComponent,IgHierarchicalGridComponent,IgComboComponent,IgCheckboxEditorComponent,IgCurrencyEditorComponent,IgDateEditorComponent,IgDatePickerComponent,IgDatePickerComponent,IgMaskEditorComponent,IgNumericEditorComponent,IgPercentEditorComponent,IgTextEditorComponent,IgTreeComponent,IgDialogComponent,IgSplitterComponent,IgLayoutManagerComponent,IgTileManagerComponent,IgHtmlEditorComponent,IgValidatorComponent,IgPivotDataSelectorComponent,IgPivotGridComponent,IgDataChartComponent,IgPieChartComponent,IgDoughnutChartComponent,IgFunnelChartComponent,IgRadialGaugeComponent,IgZoombarComponent,IgMapComponent,IgSparklineComponent,IgBulletGraphComponent,IgLinearGaugeComponent,IgQRCodeBarcodeComponent,IgUploadComponent,IgPopoverComponent,IgNotifierComponent,IgRatingComponent,IgVideoPlayerComponent,IgRadialMenuComponent,IgSplitButtonComponent, IgSpreadsheetComponent, IgSchedulerComponent]
127129
})
128130
export class IgniteUIModule {}

tests/unit/igeditors/editors.spec.ts

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,59 @@ export function main() {
491491
}, 1);
492492
});
493493
});
494-
});
494+
});
495+
496+
describe('Infragistics Angular2 TimePicker', () => {
497+
beforeEach(() => {
498+
TestBed.configureTestingModule({
499+
imports: [FormsModule],
500+
declarations: [Infragistics.IgTimePickerComponent, TestIgTimePickerComponent]
501+
});
502+
});
503+
504+
it('should initialize correctly', (done) => {
505+
var template = '<div><ig-time-picker></ig-time-picker></div>';
506+
TestBed.overrideComponent(TestIgTimePickerComponent, {
507+
set: {
508+
template: template
509+
}
510+
});
511+
TestBed.compileComponents().then(() => {
512+
let fixture = TestBed.createComponent(TestIgTimePickerComponent);
513+
fixture.detectChanges();
514+
expect(fixture.debugElement.componentInstance.viewChild instanceof Infragistics.IgTimePickerComponent)
515+
.toBe(true);
516+
done();
517+
});
518+
});
519+
520+
it('should allow setting value with ngModel', (done) => {
521+
var template = '<div><ig-time-picker [(ngModel)]="val" [widgetId]="editorId" [options]="{isLimitedToListValues:false}"></ig-time-picker></div>';
522+
TestBed.overrideComponent(TestIgTimePickerComponent, {
523+
set: {
524+
template: template
525+
}
526+
});
527+
TestBed.compileComponents().then(() => {
528+
let fixture = TestBed.createComponent(TestIgTimePickerComponent);
529+
fixture.detectChanges();
530+
setTimeout(() => {
531+
expect($(fixture.debugElement.nativeElement).find("#editor1").igTimePicker("displayValue")).toBe("12:36 AM");
532+
fixture.debugElement.componentInstance.val = "05:50 AM";
533+
fixture.detectChanges();
534+
setTimeout(() => {
535+
expect($(fixture.debugElement.nativeElement).find("#editor1").igTimePicker("displayValue")).toBe("5:50 AM");
536+
$(fixture.debugElement.nativeElement).find("#editor1").focus().trigger("focus").val("06:00 PM").blur().trigger("blur");
537+
setTimeout(() => {
538+
expect(fixture.debugElement.componentInstance.val.getHours()).toBe(6);
539+
expect(fixture.debugElement.componentInstance.val.getMinutes()).toBe(0);
540+
done();
541+
}, 100);
542+
}, 1);
543+
}, 1);
544+
});
545+
});
546+
});
495547
}
496548

497549
@Component({
@@ -575,6 +627,21 @@ class TestIgDatePickerComponent {
575627
}
576628
}
577629

630+
@Component({
631+
selector: 'test-time-picker-cmp',
632+
template: '<div></div>' //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
633+
})
634+
class TestIgTimePickerComponent {
635+
private val: string;
636+
private editorId:string;
637+
@ViewChild(Infragistics.IgTimePickerComponent) public viewChild: Infragistics.IgTimePickerComponent;
638+
639+
constructor() {
640+
this.val = "12:36 AM";
641+
this.editorId = "editor1";
642+
}
643+
}
644+
578645
@Component({
579646
selector: 'test-date-editor-cmp',
580647
template: '<div></div>' //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."

0 commit comments

Comments
 (0)