[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.
pxView = pxCell = Px('''
<form name="executeAppyAction"
var="formId='%s_%s_form' % (contextObj.UID(), name);
var="formId='%s_%s_form' % (zobj.UID(), name);
label=_(field.labelId)"
id=":formId" action=":ztool.absolute_url() + '/do'">
<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 if="field.confirm" type="button" class="button"
var="labelConfirm=_(field.labelId + '_confirm')"

View file

@ -30,7 +30,7 @@ class Boolean(Field):
</x>''')
pxEdit = Px('''
<x var="isChecked=field.isChecked(contextObj, rawValue)">
<x var="isChecked=field.isChecked(zobj, rawValue)">
<input type="checkbox" name=":name + '_visible'" id=":name"
class=":masterCss" checked=":isChecked"
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,
# via Ajax, when the user selects another month.
pxMonthView = Px('''
<div var="field=contextObj.getAppyType(req['fieldName']);
ajaxHookId=contextObj.UID() + field.name;
<div var="field=zobj.getAppyType(req['fieldName']);
ajaxHookId=zobj.UID() + field.name;
month=req['month'];
monthDayOne=DateTime('%s/01' % month);
today=DateTime('00:00');
grid=field.getMonthGrid(month);
allEventTypes=field.getEventTypes(contextObj);
preComputed=field.getPreComputedInfo(contextObj, monthDayOne, \
grid);
defaultDate=field.getDefaultDate(contextObj);
allEventTypes=field.getEventTypes(zobj);
preComputed=field.getPreComputedInfo(zobj, monthDayOne, grid);
defaultDate=field.getDefaultDate(zobj);
defaultDateMonth=defaultDate.strftime('%Y/%m');
previousMonth=field.getSiblingMonth(month, 'previous');
nextMonth=field.getSiblingMonth(month, 'next');
mayEdit=contextObj.allows(widget['writePermission']);
objUrl=contextObj.absolute_url();
startDate=field.getStartDate(contextObj);
endDate=field.getEndDate(contextObj);
otherCalendars=field.getOtherCalendars(contextObj, preComputed)"
mayEdit=zobj.allows(widget['writePermission']);
objUrl=zobj.absolute_url();
startDate=field.getStartDate(zobj);
endDate=field.getEndDate(zobj);
otherCalendars=field.getOtherCalendars(zobj, preComputed)"
id=":ajaxHookId">
<script type="text/javascript">:'var %s_maxEventLength = %d;' % \
@ -73,7 +72,7 @@ class Calendar(Field):
var="rowHeight=int(field.height/float(len(grid)))">
<!-- 1st row: names of days -->
<tr height="22px">
<th for="dayName in field.getNamesOfDays(contextObj)"
<th for="dayName in field.getNamesOfDays(zobj)"
width="14%">:dayName</th>
</tr>
<!-- The calendar in itself -->
@ -82,13 +81,13 @@ class Calendar(Field):
var2="tooEarly=startDate and (date &lt; startDate);
tooLate=endDate and not tooEarly and (date &gt; endDate);
inRange=not tooEarly and not tooLate;
cssClasses=field.getCellStyle(contextObj, date, today)">
cssClasses=field.getCellStyle(zobj, date, today)">
<!-- Dump an empty cell if we are out of the supported date range -->
<td if="not inRange" class=":cssClasses"></td>
<!-- Dump a normal cell if we are in range -->
<td if="inRange"
var2="events=field.getEventsAt(contextObj, date);
spansDays=field.hasEventsAt(contextObj, date+1, events);
var2="events=field.getEventsAt(zobj, date);
spansDays=field.hasEventsAt(zobj, date+1, events);
mayCreate=mayEdit and not events;
mayDelete=mayEdit and events;
day=date.day();
@ -105,7 +104,7 @@ class Calendar(Field):
<!-- Icon for adding an event -->
<x if="mayCreate">
<img class="clickable" style="visibility:hidden"
var="info=field.getApplicableEventsTypesAt(contextObj, date, \
var="info=field.getApplicableEventsTypesAt(zobj, date, \
allEventTypes, preComputed, True)"
if="info['eventTypes']" src=":url('plus')"
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)))"/>
<!-- A single event is allowed for the moment -->
<div if="events" var2="eventType=events[0]['eventType']">
<span style="color: grey">:field.getEventName(contextObj, \
<span style="color: grey">:field.getEventName(zobj, \
eventType)"></span>
</div>
<!-- Events from other calendars -->
<x if="otherCalendars"
var2="otherEvents=field.getOtherEventsAt(contextObj, date, \
var2="otherEvents=field.getOtherEventsAt(zobj, date, \
otherCalendars)">
<div style=":'color: %s; font-style: italic' % event['color']"
for="event in otherEvents">:event['name']</div>
</x>
<!-- Additional info -->
<x var="info=field.getAdditionalInfoAt(contextObj,date,preComputed)"
<x var="info=field.getAdditionalInfoAt(zobj, date, preComputed)"
if="info">::info</x>
</td>
</x>
@ -154,7 +153,7 @@ class Calendar(Field):
<select name="eventType">
<option value="">:_('choose_a_value')"></option>
<option for="eventType in allEventTypes"
value=":eventType">:field.getEventName(contextObj, eventType)">
value=":eventType">:field.getEventName(zobj, eventType)">
</option>
</select><br/><br/>
<!--Span the event on several days -->
@ -208,7 +207,7 @@ class Calendar(Field):
</div>''')
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('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.
pxViewContent = Px('''
<x var="name=req['fieldName'];
field=contextObj.getAppyType(name);
value=contextObj.getFieldValue(name);
field=zobj.getAppyType(name);
value=zobj.getFieldValue(name);
sync=True">:field.pxView</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>
<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)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), q(name))">
(q(ajaxHookId), q(zobj.absolute_url()), q(name))">
</script>
</div>
</x>''')

View file

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

View file

@ -27,7 +27,7 @@ class File(Field):
pxView = pxCell = Px('''
<x var="info=field.getFileInfo(value);
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">
<a href=":imgSrc">:info.filename</a>&nbsp;&nbsp;-
<i class="discreet">'%sKb' % (info.size / 1024)"></i>

View file

@ -39,13 +39,13 @@ class Pod(Field):
<!-- Ask action -->
<x if="field.askAction"
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"/>
<label lfor=":chekboxId" class="discreet">:_(doLabel)"></label>
</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)' % \
(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"/>
</x>''')

View file

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

View file

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

View file

@ -112,7 +112,7 @@ class ToolMixin(BaseMixin):
the background image of some XHTML tag.'''
# If no extension is found in p_name, we suppose it is a png image.
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
return 'background-image: url(%s)' % url

View file

@ -41,9 +41,11 @@ function showLoginForm() {
loginFields.style.display = "inline";
}
function goto(url) { window.location = url }
function switchLanguage(selectWidget) {
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");
@ -543,10 +545,8 @@ function doConfirm() {
}
theForm.submit();
}
else if (actionType == 'url') {
// We must go to the URL defined in "action"
window.location = action;
}
else if (actionType == 'url') { goto(action) }
else if (actionType == 'script') {
// We must execute Javascript code in "action"
eval(action);

View file

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

View file

@ -34,31 +34,31 @@ class ToolWrapper(AbstractWrapper):
<x if="field.name == 'title'"
var2="navInfo='search.%s.%s.%d.%d' % \
(className, searchName, startNumber+currentNumber, totalNumber);
cssClass=obj.getCssFor('title')">
<x>::obj.getSupTitle(navInfo)</x>
<a href=":obj.getUrl(nav=navInfo, page=obj.getDefaultViewPage())"
if="enableLinks" class=":cssClass">:obj.Title()</a><span
if="not enableLinks" class=":cssClass">:obj.Title()</span><span
cssClass=zobj.getCssFor('title')">
<x>::zobj.getSupTitle(navInfo)</x>
<a href=":zobj.getUrl(nav=navInfo, page=zobj.getDefaultViewPage())"
if="enableLinks" class=":cssClass">:zobj.Title()</a><span
if="not enableLinks" class=":cssClass">:zobj.Title()</span><span
style=":showSubTitles and 'display:inline' or 'display:none'"
name="subTitle">::obj.getSubTitle()</span>
name="subTitle">::zobj.getSubTitle()</span>
<!-- Actions: edit, delete -->
<div if="obj.mayAct()">
<a if="obj.mayEdit()"
<div if="zobj.mayAct()">
<a if="zobj.mayEdit()"
var2="navInfo='search.%s.%s.%d.%d' % \
(className, searchName, loop.obj.nb+1+startNumber, totalNumber)"
href=":obj.getUrl(mode='edit', page=obj.getDefaultEditPage(), \
(className, searchName, loop.zobj.nb+1+startNumber, totalNumber)"
href=":zobj.getUrl(mode='edit', page=zobj.getDefaultEditPage(), \
nav=navInfo)">
<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')"
onClick="'onDeleteObject(%s)' % q(obj.UID())"/>
onClick=":'onDeleteObject(%s)' % q(zobj.UID())"/>
</div>
</x>
<!-- Any other field -->
<x if="field.name != 'title'">
<x var="contextObj=obj; layoutType='cell'; innerRef=True"
if="contextObj.showField(field.name, 'result')">field.pxView</x>
<x var="layoutType='cell'; innerRef=True"
if="zobj.showField(field.name, 'result')">field.pxView</x>
</x>
</x>''')
@ -78,9 +78,10 @@ class ToolWrapper(AbstractWrapper):
</tr>
<!-- Results -->
<tr for="obj in objs"
var2="odd=loop.obj.odd; currentNumber=currentNumber + 1"
id="query_row" valign="top" class=":odd and 'even' or 'odd'">
<tr for="zobj in zobjects" id="query_row" valign="top"
var2="currentNumber=currentNumber + 1;
obj=zobj.appy()"
class=":loop.zobj.odd and 'even' or 'odd'">
<td for="column in columns"
var2="widget=column['field']" id=":'field_%s' % field.name"
width=":column['width']"
@ -93,10 +94,10 @@ class ToolWrapper(AbstractWrapper):
<table width="100%"
var="modeElems=resultMode.split('_');
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">
<td for="obj in row" width=":'%d%%' % (100/cols)" align="center"
style="padding-top: 25px">
<td for="zobj in row" width=":'%d%%' % (100/cols)" align="center"
style="padding-top: 25px" var2="obj=zobj.appy()">
<x var="currentNumber=currentNumber + 1"
for="column in columns"
var2="widget = column['field']">:self.pxQueryField</x>
@ -127,9 +128,10 @@ class ToolWrapper(AbstractWrapper):
remember=True, sortBy=sortKey, sortOrder=sortOrder, \
filterKey=filterKey, filterValue=filterValue, \
refObject=refObject, refField=refField);
objs=queryResult['objects'];
zobjects=queryResult['objects'];
totalNumber=queryResult['totalNumber'];
batchSize=queryResult['batchSize'];
batchNumber=len(zobjects);
ajaxHookId='queryResult';
navBaseCall='askQueryResult(%s,%s,%s,%s,**v**)' % \
(q(ajaxHookId), q(ztool.absolute_url()), q(className), \
@ -139,20 +141,20 @@ class ToolWrapper(AbstractWrapper):
showSubTitles=req.get('showSubTitles', 'true') == 'true';
resultMode=ztool.getResultMode(className)">
<x if="objs">
<x if="zobjects">
<!-- Display here POD templates if required. -->
<table var="widgets=ztool.getResultPodFields(className);
layoutType='view'"
if="objs and widgets" align=":dright">
if="zobjects and widgets" align=":dright">
<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>
</table>
<!-- The title of the search -->
<p>
<x>:searchDescr['translated']</x>
(<x>:totalNumber</x>)
<x>:searchDescr['translated']</x> (<x>:totalNumber</x>)
<x if="showNewSearch and (searchName == 'customSearch')">&nbsp;&mdash;
&nbsp;<i><a href=":newSearchUrl">:_('search_new')</a></i>
</x>
@ -170,7 +172,7 @@ class ToolWrapper(AbstractWrapper):
<!-- Results, as a list or grid -->
<x var="columnLayouts=ztool.getResultColumnsLayouts(className, refInfo);
columns=objs[0].getColumnsSpecifiers(columnLayouts, dir);
columns=zobjects[0].getColumnsSpecifiers(columnLayouts, dir);
currentNumber=0">
<x if="resultMode == 'list'">:self.pxQueryResultList</x>
<x if="resultMode != 'list'">:self.pxQueryResultGrid</x>
@ -180,7 +182,7 @@ class ToolWrapper(AbstractWrapper):
<x>:self.pxAppyNavigate</x>
</x>
<x if="not objs">
<x if="not zobjects">
<x>:_('query_no_result')></x>
<x if="showNewSearch and (searchName == 'customSearch')"><br/>
<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 -->
<td class="discreet">&nbsp;
<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>
<!-- Go to the next page -->
@ -154,7 +154,7 @@ class AbstractWrapper(object):
<table width="100%" class="navigate">
<tr>
<!-- 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">
<img if="nb != 0" src=":url('to')"/>
<!-- Display only the title of the current object -->
@ -229,13 +229,13 @@ class AbstractWrapper(object):
currentClass=req.get('className', None);
currentPage=req['PATH_INFO'].rsplit('/',1)[-1];
rootClasses=ztool.getRootClasses();
phases=contextObj and contextObj.getAppyPhases() or None">
phases=zobj and zobj.getAppyPhases() or None">
<table class="portletContent"
if="contextObj and phases and contextObj.mayNavigate()"
if="zobj and phases and zobj.mayNavigate()"
var2="singlePhase=phases and (len(phases) == 1);
page=req.get('page', '');
mayEdit=contextObj.mayEdit()">
mayEdit=zobj.mayEdit()">
<x for="phase in phases">:phase['px']</x>
</table>
@ -269,7 +269,7 @@ class AbstractWrapper(object):
<input type="button" class="button"
if="userMayAdd and ('form' in createMeans)"
style=":url('buttonAdd', bg=True)" value=":_('query_create')"
onclick=":'window.location=%s' % \
onclick=":'goto(%s)' % \
q('%s/do?action=Create&amp;className=%s' % \
(toolUrl, rootClass))"/>
@ -277,7 +277,7 @@ class AbstractWrapper(object):
<input type="button" class="button"
if="userMayAdd and ('import' in createMeans)"
style=":url('buttonImport', bg=True)" value=":_('query_import')"
onclick=":'window.location=%s' % \
onclick=":'goto(%s)' % \
q('%s/ui/import?className=%s' % (toolUrl, rootClass))"/>
</x>
@ -355,9 +355,10 @@ class AbstractWrapper(object):
req=ztool.REQUEST; resp=req.RESPONSE;
lang=ztool.getUserLanguage(); q=ztool.quote;
layoutType=ztool.getLayoutType();
contextObj=ztool.getPublishedObject(layoutType) or \
zobj=ztool.getPublishedObject(layoutType) or \
ztool.getHomeObject();
showPortlet=ztool.showPortlet(contextObj, layoutType);
obj = zobj and zobj.appy() or None;
showPortlet=ztool.showPortlet(zobj, layoutType);
dir=ztool.getLanguageDirection(lang);
discreetLogin=ztool.getAttr('discreetLogin', source='config');
dleft=(dir == 'ltr') and 'left' or 'right';
@ -528,7 +529,7 @@ class AbstractWrapper(object):
</tr>
<!-- The navigation strip -->
<tr if="contextObj and showPortlet and (layoutType != 'edit')">
<tr if="zobj and showPortlet and (layoutType != 'edit')">
<td>:self.pxNavigationStrip</td>
</tr>
<tr>
@ -558,13 +559,13 @@ class AbstractWrapper(object):
<x var="startNumber=req.get'startNumber', 0);
startNumber=int(startNumber);
batchSize=int(req.get('maxPerPage', 5));
historyInfo=contextObj.getHistory(startNumber,batchSize=batchSize)"
historyInfo=zobj.getHistory(startNumber,batchSize=batchSize)"
if="historyInfo['events']"
var2="objs=historyInfo['events'];
totalNumber=historyInfo['totalNumber'];
ajaxHookId='appyHistory';
navBaseCall='askObjectHistory(%s,%s,%d,**v**)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), batchSize)">
(q(ajaxHookId), q(zobj.absolute_url()), batchSize)">
<!-- Navigate between history pages -->
<x>:self.pxAppyNavigate</x>
@ -588,16 +589,16 @@ class AbstractWrapper(object):
<img if="user.has_role('Manager')" class="clickable"
src=":url('delete')"
onclick=":'onDeleteEvent(%s,%s)' % \
(q(contextObj.UID()), q(event['time']))"/>
(q(zobj.UID()), q(event['time']))"/>
</td>
<td if="not isDataChange">:_(contextObj.getWorkflowLabel(action))</td>
<td if="not isDataChange">:_(zobj.getWorkflowLabel(action))</td>
<td var="actorId=event.get('actor')">
<x if="not actorId">?</x>
<x if="actorId">:ztool.getUserName(actorId)</x>
</td>
<td>:ztool.formatDate(event['time'], withHour=True)"></td>
<td if="not isDataChange">
<x if="rhComments">::contextObj.formatText(rhComments)</x>
<x if="rhComments">::zobj.formatText(rhComments)</x>
<x if="not rhComments">-</x>
</td>
<td if="isDataChange">
@ -609,7 +610,7 @@ class AbstractWrapper(object):
<th align=":dleft" width="70%">:_('previous_value')</th>
</tr>
<tr for="change in event['changes'].items()" valign="top"
var2="appyType=contextObj.getAppyType(change[0], asDict=True)">
var2="appyType=zobj.getAppyType(change[0], asDict=True)">
<td>::_(appyType['labelId'])</td>
<td>::change[1][0]</td>
</tr>
@ -655,11 +656,11 @@ class AbstractWrapper(object):
# Displays header information about an object: title, workflow-related info,
# history...
pxObjectHeader = Px('''
<div if="not contextObj.isTemporary()"
var2="hasHistory=contextObj.hasHistory();
<div if="not zobj.isTemporary()"
var2="hasHistory=zobj.hasHistory();
historyMaxPerPage=req.get('maxPerPage', 5);
historyExpanded=req.get('appyHistory','collapsed') == 'expanded';
creator=contextObj.Creator()">
creator=zobj.Creator()">
<table width="100%" class="summary">
<tr>
<td colspan="2" class="by">
@ -676,8 +677,8 @@ class AbstractWrapper(object):
<!-- Creation and last modification dates -->
<x>:_('object_created_on')</x>
<x var="creationDate=contextObj.Created();
modificationDate=contextObj.Modified()">
<x var="creationDate=zobj.Created();
modificationDate=zobj.Modified()">
<x>:ztool.formatDate(creationDate, withHour=True)></x>
<x if="modificationDate != creationDate">&mdash;
<x>:_('object_modified_on')</x>
@ -686,8 +687,8 @@ class AbstractWrapper(object):
</x>
<!-- State -->
<x if="contextObj.showState()">&mdash;
<x>:_('workflow_state')</x> : <b>:_(contextObj.getWorkflowLabel())</b>
<x if="zobj.showState()">&mdash;
<x>:_('workflow_state')</x> : <b>:_(zobj.getWorkflowLabel())</b>
</x>
</td>
</tr>
@ -697,9 +698,9 @@ class AbstractWrapper(object):
<td colspan="2">
<span id="appyHistory"
style=":historyExpanded and 'display:block' or 'display:none')">
<div var="ajaxHookId=contextObj.UID() + '_history'" id=":ajaxHookId">
<div var="ajaxHookId=zobj.UID() + '_history'" id=":ajaxHookId">
<script type="text/javascript">:'askObjectHistory(%s,%s,%d,0)' % \
(q(ajaxHookId), q(contextObj.absolute_url()), \
(q(ajaxHookId), q(zobj.absolute_url()), \
historyMaxPerPage)</script>
</div>
</span>
@ -712,8 +713,8 @@ class AbstractWrapper(object):
# transitions.
pxObjectButtons = Px('''
<table cellpadding="2" cellspacing="0" style="margin-top: 7px"
var="previousPage=contextObj.getPreviousPage(phaseInfo, page)[0];
nextPage=contextObj.getNextPage(phaseInfo, page)[0];
var="previousPage=zobj.getPreviousPage(phaseInfo, page)[0];
nextPage=zobj.getNextPage(phaseInfo, page)[0];
isEdit=layoutType == 'edit';
pageInfo=phaseInfo['pagesInfo'][page]">
<tr>
@ -730,8 +731,7 @@ class AbstractWrapper(object):
<input if="not isEdit" type="button" class="button"
value=":_('page_previous')"
style=":url('buttonPrevious', bg=True)"
onclick=":'window.location=%s' % \
q(contextObj.getUrl(page=previousPage))"/>
onclick=":'goto(%s)' % q(zobj.getUrl(page=previousPage))"/>
</td>
<!-- Save -->
@ -747,14 +747,13 @@ class AbstractWrapper(object):
</td>
<td if="not isEdit"
var2="locked=contextObj.isLocked(user, page);
editable=pageInfo['showOnEdit'] and contextObj.mayEdit()">
var2="locked=zobj.isLocked(user, page);
editable=pageInfo['showOnEdit'] and zobj.mayEdit()">
<!-- Edit -->
<input type="button" class="button" if="editable and not locked"
style=":url('buttonEdit', bg=True)" value=":_('object_edit')"
onclick=":'window.location=%s' % \
q(contextObj.getUrl(mode='edit', page=page))"/>
onclick=":'goto(%s)' % q(zobj.getUrl(mode='edit', page=page))"/>
<!-- Locked -->
<a if="editable and locked">
@ -776,17 +775,16 @@ class AbstractWrapper(object):
<!-- Button on the view page -->
<input if="not isEdit" type="button" class="button"
style=":url('buttonNext', bg=True)" value=":_('page_next')"
onclick=":'window.location=%s' % \
q(contextObj.getUrl(page=nextPage))"/>
onclick=":'goto(%s)' % q(zobj.getUrl(page=nextPage))"/>
</td>
<!-- Workflow transitions -->
<td var="targetObj=contextObj"
<td var="targetObj=zobj"
if="targetObj.showTransitions(layoutType)">:self.pxTransitions</td>
<!-- Refresh -->
<td if="contextObj.isDebug()">
<a href="contextObj.getUrl(mode=layoutType, page=page, refresh='yes')">
<td if="zobj.isDebug()">
<a href="zobj.getUrl(mode=layoutType, page=page, refresh='yes')">
<img title="Refresh" style="vertical-align:top" src=":url('refresh')"/>
</a>
</td>
@ -795,16 +793,15 @@ class AbstractWrapper(object):
pxLayoutedObject = Px('''<p>Layouted object</p>''')
pxView = Px('''
<x var="x=contextObj.allows('View', raiseError=True);
<x var="x=zobj.allows('View', raiseError=True);
errors=req.get('errors', {});
layout=contextObj.getPageLayout(layoutType);
phaseInfo=contextObj.getAppyPhases(currentOnly=True, \
layoutType='view');
layout=zobj.getPageLayout(layoutType);
phaseInfo=zobj.getAppyPhases(currentOnly=True, layoutType='view');
phase=phaseInfo['name'];
cssJs={};
page=req.get('page',None) or contextObj.getDefaultViewPage();
x=contextObj.removeMyLock(user, page);
groupedWidgets=contextObj.getGroupedAppyTypes(layoutType, page, \
page=req.get('page',None) or zobj.getDefaultViewPage();
x=zobj.removeMyLock(user, page);
groupedWidgets=zobj.getGroupedAppyTypes(layoutType, page, \
cssJs=cssJs)">
<x>:self.pxPagePrologue</x>
<x var="tagId='pageLayout'">:self.pxLayoutedObject</x>
@ -812,17 +809,17 @@ class AbstractWrapper(object):
</x>''', template=pxTemplate, hook='content')
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 {};
layout=contextObj.getPageLayout(layoutType);
layout=zobj.getPageLayout(layoutType);
cssJs={};
phaseInfo=contextObj.getAppyPhases(currentOnly=True, \
phaseInfo=zobj.getAppyPhases(currentOnly=True, \
layoutType=layoutType);
phase=phaseInfo['name'];
page=req.get('page', None) or contextObj.getDefaultEditPage();
x=contextObj.setLock(user, page);
page=req.get('page', None) or zobj.getDefaultEditPage();
x=zobj.setLock(user, page);
confirmMsg=req.get('confirmMsg', None);
groupedWidgets=contextObj.getGroupedAppyTypes(layoutType, page, \
groupedWidgets=zobj.getGroupedAppyTypes(layoutType, page, \
cssJs=cssJs)">
<x>:self.pxPagePrologue</x>
<!-- Warn the user that the form should be left via buttons -->
@ -837,8 +834,7 @@ class AbstractWrapper(object):
}]]>
</script>
<form id="appyForm" name="appyForm" method="post"
enctype="multipart/form-data"
action=":contextObj.absolute_url()+'/do'">
enctype="multipart/form-data" action=":zobj.absolute_url()+'/do'">
<input type="hidden" name="action" value="Update"/>
<input type="hidden" name="button" value=""/>
<input type="hidden" name="page" value=":page"/>