2013-07-08 16:39:16 -05:00
|
|
|
<tal:comment replace="nothing">Month view macro</tal:comment>
|
2012-10-03 07:44:34 -05:00
|
|
|
<div metal:define-macro="viewMonth"
|
|
|
|
tal:define="fieldName request/fieldName;
|
|
|
|
ajaxHookId python: contextObj.UID() + fieldName;
|
|
|
|
month request/month;
|
|
|
|
monthDayOne python: DateTime('%s/01' % month);
|
|
|
|
today python: DateTime('00:00');
|
2012-10-29 23:53:45 -05:00
|
|
|
grid python: contextObj.callField(fieldName, 'getMonthGrid', month);
|
|
|
|
allEventTypes python: contextObj.callField(fieldName, 'getEventTypes', contextObj);
|
|
|
|
preComputed python: contextObj.callField(fieldName, 'getPreComputedInfo', contextObj, monthDayOne, grid);
|
2012-10-13 11:09:42 -05:00
|
|
|
defaultDate python: contextObj.callField(fieldName, 'getDefaultDate', contextObj);
|
|
|
|
defaultDateMonth python: defaultDate.strftime('%Y/%m');
|
2012-10-03 07:44:34 -05:00
|
|
|
previousMonth python: contextObj.callField(fieldName, 'getSiblingMonth', month, 'previous');
|
|
|
|
nextMonth python: contextObj.callField(fieldName, 'getSiblingMonth', month, 'next');
|
|
|
|
widget python: contextObj.getAppyType(fieldName, asDict=True);
|
|
|
|
mayEdit python: contextObj.allows(widget['writePermission']);
|
2012-10-06 00:22:24 -05:00
|
|
|
objUrl contextObj/absolute_url;
|
2012-10-13 11:09:42 -05:00
|
|
|
startDate python: contextObj.callField(fieldName, 'getStartDate', contextObj);
|
|
|
|
endDate python: contextObj.callField(fieldName, 'getEndDate', contextObj);
|
2012-10-29 23:53:45 -05:00
|
|
|
otherCalendars python: contextObj.callField(fieldName, 'getOtherCalendars', contextObj, preComputed);"
|
2012-10-03 07:44:34 -05:00
|
|
|
tal:attributes="id ajaxHookId">
|
|
|
|
|
2012-10-05 22:20:35 -05:00
|
|
|
<script type="text/javascript"
|
|
|
|
tal:content="python: 'var %s_maxEventLength = %d;' % (fieldName, widget['maxEventLength'])">
|
|
|
|
</script>
|
2012-10-03 07:44:34 -05:00
|
|
|
<tal:comment replace="nothing">Month chooser</tal:comment>
|
2012-10-13 11:09:42 -05:00
|
|
|
<div style="margin-bottom: 5px"
|
|
|
|
tal:define="fmt python: '%Y/%m/%d';
|
|
|
|
goBack python: not startDate or (startDate.strftime(fmt) < grid[0][0].strftime(fmt));
|
|
|
|
goForward python: not endDate or (endDate.strftime(fmt) > grid[-1][-1].strftime(fmt))">
|
|
|
|
<tal:comment replace="nothing">Go to the previous month</tal:comment>
|
|
|
|
<img style="cursor:pointer" tal:condition="goBack"
|
2012-10-03 07:44:34 -05:00
|
|
|
tal:attributes="src string: $appUrl/ui/arrowLeftSimple.png;
|
|
|
|
onclick python: 'askMonthView(\'%s\',\'%s\',\'%s\',\'%s\')' % (ajaxHookId,objUrl,fieldName,previousMonth)"/>
|
2012-10-13 11:09:42 -05:00
|
|
|
<tal:comment replace="nothing">Go back to the default date</tal:comment>
|
|
|
|
<tal:button condition="python: goBack or goForward">
|
|
|
|
<input type="button"
|
|
|
|
tal:define="fmt python: '%Y/%m';
|
|
|
|
label python: test(defaultDate.strftime(fmt) == today.strftime(fmt), 'today', 'goto_source')"
|
|
|
|
tal:attributes="value python: _(label);
|
|
|
|
onclick python: 'askMonthView(\'%s\',\'%s\',\'%s\',\'%s\')' % (ajaxHookId,objUrl,fieldName,defaultDateMonth);
|
|
|
|
disabled python: defaultDate.strftime(fmt) == monthDayOne.strftime(fmt)"/>
|
|
|
|
</tal:button>
|
|
|
|
<tal:comment replace="nothing">Go to the next month</tal:comment>
|
|
|
|
<img style="cursor:pointer" tal:condition="goForward"
|
2012-10-03 07:44:34 -05:00
|
|
|
tal:attributes="src string: $appUrl/ui/arrowRightSimple.png;
|
|
|
|
onclick python: 'askMonthView(\'%s\',\'%s\',\'%s\',\'%s\')' % (ajaxHookId,objUrl,fieldName,nextMonth)"/>
|
|
|
|
<span tal:content="python: _('month_%s' % monthDayOne.aMonth())"></span>
|
|
|
|
<span tal:content="python: month.split('/')[0]"></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Calendar month view</tal:comment>
|
|
|
|
<table cellpadding="0" cellspacing="0" width="100%" class="list" style="font-size: 95%"
|
|
|
|
tal:define="rowHeight python: int(widget['height']/float(len(grid)))">
|
|
|
|
<tal:comment replace="nothing">1st row: names of days</tal:comment>
|
|
|
|
<tr height="22px">
|
|
|
|
<th tal:repeat="dayName python: contextObj.callField(fieldName, 'getNamesOfDays', contextObj)"
|
|
|
|
tal:content="dayName" width="14%">
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
<tal:comment replace="nothing">The calendar in itself</tal:comment>
|
|
|
|
<tr tal:repeat="row grid" valign="top" tal:attributes="height rowHeight">
|
|
|
|
<tal:cell repeat="date row">
|
2012-10-13 11:09:42 -05:00
|
|
|
<tal:cel define="tooEarly python: startDate and (date < startDate);
|
|
|
|
tooLate python: endDate and not tooEarly and (date > endDate);
|
2012-10-18 13:57:03 -05:00
|
|
|
inRange python: not tooEarly and not tooLate;
|
|
|
|
cssClasses python: contextObj.callField(fieldName, 'getCellStyle', contextObj, date, today)">
|
2012-10-13 11:09:42 -05:00
|
|
|
<tal:comment replace="nothing">Dump an empty cell if we are out of the supported date range</tal:comment>
|
2012-10-18 13:57:03 -05:00
|
|
|
<td tal:condition="not: inRange" tal:attributes="class cssClasses">
|
2012-10-13 11:09:42 -05:00
|
|
|
</td>
|
|
|
|
<tal:comment replace="nothing">Dump a normal cell if we are in range</tal:comment>
|
|
|
|
<tal:td condition="inRange">
|
|
|
|
<td tal:define="events python: contextObj.callField(fieldName, 'getEventsAt', contextObj, date);
|
|
|
|
spansDays python: contextObj.callField(fieldName, 'hasEventsAt', contextObj, date+1, events);
|
|
|
|
mayCreate python: mayEdit and not events;
|
|
|
|
mayDelete python: mayEdit and events;"
|
|
|
|
tal:attributes="style python: test(date.isCurrentDay(), 'font-weight:bold', 'font-weight:normal');
|
2012-10-18 13:57:03 -05:00
|
|
|
class cssClasses;
|
2012-10-13 11:09:42 -05:00
|
|
|
onmouseover python: test(mayEdit, 'this.getElementsByTagName(\'img\')[0].style.visibility=\'visible\'', '');
|
|
|
|
onmouseout python: test(mayEdit, 'this.getElementsByTagName(\'img\')[0].style.visibility=\'hidden\'', '')">
|
|
|
|
<tal:day define="day date/day;
|
|
|
|
dayString python: date.strftime('%Y/%m/%d')">
|
|
|
|
<span tal:content="day"></span>
|
|
|
|
<span tal:condition="python: day == 1"
|
|
|
|
tal:content="python: _('month_%s_short' % date.aMonth())"></span>
|
|
|
|
<tal:comment replace="nothing">Icon for adding an event</tal:comment>
|
2012-10-29 23:53:45 -05:00
|
|
|
<tal:create condition="mayCreate">
|
|
|
|
<img style="visibility:hidden; cursor:pointer"
|
|
|
|
tal:define="info python: contextObj.callField(fieldName, 'getApplicableEventsTypesAt', contextObj, date, allEventTypes, preComputed, True)"
|
|
|
|
tal:condition="info/eventTypes"
|
|
|
|
tal:attributes="src string: $appUrl/ui/plus.png;
|
|
|
|
onclick python: 'openEventPopup(\'new\',\'%s\',\'%s\',null,\'%s\',\'%s\')' % (fieldName, dayString, info['eventTypes'], info['message'])"/>
|
|
|
|
</tal:create>
|
2012-10-13 11:09:42 -05:00
|
|
|
<tal:comment replace="nothing">Icon for deleting an event</tal:comment>
|
|
|
|
<img tal:condition="mayDelete" style="visibility:hidden; cursor:pointer"
|
|
|
|
tal:attributes="src string: $appUrl/ui/delete.png;
|
2012-10-29 23:53:45 -05:00
|
|
|
onclick python: 'openEventPopup(\'del\',\'%s\',\'%s\',\'%s\',null,null)' % (fieldName, dayString, str(spansDays))"/>
|
2012-10-13 11:09:42 -05:00
|
|
|
<tal:events condition="events">
|
2012-10-03 07:44:34 -05:00
|
|
|
<tal:comment replace="nothing">A single event is allowed for the moment</tal:comment>
|
|
|
|
<div tal:define="eventType python: events[0]['eventType']">
|
|
|
|
<span style="color: grey"
|
2012-10-12 09:36:04 -05:00
|
|
|
tal:content="python: contextObj.callField(fieldName, 'getEventName', contextObj, eventType)"></span>
|
2012-10-03 07:44:34 -05:00
|
|
|
</div>
|
2012-10-13 11:09:42 -05:00
|
|
|
</tal:events>
|
|
|
|
<tal:comment replace="nothing">Events from other calendars</tal:comment>
|
|
|
|
<tal:others condition="otherCalendars">
|
|
|
|
<tal:e define="otherEvents python: contextObj.callField(fieldName,'getOtherEventsAt',contextObj,date,otherCalendars)"
|
|
|
|
condition="otherEvents">
|
|
|
|
<div tal:repeat="event otherEvents" tal:content="event/name"
|
|
|
|
tal:attributes="style python: 'color: %s;; font-style: italic' % event['color']"></div>
|
|
|
|
</tal:e>
|
|
|
|
</tal:others>
|
2012-10-26 06:09:44 -05:00
|
|
|
<tal:comment replace="nothing">Additional info</tal:comment>
|
2012-10-29 23:53:45 -05:00
|
|
|
<tal:info define="info python: contextObj.callField(fieldName,'getAdditionalInfoAt', contextObj, date, preComputed)"
|
2012-10-26 06:09:44 -05:00
|
|
|
condition="info" replace="structure info"/>
|
2012-10-13 11:09:42 -05:00
|
|
|
</tal:day>
|
|
|
|
</td>
|
|
|
|
</tal:td>
|
|
|
|
</tal:cel>
|
2012-10-03 07:44:34 -05:00
|
|
|
</tal:cell>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Popup for creating a calendar event</tal:comment>
|
|
|
|
<div tal:define="prefix python: '%s_newEvent' % fieldName;
|
|
|
|
popupId python: prefix + 'Popup'"
|
|
|
|
tal:attributes="id popupId" class="popup" align="center">
|
|
|
|
<form tal:attributes="id python: prefix + 'Form'" method="post">
|
|
|
|
<input type="hidden" name="fieldName" tal:attributes="value fieldName"/>
|
|
|
|
<input type="hidden" name="month" tal:attributes="value month"/>
|
|
|
|
<input type="hidden" name="name" tal:attributes="value fieldName"/>
|
|
|
|
<input type="hidden" name="action" value="Process"/>
|
|
|
|
<input type="hidden" name="actionType" value="createEvent"/>
|
|
|
|
<input type="hidden" name="day"/>
|
|
|
|
|
2012-10-29 23:53:45 -05:00
|
|
|
<tal:comment replace="nothing">Choose an event type</tal:comment>
|
2012-10-03 07:44:34 -05:00
|
|
|
<div align="center" style="margin-bottom: 3px" tal:content="python: _('which_event')"></div>
|
|
|
|
<select name="eventType">
|
2012-10-29 23:53:45 -05:00
|
|
|
<option value="" tal:content="python: _('choose_a_value')"></option>
|
|
|
|
<option tal:repeat="eventType allEventTypes"
|
2012-10-12 09:36:04 -05:00
|
|
|
tal:content="python: contextObj.callField(fieldName, 'getEventName', contextObj, eventType)"
|
2012-10-03 07:44:34 -05:00
|
|
|
tal:attributes="value eventType">
|
|
|
|
</option>
|
|
|
|
</select><br/><br/>
|
|
|
|
<tal:comment replace="nothing">Span the event on several days</tal:comment>
|
|
|
|
<div align="center" class="discreet" style="margin-bottom: 3px">
|
|
|
|
<span tal:content="python: _('event_span')"></span>
|
|
|
|
<input type="text" size="3" name="eventSpan"/>
|
|
|
|
</div>
|
|
|
|
<input type="button"
|
|
|
|
tal:attributes="value python:_('object_save');
|
2012-10-05 22:20:35 -05:00
|
|
|
onClick python: 'triggerCalendarEvent(\'new\',\'%s\',\'%s\',\'%s\',%s_maxEventLength)' % (ajaxHookId,fieldName,objUrl,fieldName)"/>
|
2012-10-03 07:44:34 -05:00
|
|
|
<input type="button"
|
|
|
|
tal:attributes="value python:_('object_cancel');
|
|
|
|
onclick python: 'closePopup(\'%s\')' % popupId"/>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Popup for deleting a calendar event</tal:comment>
|
|
|
|
<div tal:define="prefix python: '%s_delEvent' % fieldName;
|
|
|
|
popupId python: prefix + 'Popup'"
|
|
|
|
tal:attributes="id popupId" class="popup" align="center">
|
|
|
|
<form tal:attributes="id python: prefix + 'Form'" method="post">
|
|
|
|
<input type="hidden" name="fieldName" tal:attributes="value fieldName"/>
|
|
|
|
<input type="hidden" name="month" tal:attributes="value month"/>
|
|
|
|
<input type="hidden" name="name" tal:attributes="value fieldName"/>
|
|
|
|
<input type="hidden" name="action" value="Process"/>
|
|
|
|
<input type="hidden" name="actionType" value="deleteEvent"/>
|
|
|
|
<input type="hidden" name="day"/>
|
|
|
|
|
|
|
|
<div align="center" style="margin-bottom: 5px"
|
|
|
|
tal:content="python: _('delete_confirm')"></div>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Delete successive events?</tal:comment>
|
|
|
|
<div class="discreet" style="margin-bottom: 10px"
|
|
|
|
tal:attributes="id python: prefix + 'DelNextEvent'">
|
|
|
|
<input type="checkbox" name="deleteNext_cb"
|
|
|
|
tal:attributes="id python: prefix + '_cb';
|
|
|
|
onClick python:'toggleCheckbox(\'%s_cb\', \'%s_hd\')' % (prefix, prefix);"/>
|
|
|
|
<input type="hidden" tal:attributes="id python: prefix + '_hd'" name="deleteNext"/>
|
|
|
|
<span tal:content="python: _('del_next_events')"/>
|
|
|
|
</div>
|
|
|
|
<input type="button"
|
|
|
|
tal:attributes="value python:_('yes');
|
|
|
|
onClick python: 'triggerCalendarEvent(\'del\',\'%s\',\'%s\',\'%s\')' % (ajaxHookId,fieldName,objUrl)"/>
|
|
|
|
<input type="button"
|
|
|
|
tal:attributes="value python:_('no');
|
|
|
|
onclick python: 'closePopup(\'%s\')' % popupId"/>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">View macro</tal:comment>
|
|
|
|
<metal:view define-macro="view"
|
2012-10-13 11:09:42 -05:00
|
|
|
tal:define="defaultDate python: contextObj.callField(widget['name'], 'getDefaultDate', contextObj);
|
2012-10-03 07:44:34 -05:00
|
|
|
dummy python: request.set('fieldName', widget['name']);
|
2012-10-13 11:09:42 -05:00
|
|
|
dummy python: request.set('month', defaultDate.strftime('%Y/%m'))">
|
2012-10-03 07:44:34 -05:00
|
|
|
<metal:call use-macro="app/ui/widgets/calendar/macros/viewMonth"/>
|
|
|
|
</metal:view>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Edit macro</tal:comment>
|
|
|
|
<metal:edit define-macro="edit"></metal:edit>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Cell macro</tal:comment>
|
|
|
|
<metal:cell define-macro="cell">
|
|
|
|
<metal:call use-macro="app/ui/widgets/calendar/macros/view"/>
|
|
|
|
</metal:cell>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Search macro</tal:comment>
|
|
|
|
<metal:search define-macro="search"></metal:search>
|