Skip to content

Commit cc58e30

Browse files
committed
fix(calendar): fix selection bugs clear code #4282
1 parent 825b2e2 commit cc58e30

File tree

6 files changed

+90
-95
lines changed

6 files changed

+90
-95
lines changed

projects/igniteui-angular/src/lib/calendar/calendar.component.ts

+6-14
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { IgxDaysViewComponent } from './days-view/days-view.component';
2828
import { interval, Subscription } from 'rxjs';
2929
import { takeUntil, debounce, skipLast, switchMap } from 'rxjs/operators';
3030
import { ScrollMonth } from './calendar-base';
31-
import { IMonthView, IViewChangedArgs } from './calendar.interface';
3231

3332
let NEXT_ID = 0;
3433

@@ -120,7 +119,7 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
120119
for (let i = this._monthsViewNumber; i < val; i++) {
121120
const nextMonthDate = new Date(this.viewDate);
122121
nextMonthDate.setMonth(nextMonthDate.getMonth() + i);
123-
const monthView: IMonthView = {
122+
const monthView = {
124123
value: null,
125124
viewDate: nextMonthDate
126125
};
@@ -347,15 +346,15 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
347346
/**
348347
*@hidden
349348
*/
350-
private defaultDayView: IMonthView = {
349+
private defaultDayView = {
351350
value: this.value,
352351
viewDate: this.viewDate,
353352
};
354353

355354
/**
356355
*@hidden
357356
*/
358-
public dayViews: Array<IMonthView> = [this.defaultDayView];
357+
public dayViews = [this.defaultDayView];
359358

360359
public ngAfterViewInit() {
361360
this.setSiblingMonths(this.monthViews);
@@ -518,16 +517,9 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
518517
/**
519518
* @hidden
520519
*/
521-
public viewChanged(event: IViewChangedArgs) {
522-
let date = this.viewDate,
523-
delta = event.delta;
524-
if (event.moveToFirst) {
525-
delta = 0;
526-
date = event.date;
527-
}
528-
this.viewDate = this.calendarModel.timedelta(date, 'month', delta);
520+
public viewChanged(event) {
521+
this.viewDate = this.calendarModel.timedelta(event, 'month', 0);
529522
}
530-
531523
/**
532524
* @hidden
533525
*/
@@ -778,7 +770,7 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
778770

779771

780772
/**
781-
* Helper method sthat sets references for prev/next months for each month in the view
773+
* Helper method that sets references for prev/next months for each month in the view
782774
* @hidden
783775
*/
784776
private setSiblingMonths(monthViews: QueryList<IgxDaysViewComponent>) {

projects/igniteui-angular/src/lib/calendar/calendar.interface.ts

-16
This file was deleted.

projects/igniteui-angular/src/lib/calendar/days-view/day-item.component.ts

+6-37
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class IgxDayItemComponent {
2222
*
2323
*/
2424
@Input()
25+
@HostBinding('class.igx-calendar__date--selected')
2526
public get selected(): any {
2627
return this._selected;
2728
}
@@ -85,14 +86,17 @@ export class IgxDayItemComponent {
8586
return this.elementRef.nativeElement;
8687
}
8788

89+
@HostBinding('class.igx-calendar__date--inactive')
8890
public get isInactive(): boolean {
8991
return this.date.isNextMonth || this.date.isPrevMonth;
9092
}
9193

94+
@HostBinding('class.igx-calendar__date--hidden')
9295
public get isHidden(): boolean {
9396
return this.hideOutsideDays && this.isInactive;
9497
}
9598

99+
@HostBinding('class.igx-calendar__date--current')
96100
public get isToday(): boolean {
97101
const today = new Date(Date.now());
98102
const date = this.date.date;
@@ -102,6 +106,7 @@ export class IgxDayItemComponent {
102106
);
103107
}
104108

109+
@HostBinding('class.igx-calendar__date--weekend')
105110
public get isWeekend(): boolean {
106111
const day = this.date.date.getDay();
107112
return day === 0 || day === 6;
@@ -123,6 +128,7 @@ export class IgxDayItemComponent {
123128
return isDateInRanges(this.date.date, this.outOfRangeDates);
124129
}
125130

131+
@HostBinding('class.igx-calendar__date--special')
126132
public get isSpecial(): boolean {
127133
if (this.specialDates === null) {
128134
return false;
@@ -139,53 +145,16 @@ export class IgxDayItemComponent {
139145
return this.date.isCurrentMonth && !(this.isWeekend && this.selected);
140146
}
141147

142-
@HostBinding('class.igx-calendar__date--inactive')
143-
public get isInactiveCSS(): boolean {
144-
return this.isInactive;
145-
}
146-
147-
@HostBinding('class.igx-calendar__date--hidden')
148-
get isHiddenCSS(): boolean {
149-
return this.isHidden;
150-
}
151-
152-
@HostBinding('class.igx-calendar__date--current')
153-
public get isTodayCSS(): boolean {
154-
return this.isToday;
155-
}
156-
157-
@HostBinding('class.igx-calendar__date--selected')
158-
public get isSelectedCSS(): boolean {
159-
return this.isCurrentMonth && this.selected;
160-
}
161-
162-
@HostBinding('class.igx-calendar__date--selected-dimmed')
163-
public get isSelectedDimmedCSS(): boolean {
164-
return !this.isCurrentMonth && this.isSingleSelection && this.selected;
165-
}
166-
167-
@HostBinding('class.igx-calendar__date--weekend')
168-
public get isWeekendCSS(): boolean {
169-
return this.isWeekend;
170-
}
171-
172148
@HostBinding('class.igx-calendar__date--disabled')
173149
public get isDisabledCSS(): boolean {
174150
return this.isHidden || this.isDisabled || this.isOutOfRange;
175151
}
176152

177-
178-
@HostBinding('class.igx-calendar__date--special')
179-
public get isSpecialCSS(): boolean {
180-
return this.isSpecial;
181-
}
182-
183153
@HostBinding('class.igx-calendar__date--single')
184154
public get isSingleSelection(): boolean {
185155
return this.selection !== CalendarSelection.RANGE;
186156
}
187157

188-
189158
private _selected = false;
190159

191160
constructor(private elementRef: ElementRef) { }

0 commit comments

Comments
 (0)