Skip to content

Commit

Permalink
fix(module:date-picker): no time after month selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ng-nest-moon committed Feb 6, 2021
1 parent e91dd30 commit fd38cfe
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/ng-nest/ui/date-picker/date-picker-portal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class XDatePickerPortalComponent implements OnInit, OnDestroy, AfterViewI
this.model = date;
this.nodeEmit(date);
} else {
this.type = 'date';
this.type = this._type;
}
this.cdr.detectChanges();
}
Expand Down
14 changes: 13 additions & 1 deletion lib/ng-nest/ui/date-picker/date-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,17 @@ class TestXDatePickerYearOrMonthComponent {
<x-date-picker [(ngModel)]="model1" label="时" type="date-hour"></x-date-picker>
</x-col>
</x-row>
<x-row>
<x-col span="12">
<x-date-picker [(ngModel)]="model2" label="年" type="year"></x-date-picker>
</x-col>
</x-row>
<x-row>
<x-col span="12">
<x-date-picker [(ngModel)]="model2" label="月" type="month"></x-date-picker>
</x-col>
</x-row>
<x-date-picker label="方式" [(ngModel)]="model3"></x-date-picker>
`,
styles: [
`
Expand All @@ -318,8 +329,9 @@ class TestXDatePickerYearOrMonthComponent {
]
})
class TestXDatePickerHourMinuteSecondComponent {
model1 = '2011-10-1';
model1 = '2011-10-1 13:10:57';
model2: any;
model3: any;
constructor(private cdr: ChangeDetectorRef) {
interval(0).subscribe((x) => {
this.cdr.detectChanges();
Expand Down
6 changes: 3 additions & 3 deletions lib/ng-nest/ui/date-picker/style/mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@
border-spacing: 0;
th {
font-weight: 400;
height: 1.875rem;
height: 2rem;
}
td {
height: 1.875rem;
height: 2rem;
padding: 0.125rem 0;
text-align: center;
x-button .x-button {
width: 1.625rem;
height: 1.4rem;
height: 1.5rem;
margin: 0 auto;
border: 0.0625rem solid transparent;
&:hover {
Expand Down
16 changes: 9 additions & 7 deletions lib/ng-nest/ui/time-picker/time-picker-frame.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
OnDestroy,
OnInit,
Output,
SimpleChanges,
ViewChild,
ViewEncapsulation
} from '@angular/core';
import { XTimePickerFramePrefix, XTimePickerType } from './time-picker.property';
import { XListNode } from '@ng-nest/ui/list';
import { reqAnimFrame, XIsEmpty } from '@ng-nest/ui/core';
import { reqAnimFrame, XIsChange, XIsEmpty } from '@ng-nest/ui/core';

@Component({
selector: `${XTimePickerFramePrefix}`,
Expand All @@ -22,7 +23,7 @@ import { reqAnimFrame, XIsEmpty } from '@ng-nest/ui/core';
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class XTimePickerFrameComponent implements OnInit, OnDestroy {
export class XTimePickerFrameComponent {
@Input() type: XTimePickerType = 'time';
@Input() value: number;
@Output() nodeEmit = new EventEmitter<Date>();
Expand Down Expand Up @@ -52,11 +53,11 @@ export class XTimePickerFrameComponent implements OnInit, OnDestroy {
id: i
};
});
ngOnInit(): void {}
ngOnDestroy(): void {}
ngAfterViewInit() {
this.init();
this.setScrollTop();
ngOnChanges(changes: SimpleChanges): void {
if (XIsChange(changes.value)) {
this.init();
this.setScrollTop();
}
}
constructor(private cdr: ChangeDetectorRef) {}

Expand Down Expand Up @@ -103,6 +104,7 @@ export class XTimePickerFrameComponent implements OnInit, OnDestroy {
this.model.setHours(this.hour);
this.nodeEmit.emit(this.model);
this.cdr.detectChanges();
console.log(this.hourRef);
this.scrollTo(this.hourRef.nativeElement, (date.event?.srcElement as HTMLElement).offsetTop, 120);
}

Expand Down

0 comments on commit fd38cfe

Please sign in to comment.