simple_calendar icon indicating copy to clipboard operation
simple_calendar copied to clipboard

Previous button for generic calendars go only 1 day backwards

Open EmCousin opened this issue 2 years ago • 2 comments

Thank you for this great gem for starters.

week_calendar and month_calendar work great. It appears that for the simple calendar helper, the "previous" button does not go backwards the same way than the "next" button goes forward. While the next button goes forward the number of days included in the range (4 by default), the previous button goes backward only one day.

Unless this behavior is intended for some reason, the fix would be as simple as this:

def url_for_previous_view
-  view_context.url_for(@params.merge(start_date_param => (date_range.first - 1.day).iso8601))
+  view_context.url_for(@params.merge(start_date_param => (date_range.first - (date_range.count).days)).iso8601))
end

We could then override this method in MonthCalendar and WeekCalendar to keep view_context.url_for(@params.merge(start_date_param => (date_range.first - 1.day).iso8601))

Happy to push a Pull Request if needed Thanks!

EmCousin avatar Jan 25 '22 21:01 EmCousin

Yeah, that probably should go back more days.

excid3 avatar Jan 26 '22 19:01 excid3

@excid3 PR is here: https://github.com/excid3/simple_calendar/pull/273

EmCousin avatar Jan 26 '22 20:01 EmCousin