diff --git a/fields/calendar.py b/fields/calendar.py
index a3833ad..55e7b14 100644
--- a/fields/calendar.py
+++ b/fields/calendar.py
@@ -2,18 +2,62 @@
# ------------------------------------------------------------------------------
import types
from appy import Object
+from appy.shared.utils import splitList, IterSub
from appy.gen import Field
from appy.px import Px
from DateTime import DateTime
from BTrees.IOBTree import IOBTree
from persistent.list import PersistentList
+# ------------------------------------------------------------------------------
+class Other:
+ '''Identifies a Calendar field that must be shown within another Calendar
+ (see parameter "others" in class Calendar).'''
+ def __init__(self, obj, name, color='grey'):
+ # The object on which this calendar is defined
+ self.obj = obj
+ # The other calendar instance
+ self.field = obj.getField(name)
+ # The color into which events from this calendar must be shown (in the
+ # month rendering) in the calendar integrating this one.
+ self.color = color
+
+ def getEventsAt(self, res, calendar, date, eventNames, inTimeline, colors):
+ '''Gets the events defined at p_date in this calendar and append them in
+ p_res.'''
+ events = self.field.getEventsAt(self.obj.o, date)
+ if not events: return
+ eventType = events[0].eventType
+ # Gathered info will be an Object instance
+ info = Object(color=self.color)
+ if inTimeline:
+ # Get the background color for this cell if it has been
+ # defined, or (a) nothing if showUncolored is False, (b) a
+ # tooltipped dot else.
+ if eventType in colors:
+ info.bgColor = colors[eventType]
+ info.symbol = None
+ else:
+ info.bgColor = None
+ if calendar.showUncolored:
+ info.symbol = '▪' % \
+ eventNames[eventType]
+ else:
+ info.symbol = None
+ else:
+ # Get the event name
+ info.name = eventNames[eventType]
+ res.append(info)
+
# ------------------------------------------------------------------------------
class Calendar(Field):
'''This field allows to produce an agenda (monthly view) and view/edit
events on it.'''
jsFiles = {'view': ('calendar.js',)}
DateTime = DateTime
+ Other = Other # Access to the Other class via the Calendar class
+ IterSub = IterSub
+
timelineBgColors = {'Fri': '#a6a6a6', 'Sat': '#c0c0c0', 'Sun': '#c0c0c0'}
# For timeline rendering, the row displaying month names
@@ -34,6 +78,26 @@ class Calendar(Field):
:str(date.day()).zfill(2) |
| ''')
+ # Legend for a timeline calendar
+ pxTimelineLegend = Px('''
+
+
+
+
+
+ |
+
+ :allEventNames[eventType] |
+
+
+
''')
+
# Timeline view for a calendar
pxViewTimeline = Px('''
:field.pxTimeLineMonths
:field.pxTimelineDayLetters:field.pxTimelineDayNumbers
-
+
|
|
|
-
+
::tlName |
|
::field.getTimelineCell(events) |
@@ -74,7 +138,8 @@ class Calendar(Field):
:field.pxTimelineDayNumbers:field.pxTimelineDayLetters
:field.pxTimeLineMonths
-
''')
+
+ :field.pxTimelineLegend''')
# Month view for a calendar
pxViewMonth = Px('''
@@ -112,7 +177,7 @@ class Calendar(Field):
- :eventNames[eventType]
+ :allEventNames[eventType]
-
+ others, allEventNames, render, colors)">
:event.name
@@ -143,7 +208,7 @@ class Calendar(Field):
-