2.1 --- a/css/event-aggregator.css Sun Jun 26 00:29:35 2011 +0200
2.2 +++ b/css/event-aggregator.css Sat Jul 09 20:50:17 2011 +0200
2.3 @@ -454,6 +454,20 @@
2.4 text-align: center;
2.5 }
2.6
2.7 +.event-map-unpositioned:not(:target) h2,
2.8 +.event-map-unpositioned:target .event-map-show-control,
2.9 +.event-map-unpositioned:not(:target) .event-map-hide-control,
2.10 +.event-map-unpositioned:not(:target) ul.event-map-location-events {
2.11 + display: none;
2.12 +}
2.13 +
2.14 +.event-map-unpositioned:target h2,
2.15 +.event-map-unpositioned:not(:target) .event-map-show-control,
2.16 +.event-map-unpositioned:target .event-map-hide-control,
2.17 +.event-map-unpositioned:target ul.event-map-location-events {
2.18 + display: block;
2.19 +}
2.20 +
2.21 ul.event-map-location-events {
2.22 list-style-type: none;
2.23 padding: 0.25em;
3.1 --- a/macros/EventAggregator.py Sun Jun 26 00:29:35 2011 +0200
3.2 +++ b/macros/EventAggregator.py Sat Jul 09 20:50:17 2011 +0200
3.3 @@ -84,6 +84,14 @@
3.4 self.previous_set_end = last.update(-self.duration)
3.5 self.next_set_end = last.update(self.duration)
3.6
3.7 + def getIdentifier(self):
3.8 +
3.9 + "Return a unique identifier to be used to refer to this view."
3.10 +
3.11 + # NOTE: Nasty hack to get a unique identifier if no name is given.
3.12 +
3.13 + return self.calendar_name or str(id(self))
3.14 +
3.15 def getQualifiedParameterName(self, argname):
3.16
3.17 "Return the 'argname' qualified using the calendar name."
3.18 @@ -150,6 +158,33 @@
3.19 self.getQualifiedParameterName("resolution"), resolution or self.resolution
3.20 )
3.21
3.22 + def getNewEventLink(self, start):
3.23 +
3.24 + """
3.25 + Return a query string activating the new event form, incorporating the
3.26 + calendar parameters, specialising the form for the given 'start' date or
3.27 + month.
3.28 + """
3.29 +
3.30 + if start is not None:
3.31 + details = start.as_tuple()
3.32 + pairs = zip(["start-year=%d", "start-month=%d", "start-day=%d"], details)
3.33 + args = [(param % value) for (param, value) in pairs]
3.34 + args = "&".join(args)
3.35 + else:
3.36 + args = ""
3.37 +
3.38 + # Prepare navigation details for the calendar shown with the new event
3.39 + # form.
3.40 +
3.41 + navigation_link = self.getNavigationLink(
3.42 + self.calendar_start, self.calendar_end
3.43 + )
3.44 +
3.45 + return "action=EventAggregatorNewEvent&%s&%s&template=%s&parent=%s&%s" % (
3.46 + args, self.category_name_parameters, self.template_name, self.parent_name or "",
3.47 + navigation_link)
3.48 +
3.49 def getFullDateLabel(self, date):
3.50 page = self.page
3.51 request = page.request
3.52 @@ -341,6 +376,7 @@
3.53 list_link = self.getNavigationLink(start, end, "list")
3.54 table_link = self.getNavigationLink(start, end, "table")
3.55 map_link = self.getNavigationLink(start, end, "map")
3.56 + new_event_link = self.getNewEventLink(start)
3.57
3.58 # Write the controls.
3.59
3.60 @@ -350,6 +386,10 @@
3.61 output.append(linkToPage(request, help_page, _("Help")))
3.62 output.append(fmt.span(on=0))
3.63
3.64 + output.append(fmt.span(on=1, css_class="event-view"))
3.65 + output.append(linkToPage(request, page, _("New event"), new_event_link))
3.66 + output.append(fmt.span(on=0))
3.67 +
3.68 if self.mode != "calendar":
3.69 output.append(fmt.span(on=1, css_class="event-view"))
3.70 output.append(linkToPage(request, page, _("View as calendar"), calendar_link))
3.71 @@ -499,23 +539,10 @@
3.72 fmt = page.formatter
3.73 _ = request.getText
3.74
3.75 + output = []
3.76 +
3.77 year, month, day = date.as_tuple()
3.78 - output = []
3.79 -
3.80 - # Prepare navigation details for the calendar shown with the new event
3.81 - # form.
3.82 -
3.83 - navigation_link = self.getNavigationLink(
3.84 - self.calendar_start, self.calendar_end
3.85 - )
3.86 -
3.87 - # Prepare the link to the new event form, incorporating the above
3.88 - # calendar parameters.
3.89 -
3.90 - new_event_link = "action=EventAggregatorNewEvent&start-day=%d&start-month=%d&start-year=%d" \
3.91 - "&%s&template=%s&parent=%s&%s" % (
3.92 - day, month, year, self.category_name_parameters, self.template_name, self.parent_name or "",
3.93 - navigation_link)
3.94 + new_event_link = self.getNewEventLink(date)
3.95
3.96 # Prepare a link to the day view for this day.
3.97
3.98 @@ -1577,7 +1604,8 @@
3.99
3.100 # Start of map view output.
3.101
3.102 - output.append(fmt.div(on=1, css_class="event-map"))
3.103 + map_identifier = "map-%s" % view.getIdentifier()
3.104 + output.append(fmt.div(on=1, css_class="event-map", id=map_identifier))
3.105
3.106 output.append(fmt.table(on=1))
3.107
3.108 @@ -1668,13 +1696,30 @@
3.109 # Write unpositioned events.
3.110
3.111 if unpositioned_events:
3.112 - output.append(fmt.table_row(on=1, css_class="event-map-unpositioned"))
3.113 + unpositioned_identifier = "unpositioned-%s" % view.getIdentifier()
3.114 +
3.115 + output.append(fmt.table_row(on=1, css_class="event-map-unpositioned",
3.116 + id=unpositioned_identifier))
3.117 output.append(fmt.table_cell(on=1))
3.118
3.119 output.append(fmt.heading(on=1, depth=2))
3.120 output.append(fmt.text(_("Events not shown on the map")))
3.121 output.append(fmt.heading(on=0, depth=2))
3.122
3.123 + # Show and hide controls.
3.124 +
3.125 + output.append(fmt.div(on=1, css_class="event-map-show-control"))
3.126 + output.append(fmt.anchorlink(on=1, name=unpositioned_identifier))
3.127 + output.append(fmt.text(_("Show unpositioned events")))
3.128 + output.append(fmt.anchorlink(on=0))
3.129 + output.append(fmt.div(on=0))
3.130 +
3.131 + output.append(fmt.div(on=1, css_class="event-map-hide-control"))
3.132 + output.append(fmt.anchorlink(on=1, name=map_identifier))
3.133 + output.append(fmt.text(_("Hide unpositioned events")))
3.134 + output.append(fmt.anchorlink(on=0))
3.135 + output.append(fmt.div(on=0))
3.136 +
3.137 output.append(view.writeMapEventSummaries(unpositioned_events))
3.138
3.139 # End of map view output.