Skip to content

Commit

Permalink
feat(timepicker): new timepicker implementation testing
Browse files Browse the repository at this point in the history
  • Loading branch information
artem authored and valorkin committed Jun 19, 2017
1 parent 9ab6ea7 commit 5a80a12
Show file tree
Hide file tree
Showing 16 changed files with 448 additions and 109 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,7 @@
<p>Illustrates custom validation, you have to select time between 11:00 and 12:59</p>

<div class="form-group" [class.has-success]="ctrl.valid" [class.has-danger]="!ctrl.valid">
<timepicker [(ngModel)]="myTime" [formControl]="ctrl" required></timepicker>
</div>

<pre class="alert alert-info">Time is: {{myTime}}</pre>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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;
console.log('control', control);
}
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,12 @@

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

<hr>
<br>

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

<hr>

<timepicker [(ngModel)]="mytime2" [meridians]="meridianText"></timepicker>

<pre class="alert alert-info">Time is: {{mytime2}}</pre>
11 changes: 7 additions & 4 deletions demo/src/app/components/+timepicker/demos/meridian/meridian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ 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 mytime2: Date = new Date();

public meridianText = ['12h', '24h'];

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>Without mousewheel</p>

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

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

<p>Without arrowkeys</p>

<timepicker [(ngModel)]="myTime2" [arrowkeys]="false" (change)="changed()"></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 5a80a12

Please sign in to comment.