# HG changeset patch # User Paul Boddie # Date 1310237417 -7200 # Node ID d3c1161a4194f3b8dade17711ee0bec18eaebb5c # Parent 79c6bb24d33f1fe55dc3851e9641d04986076b6b Added a "New event" link to the event view controls. Added show/hide controls for the unpositioned events list in the map view. diff -r 79c6bb24d33f -r d3c1161a4194 css/event-aggregator-print.css --- a/css/event-aggregator-print.css Sun Jun 26 00:29:35 2011 +0200 +++ b/css/event-aggregator-print.css Sat Jul 09 20:50:17 2011 +0200 @@ -142,5 +142,14 @@ display: inline-block; } +.event-map-unpositioned ul.event-map-location-events { + display: block !important; +} + +.event-map-show-control, +.event-map-hide-control { + display: none !important; +} + /* vim: tabstop=4 expandtab shiftwidth=4 */ diff -r 79c6bb24d33f -r d3c1161a4194 css/event-aggregator.css --- a/css/event-aggregator.css Sun Jun 26 00:29:35 2011 +0200 +++ b/css/event-aggregator.css Sat Jul 09 20:50:17 2011 +0200 @@ -454,6 +454,20 @@ text-align: center; } +.event-map-unpositioned:not(:target) h2, +.event-map-unpositioned:target .event-map-show-control, +.event-map-unpositioned:not(:target) .event-map-hide-control, +.event-map-unpositioned:not(:target) ul.event-map-location-events { + display: none; +} + +.event-map-unpositioned:target h2, +.event-map-unpositioned:not(:target) .event-map-show-control, +.event-map-unpositioned:target .event-map-hide-control, +.event-map-unpositioned:target ul.event-map-location-events { + display: block; +} + ul.event-map-location-events { list-style-type: none; padding: 0.25em; diff -r 79c6bb24d33f -r d3c1161a4194 macros/EventAggregator.py --- a/macros/EventAggregator.py Sun Jun 26 00:29:35 2011 +0200 +++ b/macros/EventAggregator.py Sat Jul 09 20:50:17 2011 +0200 @@ -84,6 +84,14 @@ self.previous_set_end = last.update(-self.duration) self.next_set_end = last.update(self.duration) + def getIdentifier(self): + + "Return a unique identifier to be used to refer to this view." + + # NOTE: Nasty hack to get a unique identifier if no name is given. + + return self.calendar_name or str(id(self)) + def getQualifiedParameterName(self, argname): "Return the 'argname' qualified using the calendar name." @@ -150,6 +158,33 @@ self.getQualifiedParameterName("resolution"), resolution or self.resolution ) + def getNewEventLink(self, start): + + """ + Return a query string activating the new event form, incorporating the + calendar parameters, specialising the form for the given 'start' date or + month. + """ + + if start is not None: + details = start.as_tuple() + pairs = zip(["start-year=%d", "start-month=%d", "start-day=%d"], details) + args = [(param % value) for (param, value) in pairs] + args = "&".join(args) + else: + args = "" + + # Prepare navigation details for the calendar shown with the new event + # form. + + navigation_link = self.getNavigationLink( + self.calendar_start, self.calendar_end + ) + + return "action=EventAggregatorNewEvent&%s&%s&template=%s&parent=%s&%s" % ( + args, self.category_name_parameters, self.template_name, self.parent_name or "", + navigation_link) + def getFullDateLabel(self, date): page = self.page request = page.request @@ -341,6 +376,7 @@ list_link = self.getNavigationLink(start, end, "list") table_link = self.getNavigationLink(start, end, "table") map_link = self.getNavigationLink(start, end, "map") + new_event_link = self.getNewEventLink(start) # Write the controls. @@ -350,6 +386,10 @@ output.append(linkToPage(request, help_page, _("Help"))) output.append(fmt.span(on=0)) + output.append(fmt.span(on=1, css_class="event-view")) + output.append(linkToPage(request, page, _("New event"), new_event_link)) + output.append(fmt.span(on=0)) + if self.mode != "calendar": output.append(fmt.span(on=1, css_class="event-view")) output.append(linkToPage(request, page, _("View as calendar"), calendar_link)) @@ -499,23 +539,10 @@ fmt = page.formatter _ = request.getText + output = [] + year, month, day = date.as_tuple() - output = [] - - # Prepare navigation details for the calendar shown with the new event - # form. - - navigation_link = self.getNavigationLink( - self.calendar_start, self.calendar_end - ) - - # Prepare the link to the new event form, incorporating the above - # calendar parameters. - - new_event_link = "action=EventAggregatorNewEvent&start-day=%d&start-month=%d&start-year=%d" \ - "&%s&template=%s&parent=%s&%s" % ( - day, month, year, self.category_name_parameters, self.template_name, self.parent_name or "", - navigation_link) + new_event_link = self.getNewEventLink(date) # Prepare a link to the day view for this day. @@ -1577,7 +1604,8 @@ # Start of map view output. - output.append(fmt.div(on=1, css_class="event-map")) + map_identifier = "map-%s" % view.getIdentifier() + output.append(fmt.div(on=1, css_class="event-map", id=map_identifier)) output.append(fmt.table(on=1)) @@ -1668,13 +1696,30 @@ # Write unpositioned events. if unpositioned_events: - output.append(fmt.table_row(on=1, css_class="event-map-unpositioned")) + unpositioned_identifier = "unpositioned-%s" % view.getIdentifier() + + output.append(fmt.table_row(on=1, css_class="event-map-unpositioned", + id=unpositioned_identifier)) output.append(fmt.table_cell(on=1)) output.append(fmt.heading(on=1, depth=2)) output.append(fmt.text(_("Events not shown on the map"))) output.append(fmt.heading(on=0, depth=2)) + # Show and hide controls. + + output.append(fmt.div(on=1, css_class="event-map-show-control")) + output.append(fmt.anchorlink(on=1, name=unpositioned_identifier)) + output.append(fmt.text(_("Show unpositioned events"))) + output.append(fmt.anchorlink(on=0)) + output.append(fmt.div(on=0)) + + output.append(fmt.div(on=1, css_class="event-map-hide-control")) + output.append(fmt.anchorlink(on=1, name=map_identifier)) + output.append(fmt.text(_("Hide unpositioned events"))) + output.append(fmt.anchorlink(on=0)) + output.append(fmt.div(on=0)) + output.append(view.writeMapEventSummaries(unpositioned_events)) # End of map view output.