Skip to content

Commit

Permalink
Weeknumber events
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanreyes committed Mar 4, 2021
1 parent 3a9a319 commit 8da9ab4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/components/CalendarPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export default {
);
}
const getWeeknumberCell = day =>
// Weeknumber cell
const getWeeknumberCell = isoWeek =>
h(
'div',
{
Expand All @@ -69,23 +70,32 @@ export default {
'span',
{
class: ['vc-weeknumber-content', `is-${this.showWeeknumbers_}`],
on: {
click: event => {
this.$emit('weeknumberclick', {
isoWeek,
days: this.page.days.filter(d => d.isoWeek === isoWeek),
event,
});
},
},
},
[day.isoWeek],
[isoWeek],
),
],
);
// Day cells
const dayCells = [];
const { daysInWeek } = this.locale;
this.page.days.forEach((day, i) => {
const mod = i % daysInWeek;
// Insert weeknumber cell on left side if needed
if (
(showWeeknumbersLeft && mod === 0) ||
(showWeeknumbersRight && mod === daysInWeek)
) {
dayCells.push(getWeeknumberCell(day));
dayCells.push(getWeeknumberCell(day.isoWeek));
}
dayCells.push(
h(CalendarDay, {
Expand All @@ -101,8 +111,9 @@ export default {
refInFor: true,
}),
);
// Insert weeknumber cell on right side if needed
if (showWeeknumbersRight && mod === daysInWeek - 1) {
dayCells.push(getWeeknumberCell(day));
dayCells.push(getWeeknumberCell(day.isoWeek));
}
});
Expand Down

0 comments on commit 8da9ab4

Please sign in to comment.