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

[excludeDays] doesn't work correctly in the week view component #973

Closed
ezodagrom opened this issue May 7, 2019 · 6 comments
Closed

[excludeDays] doesn't work correctly in the week view component #973

ezodagrom opened this issue May 7, 2019 · 6 comments

Comments

@ezodagrom
Copy link

ezodagrom commented May 7, 2019

Describe the bug

When using some combinations of days to be excluded, some days that shouldn't be excluded are excluded anyway, for example, setting [excludeDays]="[4, 6]", friday (day 5) is also excluded in the week view (even though it works fine in the month view).

Seems like the combinations of days "0, 2" and "4, 6" are the problematic ones for me, but I'm not sure if there's others combinations with issues as well.

Including a screenshot using [excludeDays]="[4, 6]", in both month and week views (friday is missing in the week view). The screenshot was taken in a new project:

Minimal reproduction of the problem with instructions

Screenshots

angular calendar bug report

Versions

  • @angular/core: 7.2.0
  • angular-calendar: 0.27.7
  • Browser name and version:
    Firefox 66.0.4, Google Chrome 74.0.3729.131, Microsoft Edge 44.17763.1.0
@matts-bot
Copy link

matts-bot bot commented May 7, 2019

Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider supporting me on Patreon

@mattlewis92
Copy link
Owner

Thanks for reporting, I can reproduce this issue. Would happily accept a PR to fix this, the issue lies somewhere in the getWeekView function.

@evilstiefel
Copy link

On a related note, if you specify excludedDays e.g. to be [0, 1, 2, 3, 4, 5], so only one day (to "simulate" a day view), the component also crashes. Here, the error comes from getWeekViewPeriod(), where excluded seems to be null. Can open a separate issue for that, as well.

@mattlewis92
Copy link
Owner

@evilstiefel it's probably related to this bug, I'll make sure to include a test case for that when I get round to fixing it. As a workaround you can set [daysInWeek]="1" to get the same effect.

@evilstiefel
Copy link

evilstiefel commented May 27, 2019

From a quick check, it seems that the calendar-utils function for getWeekView() is initialized with wrong values for these instances.

viewStart is assigned a value after viewDate and so the function getWeekViewHeader() returns an empty array. If I manually check and assign the earlier date, it works well, e.g.:

viewStart = (viewStart <= viewDate) ? viewStart : viewDate;
viewStart = startOfDay(viewStart)

The calls from angular-calendar to that function don't even seem to include values for viewStart and viewEnd, so the initializer-values are assigned (as far as I can tell, only glanced over it briefly).

EDIT:
I'm using your suggestion from above and it works fine, since of course, my 'fix' introduces other weird behavior. Just a pointer into the direction I was investigating :).

@mattlewis92
Copy link
Owner

Finally managed to fix this one, please give 0.27.17 a go 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants