1.1 --- a/EventAggregatorSupport.py Sat Feb 02 01:09:39 2013 +0100
1.2 +++ b/EventAggregatorSupport.py Mon Feb 04 18:54:21 2013 +0100
1.3 @@ -1301,8 +1301,11 @@
1.4
1.5 "A view of the event calendar."
1.6
1.7 - def __init__(self, page, calendar_name, raw_calendar_start, raw_calendar_end,
1.8 - original_calendar_start, original_calendar_end, calendar_start, calendar_end,
1.9 + def __init__(self, page, calendar_name,
1.10 + raw_calendar_start, raw_calendar_end,
1.11 + original_calendar_start, original_calendar_end,
1.12 + calendar_start, calendar_end,
1.13 + wider_calendar_start, wider_calendar_end,
1.14 first, last, category_names, remote_sources, search_pattern, template_name,
1.15 parent_name, mode, resolution, name_usage, map_name):
1.16
1.17 @@ -1312,10 +1315,12 @@
1.18 are the actual start and end values provided by the request), the
1.19 calculated 'original_calendar_start' and 'original_calendar_end' (which
1.20 are the result of calculating the calendar's limits from the raw start
1.21 - and end values), and the requested, calculated 'calendar_start' and
1.22 + and end values), the requested, calculated 'calendar_start' and
1.23 'calendar_end' (which may involve different start and end values due to
1.24 - navigation in the user interface), along with the 'first' and 'last'
1.25 - months of event coverage.
1.26 + navigation in the user interface), and the requested
1.27 + 'wider_calendar_start' and 'wider_calendar_end' (which indicate a wider
1.28 + view used when navigating out of the day view), along with the 'first'
1.29 + and 'last' months of event coverage.
1.30
1.31 The additional 'category_names', 'remote_sources', 'search_pattern',
1.32 'template_name', 'parent_name' and 'mode' parameters are used to
1.33 @@ -1339,6 +1344,8 @@
1.34 self.original_calendar_end = original_calendar_end
1.35 self.calendar_start = calendar_start
1.36 self.calendar_end = calendar_end
1.37 + self.wider_calendar_start = wider_calendar_start
1.38 + self.wider_calendar_end = wider_calendar_end
1.39 self.template_name = template_name
1.40 self.parent_name = parent_name
1.41 self.mode = mode
1.42 @@ -1430,23 +1437,29 @@
1.43 else:
1.44 return ""
1.45
1.46 - def getNavigationLink(self, start, end, mode=None, resolution=None):
1.47 + def getNavigationLink(self, start, end, mode=None, resolution=None, wider_start=None, wider_end=None):
1.48
1.49 """
1.50 Return a query string fragment for navigation to a view showing months
1.51 from 'start' to 'end' inclusive, with the optional 'mode' indicating the
1.52 view style and the optional 'resolution' indicating the resolution of a
1.53 view, if configurable.
1.54 +
1.55 + If the 'wider_start' and 'wider_end' arguments are given, parameters
1.56 + indicating a wider calendar view (when returning from a day view, for
1.57 + example) will be included in the link.
1.58 """
1.59
1.60 - return "%s&%s&%s=%s&%s=%s" % (
1.61 + return "%s&%s&%s=%s&%s=%s&%s&%s" % (
1.62 self.getRawDateQueryString("start", start),
1.63 self.getRawDateQueryString("end", end),
1.64 self.getQualifiedParameterName("mode"), mode or self.mode,
1.65 - self.getQualifiedParameterName("resolution"), resolution or self.resolution
1.66 + self.getQualifiedParameterName("resolution"), resolution or self.resolution,
1.67 + self.getRawDateQueryString("wider-start", wider_start),
1.68 + self.getRawDateQueryString("wider-end", wider_end),
1.69 )
1.70
1.71 - def getUpdateLink(self, start, end, mode=None, resolution=None):
1.72 + def getUpdateLink(self, start, end, mode=None, resolution=None, wider_start=None, wider_end=None):
1.73
1.74 """
1.75 Return a query string fragment for navigation to a view showing months
1.76 @@ -1456,6 +1469,10 @@
1.77 navigation link in that it is sufficient to activate the update action
1.78 and produce an updated region of the page without needing to locate and
1.79 process the page or any macro invocation.
1.80 +
1.81 + If the 'wider_start' and 'wider_end' arguments are given, parameters
1.82 + indicating a wider calendar view (when returning from a day view, for
1.83 + example) will be included in the link.
1.84 """
1.85
1.86 parameters = [
1.87 @@ -1463,6 +1480,8 @@
1.88 self.getRawDateQueryString("end", end, 0),
1.89 self.category_name_parameters,
1.90 self.remote_source_parameters,
1.91 + self.getRawDateQueryString("wider-start", wider_start, 0),
1.92 + self.getRawDateQueryString("wider-end", wider_end, 0),
1.93 ]
1.94
1.95 pairs = [
1.96 @@ -1744,10 +1763,17 @@
1.97 output = []
1.98 append = output.append
1.99
1.100 - start = self.calendar_start
1.101 - end = self.calendar_end
1.102 + # For day view links to other views, the wider view parameters should
1.103 + # be used in order to be able to return to those other views.
1.104 +
1.105 + specific_start = self.calendar_start
1.106 + specific_end = self.calendar_end
1.107 +
1.108 + start = self.wider_calendar_start or specific_start
1.109 + end = self.wider_calendar_end or specific_end
1.110
1.111 help_page = Page(request, "HelpOnEventAggregator")
1.112 +
1.113 calendar_link = self.getNavigationLink(start and start.as_month(), end and end.as_month(), "calendar", "month")
1.114 calendar_update_link = self.getUpdateLink(start and start.as_month(), end and end.as_month(), "calendar", "month")
1.115 list_link = self.getNavigationLink(start, end, "list")
1.116 @@ -1756,6 +1782,18 @@
1.117 table_update_link = self.getUpdateLink(start, end, "table")
1.118 map_link = self.getNavigationLink(start, end, "map")
1.119 map_update_link = self.getUpdateLink(start, end, "map")
1.120 +
1.121 + # Specific links permit date-level navigation.
1.122 +
1.123 + specific_day_link = self.getNavigationLink(specific_start, specific_end, "day", "date", wider_start=start, wider_end=end)
1.124 + specific_day_update_link = self.getUpdateLink(specific_start, specific_end, "day", "date", wider_start=start, wider_end=end)
1.125 + specific_list_link = self.getNavigationLink(specific_start, specific_end, "list", wider_start=start, wider_end=end)
1.126 + specific_list_update_link = self.getUpdateLink(specific_start, specific_end, "list", wider_start=start, wider_end=end)
1.127 + specific_table_link = self.getNavigationLink(specific_start, specific_end, "table", wider_start=start, wider_end=end)
1.128 + specific_table_update_link = self.getUpdateLink(specific_start, specific_end, "table", wider_start=start, wider_end=end)
1.129 + specific_map_link = self.getNavigationLink(specific_start, specific_end, "map", wider_start=start, wider_end=end)
1.130 + specific_map_update_link = self.getUpdateLink(specific_start, specific_end, "map", wider_start=start, wider_end=end)
1.131 +
1.132 new_event_link = self.getNewEventLink(start)
1.133
1.134 # Write the controls.
1.135 @@ -1771,24 +1809,55 @@
1.136 append(fmt.span(on=0))
1.137
1.138 if self.mode != "calendar":
1.139 + view_label = self.resolution == "date" and _("View day in calendar") or _("View as calendar")
1.140 append(fmt.span(on=1, css_class="event-view"))
1.141 - append(linkToPage(request, page, _("View as calendar"), calendar_link, onclick=calendar_update_link))
1.142 + append(linkToPage(request, page, view_label, calendar_link, onclick=calendar_update_link))
1.143 + append(fmt.span(on=0))
1.144 +
1.145 + if self.resolution == "date" and self.mode != "day":
1.146 + append(fmt.span(on=1, css_class="event-view"))
1.147 + append(linkToPage(request, page, _("View day as calendar"), specific_day_link, onclick=specific_day_update_link))
1.148 append(fmt.span(on=0))
1.149
1.150 - if self.mode != "list":
1.151 + if self.resolution != "date" and self.mode != "list" or self.resolution == "date":
1.152 + view_label = self.resolution == "date" and _("View day in list") or _("View as list")
1.153 append(fmt.span(on=1, css_class="event-view"))
1.154 - append(linkToPage(request, page, _("View as list"), list_link, onclick=list_update_link))
1.155 + append(linkToPage(request, page, view_label, list_link, onclick=list_update_link))
1.156 + append(fmt.span(on=0))
1.157 +
1.158 + if self.resolution == "date" and self.mode != "list":
1.159 + append(fmt.span(on=1, css_class="event-view"))
1.160 + append(linkToPage(request, page, _("View day as list"),
1.161 + specific_list_link, onclick=specific_list_update_link
1.162 + ))
1.163 append(fmt.span(on=0))
1.164
1.165 - if self.mode != "table":
1.166 + if self.resolution != "date" and self.mode != "table" or self.resolution == "date":
1.167 + view_label = self.resolution == "date" and _("View day in table") or _("View as table")
1.168 append(fmt.span(on=1, css_class="event-view"))
1.169 - append(linkToPage(request, page, _("View as table"), table_link, onclick=table_update_link))
1.170 + append(linkToPage(request, page, view_label, table_link, onclick=table_update_link))
1.171 + append(fmt.span(on=0))
1.172 +
1.173 + if self.resolution == "date" and self.mode != "table":
1.174 + append(fmt.span(on=1, css_class="event-view"))
1.175 + append(linkToPage(request, page, _("View day as table"),
1.176 + specific_table_link, onclick=specific_table_update_link
1.177 + ))
1.178 append(fmt.span(on=0))
1.179
1.180 - if self.mode != "map" and self.map_name:
1.181 - append(fmt.span(on=1, css_class="event-view"))
1.182 - append(linkToPage(request, page, _("View as map"), map_link, onclick=map_update_link))
1.183 - append(fmt.span(on=0))
1.184 + if self.map_name:
1.185 + if self.resolution != "date" and self.mode != "map" or self.resolution == "date":
1.186 + view_label = self.resolution == "date" and _("View day in map") or _("View as map")
1.187 + append(fmt.span(on=1, css_class="event-view"))
1.188 + append(linkToPage(request, page, view_label, map_link, onclick=map_update_link))
1.189 + append(fmt.span(on=0))
1.190 +
1.191 + if self.resolution == "date" and self.mode != "map":
1.192 + append(fmt.span(on=1, css_class="event-view"))
1.193 + append(linkToPage(request, page, _("View day as map"),
1.194 + specific_map_link, onclick=specific_map_update_link
1.195 + ))
1.196 + append(fmt.span(on=0))
1.197
1.198 append(fmt.div(on=0))
1.199
1.200 @@ -1942,8 +2011,8 @@
1.201
1.202 # Prepare a link to the day view for this day.
1.203
1.204 - day_view_link = self.getNavigationLink(date, date, "day", "date")
1.205 - day_view_update_link = self.getUpdateLink(date, date, "day", "date")
1.206 + day_view_link = self.getNavigationLink(date, date, "day", "date", self.calendar_start, self.calendar_end)
1.207 + day_view_update_link = self.getUpdateLink(date, date, "day", "date", self.calendar_start, self.calendar_end)
1.208
1.209 # Output the heading class.
1.210