# HG changeset patch # User Paul Boddie # Date 1422981824 -3600 # Node ID 70562154ed5bfd8ca57d47a1fa510243eb0c656f # Parent 2b70fe0513152f7707a23fdb8ccd6b308dfdd814 Introduced a means of marking whole days as selected using dynamic stylesheets. diff -r 2b70fe051315 -r 70562154ed5b htdocs/styles.css --- a/htdocs/styles.css Tue Feb 03 16:57:36 2015 +0100 +++ b/htdocs/styles.css Tue Feb 03 17:43:44 2015 +0100 @@ -69,8 +69,9 @@ display: none; } +th.container, td.container { - padding: 0; + padding: 0; /* for regions covered by labels */ } th.dayheading:hover, @@ -82,10 +83,14 @@ background-color: #af8; } +label.day, +label.newevent.popup { + display: block; /* to make labels cover regions */ + padding: 0.25em; +} + label.newevent.popup { visibility: hidden; - display: block; - padding: 0.25em; text-align: center; } @@ -94,9 +99,8 @@ visibility: visible; } -input.newevent:checked ~ .day, input.newevent:checked ~ .timepoint { - background-color: #af8; + background-color: #5f4; text-decoration: underline; } diff -r 2b70fe051315 -r 70562154ed5b imip_manager.py --- a/imip_manager.py Tue Feb 03 16:57:36 2015 +0100 +++ b/imip_manager.py Tue Feb 03 17:43:44 2015 +0100 @@ -910,6 +910,8 @@ partitioned_group_types.append(group_type) partitioned_group_sources.append(group_source) + self.show_calendar_day_controls(days) + page.table(cellspacing=5, cellpadding=5, class_="calendar") self.show_calendar_participant_headings(partitioned_group_types, partitioned_group_sources, group_columns) self.show_calendar_days(days, partitioned_groups, partitioned_group_types, group_columns) @@ -919,6 +921,36 @@ page.form.close() + def show_calendar_day_controls(self, days): + + "Show controls for the given 'days' in the calendar." + + page = self.page + slots = self.env.get_args().get("slot", []) + + for day in days: + value, identifier = self._day_value_and_identifier(day) + self._slot_selector(value, identifier, slots) + + # Generate a dynamic stylesheet to allow day selections to colour + # specific days. + # NOTE: The style details need to be coordinated with the static + # NOTE: stylesheet. + + page.style(type="text/css") + + for day in days: + daystr = format_datetime(day) + page.add("""\ +input.newevent#day-%s-:checked ~ table label.day.day-%s, +input.newevent#day-%s-:checked ~ table label.timepoint.day-%s { + background-color: #5f4; + text-decoration: underline; +} +""" % (daystr, daystr, daystr, daystr)) + + page.style.close() + def show_calendar_participant_headings(self, group_types, group_sources, group_columns): """ @@ -972,7 +1004,7 @@ for day, intervals in all_days: page.thead() page.tr() - page.th(class_="dayheading", colspan=all_columns+1) + page.th(class_="dayheading container", colspan=all_columns+1) self._day_heading(day) page.th.close() page.tr.close() @@ -1097,18 +1129,34 @@ page.tr.close() def _day_heading(self, day): + + """ + Generate a heading for 'day' of the following form: + + + """ + page = self.page + daystr = format_datetime(day) value, identifier = self._day_value_and_identifier(day) - slots = self.env.get_args().get("slot", []) - self._slot_selector(value, identifier, slots) - page.label(self.format_date(day, "full"), class_="day", for_=identifier) + page.label(self.format_date(day, "full"), class_="day day-%s" % daystr, for_=identifier) def _time_point(self, point, endpoint): + + """ + Generate headings for the 'point' to 'endpoint' period of the following + form: + + + 10:00:00 CET + """ + page = self.page + daystr = format_datetime(point.date()) value, identifier = self._slot_value_and_identifier(point, endpoint) slots = self.env.get_args().get("slot", []) self._slot_selector(value, identifier, slots) - page.label(self.format_time(point, "long"), class_="timepoint", for_=identifier) + page.label(self.format_time(point, "long"), class_="timepoint day-%s" % daystr, for_=identifier) page.span(self.format_time(endpoint or get_end_of_day(point), "long"), class_="endpoint") def _slot_selector(self, value, identifier, slots):