Skip to content

Commit

Permalink
feat(timepicker): new timepicker implementation (#2058)
Browse files Browse the repository at this point in the history
fixes #2036
fixes #1981 ( + min max demo )
fixes #1973
close #1957 ( + seconds demo )
fixes #1935
fixes #1672
feat #1007 added keyboard and mousewheel support
fixes #962
fixes #793
fixes #173
fixes #1271 added custom validation demo
fixes #1539 bs4
fixes #1253 if input is invalid

* feat(timepicker): new timepicker implementation

* feat(timepicker): new timepicker implementation testing

* chore(timepicker): removed old timepicker implementation

* chore(mini-ngrx): added ngrx licence

* fix(timepicker): fix seconds

* fix(timepicker): fix custom validation demo

* fix(tests): fix tests & aot errors

* fix(timepicker): min max restrictions

* fix(timepicker): min max checks

* feat(timepicker): add inputs validation (#2187)

* feat(timepicker): add inputs validation

* fix(timepicker): add isPM support

* feat(timepicker): add isValid output

* feat(timepicker): added test plan (#2127)

* fix(timepicker): fix ngModelChange demo

* fix(test): fix unit tests

* docs(timepicker): fix docs conflict, add isValid description
  • Loading branch information
valorkin authored Jul 19, 2017
1 parent 03e34cc commit 4a37406
Show file tree
Hide file tree
Showing 34 changed files with 2,422 additions and 334 deletions.
2 changes: 1 addition & 1 deletion demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { FormsModule} from '@angular/forms';
import { RouterModule } from '@angular/router';
import { Ng2PageScrollModule } from 'ng2-page-scroll/ng2-page-scroll';
import { AppComponent } from './app.component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { TimepickerModule } from 'ngx-bootstrap/timepicker';

Expand All @@ -17,6 +17,7 @@ import { routes } from './demo-timepicker.routes';
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
SharedModule,
TimepickerModule.forRoot(),
RouterModule.forChild(routes)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<p>Illustrates custom validation, you have to select time between 11:00 and 12:59</p>

<div class="form-group">
<timepicker [(ngModel)]="myTime" [formControl]="ctrl" required></timepicker>
</div>

<pre class="alert"
[class.alert-danger]="!ctrl.valid && !ctrl.pristine"
[class.alert-success]="ctrl.valid && !ctrl.pristine">
Time is: {{myTime}}
</pre>
<div class="alert alert-danger" *ngIf="ctrl.errors && ctrl.errors['outOfRange']">Invalid time</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';

@Component({
selector: 'demo-timepicker-custom-validation',
templateUrl: './custom-validation.html'
})
export class DemoTimepickerCustomValidationComponent {
public myTime: Date;

public ctrl = new FormControl('', (control: FormControl) => {
const value = control.value;
if (!value) {
return null;
}
const hours = value.getHours();
if (hours < 11 || hours > 12) {
return {outOfRange: true};
}

return null;
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<timepicker [(ngModel)]="mytime" (change)="changed()"></timepicker>
<timepicker [(ngModel)]="mytime" (ngModelChange)="changed()" (isValid)="isValid = $event"></timepicker>

<pre class="alert alert-info">Time is: {{mytime}}</pre>
<pre *ngIf="!isValid" class="alert alert-danger">Invalid time format</pre>

<button type="button" class="btn btn-primary" (click)="update()">Set to 14:00</button>
<button type="button" class="btn btn-danger" (click)="clear()">Clear</button>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Component } from '@angular/core';
export class DemoTimepickerDynamicComponent {

public mytime: Date = new Date();
public isValid: boolean;

public update(): void {
let d = new Date();
Expand Down
24 changes: 23 additions & 1 deletion demo/src/app/components/+timepicker/demos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import { DemoTimepickerMeridianComponent } from './meridian/meridian';
import { DemoTimepickerDisabledComponent } from './disabled/disabled';
import { DemoTimepickerCustomComponent } from './custom/custom';
import { DemoTimepickerDynamicComponent } from './dynamic/dynamic';
import { DemoTimepickerMinMaxComponent } from './min-max/min-max';
import { DemoTimepickerSecondsComponent } from './seconds/seconds';
import { DemoTimepickerMousewheelArrowkeysComponent } from './mousewheel-arrowkeys/mousewheel-arrowkeys';
import { DemoTimepickerCustomValidationComponent } from './custom-validation/custom-validation';

export const DEMO_COMPONENTS = [
DemoTimepickerBasicComponent, DemoTimepickerConfigComponent, DemoTimepickerMeridianComponent,
DemoTimepickerDisabledComponent, DemoTimepickerCustomComponent, DemoTimepickerDynamicComponent
DemoTimepickerMinMaxComponent, DemoTimepickerDisabledComponent, DemoTimepickerCustomComponent,
DemoTimepickerDynamicComponent, DemoTimepickerSecondsComponent, DemoTimepickerMousewheelArrowkeysComponent,
DemoTimepickerCustomValidationComponent
];

export const DEMOS = {
Expand All @@ -19,6 +25,10 @@ export const DEMOS = {
component: require('!!raw-loader?lang=typescript!./meridian/meridian'),
html: require('!!raw-loader?lang=markup!./meridian/meridian.html')
},
minmax: {
component: require('!!raw-loader?lang=typescript!./min-max/min-max'),
html: require('!!raw-loader?lang=markup!./min-max/min-max.html')
},
disabled: {
component: require('!!raw-loader?lang=typescript!./disabled/disabled'),
html: require('!!raw-loader?lang=markup!./disabled/disabled.html')
Expand All @@ -34,5 +44,17 @@ export const DEMOS = {
config: {
component: require('!!raw-loader?lang=typescript!./config/config'),
html: require('!!raw-loader?lang=markup!./config/config.html')
},
seconds: {
component: require('!!raw-loader?lang=typescript!./seconds/seconds'),
html: require('!!raw-loader?lang=markup!./seconds/seconds.html')
},
mousewheel: {
component: require('!!raw-loader?lang=typescript!./mousewheel-arrowkeys/mousewheel-arrowkeys'),
html: require('!!raw-loader?lang=markup!./mousewheel-arrowkeys/mousewheel-arrowkeys.html')
},
customvalidation: {
component: require('!!raw-loader?lang=typescript!./custom-validation/custom-validation'),
html: require('!!raw-loader?lang=markup!./custom-validation/custom-validation.html')
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<pre class="alert alert-info">Time is: {{mytime}}</pre>

<hr>
<br>

<button type="button" class="btn btn-info" (click)="toggleMode()">12H / 24H</button>

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { Component } from '@angular/core';
templateUrl: './meridian.html'
})
export class DemoTimepickerMeridianComponent {
public ismeridian:boolean = true;
public ismeridian: boolean = true;

public mytime:Date = new Date();
public mytime: Date = new Date();

public toggleMode():void {
public toggleMode(): void {
this.ismeridian = !this.ismeridian;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<timepicker [(ngModel)]="myTime" [min]="minTime" [max]="maxTime"></timepicker>

<pre class="alert alert-info">Time is: {{myTime}}</pre>
18 changes: 18 additions & 0 deletions demo/src/app/components/+timepicker/demos/min-max/min-max.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-timepicker-min-max',
templateUrl: './min-max.html'
})
export class DemoTimepickerMinMaxComponent {
public myTime: Date = new Date();
public minTime: Date = new Date();
public maxTime: Date = new Date();

constructor() {
this.minTime.setHours(8);
this.minTime.setMinutes(0);
this.maxTime.setHours(17);
this.maxTime.setMinutes(0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<p>Mouse wheel disabled</p>

<timepicker [(ngModel)]="myTime1" [mousewheel]="false"></timepicker>

<pre class="alert alert-info">Time is: {{myTime1}}</pre>

<p>Arrow keys disabled</p>

<timepicker [(ngModel)]="myTime2" [arrowkeys]="false"></timepicker>

<pre class="alert alert-info">Time is: {{myTime2}}</pre>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-timepicker-mousewheel-arrowkeys',
templateUrl: './mousewheel-arrowkeys.html'
})
export class DemoTimepickerMousewheelArrowkeysComponent {
public myTime1: Date = new Date();
public myTime2: Date = new Date();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<timepicker [(ngModel)]="myTime" [showSeconds]="showSec"></timepicker>

<pre class="alert alert-info">Time is: {{myTime}}</pre>
10 changes: 10 additions & 0 deletions demo/src/app/components/+timepicker/demos/seconds/seconds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-timepicker-seconds',
templateUrl: './seconds.html'
})
export class DemoTimepickerSecondsComponent {
public myTime: Date = new Date();
public showSec: boolean = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ let titleDoc = require('html-loader!markdown-loader!./docs/title.md');
<ul>
<li><a routerLink="." fragment="basic">Timepicker</a></li>
<li><a routerLink="." fragment="meridian">Meridian</a></li>
<li><a routerLink="." fragment="min-max">Min - Max</a></li>
<li><a routerLink="." fragment="seconds">Show seconds</a></li>
<li><a routerLink="." fragment="disabled">Disabled</a></li>
<li><a routerLink="." fragment="custom">Custom steps</a></li>
<li><a routerLink="." fragment="custom-validation">Custom validation</a></li>
<li><a routerLink="." fragment="dynamic">Dynamic</a></li>
<li><a routerLink="." fragment="config">Configuring defaults</a></li>
<li><a routerLink="." fragment="mouse-wheel">Mouse wheel and Arrow keys</a></li>
</ul>
</li>
<li><a routerLink="." fragment="api-reference">API Reference</a>
Expand All @@ -45,6 +49,16 @@ let titleDoc = require('html-loader!markdown-loader!./docs/title.md');
<ng-sample-box [ts]="demos.meridian.component" [html]="demos.meridian.html">
<demo-timepicker-meridian></demo-timepicker-meridian>
</ng-sample-box>
<h2 routerLink="." fragment="min-max" id="min-max">Min - Max</h2>
<ng-sample-box [ts]="demos.minmax.component" [html]="demos.minmax.html">
<demo-timepicker-min-max></demo-timepicker-min-max>
</ng-sample-box>
<h2 routerLink="." fragment="seconds" id="seconds">Show seconds</h2>
<ng-sample-box [ts]="demos.seconds.component" [html]="demos.seconds.html">
<demo-timepicker-seconds></demo-timepicker-seconds>
</ng-sample-box>
<h2 routerLink="." fragment="disabled" id="disabled">Disabled</h2>
<ng-sample-box [ts]="demos.disabled.component" [html]="demos.disabled.html">
Expand All @@ -54,6 +68,11 @@ let titleDoc = require('html-loader!markdown-loader!./docs/title.md');
<h2 routerLink="." fragment="custom" id="custom">Custom steps</h2>
<ng-sample-box [ts]="demos.custom.component" [html]="demos.custom.html">
<demo-timepicker-custom></demo-timepicker-custom>
</ng-sample-box>
<h2 routerLink="." fragment="custom-validation" id="custom-validation">Custom validation</h2>
<ng-sample-box [ts]="demos.customvalidation.component" [html]="demos.customvalidation.html">
<demo-timepicker-custom-validation></demo-timepicker-custom-validation>
</ng-sample-box>
<h2 routerLink="." fragment="dynamic" id="dynamic">Dynamic</h2>
Expand All @@ -65,6 +84,11 @@ let titleDoc = require('html-loader!markdown-loader!./docs/title.md');
<ng-sample-box [ts]="demos.config.component" [html]="demos.config.html">
<demo-timepicker-config></demo-timepicker-config>
</ng-sample-box>
<h2 routerLink="." fragment="mouse-wheel" id="mouse-wheel">Mouse wheel and Arrow keys</h2>
<ng-sample-box [ts]="demos.mousewheel.component" [html]="demos.mousewheel.html">
<demo-timepicker-mousewheel-arrowkeys></demo-timepicker-mousewheel-arrowkeys>
</ng-sample-box>
<h2 routerLink="." fragment="api-reference" id="api-reference">API Reference</h2>
Expand Down
Loading

0 comments on commit 4a37406

Please sign in to comment.