# HG changeset patch # User Paul Boddie # Date 1422643047 -3600 # Node ID b060f0b6e23835fc53da0e0cbe91be7afa2e41d3 # Parent 76cc1f55a328abe570e7d2f0d2e72313bef4f9f3 Added support for hiding/showing empty placeholder rows in the calendar. diff -r 76cc1f55a328 -r b060f0b6e238 htdocs/styles.css --- a/htdocs/styles.css Fri Jan 30 18:24:43 2015 +0100 +++ b/htdocs/styles.css Fri Jan 30 19:37:27 2015 +0100 @@ -49,6 +49,8 @@ color: #009; } +/* Selection of slots/periods for new events. */ + input.newevent { display: none; } @@ -76,3 +78,21 @@ background-color: #af8; text-decoration: underline; } + +/* Hiding/showing unused slots/periods. */ + +input#hideslots { + display: none; +} + +input#hideslots:checked ~ p label.enable[for=hideslots] { + display: none; +} + +input#hideslots:not(:checked) ~ p label.disable[for=hideslots] { + display: none; +} + +input#hideslots:checked ~ table tr.slot.daystart.empty { + display: none; +} diff -r 76cc1f55a328 -r b060f0b6e238 imip_manager.py --- a/imip_manager.py Fri Jan 30 18:24:43 2015 +0100 +++ b/imip_manager.py Fri Jan 30 19:37:27 2015 +0100 @@ -618,6 +618,16 @@ page.input(name="newevent", type="submit", value="New event", id="newevent") page.p.close() + # Show a control for hiding empty slots. + # The positioning of the control, paragraph and table are important here. + + page.input(name="hideslots", type="checkbox", value="hide", id="hideslots") + + page.p() + page.label("Hide unused time periods", for_="hideslots", class_="enable") + page.label("Show unused time periods", for_="hideslots", class_="disable") + page.p.close() + freebusy = self.store.get_freebusy(self.user) if not freebusy: @@ -817,7 +827,7 @@ page = self.page - # Produce a row for each time point. + # Produce a row for each interval. intervals = list(intervals) intervals.sort() @@ -825,7 +835,17 @@ for point, endpoint in intervals: continuation = point == get_start_of_day(point) - page.tr() + # Some rows contain no period details and are marked as such. + + have_active = reduce(lambda x, y: x or y, [slots.get(point) for slots in groups], None) + + css = " ".join( + ["slot"] + + (not have_active and ["empty"] or []) + + (continuation and ["daystart"] or []) + ) + + page.tr(class_=css) page.th(class_="timeslot") self._time_point(point, endpoint) page.th.close()