# HG changeset patch # User Paul Boddie # Date 1360000461 -3600 # Node ID 6c4df1436509707a44836e5939252c7f16b3f66c # Parent 89611d9f33b1dcb3e886a36a933ebd6e9a69538c Introduced "wider" calendar state so that it becomes possible to restore a wider month-based view of a calendar from a day view. Introduced navigation between month and day levels within view modes. diff -r 89611d9f33b1 -r 6c4df1436509 EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sat Feb 02 01:09:39 2013 +0100 +++ b/EventAggregatorSupport.py Mon Feb 04 18:54:21 2013 +0100 @@ -1301,8 +1301,11 @@ "A view of the event calendar." - def __init__(self, page, calendar_name, raw_calendar_start, raw_calendar_end, - original_calendar_start, original_calendar_end, calendar_start, calendar_end, + def __init__(self, page, calendar_name, + raw_calendar_start, raw_calendar_end, + original_calendar_start, original_calendar_end, + calendar_start, calendar_end, + wider_calendar_start, wider_calendar_end, first, last, category_names, remote_sources, search_pattern, template_name, parent_name, mode, resolution, name_usage, map_name): @@ -1312,10 +1315,12 @@ are the actual start and end values provided by the request), the calculated 'original_calendar_start' and 'original_calendar_end' (which are the result of calculating the calendar's limits from the raw start - and end values), and the requested, calculated 'calendar_start' and + and end values), the requested, calculated 'calendar_start' and 'calendar_end' (which may involve different start and end values due to - navigation in the user interface), along with the 'first' and 'last' - months of event coverage. + navigation in the user interface), and the requested + 'wider_calendar_start' and 'wider_calendar_end' (which indicate a wider + view used when navigating out of the day view), along with the 'first' + and 'last' months of event coverage. The additional 'category_names', 'remote_sources', 'search_pattern', 'template_name', 'parent_name' and 'mode' parameters are used to @@ -1339,6 +1344,8 @@ self.original_calendar_end = original_calendar_end self.calendar_start = calendar_start self.calendar_end = calendar_end + self.wider_calendar_start = wider_calendar_start + self.wider_calendar_end = wider_calendar_end self.template_name = template_name self.parent_name = parent_name self.mode = mode @@ -1430,23 +1437,29 @@ else: return "" - def getNavigationLink(self, start, end, mode=None, resolution=None): + def getNavigationLink(self, start, end, mode=None, resolution=None, wider_start=None, wider_end=None): """ Return a query string fragment for navigation to a view showing months from 'start' to 'end' inclusive, with the optional 'mode' indicating the view style and the optional 'resolution' indicating the resolution of a view, if configurable. + + If the 'wider_start' and 'wider_end' arguments are given, parameters + indicating a wider calendar view (when returning from a day view, for + example) will be included in the link. """ - return "%s&%s&%s=%s&%s=%s" % ( + return "%s&%s&%s=%s&%s=%s&%s&%s" % ( self.getRawDateQueryString("start", start), self.getRawDateQueryString("end", end), self.getQualifiedParameterName("mode"), mode or self.mode, - self.getQualifiedParameterName("resolution"), resolution or self.resolution + self.getQualifiedParameterName("resolution"), resolution or self.resolution, + self.getRawDateQueryString("wider-start", wider_start), + self.getRawDateQueryString("wider-end", wider_end), ) - def getUpdateLink(self, start, end, mode=None, resolution=None): + def getUpdateLink(self, start, end, mode=None, resolution=None, wider_start=None, wider_end=None): """ Return a query string fragment for navigation to a view showing months @@ -1456,6 +1469,10 @@ navigation link in that it is sufficient to activate the update action and produce an updated region of the page without needing to locate and process the page or any macro invocation. + + If the 'wider_start' and 'wider_end' arguments are given, parameters + indicating a wider calendar view (when returning from a day view, for + example) will be included in the link. """ parameters = [ @@ -1463,6 +1480,8 @@ self.getRawDateQueryString("end", end, 0), self.category_name_parameters, self.remote_source_parameters, + self.getRawDateQueryString("wider-start", wider_start, 0), + self.getRawDateQueryString("wider-end", wider_end, 0), ] pairs = [ @@ -1744,10 +1763,17 @@ output = [] append = output.append - start = self.calendar_start - end = self.calendar_end + # For day view links to other views, the wider view parameters should + # be used in order to be able to return to those other views. + + specific_start = self.calendar_start + specific_end = self.calendar_end + + start = self.wider_calendar_start or specific_start + end = self.wider_calendar_end or specific_end help_page = Page(request, "HelpOnEventAggregator") + calendar_link = self.getNavigationLink(start and start.as_month(), end and end.as_month(), "calendar", "month") calendar_update_link = self.getUpdateLink(start and start.as_month(), end and end.as_month(), "calendar", "month") list_link = self.getNavigationLink(start, end, "list") @@ -1756,6 +1782,18 @@ table_update_link = self.getUpdateLink(start, end, "table") map_link = self.getNavigationLink(start, end, "map") map_update_link = self.getUpdateLink(start, end, "map") + + # Specific links permit date-level navigation. + + specific_day_link = self.getNavigationLink(specific_start, specific_end, "day", "date", wider_start=start, wider_end=end) + specific_day_update_link = self.getUpdateLink(specific_start, specific_end, "day", "date", wider_start=start, wider_end=end) + specific_list_link = self.getNavigationLink(specific_start, specific_end, "list", wider_start=start, wider_end=end) + specific_list_update_link = self.getUpdateLink(specific_start, specific_end, "list", wider_start=start, wider_end=end) + specific_table_link = self.getNavigationLink(specific_start, specific_end, "table", wider_start=start, wider_end=end) + specific_table_update_link = self.getUpdateLink(specific_start, specific_end, "table", wider_start=start, wider_end=end) + specific_map_link = self.getNavigationLink(specific_start, specific_end, "map", wider_start=start, wider_end=end) + specific_map_update_link = self.getUpdateLink(specific_start, specific_end, "map", wider_start=start, wider_end=end) + new_event_link = self.getNewEventLink(start) # Write the controls. @@ -1771,24 +1809,55 @@ append(fmt.span(on=0)) if self.mode != "calendar": + view_label = self.resolution == "date" and _("View day in calendar") or _("View as calendar") append(fmt.span(on=1, css_class="event-view")) - append(linkToPage(request, page, _("View as calendar"), calendar_link, onclick=calendar_update_link)) + append(linkToPage(request, page, view_label, calendar_link, onclick=calendar_update_link)) + append(fmt.span(on=0)) + + if self.resolution == "date" and self.mode != "day": + append(fmt.span(on=1, css_class="event-view")) + append(linkToPage(request, page, _("View day as calendar"), specific_day_link, onclick=specific_day_update_link)) append(fmt.span(on=0)) - if self.mode != "list": + if self.resolution != "date" and self.mode != "list" or self.resolution == "date": + view_label = self.resolution == "date" and _("View day in list") or _("View as list") append(fmt.span(on=1, css_class="event-view")) - append(linkToPage(request, page, _("View as list"), list_link, onclick=list_update_link)) + append(linkToPage(request, page, view_label, list_link, onclick=list_update_link)) + append(fmt.span(on=0)) + + if self.resolution == "date" and self.mode != "list": + append(fmt.span(on=1, css_class="event-view")) + append(linkToPage(request, page, _("View day as list"), + specific_list_link, onclick=specific_list_update_link + )) append(fmt.span(on=0)) - if self.mode != "table": + if self.resolution != "date" and self.mode != "table" or self.resolution == "date": + view_label = self.resolution == "date" and _("View day in table") or _("View as table") append(fmt.span(on=1, css_class="event-view")) - append(linkToPage(request, page, _("View as table"), table_link, onclick=table_update_link)) + append(linkToPage(request, page, view_label, table_link, onclick=table_update_link)) + append(fmt.span(on=0)) + + if self.resolution == "date" and self.mode != "table": + append(fmt.span(on=1, css_class="event-view")) + append(linkToPage(request, page, _("View day as table"), + specific_table_link, onclick=specific_table_update_link + )) append(fmt.span(on=0)) - if self.mode != "map" and self.map_name: - append(fmt.span(on=1, css_class="event-view")) - append(linkToPage(request, page, _("View as map"), map_link, onclick=map_update_link)) - append(fmt.span(on=0)) + if self.map_name: + if self.resolution != "date" and self.mode != "map" or self.resolution == "date": + view_label = self.resolution == "date" and _("View day in map") or _("View as map") + append(fmt.span(on=1, css_class="event-view")) + append(linkToPage(request, page, view_label, map_link, onclick=map_update_link)) + append(fmt.span(on=0)) + + if self.resolution == "date" and self.mode != "map": + append(fmt.span(on=1, css_class="event-view")) + append(linkToPage(request, page, _("View day as map"), + specific_map_link, onclick=specific_map_update_link + )) + append(fmt.span(on=0)) append(fmt.div(on=0)) @@ -1942,8 +2011,8 @@ # Prepare a link to the day view for this day. - day_view_link = self.getNavigationLink(date, date, "day", "date") - day_view_update_link = self.getUpdateLink(date, date, "day", "date") + day_view_link = self.getNavigationLink(date, date, "day", "date", self.calendar_start, self.calendar_end) + day_view_update_link = self.getUpdateLink(date, date, "day", "date", self.calendar_start, self.calendar_end) # Output the heading class. diff -r 89611d9f33b1 -r 6c4df1436509 README.txt --- a/README.txt Sat Feb 02 01:09:39 2013 +0100 +++ b/README.txt Mon Feb 04 18:54:21 2013 +0100 @@ -359,6 +359,8 @@ categories. * Encoded map location pop-up headings as plain text in order to handle locations specified using Wiki formatting. + * Improved navigation between months and days, and between view modes for + both levels of calendar view. New in EventAggregator 0.8.5 (Changes since EventAggregator 0.8.4) ------------------------------------------------------------------ diff -r 89611d9f33b1 -r 6c4df1436509 TO_DO.txt --- a/TO_DO.txt Sat Feb 02 01:09:39 2013 +0100 +++ b/TO_DO.txt Mon Feb 04 18:54:21 2013 +0100 @@ -7,9 +7,6 @@ Navigation Controls ------------------- -Links to other views from the day view can override the default "all events" -limits, which is not necessarily beneficial. - The "New event" link should probably not be present when only remote events are being aggregated by a calendar. diff -r 89611d9f33b1 -r 6c4df1436509 actions/EventAggregatorUpdate.py --- a/actions/EventAggregatorUpdate.py Sat Feb 02 01:09:39 2013 +0100 +++ b/actions/EventAggregatorUpdate.py Mon Feb 04 18:54:21 2013 +0100 @@ -62,6 +62,9 @@ calendar_start = get_date(getParameter(request, "start")) or calendar_start calendar_end = get_date(getParameter(request, "end")) or calendar_end + wider_calendar_start = getParameterMonth(getParameter(request, "wider-start")) + wider_calendar_end = getParameterMonth(getParameter(request, "wider-end")) + # Get the events according to the resolution of the calendar. all_shown_events, first, last = getEventsUsingParameters( @@ -70,8 +73,11 @@ # Define a view of the calendar, retaining useful navigational information. - view = View(page, calendar_name, raw_calendar_start, raw_calendar_end, - original_calendar_start, original_calendar_end, calendar_start, calendar_end, + view = View(page, calendar_name, + raw_calendar_start, raw_calendar_end, + original_calendar_start, original_calendar_end, + calendar_start, calendar_end, + wider_calendar_start, wider_calendar_end, first, last, category_names, remote_sources, search_pattern, template_name, parent_name, mode, resolution, name_usage, map_name) diff -r 89611d9f33b1 -r 6c4df1436509 macros/EventAggregator.py --- a/macros/EventAggregator.py Sat Feb 02 01:09:39 2013 +0100 +++ b/macros/EventAggregator.py Mon Feb 04 18:54:21 2013 +0100 @@ -147,6 +147,9 @@ calendar_start = get_form_date(request, calendar_name, "start") or calendar_start calendar_end = get_form_date(request, calendar_name, "end") or calendar_end + wider_calendar_start = getFormMonth(request, calendar_name, "wider-start") + wider_calendar_end = getFormMonth(request, calendar_name, "wider-end") + # Get the events according to the resolution of the calendar. all_shown_events, first, last = getEventsUsingParameters( @@ -155,8 +158,11 @@ # Define a view of the calendar, retaining useful navigational information. - view = View(page, calendar_name, raw_calendar_start, raw_calendar_end, - original_calendar_start, original_calendar_end, calendar_start, calendar_end, + view = View(page, calendar_name, + raw_calendar_start, raw_calendar_end, + original_calendar_start, original_calendar_end, + calendar_start, calendar_end, + wider_calendar_start, wider_calendar_end, first, last, category_names, remote_sources, search_pattern, template_name, parent_name, mode, resolution, name_usage, map_name)