# HG changeset patch # User Paul Boddie # Date 1443389998 -7200 # Node ID 71ff0157387ba678e3dcfd811a37f0db66b6bb23 # Parent 57c3866a301d641f083509f5842fe4554efe1841 Fixed the generation of time selection controls so that contiguous periods can be selected even when time instants are present. diff -r 57c3866a301d -r 71ff0157387b imipweb/calendar.py --- a/imipweb/calendar.py Sun Sep 27 23:38:51 2015 +0200 +++ b/imipweb/calendar.py Sun Sep 27 23:39:58 2015 +0200 @@ -470,8 +470,43 @@ # Generate controls to select time periods. slots = self.env.get_args().get("slot", []) + last = None + + # Produce controls for the intervals/slots. Where instants in time are + # encountered, they are merged with the following slots, permitting the + # selection of contiguous time periods. However, the identifiers + # employed by controls corresponding to merged periods will encode the + # instant so that labels may reference them conveniently. + + intervals = list(intervals) + intervals.sort() + for point, endpoint in intervals: - value, identifier = self._slot_value_and_identifier(point, endpoint) + + # Merge any previous slot with this one, producing a control. + + if last: + _value, identifier = self._slot_value_and_identifier(last, last) + value, _identifier = self._slot_value_and_identifier(last, endpoint) + self._slot_selector(value, identifier, slots) + + # If representing an instant, hold the slot for merging. + + if endpoint and point.point == endpoint.point: + last = point + + # If not representing an instant, produce a control. + + else: + value, identifier = self._slot_value_and_identifier(point, endpoint) + self._slot_selector(value, identifier, slots) + last = None + + # Produce a control for any unmerged slot. + + if last: + _value, identifier = self._slot_value_and_identifier(last, last) + value, _identifier = self._slot_value_and_identifier(last, endpoint) self._slot_selector(value, identifier, slots) def show_calendar_participant_headings(self, group_types, group_sources, group_columns): @@ -622,13 +657,16 @@ ]) page.tr(class_=css) + + # Produce a time interval heading, spanning two rows if this point + # represents an instant. + if point.indicator == Point.PRINCIPAL: timestr, timeid = self._slot_value_and_identifier(point, endpoint) - page.th(class_="timeslot", id="region-%s" % timeid) + page.th(class_="timeslot", id="region-%s" % timeid, + rowspan=(endpoint and point.point == endpoint.point and 2 or 1)) self._time_point(point, endpoint) - else: - page.th() - page.th.close() + page.th.close() # Obtain slots for the time point from each group.