Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide different classes for the first and last days in date range. #85

Merged
merged 1 commit into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
'myDpCurrMonth':d.cmo === currMonthId && !d.disabledDate.disabled,
'myDpNextMonth': d.cmo === nextMonthId,
'myDpSelectedDay':!this.opts.dateRange && isDateSame(d.dateObj) || this.opts.dateRange && isDateRangeBeginOrEndSame(d.dateObj),
'myDpRangeBegin':this.opts.dateRange && isDateRangeBegin(d.dateObj),
'myDpRangeEnd':this.opts.dateRange && isDateRangeEnd(d.dateObj),
'myDpDisabled': d.disabledDate.disabled && !d.disabledDate.styleClass.length,
'myDpTableSingleDay': !d.disabledDate.disabled}"
(click)="onDayCellClicked($event, d)" (keydown)="onDayCellKeyDown($event, d)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,12 @@ export class DayViewComponent implements OnChanges, AfterViewInit {
isDateRangeBeginOrEndSame(date: IMyDate): boolean {
return this.utilService.isDateRangeBeginOrEndSame(this.selectedDateRange, date);
}

isDateRangeBegin(date: IMyDate): boolean {
return this.utilService.isDateRangeBegin(this.selectedDateRange, date);
}

isDateRangeEnd(date: IMyDate): boolean {
return this.utilService.isDateRangeEnd(this.selectedDateRange, date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@
background-color: #dbeaff;
}

.myDpRangeBegin,
.myDpRangeEnd,
.myDpSelectedDay,
.myDpSelectedMonth,
.myDpSelectedYear {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,16 @@ export class UtilService {
return this.getTimeInMilliseconds(dateRange.begin) === dateMs || this.getTimeInMilliseconds(dateRange.end) === dateMs;
}

isDateRangeBegin(dateRange: IMyDateRange, date: IMyDate): boolean {
const dateMs: number = this.getTimeInMilliseconds(date);
return this.getTimeInMilliseconds(dateRange.begin) === dateMs;
}

isDateRangeEnd(dateRange: IMyDateRange, date: IMyDate): boolean {
const dateMs: number = this.getTimeInMilliseconds(date);
return this.getTimeInMilliseconds(dateRange.end) === dateMs;
}

isDateInRange(date: IMyDate, dateRange: IMyDateRange): boolean {
if (!this.isInitializedDate(dateRange.begin) || !this.isInitializedDate(dateRange.end)) {
return false;
Expand Down