1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added ability to quickly access previous and next timerange

This commit is contained in:
Krateng 2019-04-26 17:05:29 +02:00
parent 0938eb57bc
commit f3fe8bb121
2 changed files with 35 additions and 0 deletions

View File

@ -522,6 +522,33 @@ def module_filterselection(keys,time=True,delimit=False):
# weekendstr = "/".join((str(num) for num in weekend))
# relative to current range
html += "<div>"
# if timekeys.get("timerange").next(-1) is not None:
# html += "<a href='?" + compose_querystring(unchangedkeys,internal_to_uri({"timerange":timekeys.get("timerange").next(-1)})) + "'><span class='stat_selector'>«</span></a>"
# if timekeys.get("timerange").next(-1) is not None or timekeys.get("timerange").next(1) is not None:
# html += " " + timekeys.get("timerange").desc() + " "
# if timekeys.get("timerange").next(1) is not None:
# html += "<a href='?" + compose_querystring(unchangedkeys,internal_to_uri({"timerange":timekeys.get("timerange").next(1)})) + "'><span class='stat_selector'>»</span></a>"
if timekeys.get("timerange").next(-1) is not None:
prevrange = timekeys.get("timerange").next(-1)
html += "<a href='?" + compose_querystring(unchangedkeys,internal_to_uri({"timerange":prevrange})) + "'><span class='stat_selector'>" + prevrange.desc() + "</span></a>"
html += " | "
if timekeys.get("timerange").next(-1) is not None or timekeys.get("timerange").next(1) is not None:
html += "<span class='stat_selector' style='opacity:0.5;'>" + timekeys.get("timerange").desc() + "</span>"
if timekeys.get("timerange").next(1) is not None:
html += " | "
nextrange = timekeys.get("timerange").next(1)
html += "<a href='?" + compose_querystring(unchangedkeys,internal_to_uri({"timerange":nextrange})) + "'><span class='stat_selector'>" + nextrange.desc() + "</span></a>"
html += "</div>"
# predefined ranges
html += "<div>"
if timekeys.get("timerange") == today():
html += "<span class='stat_selector' style='opacity:0.5;'>Today</span>"

View File

@ -84,6 +84,13 @@ class MRangeDescriptor:
def unlimited(self):
return False
# returns the description of the range including buttons to go back and forth
#def desc_interactive(self,**kwargs):
# if self.next(1) is None:
# return self.desc(**kwargs)
# else:
# prevrange = self.next(-1)
# nextrange = self.next(1)
# a range that is exactly a gregorian calendar unit (year, month or day)
class MTime(MRangeDescriptor):
@ -362,6 +369,7 @@ class MRange(MRangeDescriptor):
def next(self,step=1):
if abs(step) == math.inf: return None
if self.since is None or self.to is None: return None
# hop from the start element by one until we reach the end element
diff = 1
nxt = self.since