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

View file

@ -37,8 +37,7 @@ class Calendar(Field):
id=":ajaxHookId"> id=":ajaxHookId">
<script type="text/javascript">:'var %s_maxEventLength = %d;' % \ <script type="text/javascript">:'var %s_maxEventLength = %d;' % \
(field.name, field.maxEventLength)"> (field.name, field.maxEventLength)"></script>
</script>
<!-- Month chooser --> <!-- Month chooser -->
<div style="margin-bottom: 5px" <div style="margin-bottom: 5px"
@ -48,13 +47,11 @@ class Calendar(Field):
goForward=not endDate or (endDate.strftime(fmt) &gt; \ goForward=not endDate or (endDate.strftime(fmt) &gt; \
grid[-1][-1].strftime(fmt))"> grid[-1][-1].strftime(fmt))">
<!-- Go to the previous month --> <!-- Go to the previous month -->
<img style="cursor:pointer" tal:condition="goBack" <img style="cursor:pointer" if="goBack" src=":img('arrowLeftSimple')"
src=":'%s/ui/arrowLeftSimple.png' % appUrl" onclick=":'askMonthView(%s,%s,%s,%s)' % \
onclick=":'askMonthView(%s, %s, %s, %s)' % \
(q(ajaxHookId),q(objUrl),q(field.name),q(previousMonth))"/> (q(ajaxHookId),q(objUrl),q(field.name),q(previousMonth))"/>
<!-- Go back to the default date --> <!-- Go back to the default date -->
<x if="goBack or goForward"> <input type="button" if="goBack or goForward"
<input type="button"
var="fmt='%Y/%m'; var="fmt='%Y/%m';
label=(defaultDate.strftime(fmt)==today.strftime(fmt)) and \ label=(defaultDate.strftime(fmt)==today.strftime(fmt)) and \
'today' or 'goto_source'" 'today' or 'goto_source'"
@ -62,10 +59,8 @@ class Calendar(Field):
onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \ onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \
q(objUrl), q(field.name), q(defaultDateMonth))" q(objUrl), q(field.name), q(defaultDateMonth))"
disabled=":defaultDate.strftime(fmt)==monthDayOne.strftime(fmt)"/> disabled=":defaultDate.strftime(fmt)==monthDayOne.strftime(fmt)"/>
</x>
<!-- Go to the next month --> <!-- Go to the next month -->
<img style="cursor:pointer" if="goForward" <img style="cursor:pointer" if="goForward" src=":img('arrowRightSimple')"
src=":'%s/ui/arrowRightSimple.png' % appUrl"
onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \ onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \
q(objUrl), q(field.name), q(nextMonth))"/> q(objUrl), q(field.name), q(nextMonth))"/>
<span>:_('month_%s' % monthDayOne.aMonth())</span> <span>:_('month_%s' % monthDayOne.aMonth())</span>
@ -83,19 +78,21 @@ class Calendar(Field):
</tr> </tr>
<!-- The calendar in itself --> <!-- The calendar in itself -->
<tr for="row in grid" valign="top" height=":rowHeight"> <tr for="row in grid" valign="top" height=":rowHeight">
<x for="date in row"> <x for="date in row"
<x var="tooEarly=startDate and (date &lt; startDate); var2="tooEarly=startDate and (date &lt; startDate);
tooLate=endDate and not tooEarly and (date &gt; endDate); tooLate=endDate and not tooEarly and (date &gt; endDate);
inRange=not tooEarly and not tooLate; inRange=not tooEarly and not tooLate;
cssClasses=field.getCellStyle(contextObj, date, today)"> cssClasses=field.getCellStyle(contextObj, date, today)">
<!-- Dump an empty cell if we are out of the supported date range --> <!-- Dump an empty cell if we are out of the supported date range -->
<td if="not inRange" class=":cssClasses"></td> <td if="not inRange" class=":cssClasses"></td>
<!-- Dump a normal cell if we are in range --> <!-- Dump a normal cell if we are in range -->
<x if="inRange"> <td if="inRange"
<td var="events=field.getEventsAt(contextObj, date); var2="events=field.getEventsAt(contextObj, date);
spansDays=field.hasEventsAt(contextObj, date+1, events); spansDays=field.hasEventsAt(contextObj, date+1, events);
mayCreate=mayEdit and not events; mayCreate=mayEdit and not events;
mayDelete=mayEdit and events" mayDelete=mayEdit and events;
day=date.day();
dayString=date.strftime('%Y/%m/%d')"
style="date.isCurrentDay() and 'font-weight:bold' or \ style="date.isCurrentDay() and 'font-weight:bold' or \
'font-weight:normal'" 'font-weight:normal'"
class=":cssClasses" class=":cssClasses"
@ -103,8 +100,6 @@ class Calendar(Field):
%s)[0].style.visibility=%s' % (q('img'), q('visible')) or ''" %s)[0].style.visibility=%s' % (q('img'), q('visible')) or ''"
onmouseout="mayEdit and 'this.getElementsByTagName(\ onmouseout="mayEdit and 'this.getElementsByTagName(\
%s)[0].style.visibility=%s' % (q('img'), q('hidden')) or ''"> %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>:day</span>
<span if="day == 1">:_('month_%s_short' % date.aMonth())"></span> <span if="day == 1">:_('month_%s_short' % date.aMonth())"></span>
<!-- Icon for adding an event --> <!-- Icon for adding an event -->
@ -112,41 +107,33 @@ class Calendar(Field):
<img style="visibility:hidden; cursor:pointer" <img style="visibility:hidden; cursor:pointer"
var="info=field.getApplicableEventsTypesAt(contextObj, date, \ var="info=field.getApplicableEventsTypesAt(contextObj, date, \
allEventTypes, preComputed, True)" allEventTypes, preComputed, True)"
if="info['eventTypes']" if="info['eventTypes']" src=":img('plus')"
src=":'%s/ui/plus.png' % appUrl"
onclick=":'openEventPopup(%s, %s, %s, null, %s, %s)' % \ onclick=":'openEventPopup(%s, %s, %s, null, %s, %s)' % \
(q('new'), q(field.name), q(dayString), \ (q('new'), q(field.name), q(dayString), q(info['eventTypes']),\
q(info['eventTypes']), q(info['message']))"/> q(info['message']))"/>
</x> </x>
<!-- Icon for deleting an event --> <!-- Icon for deleting an event -->
<img if="mayDelete" style="visibility:hidden; cursor:pointer" <img if="mayDelete" style="visibility:hidden; cursor:pointer"
src=":'%s/ui/delete.png' % appUrl" src=":img('delete')"
onclick=":'openEventPopup(%s, %s, %s, %s, null, null)' % \ onclick=":'openEventPopup(%s, %s, %s, %s, null, null)' % \
(q('del'), q(field.name), q(dayString), q(str(spansDays)))"/> (q('del'), q(field.name), q(dayString), q(str(spansDays)))"/>
<x if="events">
<!-- A single event is allowed for the moment --> <!-- A single event is allowed for the moment -->
<div var="eventType=events[0]['eventType']"> <div if="events" var2="eventType=events[0]['eventType']">
<span style="color: grey">:field.getEventName(contextObj, \ <span style="color: grey">:field.getEventName(contextObj, \
eventType)"></span> eventType)"></span>
</div> </div>
</x>
<!-- Events from other calendars --> <!-- Events from other calendars -->
<x if="otherCalendars"> <x if="otherCalendars"
<x var="otherEvents=field.getOtherEventsAt(contextObj, date, \ var2="otherEvents=field.getOtherEventsAt(contextObj, date, \
otherCalendars)" otherCalendars)">
if="otherEvents">
<div style=":'color: %s; font-style: italic' % event['color']" <div style=":'color: %s; font-style: italic' % event['color']"
for="event in otherEvents">:event['name']</div> for="event in otherEvents">:event['name']</div>
</x> </x>
</x>
<!-- Additional info --> <!-- Additional info -->
<x var="info=field.getAdditionalInfoAt(contextObj,date,preComputed)" <x var="info=field.getAdditionalInfoAt(contextObj,date,preComputed)"
if="info">::info</x> if="info">::info</x>
</x>
</td> </td>
</x> </x>
</x>
</x>
</tr> </tr>
</table> </table>
@ -222,10 +209,8 @@ class Calendar(Field):
pxView = pxCell = Px(''' pxView = pxCell = Px('''
<x var="defaultDate=field.getDefaultDate(contextObj); <x var="defaultDate=field.getDefaultDate(contextObj);
x=req.set('fieldName', field.name); x=req.set('month', defaultDate.strftime('%Y/%m'));
x=req.set('month', defaultDate.strftime('%Y/%m'))"> x=req.set('fieldName', field.name)">:field.pxMonthView</x>''')
<x>:field.pxMonthView</x>
</x>''')
pxEdit = pxSearch = '' pxEdit = pxSearch = ''

View file

@ -28,23 +28,19 @@ class Computed(Field):
value=contextObj.getFieldValue(name); value=contextObj.getFieldValue(name);
sync=True">:field.pxView</x>''') sync=True">:field.pxView</x>''')
pxView = pxCell = pxEdit = Px(''' pxView = pxCell = pxEdit = Px('''<x>
<x>
<x if="sync"> <x if="sync">
<x if="field.plainText">:value</x> <x if="field.plainText">:value</x><x if="not field.plainText">::value></x>
<x if="not field.plainText">::value></x>
</x> </x>
<x if="not sync"> <div if="not sync">
<div var="ajaxHookId=contextObj.UID() + name" id="ajaxHookId"> var2="ajaxHookId=contextObj.UID() + name" id="ajaxHookId">
<script type="text/javascript">:'askComputedField(%s, %s, %s)' % \ <script type="text/javascript">:'askComputedField(%s, %s, %s)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), q(name))"> (q(ajaxHookId), q(contextObj.absolute_url()), q(name))">
</script> </script>
</div> </div>
</x>
</x>''') </x>''')
pxSearch = Px(''' pxSearch = Px('''<x>
<x>
<label lfor=":name">:field.labelId</label><br/>&nbsp;&nbsp; <label lfor=":name">:field.labelId</label><br/>&nbsp;&nbsp;
<input type="text" name=":'%s*string' % name" maxlength=":field.maxChars" <input type="text" name=":'%s*string' % name" maxlength=":field.maxChars"
size=":field.width" value=":field.sdefault"/> size=":field.width" value=":field.sdefault"/>

View file

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

View file

@ -35,8 +35,7 @@ class Float(Field):
maxlength=":field.maxChars" maxlength=":field.maxChars"
value=":inRequest and requestValue or value" type="text"/>''') value=":inRequest and requestValue or value" type="text"/>''')
pxSearch = Px(''' pxSearch = Px('''<x>
<x>
<label>:_(field.labelId)"></label><br/>&nbsp;&nbsp; <label>:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- From --> <!-- From -->
<x var="fromName='%s*float' % widgetName"> <x var="fromName='%s*float' % widgetName">

View file

@ -32,8 +32,7 @@ class Integer(Field):
maxlength=":field.maxChars" maxlength=":field.maxChars"
value=":inRequest and requestValue or value" type="text"/>''') value=":inRequest and requestValue or value" type="text"/>''')
pxSearch = Px(''' pxSearch = Px('''<x>
<x>
<label>:_(field.labelId)"></label><br/>&nbsp;&nbsp; <label>:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- From --> <!-- From -->
<x var="fromName='%s*int' % widgetName"> <x var="fromName='%s*int' % widgetName">

View file

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

View file

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

View file

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

View file

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

View file

@ -108,8 +108,8 @@ class String(Field):
isSelect=field.isSelect; isSelect=field.isSelect;
isMaster=field.slaves; isMaster=field.slaves;
isOneLine=fmt in (0,3,4)"> isOneLine=fmt in (0,3,4)">
<x if="isSelect"> <select if="isSelect"
<select var="possibleValues=field.getPossibleValues(contextObj, \ var2="possibleValues=field.getPossibleValues(contextObj, \
withTranslations=True, withBlankValue=True)" withTranslations=True, withBlankValue=True)"
name=":name" id=":name" class=":masterCss" name=":name" id=":name" class=":masterCss"
multiple=":isMultiple and 'multiple' or ''" multiple=":isMultiple and 'multiple' or ''"
@ -120,7 +120,6 @@ class String(Field):
title=":val[1]">:ztool.truncateValue(val[1], field.width)"> title=":val[1]">:ztool.truncateValue(val[1], field.width)">
</option> </option>
</select> </select>
</x>
<x if="isOneLine and not isSelect"> <x if="isOneLine and not isSelect">
<input id=":name" name=":name" size=":field.width" <input id=":name" name=":name" size=":field.width"
maxlength=":field.maxChars" maxlength=":field.maxChars"
@ -149,24 +148,21 @@ class String(Field):
<x if="not multipleValues">:field.pxView</x> <x if="not multipleValues">:field.pxView</x>
</x>''') </x>''')
pxSearch = Px(''' pxSearch = Px('''<x>
<x>
<label lfor="widgetName">:_(field.labelId)"></label><br/>&nbsp;&nbsp; <label lfor="widgetName">:_(field.labelId)"></label><br/>&nbsp;&nbsp;
<!-- Show a simple search field for most String fields --> <!-- Show a simple search field for most String fields -->
<x if="not field.isSelect"> <input if="not field.isSelect" type="text" maxlength=":field.maxChars"
<input type="text" maxlength=":field.maxChars" size=":field.swidth" size=":field.swidth" value=":field.sdefault"
name=":'%s*string-%s' % (widgetName, field.transform)" name=":'%s*string-%s' % (widgetName, field.transform)"
style=":'text-transform:%s' % field.transform" style=":'text-transform:%s' % field.transform"/>
value=":field.sdefault"/>
</x>
<!-- Show a multi-selection box for fields whose validator defines a list <!-- Show a multi-selection box for fields whose validator defines a list
of values, with a "AND/OR" checkbox. --> of values, with a "AND/OR" checkbox. -->
<x if="field.isSelect"> <x if="field.isSelect">
<!-- The "and" / "or" radio buttons --> <!-- The "and" / "or" radio buttons -->
<x var="operName='o_%s' % name; <x if="field.multiplicity[1] != 1"
var2="operName='o_%s' % name;
orName='%s_or' % operName; orName='%s_or' % operName;
andName='%s_and' % operName" andName='%s_and' % operName">
if="field.multiplicity[1] != 1">
<input type="radio" name=":operName" id=":orName" checked="checked" <input type="radio" name=":operName" id=":orName" checked="checked"
value="or"/> value="or"/>
<label lfor=":orName">:_('search_or')</label> <label lfor=":orName">:_('search_or')</label>

View file

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

View file

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

View file

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

View file

@ -135,6 +135,9 @@ class IfAction(BufferAction):
the result or not.''' the result or not.'''
def do(self, result, context, exprRes): def do(self, result, context, exprRes):
if exprRes: if exprRes:
if self.subAction:
self.subAction.execute(result, context)
else:
self.evaluateBuffer(result, context) self.evaluateBuffer(result, context)
else: else:
if self.buffer.isMainElement(Cell.OD): if self.buffer.isMainElement(Cell.OD):

View file

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

View file

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