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

fix(calendar): use last defined week day to determine week number #1969

Merged
merged 2 commits into from
Sep 20, 2019
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
@@ -0,0 +1,7 @@
:host {
display: flex;
}

.days-container {
width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ import { convertToBoolProperty } from '../../../helpers';
* */
@Component({
selector: 'nb-calendar-day-picker',
styles: [` :host { display: flex; } `],
template: `
<nb-calendar-week-numbers *ngIf="showWeekNumber"
[weeks]="weeks"
[size]="size"
[weekNumberSymbol]="weekNumberSymbol">
</nb-calendar-week-numbers>
<div>
<div class="days-container">
<nb-calendar-days-names></nb-calendar-days-names>
<nb-calendar-picker
[data]="weeks"
Expand All @@ -48,6 +47,7 @@ import { convertToBoolProperty } from '../../../helpers';
</nb-calendar-picker>
</div>
`,
styleUrls: ['./calendar-day-picker.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NbCalendarDayPickerComponent<D, T> implements OnChanges {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ export class NbCalendarWeekNumberComponent<D> {

getWeeks(): number[] {
return this.weeks.map((week: D[]) => {
// Find last defined day as week could contain null days in case
// boundingMonth set to false
const lastDay = [ ...week ].reverse().find((day: D) => !!day);
// Use last day of the week to determine week number.
// This way weeks which span between sibling years is marked first
return this.dateService.getWeekNumber(week[6]);
return this.dateService.getWeekNumber(lastDay);
});
}
}