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

In primeng calendar, date can be lined through or disabled using date… there is no way to disable years #12154

Merged
Merged
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
7 changes: 6 additions & 1 deletion src/app/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ export const CALENDAR_VALUE_ACCESSOR: any = {
</span>
</div>
<div class="p-yearpicker" *ngIf="currentView === 'year'">
<span *ngFor="let y of yearPickerValues()" (click)="onYearSelect($event, y)" (keydown)="onYearCellKeydown($event, y)" class="p-yearpicker-year" [ngClass]="{ 'p-highlight': isYearSelected(y) }" pRipple>
<span *ngFor="let y of yearPickerValues()" (click)="onYearSelect($event, y)" (keydown)="onYearCellKeydown($event, y)"
class="p-yearpicker-year" [ngClass]="{ 'p-highlight': isYearSelected(y), 'p-disabled': isYearDisabled(y) }" pRipple>
{{ y }}
</span>
</div>
Expand Down Expand Up @@ -1650,6 +1651,10 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor {
return true;
}

isYearDisabled(year) {
return !this.isSelectable(1, this.currentMonth, year, false);
}

isYearSelected(year: number) {
if (this.isComparable()) {
let value = this.isRangeSelection() ? this.value[0] : this.value;
Expand Down