[gen] Optimized PXs, that are almost ready. This is the last gen version where PTs are still working.

This commit is contained in:
Gaetan Delannay 2013-07-23 10:29:39 +02:00
parent efd918f175
commit d385b8514e
14 changed files with 207 additions and 210 deletions

View file

@ -27,11 +27,11 @@ class Action(Field):
# PX for viewing the Action button. # PX for viewing the Action button.
pxView = pxCell = Px(''' pxView = pxCell = Px('''
<form name="executeAppyAction" <form name="executeAppyAction"
var="formId='%s_%s_form' % (contextObj.UID(), name); var="formId='%s_%s_form' % (zobj.UID(), name);
label=_(field.labelId)" label=_(field.labelId)"
id=":formId" action=":ztool.absolute_url() + '/do'"> id=":formId" action=":ztool.absolute_url() + '/do'">
<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=":zobj.UID()"/>
<input type="hidden" name="fieldName" value=":name"/> <input type="hidden" name="fieldName" value=":name"/>
<input if="field.confirm" type="button" class="button" <input if="field.confirm" type="button" class="button"
var="labelConfirm=_(field.labelId + '_confirm')" var="labelConfirm=_(field.labelId + '_confirm')"

View file

@ -30,7 +30,7 @@ class Boolean(Field):
</x>''') </x>''')
pxEdit = Px(''' pxEdit = Px('''
<x var="isChecked=field.isChecked(contextObj, rawValue)"> <x var="isChecked=field.isChecked(zobj, rawValue)">
<input type="checkbox" name=":name + '_visible'" id=":name" <input type="checkbox" name=":name + '_visible'" id=":name"
class=":masterCss" checked=":isChecked" class=":masterCss" checked=":isChecked"
onclick=":'toggleCheckbox(%s, %s); updateSlaves(this)' % \ onclick=":'toggleCheckbox(%s, %s); updateSlaves(this)' % \

View file

@ -16,24 +16,23 @@ class Calendar(Field):
# Month view for a calendar. Called by pxView, and directly from the UI, # Month view for a calendar. Called by pxView, and directly from the UI,
# via Ajax, when the user selects another month. # via Ajax, when the user selects another month.
pxMonthView = Px(''' pxMonthView = Px('''
<div var="field=contextObj.getAppyType(req['fieldName']); <div var="field=zobj.getAppyType(req['fieldName']);
ajaxHookId=contextObj.UID() + field.name; ajaxHookId=zobj.UID() + field.name;
month=req['month']; month=req['month'];
monthDayOne=DateTime('%s/01' % month); monthDayOne=DateTime('%s/01' % month);
today=DateTime('00:00'); today=DateTime('00:00');
grid=field.getMonthGrid(month); grid=field.getMonthGrid(month);
allEventTypes=field.getEventTypes(contextObj); allEventTypes=field.getEventTypes(zobj);
preComputed=field.getPreComputedInfo(contextObj, monthDayOne, \ preComputed=field.getPreComputedInfo(zobj, monthDayOne, grid);
grid); defaultDate=field.getDefaultDate(zobj);
defaultDate=field.getDefaultDate(contextObj);
defaultDateMonth=defaultDate.strftime('%Y/%m'); defaultDateMonth=defaultDate.strftime('%Y/%m');
previousMonth=field.getSiblingMonth(month, 'previous'); previousMonth=field.getSiblingMonth(month, 'previous');
nextMonth=field.getSiblingMonth(month, 'next'); nextMonth=field.getSiblingMonth(month, 'next');
mayEdit=contextObj.allows(widget['writePermission']); mayEdit=zobj.allows(widget['writePermission']);
objUrl=contextObj.absolute_url(); objUrl=zobj.absolute_url();
startDate=field.getStartDate(contextObj); startDate=field.getStartDate(zobj);
endDate=field.getEndDate(contextObj); endDate=field.getEndDate(zobj);
otherCalendars=field.getOtherCalendars(contextObj, preComputed)" otherCalendars=field.getOtherCalendars(zobj, preComputed)"
id=":ajaxHookId"> id=":ajaxHookId">
<script type="text/javascript">:'var %s_maxEventLength = %d;' % \ <script type="text/javascript">:'var %s_maxEventLength = %d;' % \
@ -73,7 +72,7 @@ class Calendar(Field):
var="rowHeight=int(field.height/float(len(grid)))"> var="rowHeight=int(field.height/float(len(grid)))">
<!-- 1st row: names of days --> <!-- 1st row: names of days -->
<tr height="22px"> <tr height="22px">
<th for="dayName in field.getNamesOfDays(contextObj)" <th for="dayName in field.getNamesOfDays(zobj)"
width="14%">:dayName</th> width="14%">:dayName</th>
</tr> </tr>
<!-- The calendar in itself --> <!-- The calendar in itself -->
@ -82,13 +81,13 @@ class Calendar(Field):
var2="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(zobj, 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 -->
<td if="inRange" <td if="inRange"
var2="events=field.getEventsAt(contextObj, date); var2="events=field.getEventsAt(zobj, date);
spansDays=field.hasEventsAt(contextObj, date+1, events); spansDays=field.hasEventsAt(zobj, date+1, events);
mayCreate=mayEdit and not events; mayCreate=mayEdit and not events;
mayDelete=mayEdit and events; mayDelete=mayEdit and events;
day=date.day(); day=date.day();
@ -105,7 +104,7 @@ class Calendar(Field):
<!-- Icon for adding an event --> <!-- Icon for adding an event -->
<x if="mayCreate"> <x if="mayCreate">
<img class="clickable" style="visibility:hidden" <img class="clickable" style="visibility:hidden"
var="info=field.getApplicableEventsTypesAt(contextObj, date, \ var="info=field.getApplicableEventsTypesAt(zobj, date, \
allEventTypes, preComputed, True)" allEventTypes, preComputed, True)"
if="info['eventTypes']" src=":url('plus')" if="info['eventTypes']" src=":url('plus')"
onclick=":'openEventPopup(%s, %s, %s, null, %s, %s)' % \ onclick=":'openEventPopup(%s, %s, %s, null, %s, %s)' % \
@ -119,18 +118,18 @@ class Calendar(Field):
(q('del'), q(field.name), q(dayString), q(str(spansDays)))"/> (q('del'), q(field.name), q(dayString), q(str(spansDays)))"/>
<!-- A single event is allowed for the moment --> <!-- A single event is allowed for the moment -->
<div if="events" var2="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(zobj, \
eventType)"></span> eventType)"></span>
</div> </div>
<!-- Events from other calendars --> <!-- Events from other calendars -->
<x if="otherCalendars" <x if="otherCalendars"
var2="otherEvents=field.getOtherEventsAt(contextObj, date, \ var2="otherEvents=field.getOtherEventsAt(zobj, date, \
otherCalendars)"> otherCalendars)">
<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>
<!-- Additional info --> <!-- Additional info -->
<x var="info=field.getAdditionalInfoAt(contextObj,date,preComputed)" <x var="info=field.getAdditionalInfoAt(zobj, date, preComputed)"
if="info">::info</x> if="info">::info</x>
</td> </td>
</x> </x>
@ -154,7 +153,7 @@ class Calendar(Field):
<select name="eventType"> <select name="eventType">
<option value="">:_('choose_a_value')"></option> <option value="">:_('choose_a_value')"></option>
<option for="eventType in allEventTypes" <option for="eventType in allEventTypes"
value=":eventType">:field.getEventName(contextObj, eventType)"> value=":eventType">:field.getEventName(zobj, eventType)">
</option> </option>
</select><br/><br/> </select><br/><br/>
<!--Span the event on several days --> <!--Span the event on several days -->
@ -208,7 +207,7 @@ class Calendar(Field):
</div>''') </div>''')
pxView = pxCell = Px(''' pxView = pxCell = Px('''
<x var="defaultDate=field.getDefaultDate(contextObj); <x var="defaultDate=field.getDefaultDate(zobj);
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=req.set('fieldName', field.name)">:field.pxMonthView</x>''')

View file

@ -24,8 +24,8 @@ class Computed(Field):
# Ajax-called view content of a non sync Computed field. # Ajax-called view content of a non sync Computed field.
pxViewContent = Px(''' pxViewContent = Px('''
<x var="name=req['fieldName']; <x var="name=req['fieldName'];
field=contextObj.getAppyType(name); field=zobj.getAppyType(name);
value=contextObj.getFieldValue(name); value=zobj.getFieldValue(name);
sync=True">:field.pxView</x>''') sync=True">:field.pxView</x>''')
pxView = pxCell = pxEdit = Px('''<x> pxView = pxCell = pxEdit = Px('''<x>
@ -33,9 +33,9 @@ class Computed(Field):
<x if="field.plainText">:value</x><x if="not field.plainText">::value></x> <x if="field.plainText">:value</x><x if="not field.plainText">::value></x>
</x> </x>
<div if="not sync"> <div if="not sync">
var2="ajaxHookId=contextObj.UID() + name" id="ajaxHookId"> var2="ajaxHookId=zobj.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(zobj.absolute_url()), q(name))">
</script> </script>
</div> </div>
</x>''') </x>''')

View file

@ -31,7 +31,7 @@ class Date(Field):
<option value="">-</option> <option value="">-</option>
<option for="day in days" <option for="day in days"
var2="zDay=str(day).zfill(2)" value=":zDay" var2="zDay=str(day).zfill(2)" value=":zDay"
selected="field.isSelected(contextObj, 'day', day, \ selected="field.isSelected(zobj, 'day', day, \
rawValue)">:zDay</option> rawValue)">:zDay</option>
</select> </select>
@ -41,7 +41,7 @@ class Date(Field):
<option value="">-</option> <option value="">-</option>
<option for="month in months" <option for="month in months"
var2="zMonth=str(month).zfill(2)" value=":zMonth" var2="zMonth=str(month).zfill(2)" value=":zMonth"
selected="field.isSelected(contextObj, 'month', month, \ selected="field.isSelected(zobj, 'month', month, \
rawValue)">:zMonth</option> rawValue)">:zMonth</option>
</select> </select>
@ -49,7 +49,7 @@ class Date(Field):
<select name=":'%s_year' % name" id=":'%s_year' % name"> <select name=":'%s_year' % name" id=":'%s_year' % name">
<option value="">-</option> <option value="">-</option>
<option for="year in years" value=":year" <option for="year in years" value=":year"
selected="field.isSelected(contextObj, name, 'year', year, \ selected="field.isSelected(zobj, name, 'year', year, \
rawValue)">:year</option> rawValue)">:year</option>
</select> </select>
@ -67,7 +67,7 @@ class Date(Field):
<option value="">-</option> <option value="">-</option>
<option for="hour in hours" <option for="hour in hours"
var2="zHour=str(hour).zfill(2)" value=":zHour" var2="zHour=str(hour).zfill(2)" value=":zHour"
selected=":field.isSelected(contextObj, 'hour', hour, \ selected=":field.isSelected(zobj, 'hour', hour, \
rawValue)">:zHour</option> rawValue)">:zHour</option>
</select> : </select> :
<select var="minutes=range(0,60,5)" name=":'%s_minute' % name" <select var="minutes=range(0,60,5)" name=":'%s_minute' % name"
@ -75,7 +75,7 @@ class Date(Field):
<option value="">-</option> <option value="">-</option>
<option for="minute in minutes" <option for="minute in minutes"
var2="zMinute=str(minute).zfill(2)" value=":zMinute" var2="zMinute=str(minute).zfill(2)" value=":zMinute"
selected=":field.isSelected(contextObj, 'minute', minute,\ selected=":field.isSelected(zobj, 'minute', minute,\
rawValue)">:zMinute</option> rawValue)">:zMinute</option>
</select> </select>
</x> </x>

View file

@ -27,7 +27,7 @@ class File(Field):
pxView = pxCell = Px(''' pxView = pxCell = Px('''
<x var="info=field.getFileInfo(value); <x var="info=field.getFileInfo(value);
empty=not info.size; empty=not info.size;
imgSrc='%s/download?name=%s' % (contextObj.absolute_url(), name)"> imgSrc='%s/download?name=%s' % (zobj.absolute_url(), name)">
<x if="not empty and not field.isImage"> <x if="not empty and not field.isImage">
<a href=":imgSrc">:info.filename</a>&nbsp;&nbsp;- <a href=":imgSrc">:info.filename</a>&nbsp;&nbsp;-
<i class="discreet">'%sKb' % (info.size / 1024)"></i> <i class="discreet">'%sKb' % (info.size / 1024)"></i>

View file

@ -39,13 +39,13 @@ class Pod(Field):
<!-- Ask action --> <!-- Ask action -->
<x if="field.askAction" <x if="field.askAction"
var2="doLabel='%s_askaction' % field.labelId; var2="doLabel='%s_askaction' % field.labelId;
chekboxId='%s_%s_cb' % (contextObj.UID(), name)"> chekboxId='%s_%s_cb' % (zobj.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>
<img for="fmt in field.getToolInfo(contextObj.appy())[1]" src=":url(fmt)" <img for="fmt in field.getToolInfo(obj)[1]" src=":url(fmt)"
onclick=":'generatePodDocument(%s, %s, %s, %s)' % \ onclick=":'generatePodDocument(%s, %s, %s, %s)' % \
(q(contextObj.UID()), q(name), q(fmt), q(ztool.getQueryInfo()))" (q(zobj.UID()), q(name), q(fmt), q(ztool.getQueryInfo()))"
title=":fmt.capitalize()" class="clickable"/> title=":fmt.capitalize()" class="clickable"/>
</x>''') </x>''')

View file

@ -37,17 +37,17 @@ class Ref(Field):
# the URL for allowing to navigate from one object to the next/previous on # the URL for allowing to navigate from one object to the next/previous on
# ui/view. # ui/view.
pxObjectTitle = Px(''' pxObjectTitle = Px('''
<x var="navInfo='ref.%s.%s:%s.%d.%d' % (contextObj.UID(), field.name, \ <x var="navInfo='ref.%s.%s:%s.%d.%d' % (zobj.UID(), field.name, \
field.pageName, loop.obj.nb + startNumber, totalNumber); field.pageName, loop.ztied.nb + startNumber, totalNumber);
navInfo=not field.isBack and navInfo or ''; navInfo=not field.isBack and navInfo or '';
cssClass=obj.getCssFor('title')"> cssClass=ztied.getCssFor('title')">
<x>::obj.getSupTitle(navInfo)</x> <x>::ztied.getSupTitle(navInfo)</x>
<a var="pageName=field.isBack and field.back.pageName or 'main'; <a var="pageName=field.isBack and field.back.pageName or 'main';
fullUrl=obj.getUrl(page=pageName, nav=navInfo)" fullUrl=ztied.getUrl(page=pageName, nav=navInfo)"
href=":fullUrl" class=":cssClass">:(not includeShownInfo) and \ href=":fullUrl" class=":cssClass">:(not includeShownInfo) and \
obj.Title() or field.getReferenceLabel(obj.appy()) ztied.Title() or field.getReferenceLabel(ztied.appy())
</a><span name="subTitle" style=":showSubTitles and 'display:inline' or \ </a><span name="subTitle" style=":showSubTitles and 'display:inline' or \
'display:none'">::obj.getSubTitle()"</span> 'display:none'">::ztied.getSubTitle()"</span>
</x>''') </x>''')
# This PX displays icons for triggering actions on a given referenced object # This PX displays icons for triggering actions on a given referenced object
@ -56,11 +56,11 @@ 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(zobjects)&gt;1) and changeOrder and canWrite"
var2="objectIndex=field.getIndexOf(contextObj, obj); var2="objectIndex=field.getIndexOf(zobj, ztied);
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(ztied.UID()), q('move'), q('**v**')))">
<img if="objectIndex &gt; 0" class="clickable" src=":url('arrowUp')" <img if="objectIndex &gt; 0" class="clickable" src=":url('arrowUp')"
title=":_('move_up')" title=":_('move_up')"
onclick=":ajaxBaseCall.replace('**v**', 'up')"/> onclick=":ajaxBaseCall.replace('**v**', 'up')"/>
@ -69,25 +69,25 @@ class Ref(Field):
onclick=":ajaxBaseCall.replace('**v**', 'down')"/> onclick=":ajaxBaseCall.replace('**v**', 'down')"/>
</td> </td>
<!-- Workflow transitions --> <!-- Workflow transitions -->
<td if="obj.showTransitions('result')" <td if="ztied.showTransitions('result')"
var2="targetObj=obj">:targetObj.appy().pxTransitions</td> var2="targetObj=ztied">:targetObj.appy().pxTransitions</td>
<!-- Edit --> <!-- Edit -->
<td if="not field.noForm and obj.mayEdit() and field.delete"> <td if="not field.noForm and ztied.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' % (zobj.UID(), field.name, \
field.pageName, loop.obj.nb + startNumber, totalNumber)" field.pageName, loop.ztied.nb+startNumber, totalNumber)"
href=":obj.getUrl(mode='edit', page='main', nav=navInfo)"> href=":ztied.getUrl(mode='edit', page='main', nav=navInfo)">
<img src=":url('edit')" title=":_('object_edit')"/></a> <img src=":url('edit')" title=":_('object_edit')"/></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 ztied.mayDelete()">
<img class="clickable" title=":_('object_delete')" <img class="clickable" title=":_('object_delete')" src=":url('delete')"
src=":url('delete')" onclick=":'onDeleteObject(%s)'%q(obj.UID())"/> onclick=":'onDeleteObject(%s)' % q(ztied.UID())"/>
</td> </td>
<!-- Unlink --> <!-- Unlink -->
<td if="not isBack and field.unlink and canWrite"> <td if="not isBack and field.unlink and canWrite">
<img class="clickable" title=":_('object_unlink')" src=":url('unlink')" <img class="clickable" title=":_('object_unlink')" src=":url('unlink')"
onclick=":'onUnlinkObject(%s,%s,%s)' % (q(contextObj.UID()), \ onclick=":'onUnlinkObject(%s,%s,%s)' % (q(zobj.UID()), \
q(field.name), q(obj.UID()))"/> q(field.name), q(ztied.UID()))"/>
</td> </td>
</tr> </tr>
</table>''') </table>''')
@ -96,9 +96,9 @@ class Ref(Field):
# 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('''
<input if="showPlusIcon" type="button" class="button" <input if="showPlusIcon" type="button" class="button"
var2="navInfo='ref.%s.%s:%s.%d.%d' % (contextObj.UID(), \ var2="navInfo='ref.%s.%s:%s.%d.%d' % (zobj.UID(), \
field.name, field.pageName, 0, totalNumber); field.name, field.pageName, 0, totalNumber);
formCall='window.location=%s' % \ formCall='goto(%s)' % \
q('%s/do?action=Create&amp;className=%s&amp;nav=%s' % \ q('%s/do?action=Create&amp;className=%s&amp;nav=%s' % \
(folder.absolute_url(), linkedPortalType, navInfo)); (folder.absolute_url(), linkedPortalType, navInfo));
formCall=not field.addConfirm and formCall or \ formCall=not field.addConfirm and formCall or \
@ -116,7 +116,7 @@ class Ref(Field):
# 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 if="changeOrder and canWrite and ztool.isSortable(field.name, \ <x if="changeOrder and canWrite and ztool.isSortable(field.name, \
objs[0].meta_type, 'ref')" zobjects[0].meta_type, 'ref')"
var2="ajaxBaseCall=navBaseCall.replace('**v**', '%s,%s,{%s:%s,%s:%s}'% \ 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**')))">
@ -129,27 +129,27 @@ class Ref(Field):
# This PX is called by a XmlHttpRequest (or directly by pxView) for # This PX is called by a XmlHttpRequest (or directly by pxView) for
# displaying the referred objects of a reference field. # displaying the referred objects of a reference field.
pxViewContent = Px(''' pxViewContent = Px('''
<div var="field=contextObj.getAppyType(req['fieldName']); <div var="field=zobj.getAppyType(req['fieldName']);
innerRef=req.get('innerRef', False) == 'True'; innerRef=req.get('innerRef', False) == 'True';
ajaxHookId=contextObj.UID() + field.name; ajaxHookId=zobj.UID() + field.name;
startNumber=int(req.get('%s_startNumber' % ajaxHookId, 0)); startNumber=int(req.get('%s_startNumber' % ajaxHookId, 0));
refObjects=field.getLinkedObjects(contextObj, startNumber); info=field.getLinkedObjects(zobj, startNumber);
objs=refObjects.objects; zobjects=info.objects;
totalNumber=refObjects.totalNumber; totalNumber=info.totalNumber;
batchSize=refObjects.batchSize; batchSize=info.batchSize;
folder=contextObj.getCreateFolder(); batchNumber=len(zobjects);
folder=zobj.getCreateFolder();
linkedPortalType=ztool.getPortalType(field.klass); linkedPortalType=ztool.getPortalType(field.klass);
canWrite=not field.isBack and \ canWrite=not field.isBack and zobj.allows(field.writePermission);
contextObj.allows(field.writePermission); showPlusIcon=zobj.mayAddReference(field.name);
showPlusIcon=contextObj.mayAddReference(field.name);
atMostOneRef=(field.multiplicity[1] == 1) and \ atMostOneRef=(field.multiplicity[1] == 1) and \
(len(objs)&lt;=1); (len(zobjects)&lt;=1);
addConfirmMsg=field.addConfirm and \ addConfirmMsg=field.addConfirm and \
_('%s_addConfirm' % field.labelId) or ''; _('%s_addConfirm' % field.labelId) or '';
navBaseCall='askRefField(%s,%s,%s,%s,**v**)' % \ navBaseCall='askRefField(%s,%s,%s,%s,**v**)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), \ (q(ajaxHookId), q(zobj.absolute_url()), \
q(field.name), q(innerRef)); q(field.name), q(innerRef));
changeOrder=field.changeOrderEnabled(contextObj); changeOrder=field.changeOrderEnabled(zobj);
showSubTitles=req.get('showSubTitles', 'true') == 'true'" showSubTitles=req.get('showSubTitles', 'true') == 'true'"
id=":ajaxHookId"> id=":ajaxHookId">
@ -161,13 +161,13 @@ class Ref(Field):
<table if="atMostOneRef"> <table if="atMostOneRef">
<tr valign="top"> <tr valign="top">
<!-- If there is no object --> <!-- If there is no object -->
<x if="not objs"> <x if="not zobjects">
<td class="discreet">:_('no_ref')</td> <td class="discreet">:_('no_ref')</td>
<td>:field.pxAdd</td> <td>:field.pxAdd</td>
</x> </x>
<!-- If there is an object... --> <!-- If there is an object -->
<x if="objs"> <x if="zobjects">
<td for="obj in objs" <td for="ztied in zobjects"
var2="includeShownInfo=True">:field.pxObjectTitle</td> var2="includeShownInfo=True">:field.pxObjectTitle</td>
</x> </x>
</tr> </tr>
@ -179,52 +179,53 @@ class Ref(Field):
(<x>:totalNumber</x>) (<x>:totalNumber</x>)
<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="zobjects and field.queryable" type="button" class="button"
style=":url('buttonSearch', bg=True)" value=":_('search_title')" style=":url('buttonSearch', bg=True)" value=":_('search_title')"
onclick=":'window.location=%s' % \ onclick=":'goto(%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, zobj.UID(), \
field.name))"/> field.name))"/>
</div> </div>
<!-- Appy (top) navigation --> <!-- Appy (top) navigation -->
<x>:contextObj.appy().pxAppyNavigate</x> <x>:obj.pxAppyNavigate</x>
<!-- No object is present --> <!-- No object is present -->
<p class="discreet" if="not objs">:_('no_ref')</p> <p class="discreet" if="not zobjects">:_('no_ref')</p>
<table if="objs" class=":innerRef and 'innerAppyTable' or ''" <table if="zobjects" class=":innerRef and 'innerAppyTable' or ''"
width="100%"> width="100%">
<tr valign="bottom"> <tr valign="bottom">
<td> <td>
<!-- Show forward or backward reference(s) --> <!-- Show forward or backward reference(s) -->
<table class="not innerRef and 'list' or ''" <table class="not innerRef and 'list' or ''"
width=":innerRef and '100%' or field.layouts['view']['width']" width=":innerRef and '100%' or field.layouts['view']['width']"
var="columns=objs[0].getColumnsSpecifiers(field.shownInfo, dir)"> var="columns=zobjects[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']"
var2="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">:obj.pxShowDetails</x>
).pxShowDetails</x>
</th> </th>
</tr> </tr>
<tr for="obj in objs" var2="odd=loop.obj.odd" valign="top" <tr for="ztied in zobjects" valign="top"
class=":odd and 'even' or 'odd'"> class=":loop.ztied.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']"
var2="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>
<div if="obj.mayAct()">:field.pxObjectActions</div> <div if="ztied.mayAct()">:field.pxObjectActions</div>
</x> </x>
<!-- Any other field --> <!-- Any other field -->
<x if="field.name != 'title'"> <x if="field.name != 'title'">
<x var="contextObj=obj; layoutType='cell'; innerRef=True" <x var="zobj=ztied; obj=ztied.appy(); layoutType='cell';
if="obj.showField(field.name, \ innerRef=True"
if="zobj.showField(field.name, \
layoutType='result')">:field.pxView</x> layoutType='result')">:field.pxView</x>
</x> </x>
</td> </td>
@ -235,7 +236,7 @@ class Ref(Field):
</table> </table>
<!-- Appy (bottom) navigation --> <!-- Appy (bottom) navigation -->
<x>:contextObj.appy().pxAppyNavigate</x> <x>:obj.pxAppyNavigate</x>
</x> </x>
</div>''') </div>''')
@ -246,17 +247,17 @@ class Ref(Field):
<select if="field.link" <select if="field.link"
var2="requestValue=req.get(name, []); var2="requestValue=req.get(name, []);
inRequest=req.has_key(name); inRequest=req.has_key(name);
allObjects=field.getSelectableObjects(); zobjects=field.getSelectableObjects(obj);
uids=[o.UID() for o in \ uids=[o.UID() for o in \
field.getLinkedObjects(contextObj).objects]; field.getLinkedObjects(zobj).objects];
isBeingCreated=contextObj.isTemporary()" isBeingCreated=zobj.isTemporary()"
name=":name" size="isMultiple and field.height or ''" 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>
<option for="refObj in allObjects" var2="uid=refObj.o.UID()" <option for="ztied in zobjects" var2="uid=ztied.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(ztied)</option>
</select>''') </select>''')
pxSearch = Px('''<x> pxSearch = Px('''<x>
@ -622,15 +623,15 @@ class Ref(Field):
else: else:
return self.callMethod(obj, self.changeOrder) return self.callMethod(obj, self.changeOrder)
def getSelectableObjects(self, contextObj): def getSelectableObjects(self, obj):
'''This method returns the list of all objects that can be selected to '''This method returns the list of all objects that can be selected to
be linked as references to p_contextObj via p_self.''' be linked as references to p_obj via p_self.'''
if not self.select: if not self.select:
# No select method has been defined: we must retrieve all objects # No select method has been defined: we must retrieve all objects
# of the referred type that the user is allowed to access. # of the referred type that the user is allowed to access.
return contextObj.appy().search(self.klass) return obj.search(self.klass)
else: else:
return self.select(contextObj.appy()) return self.select(obj)
xhtmlToText = re.compile('<.*?>', re.S) xhtmlToText = re.compile('<.*?>', re.S)
def getReferenceLabel(self, refObject): def getReferenceLabel(self, refObject):

View file

@ -75,7 +75,7 @@ class String(Field):
pxView = Px(''' pxView = Px('''
<x var="fmt=field.format; isUrl=field.isUrl; <x var="fmt=field.format; isUrl=field.isUrl;
mayAjaxEdit=not showChanges and field.inlineEdit and \ mayAjaxEdit=not showChanges and field.inlineEdit and \
contextObj.mayEdit(field.writePermission)"> zobj.mayEdit(field.writePermission)">
<x if="fmt in (0, 3)"> <x if="fmt in (0, 3)">
<ul if="value and isMultiple"> <ul if="value and isMultiple">
<li for="sv in value"><i>::sv</i></li> <li for="sv in value"><i>::sv</i></li>
@ -90,14 +90,13 @@ class String(Field):
</x> </x>
</x> </x>
<!-- Unformatted text --> <!-- Unformatted text -->
<x if="value and (fmt == 1)">::contextObj.formatText(value, format='html') <x if="value and (fmt == 1)">::zobj.formatText(value, format='html')</x>
</x>
<!-- XHTML text --> <!-- XHTML text -->
<x if="value and (fmt == 2)"> <x if="value and (fmt == 2)">
<div if="not mayAjaxEdit" class="xhtml">::value</div> <div if="not mayAjaxEdit" class="xhtml">::value</div>
<div if="mayAjaxEdit" class="xhtml" contenteditable="true" <div if="mayAjaxEdit" class="xhtml" contenteditable="true"
id=":'%s_%s_ck' % (contextObj.UID(), name)">::value</div> id=":'%s_%s_ck' % (zobj.UID(), name)">::value</div>
<script if="mayAjaxEdit">:field.getJsInlineInit(contextObj)"></script> <script if="mayAjaxEdit">:field.getJsInlineInit(zobj)"></script>
</x> </x>
<input type="hidden" if="masterCss" class=":masterCss" value=":rawValue" <input type="hidden" if="masterCss" class=":masterCss" value=":rawValue"
name=":name" id=":name"/> name=":name" id=":name"/>
@ -109,14 +108,14 @@ class String(Field):
isMaster=field.slaves; isMaster=field.slaves;
isOneLine=fmt in (0,3,4)"> isOneLine=fmt in (0,3,4)">
<select if="isSelect" <select if="isSelect"
var2="possibleValues=field.getPossibleValues(contextObj, \ var2="possibleValues=field.getPossibleValues(zobj, \
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 ''"
onchange=":isMaster and 'updateSlaves(this)' or ''" onchange=":isMaster and 'updateSlaves(this)' or ''"
size=":isMultiple and field.height or 1"> size=":isMultiple and field.height or 1">
<option for="val in possibleValues" value=":val[0]" <option for="val in possibleValues" value=":val[0]"
selected=":field.isSelected(contextObj, val[0], rawValue)" selected=":field.isSelected(zobj, val[0], rawValue)"
title=":val[1]">:ztool.truncateValue(val[1], field.width)"> title=":val[1]">:ztool.truncateValue(val[1], field.width)">
</option> </option>
</select> </select>
@ -138,7 +137,7 @@ class String(Field):
rows=":field.height">:inRequest and requestValue or value rows=":field.height">:inRequest and requestValue or value
</textarea> </textarea>
<script if="fmt == 2" <script if="fmt == 2"
type="text/javascript">:field.getJsInit(contextObj)</script> type="text/javascript">:field.getJsInit(zobj)</script>
</x> </x>
</x>''') </x>''')

View file

@ -112,7 +112,7 @@ class ToolMixin(BaseMixin):
the background image of some XHTML tag.''' the background image of some XHTML tag.'''
# If no extension is found in p_name, we suppose it is a png image. # If no extension is found in p_name, we suppose it is a png image.
if '.' not in name: name += '.png' if '.' not in name: name += '.png'
url = '%s/ui/%s' % (self.getPhysicalRoot(),absolute_url(), name) url = '%s/ui/%s' % (self.getPhysicalRoot().absolute_url(), name)
if not bg: return url if not bg: return url
return 'background-image: url(%s)' % url return 'background-image: url(%s)' % url

View file

@ -41,9 +41,11 @@ function showLoginForm() {
loginFields.style.display = "inline"; loginFields.style.display = "inline";
} }
function goto(url) { window.location = url }
function switchLanguage(selectWidget) { function switchLanguage(selectWidget) {
var language = selectWidget.options[selectWidget.selectedIndex].value; var language = selectWidget.options[selectWidget.selectedIndex].value;
window.location = "/config/changeLanguage?language=" + language; goto("/config/changeLanguage?language=" + language);
} }
var isIe = (navigator.appName == "Microsoft Internet Explorer"); var isIe = (navigator.appName == "Microsoft Internet Explorer");
@ -543,10 +545,8 @@ function doConfirm() {
} }
theForm.submit(); theForm.submit();
} }
else if (actionType == 'url') {
// We must go to the URL defined in "action" // We must go to the URL defined in "action"
window.location = action; else if (actionType == 'url') { goto(action) }
}
else if (actionType == 'script') { else if (actionType == 'script') {
// We must execute Javascript code in "action" // We must execute Javascript code in "action"
eval(action); eval(action);

View file

@ -156,7 +156,7 @@ class PhaseDescr(Descr):
pxPhase = Px(''' pxPhase = Px('''
<tr var="singlePage=len(phase['pages']) == 1"> <tr var="singlePage=len(phase['pages']) == 1">
<td var="label='%s_phase_%s' % (contextObj.meta_type, phase['name'])"> <td var="label='%s_phase_%s' % (zobj.meta_type, phase['name'])">
<!-- The title of the phase --> <!-- The title of the phase -->
<div class="portletGroup" <div class="portletGroup"
@ -168,12 +168,12 @@ class PhaseDescr(Descr):
<div if="not (singlePhase and singlePage)" <div if="not (singlePhase and singlePage)"
class=":aPage==page and 'portletCurrent portletPage' or \ class=":aPage==page and 'portletCurrent portletPage' or \
'portletPage'"> 'portletPage'">
<a href=":contextObj.getUrl(page=aPage)">::_('%s_page_%s' % \ <a href=":zobj.getUrl(page=aPage)">::_('%s_page_%s' % \
(contextObj.meta_type, aPage))</a> (zobj.meta_type, aPage))</a>
<x var="locked=contextObj.isLocked(user, aPage); <x var="locked=zobj.isLocked(user, aPage);
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="zobj.getUrl(mode='edit', page=aPage)">
<img src=":url('edit')" title=":_('object_edit')"/></a> <img src=":url('edit')" title=":_('object_edit')"/></a>
<a if="editable and locked"> <a if="editable and locked">
<img style="cursor: help" <img style="cursor: help"
@ -185,7 +185,7 @@ class PhaseDescr(Descr):
<a if="editable and locked and user.has_role('Manager')"> <a if="editable and locked and user.has_role('Manager')">
<img class="clickable" title=":_('page_unlock')" src=":url('unlock')" <img class="clickable" title=":_('page_unlock')" src=":url('unlock')"
onclick=":'onUnlockPage(%s,%s)' % \ onclick=":'onUnlockPage(%s,%s)' % \
(q(contextObj.UID()), q(aPage))"/></a> (q(zobj.UID()), q(aPage))"/></a>
</x> </x>
</div> </div>
<!-- Next lines: links --> <!-- Next lines: links -->

View file

@ -34,31 +34,31 @@ class ToolWrapper(AbstractWrapper):
<x if="field.name == 'title'" <x if="field.name == 'title'"
var2="navInfo='search.%s.%s.%d.%d' % \ var2="navInfo='search.%s.%s.%d.%d' % \
(className, searchName, startNumber+currentNumber, totalNumber); (className, searchName, startNumber+currentNumber, totalNumber);
cssClass=obj.getCssFor('title')"> cssClass=zobj.getCssFor('title')">
<x>::obj.getSupTitle(navInfo)</x> <x>::zobj.getSupTitle(navInfo)</x>
<a href=":obj.getUrl(nav=navInfo, page=obj.getDefaultViewPage())" <a href=":zobj.getUrl(nav=navInfo, page=zobj.getDefaultViewPage())"
if="enableLinks" class=":cssClass">:obj.Title()</a><span if="enableLinks" class=":cssClass">:zobj.Title()</a><span
if="not enableLinks" class=":cssClass">:obj.Title()</span><span if="not enableLinks" class=":cssClass">:zobj.Title()</span><span
style=":showSubTitles and 'display:inline' or 'display:none'" style=":showSubTitles and 'display:inline' or 'display:none'"
name="subTitle">::obj.getSubTitle()</span> name="subTitle">::zobj.getSubTitle()</span>
<!-- Actions: edit, delete --> <!-- Actions: edit, delete -->
<div if="obj.mayAct()"> <div if="zobj.mayAct()">
<a if="obj.mayEdit()" <a if="zobj.mayEdit()"
var2="navInfo='search.%s.%s.%d.%d' % \ var2="navInfo='search.%s.%s.%d.%d' % \
(className, searchName, loop.obj.nb+1+startNumber, totalNumber)" (className, searchName, loop.zobj.nb+1+startNumber, totalNumber)"
href=":obj.getUrl(mode='edit', page=obj.getDefaultEditPage(), \ href=":zobj.getUrl(mode='edit', page=zobj.getDefaultEditPage(), \
nav=navInfo)"> nav=navInfo)">
<img src=":url('edit')" title=":_('object_edit')"/></a> <img src=":url('edit')" title=":_('object_edit')"/></a>
<img if="obj.mayDelete()" class="clickable" src=":url('delete')" <img if="zobj.mayDelete()" class="clickable" src=":url('delete')"
title=":_('object_delete')" title=":_('object_delete')"
onClick="'onDeleteObject(%s)' % q(obj.UID())"/> onClick=":'onDeleteObject(%s)' % q(zobj.UID())"/>
</div> </div>
</x> </x>
<!-- Any other field --> <!-- Any other field -->
<x if="field.name != 'title'"> <x if="field.name != 'title'">
<x var="contextObj=obj; layoutType='cell'; innerRef=True" <x var="layoutType='cell'; innerRef=True"
if="contextObj.showField(field.name, 'result')">field.pxView</x> if="zobj.showField(field.name, 'result')">field.pxView</x>
</x> </x>
</x>''') </x>''')
@ -78,9 +78,10 @@ class ToolWrapper(AbstractWrapper):
</tr> </tr>
<!-- Results --> <!-- Results -->
<tr for="obj in objs" <tr for="zobj in zobjects" id="query_row" valign="top"
var2="odd=loop.obj.odd; currentNumber=currentNumber + 1" var2="currentNumber=currentNumber + 1;
id="query_row" valign="top" class=":odd and 'even' or 'odd'"> obj=zobj.appy()"
class=":loop.zobj.odd and 'even' or 'odd'">
<td for="column in columns" <td for="column in columns"
var2="widget=column['field']" id=":'field_%s' % field.name" var2="widget=column['field']" id=":'field_%s' % field.name"
width=":column['width']" width=":column['width']"
@ -93,10 +94,10 @@ class ToolWrapper(AbstractWrapper):
<table width="100%" <table width="100%"
var="modeElems=resultMode.split('_'); var="modeElems=resultMode.split('_');
cols=(len(modeElems)==2) and int(modeElems[1]) or 4; cols=(len(modeElems)==2) and int(modeElems[1]) or 4;
rows=ztool.splitList(objs, cols)"> rows=ztool.splitList(zobjects, cols)">
<tr for="row in rows" valign="middle"> <tr for="row in rows" valign="middle">
<td for="obj in row" width=":'%d%%' % (100/cols)" align="center" <td for="zobj in row" width=":'%d%%' % (100/cols)" align="center"
style="padding-top: 25px"> style="padding-top: 25px" var2="obj=zobj.appy()">
<x var="currentNumber=currentNumber + 1" <x var="currentNumber=currentNumber + 1"
for="column in columns" for="column in columns"
var2="widget = column['field']">:self.pxQueryField</x> var2="widget = column['field']">:self.pxQueryField</x>
@ -127,9 +128,10 @@ class ToolWrapper(AbstractWrapper):
remember=True, sortBy=sortKey, sortOrder=sortOrder, \ remember=True, sortBy=sortKey, sortOrder=sortOrder, \
filterKey=filterKey, filterValue=filterValue, \ filterKey=filterKey, filterValue=filterValue, \
refObject=refObject, refField=refField); refObject=refObject, refField=refField);
objs=queryResult['objects']; zobjects=queryResult['objects'];
totalNumber=queryResult['totalNumber']; totalNumber=queryResult['totalNumber'];
batchSize=queryResult['batchSize']; batchSize=queryResult['batchSize'];
batchNumber=len(zobjects);
ajaxHookId='queryResult'; ajaxHookId='queryResult';
navBaseCall='askQueryResult(%s,%s,%s,%s,**v**)' % \ navBaseCall='askQueryResult(%s,%s,%s,%s,**v**)' % \
(q(ajaxHookId), q(ztool.absolute_url()), q(className), \ (q(ajaxHookId), q(ztool.absolute_url()), q(className), \
@ -139,20 +141,20 @@ class ToolWrapper(AbstractWrapper):
showSubTitles=req.get('showSubTitles', 'true') == 'true'; showSubTitles=req.get('showSubTitles', 'true') == 'true';
resultMode=ztool.getResultMode(className)"> resultMode=ztool.getResultMode(className)">
<x if="objs"> <x if="zobjects">
<!-- Display here POD templates if required. --> <!-- Display here POD templates if required. -->
<table var="widgets=ztool.getResultPodFields(className); <table var="widgets=ztool.getResultPodFields(className);
layoutType='view'" layoutType='view'"
if="objs and widgets" align=":dright"> if="zobjects and widgets" align=":dright">
<tr> <tr>
<td var="contextObj=objs[0]" for="field in widgets">:field.pxView</td> <td var="zobj=zobjects[0]; obj=zobj.appy()"
for="field in widgets">:field.pxView</td>
</tr> </tr>
</table> </table>
<!-- The title of the search --> <!-- The title of the search -->
<p> <p>
<x>:searchDescr['translated']</x> <x>:searchDescr['translated']</x> (<x>:totalNumber</x>)
(<x>:totalNumber</x>)
<x if="showNewSearch and (searchName == 'customSearch')">&nbsp;&mdash; <x if="showNewSearch and (searchName == 'customSearch')">&nbsp;&mdash;
&nbsp;<i><a href=":newSearchUrl">:_('search_new')</a></i> &nbsp;<i><a href=":newSearchUrl">:_('search_new')</a></i>
</x> </x>
@ -170,7 +172,7 @@ class ToolWrapper(AbstractWrapper):
<!-- Results, as a list or grid --> <!-- Results, as a list or grid -->
<x var="columnLayouts=ztool.getResultColumnsLayouts(className, refInfo); <x var="columnLayouts=ztool.getResultColumnsLayouts(className, refInfo);
columns=objs[0].getColumnsSpecifiers(columnLayouts, dir); columns=zobjects[0].getColumnsSpecifiers(columnLayouts, dir);
currentNumber=0"> currentNumber=0">
<x if="resultMode == 'list'">:self.pxQueryResultList</x> <x if="resultMode == 'list'">:self.pxQueryResultList</x>
<x if="resultMode != 'list'">:self.pxQueryResultGrid</x> <x if="resultMode != 'list'">:self.pxQueryResultGrid</x>
@ -180,7 +182,7 @@ class ToolWrapper(AbstractWrapper):
<x>:self.pxAppyNavigate</x> <x>:self.pxAppyNavigate</x>
</x> </x>
<x if="not objs"> <x if="not zobjects">
<x>:_('query_no_result')></x> <x>:_('query_no_result')></x>
<x if="showNewSearch and (searchName == 'customSearch')"><br/> <x if="showNewSearch and (searchName == 'customSearch')"><br/>
<i class="discreet"><a href=":newSearchUrl">:_('search_new')</a></i></x> <i class="discreet"><a href=":newSearchUrl">:_('search_new')</a></i></x>

View file

@ -81,7 +81,7 @@ class AbstractWrapper(object):
<!-- 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=":url('to')"/> <x>:startNumber + 1</x><img src=":url('to')"/>
<x>:startNumber + len(objs)</x>&nbsp;<b>//</b> <x>:startNumber + batchNumber</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 -->
@ -154,7 +154,7 @@ class AbstractWrapper(object):
<table width="100%" class="navigate"> <table width="100%" class="navigate">
<tr> <tr>
<!-- Breadcrumb --> <!-- Breadcrumb -->
<td var="breadcrumb=contextObj.getBreadCrumb()" class="breadcrumb"> <td var="breadcrumb=zobj.getBreadCrumb()" class="breadcrumb">
<x for="bc in breadcrumb" var2="nb=loop.bc.nb"> <x for="bc in breadcrumb" var2="nb=loop.bc.nb">
<img if="nb != 0" src=":url('to')"/> <img if="nb != 0" src=":url('to')"/>
<!-- Display only the title of the current object --> <!-- Display only the title of the current object -->
@ -229,13 +229,13 @@ class AbstractWrapper(object):
currentClass=req.get('className', None); currentClass=req.get('className', None);
currentPage=req['PATH_INFO'].rsplit('/',1)[-1]; currentPage=req['PATH_INFO'].rsplit('/',1)[-1];
rootClasses=ztool.getRootClasses(); rootClasses=ztool.getRootClasses();
phases=contextObj and contextObj.getAppyPhases() or None"> phases=zobj and zobj.getAppyPhases() or None">
<table class="portletContent" <table class="portletContent"
if="contextObj and phases and contextObj.mayNavigate()" if="zobj and phases and zobj.mayNavigate()"
var2="singlePhase=phases and (len(phases) == 1); var2="singlePhase=phases and (len(phases) == 1);
page=req.get('page', ''); page=req.get('page', '');
mayEdit=contextObj.mayEdit()"> mayEdit=zobj.mayEdit()">
<x for="phase in phases">:phase['px']</x> <x for="phase in phases">:phase['px']</x>
</table> </table>
@ -269,7 +269,7 @@ class AbstractWrapper(object):
<input type="button" class="button" <input type="button" class="button"
if="userMayAdd and ('form' in createMeans)" if="userMayAdd and ('form' in createMeans)"
style=":url('buttonAdd', bg=True)" value=":_('query_create')" style=":url('buttonAdd', bg=True)" value=":_('query_create')"
onclick=":'window.location=%s' % \ onclick=":'goto(%s)' % \
q('%s/do?action=Create&amp;className=%s' % \ q('%s/do?action=Create&amp;className=%s' % \
(toolUrl, rootClass))"/> (toolUrl, rootClass))"/>
@ -277,7 +277,7 @@ class AbstractWrapper(object):
<input type="button" class="button" <input type="button" class="button"
if="userMayAdd and ('import' in createMeans)" if="userMayAdd and ('import' in createMeans)"
style=":url('buttonImport', bg=True)" value=":_('query_import')" style=":url('buttonImport', bg=True)" value=":_('query_import')"
onclick=":'window.location=%s' % \ onclick=":'goto(%s)' % \
q('%s/ui/import?className=%s' % (toolUrl, rootClass))"/> q('%s/ui/import?className=%s' % (toolUrl, rootClass))"/>
</x> </x>
@ -355,9 +355,10 @@ class AbstractWrapper(object):
req=ztool.REQUEST; resp=req.RESPONSE; req=ztool.REQUEST; resp=req.RESPONSE;
lang=ztool.getUserLanguage(); q=ztool.quote; lang=ztool.getUserLanguage(); q=ztool.quote;
layoutType=ztool.getLayoutType(); layoutType=ztool.getLayoutType();
contextObj=ztool.getPublishedObject(layoutType) or \ zobj=ztool.getPublishedObject(layoutType) or \
ztool.getHomeObject(); ztool.getHomeObject();
showPortlet=ztool.showPortlet(contextObj, layoutType); obj = zobj and zobj.appy() or None;
showPortlet=ztool.showPortlet(zobj, layoutType);
dir=ztool.getLanguageDirection(lang); dir=ztool.getLanguageDirection(lang);
discreetLogin=ztool.getAttr('discreetLogin', source='config'); discreetLogin=ztool.getAttr('discreetLogin', source='config');
dleft=(dir == 'ltr') and 'left' or 'right'; dleft=(dir == 'ltr') and 'left' or 'right';
@ -528,7 +529,7 @@ class AbstractWrapper(object):
</tr> </tr>
<!-- The navigation strip --> <!-- The navigation strip -->
<tr if="contextObj and showPortlet and (layoutType != 'edit')"> <tr if="zobj and showPortlet and (layoutType != 'edit')">
<td>:self.pxNavigationStrip</td> <td>:self.pxNavigationStrip</td>
</tr> </tr>
<tr> <tr>
@ -558,13 +559,13 @@ 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=zobj.getHistory(startNumber,batchSize=batchSize)"
if="historyInfo['events']" if="historyInfo['events']"
var2="objs=historyInfo['events']; var2="objs=historyInfo['events'];
totalNumber=historyInfo['totalNumber']; totalNumber=historyInfo['totalNumber'];
ajaxHookId='appyHistory'; ajaxHookId='appyHistory';
navBaseCall='askObjectHistory(%s,%s,%d,**v**)' % \ navBaseCall='askObjectHistory(%s,%s,%d,**v**)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), batchSize)"> (q(ajaxHookId), q(zobj.absolute_url()), batchSize)">
<!-- Navigate between history pages --> <!-- Navigate between history pages -->
<x>:self.pxAppyNavigate</x> <x>:self.pxAppyNavigate</x>
@ -588,16 +589,16 @@ class AbstractWrapper(object):
<img if="user.has_role('Manager')" class="clickable" <img if="user.has_role('Manager')" class="clickable"
src=":url('delete')" src=":url('delete')"
onclick=":'onDeleteEvent(%s,%s)' % \ onclick=":'onDeleteEvent(%s,%s)' % \
(q(contextObj.UID()), q(event['time']))"/> (q(zobj.UID()), q(event['time']))"/>
</td> </td>
<td if="not isDataChange">:_(contextObj.getWorkflowLabel(action))</td> <td if="not isDataChange">:_(zobj.getWorkflowLabel(action))</td>
<td var="actorId=event.get('actor')"> <td var="actorId=event.get('actor')">
<x if="not actorId">?</x> <x if="not actorId">?</x>
<x if="actorId">:ztool.getUserName(actorId)</x> <x if="actorId">:ztool.getUserName(actorId)</x>
</td> </td>
<td>:ztool.formatDate(event['time'], withHour=True)"></td> <td>:ztool.formatDate(event['time'], withHour=True)"></td>
<td if="not isDataChange"> <td if="not isDataChange">
<x if="rhComments">::contextObj.formatText(rhComments)</x> <x if="rhComments">::zobj.formatText(rhComments)</x>
<x if="not rhComments">-</x> <x if="not rhComments">-</x>
</td> </td>
<td if="isDataChange"> <td if="isDataChange">
@ -609,7 +610,7 @@ class AbstractWrapper(object):
<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"
var2="appyType=contextObj.getAppyType(change[0], asDict=True)"> var2="appyType=zobj.getAppyType(change[0], asDict=True)">
<td>::_(appyType['labelId'])</td> <td>::_(appyType['labelId'])</td>
<td>::change[1][0]</td> <td>::change[1][0]</td>
</tr> </tr>
@ -655,11 +656,11 @@ class AbstractWrapper(object):
# 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 if="not contextObj.isTemporary()" <div if="not zobj.isTemporary()"
var2="hasHistory=contextObj.hasHistory(); var2="hasHistory=zobj.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=zobj.Creator()">
<table width="100%" class="summary"> <table width="100%" class="summary">
<tr> <tr>
<td colspan="2" class="by"> <td colspan="2" class="by">
@ -676,8 +677,8 @@ class AbstractWrapper(object):
<!-- Creation and last modification dates --> <!-- Creation and last modification dates -->
<x>:_('object_created_on')</x> <x>:_('object_created_on')</x>
<x var="creationDate=contextObj.Created(); <x var="creationDate=zobj.Created();
modificationDate=contextObj.Modified()"> modificationDate=zobj.Modified()">
<x>:ztool.formatDate(creationDate, withHour=True)></x> <x>:ztool.formatDate(creationDate, withHour=True)></x>
<x if="modificationDate != creationDate">&mdash; <x if="modificationDate != creationDate">&mdash;
<x>:_('object_modified_on')</x> <x>:_('object_modified_on')</x>
@ -686,8 +687,8 @@ class AbstractWrapper(object):
</x> </x>
<!-- State --> <!-- State -->
<x if="contextObj.showState()">&mdash; <x if="zobj.showState()">&mdash;
<x>:_('workflow_state')</x> : <b>:_(contextObj.getWorkflowLabel())</b> <x>:_('workflow_state')</x> : <b>:_(zobj.getWorkflowLabel())</b>
</x> </x>
</td> </td>
</tr> </tr>
@ -697,9 +698,9 @@ 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'" id=":ajaxHookId"> <div var="ajaxHookId=zobj.UID() + '_history'" id=":ajaxHookId">
<script type="text/javascript">:'askObjectHistory(%s,%s,%d,0)' % \ <script type="text/javascript">:'askObjectHistory(%s,%s,%d,0)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), \ (q(ajaxHookId), q(zobj.absolute_url()), \
historyMaxPerPage)</script> historyMaxPerPage)</script>
</div> </div>
</span> </span>
@ -712,8 +713,8 @@ class AbstractWrapper(object):
# transitions. # transitions.
pxObjectButtons = Px(''' pxObjectButtons = Px('''
<table cellpadding="2" cellspacing="0" style="margin-top: 7px" <table cellpadding="2" cellspacing="0" style="margin-top: 7px"
var="previousPage=contextObj.getPreviousPage(phaseInfo, page)[0]; var="previousPage=zobj.getPreviousPage(phaseInfo, page)[0];
nextPage=contextObj.getNextPage(phaseInfo, page)[0]; nextPage=zobj.getNextPage(phaseInfo, page)[0];
isEdit=layoutType == 'edit'; isEdit=layoutType == 'edit';
pageInfo=phaseInfo['pagesInfo'][page]"> pageInfo=phaseInfo['pagesInfo'][page]">
<tr> <tr>
@ -730,8 +731,7 @@ class AbstractWrapper(object):
<input if="not isEdit" type="button" class="button" <input if="not isEdit" type="button" class="button"
value=":_('page_previous')" value=":_('page_previous')"
style=":url('buttonPrevious', bg=True)" style=":url('buttonPrevious', bg=True)"
onclick=":'window.location=%s' % \ onclick=":'goto(%s)' % q(zobj.getUrl(page=previousPage))"/>
q(contextObj.getUrl(page=previousPage))"/>
</td> </td>
<!-- Save --> <!-- Save -->
@ -747,14 +747,13 @@ class AbstractWrapper(object):
</td> </td>
<td if="not isEdit" <td if="not isEdit"
var2="locked=contextObj.isLocked(user, page); var2="locked=zobj.isLocked(user, page);
editable=pageInfo['showOnEdit'] and contextObj.mayEdit()"> editable=pageInfo['showOnEdit'] and zobj.mayEdit()">
<!-- Edit --> <!-- Edit -->
<input type="button" class="button" if="editable and not locked" <input type="button" class="button" if="editable and not locked"
style=":url('buttonEdit', bg=True)" value=":_('object_edit')" style=":url('buttonEdit', bg=True)" value=":_('object_edit')"
onclick=":'window.location=%s' % \ onclick=":'goto(%s)' % q(zobj.getUrl(mode='edit', page=page))"/>
q(contextObj.getUrl(mode='edit', page=page))"/>
<!-- Locked --> <!-- Locked -->
<a if="editable and locked"> <a if="editable and locked">
@ -776,17 +775,16 @@ class AbstractWrapper(object):
<!-- Button on the view page --> <!-- Button on the view page -->
<input if="not isEdit" type="button" class="button" <input if="not isEdit" type="button" class="button"
style=":url('buttonNext', bg=True)" value=":_('page_next')" style=":url('buttonNext', bg=True)" value=":_('page_next')"
onclick=":'window.location=%s' % \ onclick=":'goto(%s)' % q(zobj.getUrl(page=nextPage))"/>
q(contextObj.getUrl(page=nextPage))"/>
</td> </td>
<!-- Workflow transitions --> <!-- Workflow transitions -->
<td var="targetObj=contextObj" <td var="targetObj=zobj"
if="targetObj.showTransitions(layoutType)">:self.pxTransitions</td> if="targetObj.showTransitions(layoutType)">:self.pxTransitions</td>
<!-- Refresh --> <!-- Refresh -->
<td if="contextObj.isDebug()"> <td if="zobj.isDebug()">
<a href="contextObj.getUrl(mode=layoutType, page=page, refresh='yes')"> <a href="zobj.getUrl(mode=layoutType, page=page, refresh='yes')">
<img title="Refresh" style="vertical-align:top" src=":url('refresh')"/> <img title="Refresh" style="vertical-align:top" src=":url('refresh')"/>
</a> </a>
</td> </td>
@ -795,16 +793,15 @@ class AbstractWrapper(object):
pxLayoutedObject = Px('''<p>Layouted object</p>''') pxLayoutedObject = Px('''<p>Layouted object</p>''')
pxView = Px(''' pxView = Px('''
<x var="x=contextObj.allows('View', raiseError=True); <x var="x=zobj.allows('View', raiseError=True);
errors=req.get('errors', {}); errors=req.get('errors', {});
layout=contextObj.getPageLayout(layoutType); layout=zobj.getPageLayout(layoutType);
phaseInfo=contextObj.getAppyPhases(currentOnly=True, \ phaseInfo=zobj.getAppyPhases(currentOnly=True, layoutType='view');
layoutType='view');
phase=phaseInfo['name']; phase=phaseInfo['name'];
cssJs={}; cssJs={};
page=req.get('page',None) or contextObj.getDefaultViewPage(); page=req.get('page',None) or zobj.getDefaultViewPage();
x=contextObj.removeMyLock(user, page); x=zobj.removeMyLock(user, page);
groupedWidgets=contextObj.getGroupedAppyTypes(layoutType, page, \ groupedWidgets=zobj.getGroupedAppyTypes(layoutType, page, \
cssJs=cssJs)"> cssJs=cssJs)">
<x>:self.pxPagePrologue</x> <x>:self.pxPagePrologue</x>
<x var="tagId='pageLayout'">:self.pxLayoutedObject</x> <x var="tagId='pageLayout'">:self.pxLayoutedObject</x>
@ -812,17 +809,17 @@ class AbstractWrapper(object):
</x>''', template=pxTemplate, hook='content') </x>''', template=pxTemplate, hook='content')
pxEdit = Px(''' pxEdit = Px('''
<x var="x=contextObj.allows('Modify portal content', raiseError=True); <x var="x=zobj.allows('Modify portal content', raiseError=True);
errors=req.get('errors', None) or {}; errors=req.get('errors', None) or {};
layout=contextObj.getPageLayout(layoutType); layout=zobj.getPageLayout(layoutType);
cssJs={}; cssJs={};
phaseInfo=contextObj.getAppyPhases(currentOnly=True, \ phaseInfo=zobj.getAppyPhases(currentOnly=True, \
layoutType=layoutType); layoutType=layoutType);
phase=phaseInfo['name']; phase=phaseInfo['name'];
page=req.get('page', None) or contextObj.getDefaultEditPage(); page=req.get('page', None) or zobj.getDefaultEditPage();
x=contextObj.setLock(user, page); x=zobj.setLock(user, page);
confirmMsg=req.get('confirmMsg', None); confirmMsg=req.get('confirmMsg', None);
groupedWidgets=contextObj.getGroupedAppyTypes(layoutType, page, \ groupedWidgets=zobj.getGroupedAppyTypes(layoutType, page, \
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 -->
@ -837,8 +834,7 @@ class AbstractWrapper(object):
}]]> }]]>
</script> </script>
<form id="appyForm" name="appyForm" method="post" <form id="appyForm" name="appyForm" method="post"
enctype="multipart/form-data" enctype="multipart/form-data" action=":zobj.absolute_url()+'/do'">
action=":contextObj.absolute_url()+'/do'">
<input type="hidden" name="action" value="Update"/> <input type="hidden" name="action" value="Update"/>
<input type="hidden" name="button" value=""/> <input type="hidden" name="button" value=""/>
<input type="hidden" name="page" value=":page"/> <input type="hidden" name="page" value=":page"/>