[gen] Optimized PXs. [px] added tag 'var2', similar to 'var', but that is executed after tags 'for' and 'if'.

This commit is contained in:
Gaetan Delannay 2013-07-15 11:23:29 +02:00
parent 73c3cfb2c7
commit 1810373304
18 changed files with 834 additions and 956 deletions

View file

@ -33,17 +33,15 @@ class Action(Field):
<input type="hidden" name="action" value="ExecuteAppyAction"/>
<input type="hidden" name="objectUid" value=":contextObj.UID()"/>
<input type="hidden" name="fieldName" value=":name"/>
<x if="field.confirm"><input
type="button" class="button"
<input if="field.confirm" type="button" class="button"
var="labelConfirm=_(field.labelId + '_confirm')"
value=":ztool.truncateValue(label)" title=":label"
style=":'background-image: url(%s/ui/buttonAction.png)' % appUrl"
style=":img('buttonAction', bg=True)"
onclick=":'askConfirm(%s,%s,%s)' % (q('form'), q(formId), \
q(labelConfirm))"/>
</x>
<input if="not field.confirm" type="submit" class="button" name="do"
value=":ztool.truncateValue(label)" title=":label"
style=":'background-image: url(%s/ui/buttonAction.png)' % appUrl"/>
style=":img('buttonAction', bg=True)"/>
</form>''')
# It is not possible to edit an action, not to search it.

View file

@ -36,25 +36,22 @@ class Calendar(Field):
otherCalendars=field.getOtherCalendars(contextObj, preComputed)"
id=":ajaxHookId">
<script type="text/javascript">:'var %s_maxEventLength = %d;' % \
(field.name, field.maxEventLength)">
</script>
<script type="text/javascript">:'var %s_maxEventLength = %d;' % \
(field.name, field.maxEventLength)"></script>
<!-- Month chooser -->
<div style="margin-bottom: 5px"
var="fmt='%Y/%m/%d';
goBack=not startDate or (startDate.strftime(fmt) &lt; \
grid[0][0].strftime(fmt));
goForward=not endDate or (endDate.strftime(fmt) &gt; \
grid[-1][-1].strftime(fmt))">
<!-- Go to the previous month -->
<img style="cursor:pointer" tal:condition="goBack"
src=":'%s/ui/arrowLeftSimple.png' % appUrl"
onclick=":'askMonthView(%s, %s, %s, %s)' % \
<!-- Month chooser -->
<div style="margin-bottom: 5px"
var="fmt='%Y/%m/%d';
goBack=not startDate or (startDate.strftime(fmt) &lt; \
grid[0][0].strftime(fmt));
goForward=not endDate or (endDate.strftime(fmt) &gt; \
grid[-1][-1].strftime(fmt))">
<!-- Go to the previous month -->
<img style="cursor:pointer" if="goBack" src=":img('arrowLeftSimple')"
onclick=":'askMonthView(%s,%s,%s,%s)' % \
(q(ajaxHookId),q(objUrl),q(field.name),q(previousMonth))"/>
<!-- Go back to the default date -->
<x if="goBack or goForward">
<input type="button"
<!-- Go back to the default date -->
<input type="button" if="goBack or goForward"
var="fmt='%Y/%m';
label=(defaultDate.strftime(fmt)==today.strftime(fmt)) and \
'today' or 'goto_source'"
@ -62,170 +59,158 @@ class Calendar(Field):
onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \
q(objUrl), q(field.name), q(defaultDateMonth))"
disabled=":defaultDate.strftime(fmt)==monthDayOne.strftime(fmt)"/>
</x>
<!-- Go to the next month -->
<img style="cursor:pointer" if="goForward"
src=":'%s/ui/arrowRightSimple.png' % appUrl"
onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \
<!-- Go to the next month -->
<img style="cursor:pointer" if="goForward" src=":img('arrowRightSimple')"
onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \
q(objUrl), q(field.name), q(nextMonth))"/>
<span>:_('month_%s' % monthDayOne.aMonth())</span>
<span>:month.split('/')[0]</span>
</div>
<span>:_('month_%s' % monthDayOne.aMonth())</span>
<span>:month.split('/')[0]</span>
</div>
<!-- Calendar month view -->
<table cellpadding="0" cellspacing="0" width="100%" class="list"
style="font-size: 95%"
var="rowHeight=int(field.height/float(len(grid)))">
<!-- 1st row: names of days -->
<tr height="22px">
<th for="dayName in field.getNamesOfDays(contextObj)"
width="14%">:dayName</th>
</tr>
<!-- The calendar in itself -->
<tr for="row in grid" valign="top" height=":rowHeight">
<x for="date in row">
<x var="tooEarly=startDate and (date &lt; startDate);
tooLate=endDate and not tooEarly and (date &gt; endDate);
inRange=not tooEarly and not tooLate;
cssClasses=field.getCellStyle(contextObj, date, today)">
<!-- Calendar month view -->
<table cellpadding="0" cellspacing="0" width="100%" class="list"
style="font-size: 95%"
var="rowHeight=int(field.height/float(len(grid)))">
<!-- 1st row: names of days -->
<tr height="22px">
<th for="dayName in field.getNamesOfDays(contextObj)"
width="14%">:dayName</th>
</tr>
<!-- The calendar in itself -->
<tr for="row in grid" valign="top" height=":rowHeight">
<x for="date in row"
var2="tooEarly=startDate and (date &lt; startDate);
tooLate=endDate and not tooEarly and (date &gt; endDate);
inRange=not tooEarly and not tooLate;
cssClasses=field.getCellStyle(contextObj, date, today)">
<!-- Dump an empty cell if we are out of the supported date range -->
<td if="not inRange" class=":cssClasses"></td>
<!-- Dump a normal cell if we are in range -->
<x if="inRange">
<td var="events=field.getEventsAt(contextObj, date);
<td if="inRange"
var2="events=field.getEventsAt(contextObj, date);
spansDays=field.hasEventsAt(contextObj, date+1, events);
mayCreate=mayEdit and not events;
mayDelete=mayEdit and events"
style="date.isCurrentDay() and 'font-weight:bold' or \
'font-weight:normal'"
class=":cssClasses"
onmouseover=":mayEdit and 'this.getElementsByTagName(\
%s)[0].style.visibility=%s' % (q('img'), q('visible')) or ''"
onmouseout="mayEdit and 'this.getElementsByTagName(\
%s)[0].style.visibility=%s' % (q('img'), q('hidden')) or ''">
<x var="day=date.day();
dayString=date.strftime('%Y/%m/%d')">
<span>:day</span>
<span if="day == 1">:_('month_%s_short' % date.aMonth())"></span>
<!-- Icon for adding an event -->
<x if="mayCreate">
<img style="visibility:hidden; cursor:pointer"
var="info=field.getApplicableEventsTypesAt(contextObj, date, \
mayDelete=mayEdit and events;
day=date.day();
dayString=date.strftime('%Y/%m/%d')"
style="date.isCurrentDay() and 'font-weight:bold' or \
'font-weight:normal'"
class=":cssClasses"
onmouseover=":mayEdit and 'this.getElementsByTagName(\
%s)[0].style.visibility=%s' % (q('img'), q('visible')) or ''"
onmouseout="mayEdit and 'this.getElementsByTagName(\
%s)[0].style.visibility=%s' % (q('img'), q('hidden')) or ''">
<span>:day</span>
<span if="day == 1">:_('month_%s_short' % date.aMonth())"></span>
<!-- Icon for adding an event -->
<x if="mayCreate">
<img style="visibility:hidden; cursor:pointer"
var="info=field.getApplicableEventsTypesAt(contextObj, date, \
allEventTypes, preComputed, True)"
if="info['eventTypes']"
src=":'%s/ui/plus.png' % appUrl"
onclick=":'openEventPopup(%s, %s, %s, null, %s, %s)' % \
(q('new'), q(field.name), q(dayString), \
q(info['eventTypes']), q(info['message']))"/>
</x>
<!-- Icon for deleting an event -->
<img if="mayDelete" style="visibility:hidden; cursor:pointer"
src=":'%s/ui/delete.png' % appUrl"
onclick=":'openEventPopup(%s, %s, %s, %s, null, null)' % \
(q('del'), q(field.name), q(dayString), q(str(spansDays)))"/>
<x if="events">
<!-- A single event is allowed for the moment -->
<div var="eventType=events[0]['eventType']">
<span style="color: grey">:field.getEventName(contextObj, \
eventType)"></span>
</div>
</x>
<!-- Events from other calendars -->
<x if="otherCalendars">
<x var="otherEvents=field.getOtherEventsAt(contextObj, date, \
otherCalendars)"
if="otherEvents">
<div style=":'color: %s; font-style: italic' % event['color']"
for="event in otherEvents">:event['name']</div>
</x>
</x>
<!-- Additional info -->
<x var="info=field.getAdditionalInfoAt(contextObj,date,preComputed)"
if="info">::info</x>
</x>
</td>
</x>
if="info['eventTypes']" src=":img('plus')"
onclick=":'openEventPopup(%s, %s, %s, null, %s, %s)' % \
(q('new'), q(field.name), q(dayString), q(info['eventTypes']),\
q(info['message']))"/>
</x>
<!-- Icon for deleting an event -->
<img if="mayDelete" style="visibility:hidden; cursor:pointer"
src=":img('delete')"
onclick=":'openEventPopup(%s, %s, %s, %s, null, null)' % \
(q('del'), q(field.name), q(dayString), q(str(spansDays)))"/>
<!-- A single event is allowed for the moment -->
<div if="events" var2="eventType=events[0]['eventType']">
<span style="color: grey">:field.getEventName(contextObj, \
eventType)"></span>
</div>
<!-- Events from other calendars -->
<x if="otherCalendars"
var2="otherEvents=field.getOtherEventsAt(contextObj, date, \
otherCalendars)">
<div style=":'color: %s; font-style: italic' % event['color']"
for="event in otherEvents">:event['name']</div>
</x>
<!-- Additional info -->
<x var="info=field.getAdditionalInfoAt(contextObj,date,preComputed)"
if="info">::info</x>
</td>
</x>
</x>
</tr>
</table>
</tr>
</table>
<!-- Popup for creating a calendar event -->
<div var="prefix='%s_newEvent' % field.name;
popupId=prefix + 'Popup'"
id=":popupId" class="popup" align="center">
<form id="prefix + 'Form'" method="post">
<input type="hidden" name="fieldName" value=":field.name"/>
<input type="hidden" name="month" value=":month"/>
<input type="hidden" name="name" value=":field.name"/>
<input type="hidden" name="action" value="Process"/>
<input type="hidden" name="actionType" value="createEvent"/>
<input type="hidden" name="day"/>
<!-- Popup for creating a calendar event -->
<div var="prefix='%s_newEvent' % field.name;
popupId=prefix + 'Popup'"
id=":popupId" class="popup" align="center">
<form id="prefix + 'Form'" method="post">
<input type="hidden" name="fieldName" value=":field.name"/>
<input type="hidden" name="month" value=":month"/>
<input type="hidden" name="name" value=":field.name"/>
<input type="hidden" name="action" value="Process"/>
<input type="hidden" name="actionType" value="createEvent"/>
<input type="hidden" name="day"/>
<!-- Choose an event type -->
<div align="center" style="margin-bottom: 3px">:_('which_event')"></div>
<select name="eventType">
<option value="">:_('choose_a_value')"></option>
<option for="eventType in allEventTypes"
value=":eventType">:field.getEventName(contextObj, eventType)">
</option>
</select><br/><br/>
<!--Span the event on several days -->
<div align="center" class="discreet" style="margin-bottom: 3px">
<span>:_('event_span')"></span>
<input type="text" size="3" name="eventSpan"/>
</div>
<input type="button"
value=":_('object_save')"
onclick=":'triggerCalendarEvent(%s, %s, %s, %s, \
%s_maxEventLength)' % (q('new'), q(ajaxHookId), \
q(field.name), q(objUrl), field.name)"/>
<input type="button"
value=":_('object_cancel')"
onclick=":'closePopup(%s)' % q(popupId)"/>
</form>
</div>
<!-- Choose an event type -->
<div align="center" style="margin-bottom: 3px">:_('which_event')"></div>
<select name="eventType">
<option value="">:_('choose_a_value')"></option>
<option for="eventType in allEventTypes"
value=":eventType">:field.getEventName(contextObj, eventType)">
</option>
</select><br/><br/>
<!--Span the event on several days -->
<div align="center" class="discreet" style="margin-bottom: 3px">
<span>:_('event_span')"></span>
<input type="text" size="3" name="eventSpan"/>
</div>
<input type="button"
value=":_('object_save')"
onclick=":'triggerCalendarEvent(%s, %s, %s, %s, \
%s_maxEventLength)' % (q('new'), q(ajaxHookId), \
q(field.name), q(objUrl), field.name)"/>
<input type="button"
value=":_('object_cancel')"
onclick=":'closePopup(%s)' % q(popupId)"/>
</form>
</div>
<!-- Popup for deleting a calendar event -->
<div var="prefix='%s_delEvent' % field.name;
popupId=prefix + 'Popup'"
id=":popupId" class="popup" align="center">
<form id=":prefix + 'Form'" method="post">
<input type="hidden" name="fieldName" value=":field.name"/>
<input type="hidden" name="month" value=":month"/>
<input type="hidden" name="name" value=":field.name"/>
<input type="hidden" name="action" value="Process"/>
<input type="hidden" name="actionType" value="deleteEvent"/>
<input type="hidden" name="day"/>
<!-- Popup for deleting a calendar event -->
<div var="prefix='%s_delEvent' % field.name;
popupId=prefix + 'Popup'"
id=":popupId" class="popup" align="center">
<form id=":prefix + 'Form'" method="post">
<input type="hidden" name="fieldName" value=":field.name"/>
<input type="hidden" name="month" value=":month"/>
<input type="hidden" name="name" value=":field.name"/>
<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">_('delete_confirm')">
</div>
<div align="center" style="margin-bottom: 5px">_('delete_confirm')">
</div>
<!-- Delete successive events ? -->
<div class="discreet" style="margin-bottom: 10px"
id=":prefix + 'DelNextEvent'">
<input type="checkbox" name="deleteNext_cb"
id=":prefix + '_cb'"
onClick=":'toggleCheckbox(%s, %s)' % \
(q('%s_cb' % prefix), q('%s_hd' % prefix))"/>
<input type="hidden" id=":prefix + '_hd'" name="deleteNext"/>
<span>:_('del_next_events')"></span>
</div>
<input type="button" value=":_('yes')"
onClick=":'triggerCalendarEvent(%s, %s, %s, %s)' % \
(q('del'), q(ajaxHookId), q(field.name), q(objUrl))"/>
<input type="button" value=":_('no')"
onclick=":'closePopup(%s)' % q(popupId)"/>
</form>
</div>
</div>''')
<!-- Delete successive events ? -->
<div class="discreet" style="margin-bottom: 10px"
id=":prefix + 'DelNextEvent'">
<input type="checkbox" name="deleteNext_cb"
id=":prefix + '_cb'"
onClick=":'toggleCheckbox(%s, %s)' % \
(q('%s_cb' % prefix), q('%s_hd' % prefix))"/>
<input type="hidden" id=":prefix + '_hd'" name="deleteNext"/>
<span>:_('del_next_events')"></span>
</div>
<input type="button" value=":_('yes')"
onClick=":'triggerCalendarEvent(%s, %s, %s, %s)' % \
(q('del'), q(ajaxHookId), q(field.name), q(objUrl))"/>
<input type="button" value=":_('no')"
onclick=":'closePopup(%s)' % q(popupId)"/>
</form>
</div>
</div>''')
pxView = pxCell = Px('''
<x var="defaultDate=field.getDefaultDate(contextObj);
x=req.set('fieldName', field.name);
x=req.set('month', defaultDate.strftime('%Y/%m'))">
<x>:field.pxMonthView</x>
</x>''')
x=req.set('month', defaultDate.strftime('%Y/%m'));
x=req.set('fieldName', field.name)">:field.pxMonthView</x>''')
pxEdit = pxSearch = ''

View file

@ -28,27 +28,23 @@ class Computed(Field):
value=contextObj.getFieldValue(name);
sync=True">:field.pxView</x>''')
pxView = pxCell = pxEdit = Px('''
<x>
<x if="sync">
<x if="field.plainText">:value</x>
<x if="not field.plainText">::value></x>
</x>
<x if="not sync">
<div var="ajaxHookId=contextObj.UID() + name" id="ajaxHookId">
<script type="text/javascript">:'askComputedField(%s, %s, %s)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), q(name))">
</script>
</div>
</x>
</x>''')
pxView = pxCell = pxEdit = Px('''<x>
<x if="sync">
<x if="field.plainText">:value</x><x if="not field.plainText">::value></x>
</x>
<div if="not sync">
var2="ajaxHookId=contextObj.UID() + name" id="ajaxHookId">
<script type="text/javascript">:'askComputedField(%s, %s, %s)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), q(name))">
</script>
</div>
</x>''')
pxSearch = Px('''
<x>
<label lfor=":name">:field.labelId</label><br/>&nbsp;&nbsp;
<input type="text" name=":'%s*string' % name" maxlength=":field.maxChars"
size=":field.width" value=":field.sdefault"/>
</x>''')
pxSearch = Px('''<x>
<label lfor=":name">:field.labelId</label><br/>&nbsp;&nbsp;
<input type="text" name=":'%s*string' % name" maxlength=":field.maxChars"
size=":field.width" value=":field.sdefault"/>
</x>''')
def __init__(self, validator=None, multiplicity=(0,1), default=None,
show='view', page='main', group=None, layouts=None, move=0,

View file

@ -29,20 +29,20 @@ class Date(Field):
<select var="days=range(1,32)"
name=":'%s_day' % name" id=":'%s_day' % name">
<option value="">-</option>
<x for="day in days">
<option var="zDay=str(day).zfill(2)" value=":zDay"
selected="field.isSelected(contextObj, 'day', day, \
rawValue)">:zDay</option></x>
<option for="day in days"
var2="zDay=str(day).zfill(2)" value=":zDay"
selected="field.isSelected(contextObj, 'day', day, \
rawValue)">:zDay</option>
</select>
<!-- Month -->
<select var="months=range(1,13)"
name=":'%s_month' % name" id=":'%s_month' % name">
<option value="">-</option>
<x for="month in months">
<option var="zMonth=str(month).zfill(2)" value=":zMonth"
selected="field.isSelected(contextObj, 'month', month, \
rawValue)">:zMonth</option></x>
<option for="month in months"
var2="zMonth=str(month).zfill(2)" value=":zMonth"
selected="field.isSelected(contextObj, 'month', month, \
rawValue)">:zMonth</option>
</select>
<!-- Year -->
@ -56,7 +56,7 @@ class Date(Field):
<!-- The icon for displaying the calendar popup -->
<x if="field.calendar">
<input type="hidden" id=":name" name=":name"/>
<img id=":'%s_img' % name" src=":'%s/ui/calendar.gif' % appUrl"/>
<img id=":'%s_img' % name" src=":img('calendar.gif')"/>
<script type="text/javascript">:field.getJsInit(name, years)</script>
</x>
@ -65,19 +65,18 @@ class Date(Field):
<select var="hours=range(0,24)" name=":'%s_hour' % name"
id=":'%s_hour' % name">
<option value="">-</option>
<x for="hour in hours">
<option var="zHour=str(hour).zfill(2)" value=":zHour"
selected=":field.isSelected(contextObj, 'hour', hour, \
rawValue)">:zHour</option>
</x>
<option for="hour in hours"
var2="zHour=str(hour).zfill(2)" value=":zHour"
selected=":field.isSelected(contextObj, 'hour', hour, \
rawValue)">:zHour</option>
</select> :
<select var="minutes=range(0,60,5)" name=":'%s_minute' % name"
id=":'%s_minute' % name">
<option value="">-</option>
<x for="minute in minutes">
<option var="zMinute=str(minute).zfill(2)" value=":zMinute"
selected=":field.isSelected(contextObj, 'minute', minute,\
rawValue)">:zMinute</option></x>
<option for="minute in minutes"
var2="zMinute=str(minute).zfill(2)" value=":zMinute"
selected=":field.isSelected(contextObj, 'minute', minute,\
rawValue)">:zMinute</option>
</select>
</x>
</x>''')
@ -112,7 +111,7 @@ class Date(Field):
<!-- The icon for displaying the calendar popup -->
<x if="field.calendar">
<input type="hidden" id=":fromName" name=":fromName"/>
<img id=":'%s_img' % fromName" src=":'%s/ui/calendar.gif' % appUrl"/>
<img id=":'%s_img' % fromName" src=":img('calendar.gif')"/>
<script type="text/javascript">:field.getJsInit(fromName, years)
</script>
</x>
@ -145,7 +144,7 @@ class Date(Field):
<!-- The icon for displaying the calendar popup -->
<x if="widget.calendar">
<input type="hidden" id=":toName" name=":toName"/>
<img id=":'%s_img' % toName" src=":%s/ui/calendar.gif' % appUrl"/>
<img id=":'%s_img' % toName" src=":img('calendar.gif')"/>
<script type="text/javascript">:field.getJsInit(toName, years)">
</script>
</x>

View file

@ -31,26 +31,25 @@ class Float(Field):
</x>''')
pxEdit = Px('''
<input id=":name" name=":name" size=":field.width"
maxlength=":field.maxChars"
value=":inRequest and requestValue or value" type="text"/>''')
<input id=":name" name=":name" size=":field.width"
maxlength=":field.maxChars"
value=":inRequest and requestValue or value" type="text"/>''')
pxSearch = Px('''
<x>
<label>:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- From -->
<x var="fromName='%s*float' % widgetName">
<label lfor=":fromName">:_('search_from')"></label>
<input type="text" name=":fromName" maxlength=":field.maxChars"
value=":field.sdefault[0]" size=":field.swidth"/>
</x>
<!-- To -->
<x var="toName='%s_to' % name">
<label lfor=":toName">:_('search_to')</label>
<input type="text" name=":toName" maxlength=":field.maxChars"
value=":field.sdefault[1]" size="field.swidth"/>
</x><br/>
</x>''')
pxSearch = Px('''<x>
<label>:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- From -->
<x var="fromName='%s*float' % widgetName">
<label lfor=":fromName">:_('search_from')"></label>
<input type="text" name=":fromName" maxlength=":field.maxChars"
value=":field.sdefault[0]" size=":field.swidth"/>
</x>
<!-- To -->
<x var="toName='%s_to' % name">
<label lfor=":toName">:_('search_to')</label>
<input type="text" name=":toName" maxlength=":field.maxChars"
value=":field.sdefault[1]" size="field.swidth"/>
</x><br/>
</x>''')
def __init__(self, validator=None, multiplicity=(0,1), default=None,
show=True, page='main', group=None, layouts=None, move=0,

View file

@ -32,22 +32,21 @@ class Integer(Field):
maxlength=":field.maxChars"
value=":inRequest and requestValue or value" type="text"/>''')
pxSearch = Px('''
<x>
<label>:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- From -->
<x var="fromName='%s*int' % widgetName">
<label lfor=":fromName">:_('search_from')</label>
<input type="text" name=":fromName" maxlength=":field.maxChars"
value=":field.sdefault[0]" size=":field.swidth"/>
</x>
<!-- To -->
<x var="toName='%s_to' % name">
<label lfor=":toName">:_('search_to')"></label>
<input type="text" name=":toName" maxlength=":field.maxChars"
value=":field.sdefault[1]" size=":field.swidth"/>
</x><br/>
</x>''')
pxSearch = Px('''<x>
<label>:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- From -->
<x var="fromName='%s*int' % widgetName">
<label lfor=":fromName">:_('search_from')</label>
<input type="text" name=":fromName" maxlength=":field.maxChars"
value=":field.sdefault[0]" size=":field.swidth"/>
</x>
<!-- To -->
<x var="toName='%s_to' % name">
<label lfor=":toName">:_('search_to')"></label>
<input type="text" name=":toName" maxlength=":field.maxChars"
value=":field.sdefault[1]" size=":field.swidth"/>
</x><br/>
</x>''')
def __init__(self, validator=None, multiplicity=(0,1), default=None,
show=True, page='main', group=None, layouts=None, move=0,

View file

@ -27,15 +27,14 @@ class List(Field):
# PX for rendering a single row.
pxRow = Px('''
<tr valign="top" style="(rowIndex==-1) and 'display: none' or ''">
<td align="center" for="info in field.fields">
<x var="field=info[1];
tagCss='noStyle';
widgetName='%s*%d' % (field.name, rowIndex)">:field.pxView</x>
</td>
<td align="center" for="info in field.fields"
var2="field=info[1];
tagCss='noStyle';
widgetName='%s*%d' % (field.name, rowIndex)">:field.pxView</td>
<!-- Icon for removing the row -->
<td if="layoutType=='edit'" align=":dright">
<img style="cursor:pointer" src=":'%s/ui/delete.png' % appUrl"
title="Delete"
<img style="cursor:pointer" src=":img(delete')"
title=":_('object_delete')"
onclick=":'deleteRow(%s, this)' % q('list_%s' % name)"/>
</td>
</tr>''')
@ -49,8 +48,7 @@ class List(Field):
<th for="info in field.fields">::_(info[1].labelId)</th>
<!-- Icon for adding a new row. -->
<th if="isEdit">
<img style="cursor:pointer" src=":'%s/ui/plus.png' % appUrl"
title=":_('add_ref')"
<img style="cursor:pointer" src=":img('plus')" title=":_('add_ref')"
onclick=":'insertRow(%s)' % q('list_%s' % name)"/>
</th>
</tr>
@ -60,17 +58,15 @@ class List(Field):
<tr height="7px" if="isEdit"><td></td></tr>
<!-- Rows of data -->
<x var="rows=inRequest and requestValue or value" for="row in rows">
<x var="rowIndex=loop.row.nb">:field.pxRow</x>
</x>
<x var="rows=inRequest and requestValue or value"
for="row in rows" var2="rowIndex=loop.row.nb">:field.pxRow</x>
</table>''')
pxView = pxCell = Px('''<x>:field.pxTable</x>''')
pxEdit = Px('''
<x>
<!-- This input makes Appy aware that this field is in the request -->
<input type="hidden" name=":name" value=""/><x>:field.pxTable</x>
</x>''')
pxEdit = Px('''<x>
<!-- This input makes Appy aware that this field is in the request -->
<input type="hidden" name=":name" value=""/><x>:field.pxTable</x>
</x>''')
pxSearch = ''

View file

@ -30,21 +30,18 @@ class Ogone(Field):
'''This field allows to perform payments with the Ogone (r) system.'''
urlTypes = ('accept', 'decline', 'exception', 'cancel')
pxView = pxCell = Px('''
<x>
<!-- var "value" is misused and contains the contact params for Ogone -->
<!-- The form for sending the payment request to Ogone -->
<form method="post" id="form1" name="form1" var="env=value['env']"
action=":'https://secure.ogone.com/ncol/%s/orderstandard.asp'% env">
<x for="item in value.items()">
<input type="hidden" if="item[0] != 'env'" id=":item[0]"
name=":item[0]" value=":item[1]"/>
</x>
<!-- Submit image -->
<input type="image" id="submit2" name="submit2"
src=":'%s/ui/ogone.gif' % $appUrl" title=":_('custom_pay')"/>
</form>
</x>''')
pxView = pxCell = Px('''<x>
<!-- var "value" is misused and contains the contact params for Ogone -->
<!-- The form for sending the payment request to Ogone -->
<form method="post" id="form1" name="form1" var="env=value['env']"
action=":'https://secure.ogone.com/ncol/%s/orderstandard.asp'% env">
<input type="hidden" for="item in value.items()" if="item[0] != 'env'"
id=":item[0]" name=":item[0]" value=":item[1]"/>
<!-- Submit image -->
<input type="image" id="submit2" name="submit2" src=":img('ogone.gif')"
title=":_('custom_pay')"/>
</form>
</x>''')
pxEdit = pxSearch = ''

View file

@ -35,23 +35,19 @@ class Pod(Field):
'contact the system administrator.'
DELETE_TEMP_DOC_ERROR = 'A temporary document could not be removed. %s.'
pxView = pxCell = Px('''
<x>
<!-- Ask action -->
<x if="field.askAction">
<x var="doLabel='%s_askaction' % field.labelId;
chekboxId='%s_%s_cb' % (contextObj.UID(), name)">
<input type="checkbox" name=":doLabel" id=":chekboxId"/>
<label lfor=":chekboxId" class="discreet">:_(doLabel)"></label>
</x>
</x>
<img for="podFormat in field.getToolInfo(contextObj.appy())[1]"
src=":'%s/ui/%s.png' % (appUrl, podFormat)"
onclick=":'generatePodDocument(%s, %s, %s, %s)' % \
(q(contextObj.UID()), q(name), q(podFormat), \
q(ztool.getQueryInfo()))"
title=":podFormat.capitalize()" style="cursor:pointer"/>
</x>''')
pxView = pxCell = Px('''<x>
<!-- Ask action -->
<x if="field.askAction"
var2="doLabel='%s_askaction' % field.labelId;
chekboxId='%s_%s_cb' % (contextObj.UID(), name)">
<input type="checkbox" name=":doLabel" id=":chekboxId"/>
<label lfor=":chekboxId" class="discreet">:_(doLabel)"></label>
</x>
<img for="fmt in field.getToolInfo(contextObj.appy())[1]" src=":img(fmt)"
onclick=":'generatePodDocument(%s, %s, %s, %s)' % \
(q(contextObj.UID()), q(name), q(fmt), q(ztool.getQueryInfo()))"
title=":fmt.capitalize()" style="cursor:pointer"/>
</x>''')
pxEdit = pxSearch = ''

View file

@ -56,41 +56,37 @@ class Ref(Field):
<table class="noStyle" var="isBack=field.isBack">
<tr>
<!-- Arrows for moving objects up or down -->
<td if="not isBack and (len(objs)&gt;1) and changeOrder and canWrite">
<x var="objectIndex=field.getIndexOf(contextObj, obj);
<td if="not isBack and (len(objs)&gt;1) and changeOrder and canWrite"
var2="objectIndex=field.getIndexOf(contextObj, obj);
ajaxBaseCall=navBaseCall.replace('**v**','%s,%s,{%s:%s,%s:%s}'%\
(q(startNumber), q('ChangeRefOrder'), q('refObjectUid'),
q(obj.UID()), q('move'), q('**v**')))">
<img if="objectIndex &gt; 0" style="cursor:pointer"
src=":'%s/ui/arrowUp.png' % appUrl" title=":_('move_up')"
onclick=":ajaxBaseCall.replace('**v**', 'up')"/><img
style="cursor:pointer" if="objectIndex &lt; (totalNumber-1)"
src=":'%s/ui/arrowDown.png' % appUrl" title=":_('move_down')"
src=":img('arrowUp')" title=":_('move_up')"
onclick=":ajaxBaseCall.replace('**v**', 'up')"/>
<img if="objectIndex &lt; (totalNumber-1)" style="cursor:pointer"
src=":img('arrowDown')" title=":_('move_down')"
onclick=":ajaxBaseCall.replace('**v**', 'down')"/>
</x>
</td>
<!-- Workflow transitions -->
<td if="obj.showTransitions('result')">
<x var="targetObj=obj">:targetObj.appy().pxTransitions</x>
</td>
<td if="obj.showTransitions('result')"
var2="targetObj=obj">:targetObj.appy().pxTransitions</td>
<!-- Edit -->
<td if="not field.noForm and obj.mayEdit() and field.delete">
<a var="navInfo='ref.%s.%s:%s.%d.%d' % (contextObj.UID(), field.name, \
field.pageName, loop.obj.nb + startNumber, totalNumber)"
href=":obj.getUrl(mode='edit', page='main', nav=navInfo)">
<img src=":'%s/ui/edit.png' % appUrl" title=":_('object_edit')"/>
</a>
<img src=":img('edit')" title=":_('object_edit')"/></a>
</td>
<!-- Delete -->
<td if="not isBack and field.delete and canWrite and obj.mayDelete()">
<img style="cursor:pointer" title=":_('object_delete')"
src=":'%s/ui/delete.png' % appUrl"
onclick=":'onDeleteObject(%s)' % q(obj.UID())"/>
src=":img('delete')" onclick=":'onDeleteObject(%s)'%q(obj.UID())"/>
</td>
<!-- Unlink -->
<td if="not isBack and field.unlink and canWrite">
<img style="cursor:pointer" title=":_('object_unlink')"
src=":'%s/ui/unlink.png' % appUrl"
src=":img('unlink')"
onclick=":'onUnlinkObject(%s,%s,%s)' % (q(contextObj.UID()), \
q(field.name), q(obj.UID()))"/>
</td>
@ -100,37 +96,34 @@ class Ref(Field):
# Displays the button allowing to add a new object through a Ref field, if
# it has been declared as addable and if multiplicities allow it.
pxAdd = Px('''
<x if="showPlusIcon">
<input type="button" class="button"
var="navInfo='ref.%s.%s:%s.%d.%d' % (contextObj.UID(), \
field.name, field.pageName, 0, totalNumber);
formCall='window.location=%s' % \
q('%s/do?action=Create&amp;className=%s&amp;nav=%s' % \
(folder.absolute_url(), linkedPortalType, navInfo));
formCall=not field.addConfirm and formCall or \
'askConfirm(%s,%s,%s)' % (q('script'), q(formCall), \
q(addConfirmMsg));
noFormCall=navBaseCall.replace('**v**', \
'%d,%s' % (startNumber, q('CreateWithoutForm')));
noFormCall=not field.addConfirm and noFormCall or \
'askConfirm(%s, %s, %s)' % (q('script'), q(noFormCall), \
q(addConfirmMsg))"
style=":'background-image: url(%s/ui/buttonAdd.png)' % appUrl"
value=":_('add_ref')"
onclick=":field.noForm and noFormCall or formCall"/>
</x>''')
<input if="showPlusIcon" type="button" class="button"
var2="navInfo='ref.%s.%s:%s.%d.%d' % (contextObj.UID(), \
field.name, field.pageName, 0, totalNumber);
formCall='window.location=%s' % \
q('%s/do?action=Create&amp;className=%s&amp;nav=%s' % \
(folder.absolute_url(), linkedPortalType, navInfo));
formCall=not field.addConfirm and formCall or \
'askConfirm(%s,%s,%s)' % (q('script'), q(formCall), \
q(addConfirmMsg));
noFormCall=navBaseCall.replace('**v**', \
'%d,%s' % (startNumber, q('CreateWithoutForm')));
noFormCall=not field.addConfirm and noFormCall or \
'askConfirm(%s, %s, %s)' % (q('script'), q(noFormCall), \
q(addConfirmMsg))"
style=":img('buttonAdd', bg=True)" value=":_('add_ref')"
onclick=":field.noForm and noFormCall or formCall"/>''')
# This PX displays, in a cell header from a ref table, icons for sorting the
# ref field according to the field that corresponds to this column.
pxSortIcons = Px('''
<x var="ajaxBaseCall=navBaseCall.replace('**v**', '%s,%s,{%s:%s,%s:%s}' % \
<x if="changeOrder and canWrite and ztool.isSortable(field.name, \
objs[0].meta_type, 'ref')"
var2="ajaxBaseCall=navBaseCall.replace('**v**', '%s,%s,{%s:%s,%s:%s}'% \
(q(startNumber), q('SortReference'), q('sortKey'), \
q(field.name), q('reverse'), q('**v**')))"
if="changeOrder and canWrite and ztool.isSortable(field.name, \
objs[0].meta_type, 'ref')">
<img style="cursor:pointer" src=":'%s/ui/sortAsc.png' % appUrl"
q(field.name), q('reverse'), q('**v**')))">
<img style="cursor:pointer" src=":img('sortAsc')"
onclick=":ajaxBaseCall.replace('**v**', 'False')"/>
<img style="cursor:pointer" src=":'%s/ui/sortDesc.png' % appUrl"
<img style="cursor:pointer" src=":img('sortDesc')"
onclick=":ajaxBaseCall.replace('**v**', 'True')"/>
</x>''')
@ -165,25 +158,21 @@ class Ref(Field):
shouldn't check the actual number of referenced objects. But for
back references people often forget to specify multiplicities. So
concretely, multiplicities (0,None) are coded as (0,1). -->
<x if="atMostOneRef">
<!-- Display a simplified widget if maximum number of referenced objects
is 1. -->
<table>
<tr valign="top">
<!-- If there is no object -->
<x if="not objs">
<td class="discreet">:_('no_ref')</td>
<td>:field.pxAdd</td>
</x>
<!-- If there is an object... -->
<x if="objs">
<x for="obj in objs">
<td var="includeShownInfo=True">:field.pxObjectTitle</td>
</x>
</x>
</tr>
</table>
</x>
<!-- Display a simplified widget if at most 1 referenced object. -->
<table if="atMostOneRef">
<tr valign="top">
<!-- If there is no object -->
<x if="not objs">
<td class="discreet">:_('no_ref')</td>
<td>:field.pxAdd</td>
</x>
<!-- If there is an object... -->
<x if="objs">
<td for="obj in objs"
var2="includeShownInfo=True">:field.pxObjectTitle</td>
</x>
</tr>
</table>
<!-- Display a table in all other cases -->
<x if="not atMostOneRef">
@ -192,8 +181,7 @@ class Ref(Field):
<x>:field.pxAdd</x>
<!-- The search button if field is queryable -->
<input if="objs and field.queryable" type="button" class="button"
style=":'background-image: url(%s/ui/buttonSearch.png)' % appUrl"
value=":_('search_title')"
style=":img('buttonSearch', bg=True)" value=":_('search_title')"
onclick=":'window.location=%s' % \
q('%s/ui/search?className=%s&amp;ref=%s:%s' % \
(ztool.absolute_url(), linkedPortalType, contextObj.UID(), \
@ -207,7 +195,7 @@ class Ref(Field):
<p class="discreet" if="not objs">:_('no_ref')</p>
<table if="objs" class=":innerRef and 'innerAppyTable' or ''"
width="100%">
width="100%">
<tr valign="bottom">
<td>
<!-- Show forward or backward reference(s) -->
@ -216,39 +204,32 @@ class Ref(Field):
var="columns=objs[0].getColumnsSpecifiers(field.shownInfo, dir)">
<tr if="field.showHeaders">
<th for="column in columns" width=":column['width']"
align="column['align']">
<x var="field=column['field']">
<span>_(field.labelId)</span>
<x>:field.pxSortIcons</x>
<x var="className=linkedPortalType">:contextObj.appy(\
).pxShowDetails</x>
</x>
align="column['align']"
var2="field=column['field']">
<span>:_(field.labelId)</span>
<x>:field.pxSortIcons</x>
<x var="className=linkedPortalType">:contextObj.appy(\
).pxShowDetails</x>
</th>
</tr>
<x for="obj in objs">
<tr valign="top" var="odd=loop.obj.odd"
class=":odd and 'even' or 'odd'">
<td for="column in columns"
width=":column['width']" align=":column['align']">
<x var="field=column['field']">
<!-- The "title" field -->
<x if="python: field.name == 'title'">
<x>:field.pxObjectTitle</x>
<div if="obj.mayAct()">:field.pxObjectActions</div>
</x>
<!-- Any other field -->
<x if="field.name != 'title'">
<x var="contextObj=obj;
layoutType='cell';
innerRef=True"
if="obj.showField(field.name, layoutType='result')">
<!-- use-macro="app/ui/widgets/show/macros/field"/-->
</x>
</x>
</x>
</td>
</tr>
</x>
<tr for="obj in objs" var2="odd=loop.obj.odd" valign="top"
class=":odd and 'even' or 'odd'">
<td for="column in columns"
width=":column['width']" align=":column['align']"
var2="field=column['field']">
<!-- The "title" field -->
<x if="python: field.name == 'title'">
<x>:field.pxObjectTitle</x>
<div if="obj.mayAct()">:field.pxObjectActions</div>
</x>
<!-- Any other field -->
<x if="field.name != 'title'">
<x var="contextObj=obj; layoutType='cell'; innerRef=True"
if="obj.showField(field.name, \
layoutType='result')">:field.pxView</x>
</x>
</td>
</tr>
</table>
</td>
</tr>
@ -263,49 +244,42 @@ class Ref(Field):
<x var="x=req.set('fieldName', field.name)">:field.pxViewContent</x>''')
pxEdit = Px('''
<x if="field.link"
var="requestValue=req.get(name, []);
inRequest=req.has_key(name);
allObjects=field.getSelectableObjects();
uids=[o.UID() for o in field.getLinkedObjects(contextObj).objects];
isBeingCreated=contextObj.isTemporary()">
<select name=":name" size="isMultiple and field.height or ''"
multiple="isMultiple and 'multiple' or ''">
<option value="" if="not isMultiple">:_('choose_a_value')"></option>
<x for="refObj in allObjects">
<option var="uid=refObj.o.UID()"
selected=":inRequest and (uid in requestValue) or \
(uid in uids)"
value=":uid">:field.getReferenceLabel(refObj)</option>
</x>
</select>
</x>''')
<select if="field.link"
var2="requestValue=req.get(name, []);
inRequest=req.has_key(name);
allObjects=field.getSelectableObjects();
uids=[o.UID() for o in \
field.getLinkedObjects(contextObj).objects];
isBeingCreated=contextObj.isTemporary()"
name=":name" size="isMultiple and field.height or ''"
multiple="isMultiple and 'multiple' or ''">
<option value="" if="not isMultiple">:_('choose_a_value')"></option>
<option for="refObj in allObjects" var2="uid=refObj.o.UID()"
selected=":inRequest and (uid in requestValue) or \
(uid in uids)"
value=":uid">:field.getReferenceLabel(refObj)</option>
</select>''')
pxSearch = Px('''
<x>
<label lfor=":widgetName">:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- The "and" / "or" radio buttons -->
<x var="operName='o_%s' % name;
pxSearch = Px('''<x>
<label lfor=":widgetName">:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- The "and" / "or" radio buttons -->
<x if="field.multiplicity[1] != 1"
var2="operName='o_%s' % name;
orName='%s_or' % operName;
andName='%s_and' % operName"
if="field.multiplicity[1] != 1">
<input type="radio" name=":operName" id=":orName"
checked="checked" value="or"/>
<label lfor=":orName">:_('search_or')"></label>
<input type="radio" name=":operName" id=":andName" value="and"/>
<label lfor=":andName">:_('search_and')"></label><br/>
</x>
<!-- The list of values -->
<select name=":widgetName" size=":field.sheight" multiple="multiple">
<x for="v in ztool.getSearchValues(name, className)">
<option var="uid=v[0];
title=field.getReferenceLabel(v[1])"
value=":uid"
title=":title">:ztool.truncateValue(title, field.swidth)">
</option>
</x>
</select>
</x>''')
andName='%s_and' % operName">
<input type="radio" name=":operName" id=":orName" checked="checked"
value="or"/>
<label lfor=":orName">:_('search_or')"></label>
<input type="radio" name=":operName" id=":andName" value="and"/>
<label lfor=":andName">:_('search_and')"></label><br/>
</x>
<!-- The list of values -->
<select name=":widgetName" size=":field.sheight" multiple="multiple">
<option for="v in ztool.getSearchValues(name, className)"
var2="uid=v[0]; title=field.getReferenceLabel(v[1])" value=":uid"
title=":title">:ztool.truncateValue(title,field.swidth)"></option>
</select>
</x>''')
def __init__(self, klass=None, attribute=None, validator=None,
multiplicity=(0,1), default=None, add=False, addConfirm=False,

View file

@ -108,29 +108,28 @@ class String(Field):
isSelect=field.isSelect;
isMaster=field.slaves;
isOneLine=fmt in (0,3,4)">
<x if="isSelect">
<select var="possibleValues=field.getPossibleValues(contextObj, \
withTranslations=True, withBlankValue=True)"
name=":name" id=":name" class=":masterCss"
multiple=":isMultiple and 'multiple' or ''"
onchange=":isMaster and 'updateSlaves(this)' or ''"
size=":isMultiple and field.height or 1">
<option for="val in possibleValues" value=":val[0]"
selected=":field.isSelected(contextObj, val[0], rawValue)"
title=":val[1]">:ztool.truncateValue(val[1], field.width)">
</option>
</select>
</x>
<select if="isSelect"
var2="possibleValues=field.getPossibleValues(contextObj, \
withTranslations=True, withBlankValue=True)"
name=":name" id=":name" class=":masterCss"
multiple=":isMultiple and 'multiple' or ''"
onchange=":isMaster and 'updateSlaves(this)' or ''"
size=":isMultiple and field.height or 1">
<option for="val in possibleValues" value=":val[0]"
selected=":field.isSelected(contextObj, val[0], rawValue)"
title=":val[1]">:ztool.truncateValue(val[1], field.width)">
</option>
</select>
<x if="isOneLine and not isSelect">
<input id=":name" name=":name" size=":field.width"
maxlength=":field.maxChars"
value=":inRequest and requestValue or value"
style=":'text-transform:%s' % field.transform"
type=":(fmt == 3) and 'password' or 'text'"/>
<!-- Display a captcha if required -->
<span if="fmt == 4">:_('captcha_text', \
mapping=field.getCaptchaChallenge(req.SESSION))
</span>
<!-- Display a captcha if required -->
<span if="fmt == 4">:_('captcha_text', \
mapping=field.getCaptchaChallenge(req.SESSION))
</span>
</x>
<x if="fmt in (1,2)">
<textarea id=":name" name=":name" cols=":field.width"
@ -149,40 +148,37 @@ class String(Field):
<x if="not multipleValues">:field.pxView</x>
</x>''')
pxSearch = Px('''
<x>
<label lfor="widgetName">:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- Show a simple search field for most String fields -->
<x if="not field.isSelect">
<input type="text" maxlength=":field.maxChars" size=":field.swidth"
name=":'%s*string-%s' % (widgetName, field.transform)"
style=":'text-transform:%s' % field.transform"
value=":field.sdefault"/>
pxSearch = Px('''<x>
<label lfor="widgetName">:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- Show a simple search field for most String fields -->
<input if="not field.isSelect" type="text" maxlength=":field.maxChars"
size=":field.swidth" value=":field.sdefault"
name=":'%s*string-%s' % (widgetName, field.transform)"
style=":'text-transform:%s' % field.transform"/>
<!-- Show a multi-selection box for fields whose validator defines a list
of values, with a "AND/OR" checkbox. -->
<x if="field.isSelect">
<!-- The "and" / "or" radio buttons -->
<x if="field.multiplicity[1] != 1"
var2="operName='o_%s' % name;
orName='%s_or' % operName;
andName='%s_and' % operName">
<input type="radio" name=":operName" id=":orName" checked="checked"
value="or"/>
<label lfor=":orName">:_('search_or')</label>
<input type="radio" name=":operName" id=":andName" value="and"/>
<label lfor=":andName">:_('search_and')"></label><br/>
</x>
<!-- Show a multi-selection box for fields whose validator defines a list
of values, with a "AND/OR" checkbox. -->
<x if="field.isSelect">
<!-- The "and" / "or" radio buttons -->
<x var="operName='o_%s' % name;
orName='%s_or' % operName;
andName='%s_and' % operName"
if="field.multiplicity[1] != 1">
<input type="radio" name=":operName" id=":orName" checked="checked"
value="or"/>
<label lfor=":orName">:_('search_or')</label>
<input type="radio" name=":operName" id=":andName" value="and"/>
<label lfor=":andName">:_('search_and')"></label><br/>
</x>
<!-- The list of values -->
<select var="preSelected=field.sdefault"
name=":widgetName" size=":field.sheight" multiple="multiple">
<option for="v in field.getPossibleValues(ztool, withTranslations=True,\
<!-- The list of values -->
<select var="preSelected=field.sdefault"
name=":widgetName" size=":field.sheight" multiple="multiple">
<option for="v in field.getPossibleValues(ztool, withTranslations=True,\
withBlankValue=False, className=className)"
selected=":v[0] in preSelected" value=":v[0]"
title=":v[1]">ztool.truncateValue(v[1], field.swidth)</option>
</select>
</x><br/>
</x>''')
selected=":v[0] in preSelected" value=":v[0]"
title=":v[1]">ztool.truncateValue(v[1], field.swidth)</option>
</select>
</x><br/>
</x>''')
# Some predefined functions that may also be used as validators
@staticmethod

View file

@ -105,6 +105,17 @@ class ToolMixin(BaseMixin):
podField = self.getAppyType(name, className=obj.meta_type)
return podField.getToolInfo(obj.appy())
def getImageUrl(self, name, bg=False):
'''Gets the full URL of an image named p_name. If p_bg is False, the URL
is meant to be used as content for an img's "src" attribute. If p_bg
is True, the URL is meant to be used in a "style" attribute for
defining the background image of the current tag.'''
# If not extension is found in the image p_name, suppose it is a png.
if '.' not in name: name += '.png'
url = '%s/ui/%s' % (self.getPhysicalRoot(),absolute_url(), name)
if not bg: return url
return 'background-image: url(%s)' % url
def generateDocument(self):
'''Generates the document from field-related info. UID of object that
is the template target is given in the request.'''

View file

@ -64,38 +64,34 @@ class GroupDescr(Descr):
sharing the same appy.gen.Group instance, that some logged user can
see.'''
# PX that renders a group of fields
pxGroupedFields = Px('''<p>pxGroupedFields</p>''')
pxView = Px('''<p>pxGroupedFields</p>''')
# PX that renders a group of fields
pxGroupedSearches = Px('''
<x var="expanded=req.get(widget['labelId'], 'collapsed') == 'expanded'">
# PX that renders a group of searches
pxViewSearches = Px('''
<x var="expanded=req.get(field.labelId, 'collapsed') == 'expanded'">
<!-- Group name, prefixed by the expand/collapse icon -->
<div class="portletGroup">
<img style="cursor:pointer; margin-right: 3px" align=":dleft"
id=":'%s_img' % widget['labelId']"
src=":expanded and 'ui/collapse.gif' or 'ui/expand.gif'"
onclick=":'toggleCookie(&quot;%s&quot;)' % widget['labelId']"/>
<x if="not widget['translated']">:_(widget['labelId'])</x>
<x if="widget['translated']">:widget['translated']</x>
id=":'%s_img' % field.labelId"
src=":expanded and img('collapse.gif') or img('expand.gif')"
onclick=":'toggleCookie(%s)' % q(field.labelId)"/>
<x if="not field.translated">:_(field.labelId)</x>
<x if="field.translated">:field.translated</x>
</div>
<!-- Group content -->
<div var="display=expanded and 'display:block' or 'display:none'"
id=":widget['labelId']" style=":'padding-left: 10px; %s' % display">
<x for="searches in widget['widgets']">
<x for="searchElem in searches">
id=":field.labelId" style=":'padding-left: 10px; %s' % display">
<x for="searches in field.widgets">
<x for="elem in searches">
<!-- An inner group within this group -->
<x if="searchElem['type'] == 'group'">
<x var="widget=searchElem">:widget['px']</x>
</x>
<x if="elem['type'] == 'group'"
var2="field=elem">:field.pxViewSearches</x>
<!-- A search -->
<x if="searchElem['type'] != 'group'">
<x var="search=searchElem">:search['px']</x>
</x>
<x if="elem['type'] != 'group'" var2="search=elem">:search.pxView</x>
</x>
</x>
</div>
</x>
''')
</x>''')
def __init__(self, group, page, metaType, forSearch=False):
self.type = 'group'
@ -125,7 +121,7 @@ class GroupDescr(Descr):
# they will be rendered as a table.
self.widgets = [[]]
# PX to user for rendering this group.
self.px = forSearch and self.pxGroupedSearches or self.pxGroupedFields
self.px = forSearch and self.pxViewSearches or self.pxView
@staticmethod
def addWidget(groupDict, newWidget):
@ -178,20 +174,19 @@ class PhaseDescr(Descr):
editable=mayEdit and phase['pagesInfo'][aPage]['showOnEdit']">
<a if="editable and not locked"
href="contextObj.getUrl(mode='edit', page=aPage)">
<img src=":'%s/ui/edit.png' % appUrl" title=":_('object_edit')"/>
</a>
<img src=":img('edit')" title=":_('object_edit')"/></a>
<a if="editable and locked">
<img style="cursor: help"
var="lockDate=tool.formatDate(locked[1]);
lockMap={'user':ztool.getUserName(locked[0]), \
'date':lockDate};
lockMsg=_('page_locked', mapping=lockMap)"
src=":'%s/ui/locked.png' % appUrl" title=":lockMsg"/></a>
src=":img('locked')" title=":lockMsg"/></a>
<a if="editable and locked and user.has_role('Manager')">
<img style="cursor: pointer" title=":_('page_unlock')"
src=":'%s/ui/unlock.png' % appUrl"
onclick=":'onUnlockPage(&quot;%s&quot;,&quot;%s&quot;)' % \
(contextObj.UID(), aPage)"/></a>
src=":img('unlock')"
onclick=":'onUnlockPage(%s,%s)' % \
(q(contextObj.UID()), q(aPage))"/></a>
</x>
</div>
<!-- Next lines: links -->
@ -202,8 +197,7 @@ class PhaseDescr(Descr):
</x>
</x>
</td>
</tr>
''')
</tr>''')
def __init__(self, name, obj):
self.name = name
@ -266,14 +260,13 @@ class PhaseDescr(Descr):
class SearchDescr(Descr):
'''Describes a Search.'''
# PX for rendering a search.
pxSearch = Px('''
pxView = Px('''
<div class="portletSearch">
<a href=":'%s?className=%s&amp;search=%s' % \
(queryUrl, rootClass, search['name'])"
class=":search['name'] == currentSearch and 'portletCurrent' or ''"
title=":search['translatedDescr']">:search['translated']</a>
</div>
''')
</div>''')
def __init__(self, search, className, tool):
self.search = search

View file

@ -29,75 +29,63 @@ class ToolWrapper(AbstractWrapper):
</table>''', template=AbstractWrapper.pxTemplate, hook='content')
# Show on query list or grid, the field content for a given object.
pxQueryField = Px('''
<x><!-- Title -->
<x if="widget['name'] == 'title'">
<x var="navInfo='search.%s.%s.%d.%d' % (className, searchName, \
startNumber+currentNumber, \
totalNumber);
cssClass=obj.getCssFor('title')">
<x>::obj.getSupTitle(navInfo)</x>
<a href=":obj.getUrl(nav=navInfo, page=obj.getDefaultViewPage())"
if="enableLinks" class=":cssClass">:obj.Title()</a><span
if="not enableLinks" class=":cssClass">:obj.Title()</span><span
style=":showSubTitles and 'display:inline' or 'display:none'"
name="subTitle">::obj.getSubTitle()</span>
pxQueryField = Px('''<x>
<!-- Title -->
<x if="field.name == 'title'"
var2="navInfo='search.%s.%s.%d.%d' % \
(className, searchName, startNumber+currentNumber, totalNumber);
cssClass=obj.getCssFor('title')">
<x>::obj.getSupTitle(navInfo)</x>
<a href=":obj.getUrl(nav=navInfo, page=obj.getDefaultViewPage())"
if="enableLinks" class=":cssClass">:obj.Title()</a><span
if="not enableLinks" class=":cssClass">:obj.Title()</span><span
style=":showSubTitles and 'display:inline' or 'display:none'"
name="subTitle">::obj.getSubTitle()</span>
<!-- Actions: edit, delete -->
<div if="obj.mayAct()">
<a var="navInfo='search.%s.%s.%d.%d' % (className, searchName, \
loop.obj.nb+1+startNumber, \
totalNumber)"
if="obj.mayEdit()"
href=":obj.getUrl(mode='edit', page=obj.getDefaultEditPage(), \
nav=navInfo)">
<img src=":'%s/ui/edit.png' % appUrl"
title=":_('object_edit')"/></a><img
if="obj.mayDelete()" style="cursor:pointer"
src=":'%s/ui/delete.png' % appUrl"
title=":_('object_delete')"
onClick="'onDeleteObject(&quot;%s&quot;)' % obj.UID()"/>
</div>
</x>
</x>
<!-- Any other field -->
<x if="widget['name'] != 'title'">
<x var="contextObj=obj;
layoutType='cell';
innerRef=True"
if="contextObj.showField(widget['name'], 'result')">
<!-- metal:f use-macro="context/ui/widgets/show/macros/field"/-->
</x>
</x>
</x>''')
<!-- Actions: edit, delete -->
<div if="obj.mayAct()">
<a if="obj.mayEdit()"
var2="navInfo='search.%s.%s.%d.%d' % \
(className, searchName, loop.obj.nb+1+startNumber, totalNumber)"
href=":obj.getUrl(mode='edit', page=obj.getDefaultEditPage(), \
nav=navInfo)">
<img src=":img('edit')" title=":_('object_edit')"/></a>
<img if="obj.mayDelete()" style="cursor:pointer" src=":img('delete')"
title=":_('object_delete')"
onClick="'onDeleteObject(%s)' % q(obj.UID())"/>
</div>
</x>
<!-- Any other field -->
<x if="field.name != 'title'">
<x var="contextObj=obj; layoutType='cell'; innerRef=True"
if="contextObj.showField(field.name, 'result')">field.pxView</x>
</x>
</x>''')
# Show query results as a list.
pxQueryResultList = Px('''
<table class="list" width="100%">
<!-- Headers, with filters and sort arrows -->
<tr if="showHeaders">
<x for="column in columns">
<th var="widget=column['field'];
sortable=ztool.isSortable(widget['name'], className, 'search');
filterable=widget.get('filterable', None)"
width=":column['width']" align=":column['align']">
<x>::ztool.truncateText(_(widget['labelId']))</x>
<x>:self.pxSortAndFilter</x><x>:self.pxShowDetails</x>
</th>
</x>
<th for="column in columns"
var2="widget=column['field'];
sortable=ztool.isSortable(field.name, className, 'search');
filterable=widget.filterable"
width=":column['width']" align=":column['align']">
<x>::ztool.truncateText(_(field.labelId))</x>
<x>:self.pxSortAndFilter</x><x>:self.pxShowDetails</x>
</th>
</tr>
<!-- Results -->
<x for="obj in objs">
<tr var="odd=loop.obj.odd; currentNumber=currentNumber + 1"
id="query_row" valign="top" class=":odd and 'even' or 'odd'">
<x for="column in columns">
<td var="widget=column['field']" id=":'field_%s' % widget['name']"
width=":column['width']"
align=":column['align']">:self.pxQueryField</td>
</x>
</tr>
</x>
<tr for="obj in objs"
var2="odd=loop.obj.odd; currentNumber=currentNumber + 1"
id="query_row" valign="top" class=":odd and 'even' or 'odd'">
<td for="column in columns"
var2="widget=column['field']" id=":'field_%s' % field.name"
width=":column['width']"
align=":column['align']">:self.pxQueryField</td>
</tr>
</table>''')
# Show query results as a grid.
@ -110,9 +98,8 @@ class ToolWrapper(AbstractWrapper):
<td for="obj in row" width=":'%d%%' % (100/cols)" align="center"
style="padding-top: 25px">
<x var="currentNumber=currentNumber + 1"
for="column in columns">
<x var="widget = column['field']">:self.pxQueryField</x>
</x>
for="column in columns"
var2="widget = column['field']">:self.pxQueryField</x>
</td>
</tr>
</table>''')
@ -144,9 +131,9 @@ class ToolWrapper(AbstractWrapper):
totalNumber=queryResult['totalNumber'];
batchSize=queryResult['batchSize'];
ajaxHookId='queryResult';
navBaseCall='askQueryResult(&quot;%s&quot;,&quot;%s&quot;, \
&quot;%s&quot;, &quot;%s&quot;, **v**)' % (ajaxHookId, \
ztool.absolute_url(), className, searchName);
navBaseCall='askQueryResult(%s,%s,%s,%s,**v**)' % \
(q(ajaxHookId), q(ztool.absolute_url()), q(className), \
q(searchName));
newSearchUrl='%s/ui/search?className=%s%s' % \
(ztool.absolute_url(), className, refUrlPart);
showSubTitles=req.get('showSubTitles', 'true') == 'true';
@ -158,9 +145,7 @@ class ToolWrapper(AbstractWrapper):
layoutType='view'"
if="objs and widgets" align=":dright">
<tr>
<td var="contextObj=objs[0]" for="widget in widgets">
<!--use-macro="context/ui/widgets/show/macros/field"/>&nbsp;&nbsp;&nbsp;-->
</td>
<td var="contextObj=objs[0]" for="field in widgets">:field.pxView</td>
</tr>
</table>
@ -238,30 +223,25 @@ class ToolWrapper(AbstractWrapper):
<table width="100%">
<tr for="searchRow in ztool.getGroupedSearchFields(searchInfo)"
valign="top">
<x for="widget in searchRow">
<td var="scolspan=widget and widget['scolspan'] or 1"
colspan=":scolspan"
width=":'%d%%' % ((100/searchInfo['nbOfColumns'])*scolspan)">
<x if="widget">
<x var="name=widget['name'];
widgetName='w_%s' % name;
macroPage=widget['type'].lower()">
<!--metal:call use-macro="python: getattr(appFolder.ui.widgets, macroPage).macros['search']"/-->
</x>
</x><br class="discreet"/>
</td>
</x>
<td for="field in searchRow"
var2="scolspan=field and field.scolspan or 1"
colspan=":scolspan"
width=":'%d%%' % ((100/searchInfo['nbOfColumns'])*scolspan)">
<x if="field"
var2="name=field.name;
widgetName='w_%s' % name">field.pxSearch</x>
<br class="discreet"/>
</td>
</tr>
</table>
<!-- Submit button -->
<p align=":dright"><br/>
<input type="submit" class="button" value=":_('search_button')"
style=":'background-image: url(%s/ui/buttonSearch.png)'%appUrl"/>
style=":img('buttonSearch', bg=True)"/>
</p>
</form>
</x>
''', template=AbstractWrapper.pxTemplate, hook='content')
</x>''', template=AbstractWrapper.pxTemplate, hook='content')
pxImport = Px('''
<x var="className=req['className'];
@ -325,37 +305,35 @@ class ToolWrapper(AbstractWrapper):
<table class="list" width="100%">
<tr>
<th for="columnHeader in importElems[0]">
<img if="loop.columnHeader.nb == 0" src=":'%s/ui/eye.png' % appUrl"
<img if="loop.columnHeader.nb == 0" src=":img('eye')"
title="_('import_show_hide')" style="cursor:pointer"
onClick="toggleViewableElements()" align=":dleft" />
<x>:columnHeader</x>
</th>
<th></th>
<th width="20px"><img src=":'%s/ui/select_elems.png' % $appUrl"
title=":_('select_delesect')" onClick="toggleCheckboxes()"
style="cursor:pointer"/></th>
<th width="20px"><img src=":img('select_elems')" style="cursor:pointer"
title=":_('select_delesect')" onClick="toggleCheckboxes()"/></th>
</tr>
<x for="row in importElems[1]">
<tr var="alreadyImported=ztool.isAlreadyImported(className, row[0]);
<tr for="row in importElems[1]"
var2="alreadyImported=ztool.isAlreadyImported(className, row[0]);
allAreImported=allAreImported and alreadyImported;
odd=loop.row.odd"
id=":alreadyImported and 'importedElem' or 'notImportedElem'"
name=":alreadyImported and 'importedElem' or 'notImportedElem'"
style=":alreadyImported and 'display:none' or 'display:table-row'"
class=":odd and 'even' or 'odd'">
<td for="elem in row[1:]">:elem</td>
<td>
<input type="button" if="not alreadyImported"
onClick=":'importSingleElement(&quot;%s&quot;)' % row[0]"
value=":_('query_import')"/>
<x if="alreadyImported">:_('import_already')</x>
</td>
<td align="center">
<input if="not alreadyImported" type="checkbox" checked="checked"
id="cbElem" name="cbElem" value="row[0]" />
</td>
</tr>
</x>
id=":alreadyImported and 'importedElem' or 'notImportedElem'"
name=":alreadyImported and 'importedElem' or 'notImportedElem'"
style=":alreadyImported and 'display:none' or 'display:table-row'"
class=":odd and 'even' or 'odd'">
<td for="elem in row[1:]">:elem</td>
<td>
<input type="button" if="not alreadyImported"
onClick=":'importSingleElement(%s)' % q(row[0])"
value=":_('query_import')"/>
<x if="alreadyImported">:_('import_already')</x>
</td>
<td align="center">
<input if="not alreadyImported" type="checkbox" checked="checked"
id="cbElem" name="cbElem" value="row[0]"/>
</td>
</tr>
<tr if="not importElems[1] or allAreImported">
<td colspan="15">:_('query_no_result')</td></tr>
</table>

View file

@ -32,35 +32,30 @@ class AbstractWrapper(object):
# --------------------------------------------------------------------------
# Icon for hiding/showing details below the title.
pxShowDetails = Px('''
<x if="ztool.subTitleIsUsed(className)">
<img if="widget['name'] == 'title'" style="cursor:pointer"
src=":'%s/ui/toggleDetails.png'%appUrl" onClick="toggleSubTitles()"/>
</x>''')
<img if="ztool.subTitleIsUsed(className) and (field.name == 'title')"
style="cursor:pointer" src=":img('toggleDetails')"
onClick="toggleSubTitles()"/>''')
# Displays up/down arrows in a table header column for sorting a given
# column. Requires variables "sortable", 'filterable' and 'fieldName'.
pxSortAndFilter = Px('''
<x var="fieldName=widget['name']">
<x if="sortable">
<img if="(sortKey != fieldName) or (sortOrder == 'desc')"
onclick=":navBaseCall.replace('**v**', '0,&quot;%s&quot;, \
&quot;asc&quot;, &quot;%s&quot;' % (fieldName,filterKey))"
src=":'%s/ui/sortDown.gif' % appUrl" style="cursor:pointer"/>
<img if="(sortKey != fieldName) or (sortOrder == 'asc')"
onClick=":navBaseCall.replace('**v**', '0,&quot;%s&quot;, \
&quot;desc&quot;, &quot;%s&quot;' % (fieldName,filterKey))"
src=":'%s/ui/sortUp.gif' % appUrl" style="cursor:pointer"/>
</x>
<x if="filterable">
<input type="text" size="7"
id=":'%s_%s' % (ajaxHookId, fieldName)"
value=":filterKey == fieldName and filterValue or ''"/>
<img onClick=":navBaseCall.replace('**v**', '0, &quot;%s&quot;, \
&quot;%s&quot;, &quot;%s&quot;' % \
(sortKey, sortOrder, fieldName))"
src=":'%s/ui/funnel.png' % appUrl" style="cursor:pointer"/>
</x>
</x>''')
# column. Requires variables "sortable", 'filterable' and 'field'.
pxSortAndFilter = Px('''<x>
<x if="sortable">
<img if="(sortKey != field.name) or (sortOrder == 'desc')"
onclick=":navBaseCall.replace('**v**', '0,%s,%s,%s' % \
(q(field.name), q('asc'), q(filterKey)))"
src=":img('sortDown.gif')" style="cursor:pointer"/>
<img if="(sortKey != field.name) or (sortOrder == 'asc')"
onClick=":navBaseCall.replace('**v**', '0,%s,%s,%s' % \
(q(field.name), q('desc'), q(filterKey)))"
src=":img('sortUp.gif')" style="cursor:pointer"/>
</x>
<x if="filterable">
<input type="text" size="7" id=":'%s_%s' % (ajaxHookId, field.name)"
value=":filterKey == field.name and filterValue or ''"/>
<img onClick=":navBaseCall.replace('**v**', '0, %s,%s,%s' % \
(q(sortKey), q(sortOrder), q(field.name)))"
src=":img('funnel')" style="cursor:pointer"/>
</x></x>''')
# Buttons for navigating among a list of elements: next,back,first,last...
pxAppyNavigate = Px('''
@ -68,33 +63,31 @@ class AbstractWrapper(object):
<table class="listNavigate"
var="mustSortAndFilter=ajaxHookId == 'queryResult';
sortAndFilter=mustSortAndFilter and \
',&quot;%s&quot;, &quot;%s&quot;, &quot;%s&quot;' % \
(sortKey, sortOrder, filterKey) or ''">
',%s,%s,%s' % (q(sortKey),q(sortOrder),q(filterKey)) or ''">
<tr valign="middle">
<!-- Go to the first page -->
<td if="(startNumber != 0) and (startNumber != batchSize)"><img
style="cursor:pointer" src=":'%s/ui/arrowLeftDouble.png' % appUrl"
style="cursor:pointer" src=":img('arrowLeftDouble')"
title=":_('goto_first')"
onClick=":navBaseCall.replace('**v**', '0'+sortAndFilter)"/></td>
<!-- Go to the previous page -->
<td var="sNumber=startNumber - batchSize" if="startNumber != 0"><img
style="cursor:pointer" src=":'%s/ui/arrowLeftSimple.png' % appUrl"
style="cursor:pointer" src=":img('arrowLeftSimple')"
title=":_('goto_previous')"
onClick="navBaseCall.replace('**v**', \
str(sNumber)+sortAndFilter)"/></td>
<!-- Explain which elements are currently shown -->
<td class="discreet">&nbsp;
<x>:startNumber + 1</x><img src=":'%s/ui/to.png' % appUrl"/>
<x>:startNumber + 1</x><img src=":img('to')"/>
<x>:startNumber + len(objs)</x>&nbsp;<b>//</b>
<x>:totalNumber</x>&nbsp;&nbsp;</td>
<!-- Go to the next page -->
<td var="sNumber=startNumber + batchSize"
if="sNumber &lt; totalNumber"><img style="cursor:pointer"
src=":'%s/ui/arrowRightSimple.png' % appUrl"
title=":_('goto_next')"
src=":img('arrowRightSimple')" title=":_('goto_next')"
onClick=":navBaseCall.replace('**v**', \
str(sNumber)+sortAndFilter)"/></td>
@ -106,8 +99,7 @@ class AbstractWrapper(object):
sNumber= nbOfCountedPages * batchSize"
if="(startNumber != sNumber) and \
(startNumber != sNumber-batchSize)"><img style="cursor:pointer"
src=":'%s/ui/arrowRightDouble.png' % appUrl"
title=":_('goto_last')"
src=":img('arrowRightDouble')" title=":_('goto_last')"
onClick="navBaseCall.replace('**v**', \
str(sNumber)+sortAndFilter)"/></td>
</tr>
@ -117,8 +109,8 @@ class AbstractWrapper(object):
# Buttons for going to next/previous elements if this one is among bunch of
# referenced or searched objects. currentNumber starts with 1.
pxObjectNavigate = Px('''
<x if="req.get('nav', None)">
<div var="navInfo=ztool.getNavigationInfo();
<div if="req.get('nav', None)"
var2="navInfo=ztool.getNavigationInfo();
currentNumber=navInfo['currentNumber'];
totalNumber=navInfo['totalNumber'];
firstUrl=navInfo['firstUrl'];
@ -133,15 +125,15 @@ class AbstractWrapper(object):
var="gotoSource=_('goto_source');
goBack=backText and ('%s - %s' % (backText, gotoSource)) \
or gotoSource"
src=":'%s/ui/gotoSource.png' % appUrl" title=":goBack"/></a>
src=":img('gotoSource')" title=":goBack"/></a>
<!-- Go to the first page -->
<a if="firstUrl" href=":firstUrl"><img title=":_('goto_first')"
src=":'%s/ui/arrowLeftDouble.png' % appUrl"/></a>
src=":img('arrowLeftDouble')"/></a>
<!-- Go to the previous page -->
<a if="previousUrl" href=":previousUrl"><img title=":_('goto_previous')"
src=":'%s/ui/arrowLeftSimple.png' % appUrl"/></a>
src=":img('arrowLeftSimple')"/></a>
<!-- Explain which element is currently shown -->
<span class="discreet">&nbsp;
@ -151,29 +143,28 @@ class AbstractWrapper(object):
<!-- Go to the next page -->
<a if="nextUrl" href=":nextUrl"><img title=":_('goto_next')"
src=":'%s/ui/arrowRightSimple.png' % appUrl"/></a>
src=":img('arrowRightSimple')"/></a>
<!-- Go to the last page -->
<a if="lastUrl" href=":lastUrl"><img title=":_('goto_last')"
src=":'%s/ui/arrowRightDouble.png' % appUrl"/></a>
</div>
</x>''')
src=":img('arrowRightDouble')"/></a>
</div>''')
pxNavigationStrip = Px('''
<table width="100%" class="navigate">
<tr>
<!-- Breadcrumb -->
<td var="breadcrumb=contextObj.getBreadCrumb()" class="breadcrumb">
<x for="bc in breadcrumb">
<x var="nb=loop.bc.nb">
<img if="nb != 0" src=":'%s/ui/to.png' % appUrl"/>
<!-- Display only the title of the current object -->
<span if="nb == len(breadcrumb)-1">:bc['title']</span>
<!-- Display a link for parent objects -->
<a if="nb != len(breadcrumb)-1" href=":bc['url']">:bc['title']</a>
</x>
<x for="bc in breadcrumb" var2="nb=loop.bc.nb">
<img if="nb != 0" src=":img('to')"/>
<!-- Display only the title of the current object -->
<span if="nb == len(breadcrumb)-1">:bc['title']</span>
<!-- Display a link for parent objects -->
<a if="nb != len(breadcrumb)-1" href=":bc['url']">:bc['title']</a>
</x>
</td>
<td align="right">:self.pxObjectNavigate</td>
<!-- Object navigation -->
<td align=":dright">:self.pxObjectNavigate</td>
</tr>
</table>''')
@ -181,53 +172,52 @@ class AbstractWrapper(object):
# PXs for graphical elements shown on every page
# --------------------------------------------------------------------------
# Global elements included in every page.
pxPagePrologue = Px('''
<div>
<!-- Include type-specific CSS and JS. -->
<x if="cssJs">
<link for="cssFile in cssJs['css']" rel="stylesheet" type="text/css"
href=":'%s/ui/%s' % (appUrl, cssFile)"/>
<script for="jsFile in cssJs['js']" type="text/javascript"
src=":'%s/ui/%s' % (appUrl, jsFile)"></script></x>
pxPagePrologue = Px('''<x>
<!-- Include type-specific CSS and JS. -->
<x if="cssJs">
<link for="cssFile in cssJs['css']" rel="stylesheet" type="text/css"
href=":'%s/ui/%s' % (appUrl, cssFile)"/>
<script for="jsFile in cssJs['js']" type="text/javascript"
src=":'%s/ui/%s' % (appUrl, jsFile)"></script></x>
<!-- Javascript messages -->
<script type="text/javascript">:ztool.getJavascriptMessages()</script>
<!-- Javascript messages -->
<script type="text/javascript">:ztool.getJavascriptMessages()</script>
<!-- Global form for deleting an object -->
<form id="deleteForm" method="post" action="do">
<input type="hidden" name="action" value="Delete"/>
<input type="hidden" name="objectUid"/>
</form>
<!-- Global form for deleting an event from an object's history -->
<form id="deleteEventForm" method="post" action="do">
<input type="hidden" name="action" value="DeleteEvent"/>
<input type="hidden" name="objectUid"/>
<input type="hidden" name="eventTime"/>
</form>
<!-- Global form for unlinking an object -->
<form id="unlinkForm" method="post" action="do">
<input type="hidden" name="action" value="Unlink"/>
<input type="hidden" name="sourceUid"/>
<input type="hidden" name="fieldName"/>
<input type="hidden" name="targetUid"/>
</form>
<!-- Global form for unlocking a page -->
<form id="unlockForm" method="post" action="do">
<input type="hidden" name="action" value="Unlock"/>
<input type="hidden" name="objectUid"/>
<input type="hidden" name="pageName"/>
</form>
<!-- Global form for generating a document from a pod template -->
<form id="podTemplateForm" name="podTemplateForm" method="post"
action=":ztool.absolute_url() + '/generateDocument'">
<input type="hidden" name="objectUid"/>
<input type="hidden" name="fieldName"/>
<input type="hidden" name="podFormat"/>
<input type="hidden" name="askAction"/>
<input type="hidden" name="queryData"/>
<input type="hidden" name="customParams"/>
</form>
</div>''')
<!-- Global form for deleting an object -->
<form id="deleteForm" method="post" action="do">
<input type="hidden" name="action" value="Delete"/>
<input type="hidden" name="objectUid"/>
</form>
<!-- Global form for deleting an event from an object's history -->
<form id="deleteEventForm" method="post" action="do">
<input type="hidden" name="action" value="DeleteEvent"/>
<input type="hidden" name="objectUid"/>
<input type="hidden" name="eventTime"/>
</form>
<!-- Global form for unlinking an object -->
<form id="unlinkForm" method="post" action="do">
<input type="hidden" name="action" value="Unlink"/>
<input type="hidden" name="sourceUid"/>
<input type="hidden" name="fieldName"/>
<input type="hidden" name="targetUid"/>
</form>
<!-- Global form for unlocking a page -->
<form id="unlockForm" method="post" action="do">
<input type="hidden" name="action" value="Unlock"/>
<input type="hidden" name="objectUid"/>
<input type="hidden" name="pageName"/>
</form>
<!-- Global form for generating a document from a pod template -->
<form id="podTemplateForm" name="podTemplateForm" method="post"
action=":ztool.absolute_url() + '/generateDocument'">
<input type="hidden" name="objectUid"/>
<input type="hidden" name="fieldName"/>
<input type="hidden" name="podFormat"/>
<input type="hidden" name="askAction"/>
<input type="hidden" name="queryData"/>
<input type="hidden" name="customParams"/>
</form>
</x>''')
pxPageBottom = Px('''
<script type="text/javascript">initSlaves();</script>''')
@ -241,14 +231,13 @@ class AbstractWrapper(object):
rootClasses=ztool.getRootClasses();
phases=contextObj and contextObj.getAppyPhases() or None">
<x if="contextObj and phases and contextObj.mayNavigate()">
<table class="portletContent"
var="singlePhase=phases and (len(phases) == 1);
<table class="portletContent"
if="contextObj and phases and contextObj.mayNavigate()"
var2="singlePhase=phases and (len(phases) == 1);
page=req.get('page', '');
mayEdit=contextObj.mayEdit()">
<x for="phase in phases">:phase['px']</x>
</table>
</x>
<x for="phase in phases">:phase['px']</x>
</table>
<!-- One section for every searchable root class -->
<x for="rootClass in [rc for rc in rootClasses \
@ -279,18 +268,17 @@ class AbstractWrapper(object):
<!-- Create a new object from a web form -->
<input type="button" class="button"
if="userMayAdd and ('form' in createMeans)"
style=":'background-image: url(%s/ui/buttonAdd.png)' % appUrl"
value=":_('query_create')"
onclick=":'window.location=&quot;%s/do?action=Create&amp;' \
'className=%s&quot;' % (toolUrl, rootClass)"/>
style=":img('buttonAdd', bg=True)" value=":_('query_create')"
onclick=":'window.location=%s' % \
q('%s/do?action=Create&amp;className=%s' % \
(toolUrl, rootClass))"/>
<!-- Create object(s) by importing data -->
<input type="button" class="button"
if="userMayAdd and ('import' in createMeans)"
style=":'background-image: url(%s/ui/buttonImport.png)'% appUrl"
value=":_('query_import')"
onclick=":'window.location=&quot;%s/ui/import?' \
'className=%s&quot;' % (toolUrl, rootClass)"/>
style=":img('buttonImport', bg=True)" value=":_('query_import')"
onclick=":'window.location=%s' % \
q('%s/ui/import?className=%s' % (toolUrl, rootClass))"/>
</x>
<!-- Searches -->
@ -304,9 +292,9 @@ class AbstractWrapper(object):
<tr valign="bottom">
<td><input type="text" size="14" name="w_SearchableText"
class="inputSearch"/></td>
<td><input type="image" style="cursor:pointer"
src=":'%s/ui/search.gif' % appUrl"
title=":_('search_button')"/></td>
<td>
<input type="image" style="cursor:pointer" src=":img('search.gif')"
title=":_('search_button')"/></td>
</tr>
</table>
</form>
@ -325,10 +313,8 @@ class AbstractWrapper(object):
<!-- Predefined searches -->
<x for="widget in searchInfo['searches']">
<x if="widget['type'] == 'group'">:widget['px']</x>
<x if="widget['type'] != 'group'">
<x var="search=widget">:search['px']</x>
</x>
<x if="widget['type']=='group'">:widget['px']</x>
<x if="widget['type']!='group'" var2="search=widget">:search['px']</x>
</x>
</div>
</x>
@ -336,16 +322,13 @@ class AbstractWrapper(object):
# The message that is shown when a user triggers an action.
pxMessage = Px('''
<x var="messages=ztool.consumeMessages()" if="messages">
<div class="message">
<!-- The icon for closing the message -->
<img src=":'%s/ui/close.png' % appUrl" align=":dright"
style="cursor:pointer"
onclick="this.parentNode.style.display='none'"/>
<!-- The message content -->
<x>::messages</x>
</div>
</x>''')
<div var="messages=ztool.consumeMessages()" if="messages" class="message">
<!-- The icon for closing the message -->
<img src=":img('close')" align=":dright" style="cursor:pointer"
onclick="this.parentNode.style.display='none'"/>
<!-- The message content -->
<x>::messages</x>
</div>''')
# The page footer.
pxFooter = Px('''
@ -371,6 +354,7 @@ class AbstractWrapper(object):
appName=ztool.getAppName(); _=ztool.translate;
req=ztool.REQUEST; resp=req.RESPONSE;
lang=ztool.getUserLanguage(); q=ztool.quote;
img = ztool.getImageUrl;
layoutType=ztool.getLayoutType();
contextObj=ztool.getPublishedObject(layoutType) or \
ztool.getHomeObject();
@ -405,52 +389,51 @@ class AbstractWrapper(object):
<!-- Popup for confirming an action -->
<div id="confirmActionPopup" class="popup">
<form id="confirmActionForm" method="post">
<div align="center">
<p id="appyConfirmText"></p>
<input type="hidden" name="actionType"/>
<input type="hidden" name="action"/>
<div id="commentArea" align=":dleft"><br/>
<span class="discreet">:_('workflow_comment')</span>
<textarea name="comment" cols="30" rows="3"></textarea>
<br/>
</div>
<br/>
<input type="button" onclick="doConfirm()" value=":_('yes')"/>
<input type="button" onclick="closePopup('confirmActionPopup')"
<form id="confirmActionForm" method="post">
<div align="center">
<p id="appyConfirmText"></p>
<input type="hidden" name="actionType"/>
<input type="hidden" name="action"/>
<div id="commentArea" align=":dleft"><br/>
<span class="discreet">:_('workflow_comment')</span>
<textarea name="comment" cols="30" rows="3"></textarea>
<br/>
</div><br/>
<input type="button" onclick="doConfirm()" value=":_('yes')"/>
<input type="button" onclick="closePopup('confirmActionPopup')"
value=":_('no')"/>
</div>
</form>
</div>
</form>
</div>
<!-- Popup for reinitializing the password -->
<div id="askPasswordReinitPopup" class="popup"
if="isAnon and ztool.showForgotPassword()">
<form id="askPasswordReinitForm" method="post"
<form id="askPasswordReinitForm" method="post"
action=":ztool.absolute_url() + '/askPasswordReinit'">
<div align="center">
<p>:_('app_login')</p>
<input type="text" size="35" name="login" id="login" value=""/>
<br/><br/>
<input type="button" onclick="doAskPasswordReinit()"
value=":_('ask_password_reinit')"/>
<input type="button" onclick="closePopup('askPasswordReinitPopup')"
value=":_('object_cancel')"/>
</div>
</form>
<div align="center">
<p>:_('app_login')</p>
<input type="text" size="35" name="login" id="login" value=""/>
<br/><br/>
<input type="button" onclick="doAskPasswordReinit()"
value=":_('ask_password_reinit')"/>
<input type="button" onclick="closePopup('askPasswordReinitPopup')"
value=":_('object_cancel')"/>
</div>
</form>
</div>
<table class="main" align="center" cellpadding="0">
<tr class="top">
<!-- Top banner -->
<td var="bannerName=(dir == 'ltr') and 'banner' or 'bannerrtl'"
style=":'background-image: url(%s/ui/%s.jpg)'% (appUrl,bannerName)">
style=":img('%s.jpg' % bannerName, bg=True)">
<!-- Top links -->
<div style="margin-top: 4px" align=":dright">
<!-- Icon "home" -->
<a class="pageLink" href=":appUrl" title=": _('app_home')">
<img src=":'%s/ui/home.gif' % appUrl" style="margin-right: 3px"/>
<img src=":img('home.gif')" style="margin-right: 3px"/>
</a>
<!-- Additional links -->
@ -466,14 +449,13 @@ class AbstractWrapper(object):
style="cursor:pointer">:_('app_connect')</a>
<!-- Language selector -->
<x if="ztool.showLanguageSelector()">
<select var="languages=ztool.getLanguages();
defaultLanguage=languages[0]"
class="pageLink" onchange="switchLanguage(this)">
<option for="lg in languages" value=":lg"
selected=":lang == lg">:ztool.getLanguageName(lg)</option>
</select>
</x>
<select if="ztool.showLanguageSelector()"
var2="languages=ztool.getLanguages();
defaultLanguage=languages[0]"
class="pageLink" onchange="switchLanguage(this)">
<option for="lg in languages" value=":lg"
selected=":lang == lg">:ztool.getLanguageName(lg)</option>
</select>
</div>
</td>
</tr>
@ -526,18 +508,18 @@ class AbstractWrapper(object):
<!-- Config -->
<a if="user.has_role('Manager')" href=":tool.url"
title=":_('%sTool' % appName)">
<img src=":'%s/ui/appyConfig.gif' % appUrl"/></a>
<img src=":img('appyConfig.gif')"/></a>
<!-- Additional icons -->
<x>:self.pxIcons</x>
<!-- Log out -->
<a href=":tool.url + '/performLogout'" title=":_('app_logout')">
<img src=":'%s/ui/logout.gif' % appUrl"/></a>
<img src=":img('logout.gif')"/></a>
</td>
<td class="userStripText" var="userInfo=ztool.getUserLine()"
align=":dright">
<span>:userInfo[0]</span>
<a if="userInfo[1]" href=":userInfo[1]">
<img src=":'%s/ui/edit.png' % appUrl"/></a>
<a if="userInfo[1]"
href=":userInfo[1]"><img src=":img('edit')"/></a>
</td>
</tr>
</table>
@ -578,130 +560,121 @@ class AbstractWrapper(object):
<x var="startNumber=req.get'startNumber', 0);
startNumber=int(startNumber);
batchSize=int(req.get('maxPerPage', 5));
historyInfo=contextObj.getHistory(startNumber,batchSize=batchSize);
objs=historyInfo['events'];
totalNumber=historyInfo['totalNumber'];
ajaxHookId='appyHistory';
navBaseCall='askObjectHistory(&quot;%s&quot;, &quot;%s&quot;, \
%d, **v**)' % (ajaxHookId,contextObj.absolute_url(),batchSize)">
historyInfo=contextObj.getHistory(startNumber,batchSize=batchSize)"
if="historyInfo['events']"
var2="objs=historyInfo['events'];
totalNumber=historyInfo['totalNumber'];
ajaxHookId='appyHistory';
navBaseCall='askObjectHistory(%s,%s,%d,**v**)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), batchSize)">
<!-- Table containing the history -->
<x if="objs">
<x>:self.pxAppyNavigate</x>
<table width="100%" class="history">
<tr>
<th align=":dleft">:_('object_action')</th>
<th align=":dleft">:_('object_author')</th>
<th align=":dleft">:_('action_date')</th>
<th align=":dleft">:_('action_comment')</th>
</tr>
<x for="event in objs">
<tr var="odd=loop.event.odd;
rhComments=event.get('comments', None);
state=event.get('review_state', None);
action=event['action'];
isDataChange=action == '_datachange_'"
class="odd and 'even' or 'odd'" valign="top">
<td if="isDataChange">
<x>:_('data_change')</x>
<img if="user.has_role('Manager')" style="cursor:pointer"
src=":'%s/ui/delete.png' % appUrl"
onclick=":'onDeleteEvent(&quot;%s&quot;, &quot;%s&quot;)' % \
(contextObj.UID(), event['time'])"/>
</td>
<td if="not isDataChange">:_(contextObj.getWorkflowLabel(action))</td>
<td var="actorId=event.get('actor')">
<x if="not actorId">?</x>
<x if="actorId">:ztool.getUserName(actorId)</x>
</td>
<td>:ztool.formatDate(event['time'], withHour=True)"></td>
<td if="not isDataChange">
<x if="rhComments">::contextObj.formatText(rhComments)</x>
<x if="not rhComments">-</x>
</td>
<td if="isDataChange">
<!-- Display the previous values of the fields whose value were
modified in this change. -->
<table class="appyChanges" width="100%">
<tr>
<th align=":dleft" width="30%">:_('modified_field')</th>
<th align=":dleft" width="70%">:_('previous_value')</th>
</tr>
<tr for="change in event['changes'].items()" valign="top">
<x var="appyType=contextObj.getAppyType(change[0], asDict=True)">
<td>::_(appyType['labelId'])</td>
<td>::change[1][0]</td>
</x>
</tr>
</table>
</td>
</tr>
</x>
</table>
</x>
</x>
''')
<!-- Navigate between history pages -->
<x>:self.pxAppyNavigate</x>
<!-- History -->
<table width="100%" class="history">
<tr>
<th align=":dleft">:_('object_action')</th>
<th align=":dleft">:_('object_author')</th>
<th align=":dleft">:_('action_date')</th>
<th align=":dleft">:_('action_comment')</th>
</tr>
<tr for="event in objs"
var2="odd=loop.event.odd;
rhComments=event.get('comments', None);
state=event.get('review_state', None);
action=event['action'];
isDataChange=action == '_datachange_'"
class="odd and 'even' or 'odd'" valign="top">
<td if="isDataChange">
<x>:_('data_change')</x>
<img if="user.has_role('Manager')" style="cursor:pointer"
src=":img('delete')"
onclick=":'onDeleteEvent(%s,%s)' % \
(q(contextObj.UID()), q(event['time']))"/>
</td>
<td if="not isDataChange">:_(contextObj.getWorkflowLabel(action))</td>
<td var="actorId=event.get('actor')">
<x if="not actorId">?</x>
<x if="actorId">:ztool.getUserName(actorId)</x>
</td>
<td>:ztool.formatDate(event['time'], withHour=True)"></td>
<td if="not isDataChange">
<x if="rhComments">::contextObj.formatText(rhComments)</x>
<x if="not rhComments">-</x>
</td>
<td if="isDataChange">
<!-- Display the previous values of the fields whose value were
modified in this change. -->
<table class="appyChanges" width="100%">
<tr>
<th align=":dleft" width="30%">:_('modified_field')</th>
<th align=":dleft" width="70%">:_('previous_value')</th>
</tr>
<tr for="change in event['changes'].items()" valign="top"
var2="appyType=contextObj.getAppyType(change[0], asDict=True)">
<td>::_(appyType['labelId'])</td>
<td>::change[1][0]</td>
</tr>
</table>
</td>
</tr>
</table>
</x>''')
# Displays an object's transitions(s).
pxTransitions = Px('''
<x var="transitions=targetObj.getAppyTransitions()" if="transitions">
<form var="formId='trigger_%s' % targetObj.UID()" method="post"
id=":formId" action=":targetObj.absolute_url() + '/do'">
<input type="hidden" name="action" value="Trigger"/>
<input type="hidden" name="workflow_action"/>
<table>
<tr valign="middle">
<!-- Input field for storing comment -->
<textarea id="comment" name="comment" cols="30" rows="3"
style="display:none"></textarea>
<!-- Buttons for triggering transitions -->
<td align=":dright" for="transition in transitions">
<!-- Real button -->
<input type="button" class="button" if="transition['may_trigger']"
style=":'background-image: \
url(%s/ui/buttonTransition.png)' % appUrl"
title=":transition['title']"
value=":ztool.truncateValue(transition['title'])"
onclick=":'triggerTransition(&quot;%s&quot;, &quot;%s&quot;, \
&quot;%s&quot;)' % (formId, transition['name'], \
transition['confirm'])"/>
<form var="transitions=targetObj.getAppyTransitions()" if="transitions"
var2="formId='trigger_%s' % targetObj.UID()" method="post"
id=":formId" action=":targetObj.absolute_url() + '/do'">
<input type="hidden" name="action" value="Trigger"/>
<input type="hidden" name="workflow_action"/>
<table>
<tr valign="middle">
<!-- Input field for storing comment -->
<textarea id="comment" name="comment" cols="30" rows="3"
style="display:none"></textarea>
<!-- Buttons for triggering transitions -->
<td align=":dright" for="transition in transitions">
<!-- Real button -->
<input type="button" class="button" if="transition['may_trigger']"
style=":img('buttonTransition', bg=True)"
title=":transition['title']"
value=":ztool.truncateValue(transition['title'])"
onclick=":'triggerTransition(%s,%s,%s)' % (q(formId), \
q(transition['name']), q(transition['confirm']))"/>
<!-- Fake button, explaining why the transition can't be triggered -->
<input type="button" class="button" if="not transition['may_trigger']"
style=":'background-image: url(%s/ui/buttonFake.png); \
cursor: help' % appUrl"
value=":ztool.truncateValue(transition['title'])"
title=":'%s: %s' % (transition['title'], \
transition['reason'])"/>
</td>
</tr>
</table>
</form>
</x>''')
<!-- Fake button, explaining why the transition can't be triggered -->
<input type="button" class="button" if="not transition['may_trigger']"
style=":img('buttonFake', bg=True) + ';cursor: help'"
value=":ztool.truncateValue(transition['title'])"
title=":'%s: %s' % (transition['title'], \
transition['reason'])"/>
</td>
</tr>
</table>
</form>''')
# Displays header information about an object: title, workflow-related info,
# history...
pxObjectHeader = Px('''
<div var="hasHistory=contextObj.hasHistory();
historyMaxPerPage=req.get('maxPerPage', 5);
historyExpanded=req.get('appyHistory','collapsed') == 'expanded';
creator=contextObj.Creator()"
if="not contextObj.isTemporary()">
<div if="not contextObj.isTemporary()"
var2="hasHistory=contextObj.hasHistory();
historyMaxPerPage=req.get('maxPerPage', 5);
historyExpanded=req.get('appyHistory','collapsed') == 'expanded';
creator=contextObj.Creator()">
<table width="100%" class="summary">
<tr>
<td colspan="2" class="by">
<!-- Plus/minus icon for accessing history -->
<x if="hasHistory">
<img style="cursor:pointer" onClick="toggleCookie('appyHistory')"
src="historyExpanded and 'ui/collapse.gif' or 'ui/expand.gif'"
align=":dleft" id="appyHistory_img"/>
<img style="cursor:pointer" onclick="toggleCookie('appyHistory')"
src="historyExpanded and img('collapse.gif') or img('expand.gif')"
align=":dleft" id="appyHistory_img"/>
<x>:_('object_history')</x> ||
</x>
<!-- Creator and last modification date -->
<x>:_('object_created_by')</x>
<x>:ztool.getUserName(creator)</x>
<x>:_('object_created_by')</x><x>:ztool.getUserName(creator)</x>
<!-- Creation and last modification dates -->
<x>:_('object_created_on')</x>
@ -726,18 +699,16 @@ class AbstractWrapper(object):
<td colspan="2">
<span id="appyHistory"
style=":historyExpanded and 'display:block' or 'display:none')">
<div var="ajaxHookId=contextObj.UID() + '_history'"
id=":ajaxHookId">
<script type="text/javascript">:'askObjectHistory(&quot;%s&quot;, \
&quot;%s&quot;, %d, 0)' % (ajaxHookId, contextObj.absolute_url(),\
historyMaxPerPage)</script>
<div var="ajaxHookId=contextObj.UID() + '_history'" id=":ajaxHookId">
<script type="text/javascript">:'askObjectHistory(%s,%s,%d,0)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), \
historyMaxPerPage)</script>
</div>
</span>
</td>
</tr>
</table>
</div>
''')
</div>''')
# Shows the range of buttons (next, previous, save,...) and the workflow
# transitions.
@ -754,73 +725,61 @@ class AbstractWrapper(object):
<x if="isEdit">
<input type="button" class="button" value=":_('page_previous')"
onClick="submitAppyForm('previous')"
style=":'background-image: \
url(%s/ui/buttonPrevious.png)' % appUrl"/>
style=":img('buttonPrevious', bg=True)"/>
<input type="hidden" name="previousPage" value=":previousPage"/>
</x>
<!-- Button on the view page -->
<x if="not isEdit">
<input type="button" class="button" value=":_('page_previous')"
style=":'background-image: \
url(%s/ui/buttonPrevious.png)' % appUrl"
onclick=":'window.location=&quot;%s&quot;' % \
contextObj.getUrl(page=previousPage)"/>
</x>
<input if="not isEdit" type="button" class="button"
value=":_('page_previous')"
style=":img('buttonPrevious', bg=True)"
onclick=":'window.location=%s' % \
q(contextObj.getUrl(page=previousPage))"/>
</td>
<!-- Save -->
<td if="isEdit and pageInfo['showSave']">
<input type="button" class="button" onClick="submitAppyForm('save')"
style=":'background-image: url(%s/ui/buttonSave.png)' % appUrl"
value=":_('object_save')"/>
style=":img(buttonSave', bg=True)" value=":_('object_save')"/>
</td>
<!-- Cancel -->
<td if="isEdit and pageInfo['showCancel']">
<input type="button" class="button" onClick="submitAppyForm('cancel')"
style=":'background-image: url(%s/ui/buttonCancel.png)' % appUrl"
value=":_('object_cancel')"/>
style=":img('buttonCancel', bg=True)" value=":_('object_cancel')"/>
</td>
<x if="not isEdit">
<td var="locked=contextObj.isLocked(user, page);
<td if="not isEdit"
var2="locked=contextObj.isLocked(user, page);
editable=pageInfo['showOnEdit'] and contextObj.mayEdit()">
<!-- Edit -->
<input type="button" class="button" if="editable and not locked"
style=":'background-image: url(%s/ui/buttonEdit.png)' % appUrl"
value=":_('object_edit')"
onclick=":'window.location=&quot;%s&quot;' % \
contextObj.getUrl(mode='edit', page=page)"/>
<!-- Edit -->
<input type="button" class="button" if="editable and not locked"
style=":img('buttonEdit', bg=True)" value=":_('object_edit')"
onclick=":'window.location=%s' % \
q(contextObj.getUrl(mode='edit', page=page))"/>
<!-- Locked -->
<a if="editable and locked">
<img style="cursor: help"
var="lockDate=tool.formatDate(locked[1]);
lockMap={'user': tool.getUserName(locked[0]),\
'date': lockDate};
lockMsg=_('page_locked', mapping=lockMap)"
src=":'%s/ui/lockedBig.png' % appUrl" title=":lockMsg"/></a>
</td>
</x>
<!-- Locked -->
<a if="editable and locked">
<img style="cursor: help"
var="lockDate=tool.formatDate(locked[1]);
lockMap={'user':tool.getUserName(locked[0]),'date':lockDate};
lockMsg=_('page_locked', mapping=lockMap)"
src=":img('lockedBig')" title=":lockMsg"/></a>
</td>
<!-- Next -->
<td if="nextPage and pageInfo['showNext']">
<!-- Button on the edit page -->
<x if="isEdit">
<input type="button" class="button" onClick="submitAppyForm('next')"
style=":'background-image: url(%s/ui/buttonNext.png)' % appUrl"
value=":_('page_next')"/>
style=":img('buttonNext', bg=True)" value=":_('page_next')"/>
<input type="hidden" name="nextPage" value=":nextPage"/>
</x>
<!-- Button on the view page -->
<x if="not isEdit">
<input type="button" class="button"
style=":'background-image: url(%s/ui/buttonNext.png)' % appUrl"
value=":_('page_next')"
onclick=":'window.location=&quot;%s&quot;' % \
contextObj.getUrl(page=nextPage)"/>
</x>
<input if="not isEdit" type="button" class="button"
style=":img('buttonNext', bg=True)" value=":_('page_next')"
onclick=":'window.location=%s' % \
q(contextObj.getUrl(page=nextPage))"/>
</td>
<!-- Workflow transitions -->
@ -830,8 +789,8 @@ class AbstractWrapper(object):
<!-- Refresh -->
<td if="contextObj.isDebug()">
<a href="contextObj.getUrl(mode=layoutType, page=page, refresh='yes')">
<img title="Refresh" style="vertical-align:top"
src=":'%s/ui/refresh.png' % appUrl"/></a>
<img title="Refresh" style="vertical-align:top" src=":img('refresh')"/>
</a>
</td>
</tr>
</table>''')
@ -869,7 +828,7 @@ class AbstractWrapper(object):
cssJs=cssJs)">
<x>:self.pxPagePrologue</x>
<!-- Warn the user that the form should be left via buttons -->
<script type="text/javascript">
<script type="text/javascript"><![CDATA[
window.onbeforeunload = function(e){
theForm = document.getElementById('appyForm');
if (theForm.button.value == "") {
@ -877,22 +836,21 @@ class AbstractWrapper(object):
if (e) {e.returnValue = warn_leave_form;}
return warn_leave_form;
}
}
}]]>
</script>
<form id="appyForm" name="appyForm" method="post"
enctype="multipart/form-data"
action=":contextObj.absolute_url()+'/do'">
<input type="hidden" name="action" value="Update"/>
<input type="hidden" name="button" value=""/>
<input type="hidden" name="page" value=":page"/>
<input type="hidden" name="nav" value=":req.get('nav', None)"/>
<input type="hidden" name="confirmed" value="False"/>
<x var="tagId='pageLayout'">:self.pxLayoutedObject</x>
<input type="hidden" name="action" value="Update"/>
<input type="hidden" name="button" value=""/>
<input type="hidden" name="page" value=":page"/>
<input type="hidden" name="nav" value=":req.get('nav', None)"/>
<input type="hidden" name="confirmed" value="False"/>
<x var="tagId='pageLayout'">:self.pxLayoutedObject</x>
</form>
<script type="text/javascript"
if="confirmMsg">:'askConfirm(&quot;script&quot;, \
&quot;postConfirmedEditForm()&quot;, \
&quot;%s&quot;)' % confirmMsg</script>
if="confirmMsg">:'askConfirm(%s,%s,%s)' % \
(q('script'), q('postConfirmedEditForm()'), q(confirmMsg))</script>
<x>:self.pxPageBottom</x>
</x>''', template=pxTemplate, hook='content')

View file

@ -135,7 +135,10 @@ class IfAction(BufferAction):
the result or not.'''
def do(self, result, context, exprRes):
if exprRes:
self.evaluateBuffer(result, context)
if self.subAction:
self.subAction.execute(result, context)
else:
self.evaluateBuffer(result, context)
else:
if self.buffer.isMainElement(Cell.OD):
# Don't leave the current row with a wrong number of cells

View file

@ -499,7 +499,7 @@ class MemoryBuffer(Buffer):
'buffer', None)
elif actionType == 'if':
action= IfAction('if', self, statement, elem, False, 'buffer', None)
elif actionType == 'var':
elif actionType in ('var', 'var2'):
variables = self._getVariables(statement)
action = VariablesAction('var', self, elem, False, variables,
'buffer', None)

View file

@ -44,7 +44,7 @@ class PxEnvironment(XmlEnvironment):
# ------------------------------------------------------------------------------
class PxParser(XmlParser):
'''PX parser that is specific for parsing PX data.'''
pxAttributes = ('var', 'for', 'if')
pxAttributes = ('var', 'for', 'if', 'var2')
# No-end tags
noEndTags = ('br', 'img', 'link', 'input')
noDumpTags = ('selected', 'checked', 'disabled', 'multiple')
@ -79,7 +79,7 @@ class PxParser(XmlParser):
# the main element or to a sub-element.
e.currentBuffer.addElement(elem, elemType='px')
if elem != 'x':
# Dump the start elements and its attributes. But as a preamble,
# Dump the start element and its attributes. But as a preamble,
# manage special attributes that could not be dumped at all, like
# "selected" or "checked".
hook = None