[gen] Optimized PXs, that are almost ready. This is the last gen version where PTs are still working.
This commit is contained in:
parent
efd918f175
commit
d385b8514e
14 changed files with 207 additions and 210 deletions
|
@ -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')"
|
||||
|
|
|
@ -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)' % \
|
||||
|
|
|
@ -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 < startDate);
|
||||
tooLate=endDate and not tooEarly and (date > 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>''')
|
||||
|
||||
|
|
|
@ -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>''')
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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> -
|
||||
<i class="discreet">'%sKb' % (info.size / 1024)"></i>
|
||||
|
|
|
@ -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>''')
|
||||
|
||||
|
|
133
fields/ref.py
133
fields/ref.py
|
@ -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)>1) and changeOrder and canWrite"
|
||||
var2="objectIndex=field.getIndexOf(contextObj, obj);
|
||||
<td if="not isBack and (len(zobjects)>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 > 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&className=%s&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)<=1);
|
||||
(len(zobjects)<=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,53 +179,54 @@ 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&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, \
|
||||
layoutType='result')">:field.pxView</x>
|
||||
<x var="zobj=ztied; obj=ztied.appy(); layoutType='cell';
|
||||
innerRef=True"
|
||||
if="zobj.showField(field.name, \
|
||||
layoutType='result')">:field.pxView</x>
|
||||
</x>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -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):
|
||||
|
|
|
@ -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>''')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue