[gen] Created method mixin.getListTitle that is responsible for displaying an object's title in the various lists (queries, refs).
This commit is contained in:
parent
701eae1b19
commit
dcf90f2b94
|
@ -38,21 +38,16 @@ class Ref(Field):
|
|||
# defined. If we are on a forward reference, the "nav" parameter is added to
|
||||
# the URL for allowing to navigate from one object to the next/previous one.
|
||||
pxObjectTitle = Px('''
|
||||
<x var="includeShownInfo=includeShownInfo|False;
|
||||
navInfo='ref.%s.%s:%s.%d.%d' % (zobj.id, field.name, \
|
||||
<x var="navInfo='ref.%s.%s:%s.%d.%d' % (zobj.id, field.name, \
|
||||
field.pageName, loop.tied.nb + 1 + startNumber, totalNumber);
|
||||
navInfo=(not field.isBack and not inPickList) and navInfo or '';
|
||||
cssClass=tied.o.getCssFor('title')">
|
||||
pageName=field.isBack and field.back.pageName or 'main'">
|
||||
<x>::tied.o.getSupTitle(navInfo)</x>
|
||||
<a var="pageName=field.isBack and field.back.pageName or 'main';
|
||||
linkInPopup=inPopup or (target.target != '_self');
|
||||
fullUrl=tied.o.getUrl(page=pageName, nav=navInfo, \
|
||||
inPopup=linkInPopup)"
|
||||
href=":fullUrl" class=":cssClass" target=":target.target"
|
||||
onclick=":target.openPopup">:(not includeShownInfo) and \
|
||||
tied.o.getShownValue('title') or field.getReferenceLabel(tied)
|
||||
</a><span name="subTitle" style=":showSubTitles and 'display:inline' or \
|
||||
'display:none'">::tied.o.getSubTitle()</span></x>''')
|
||||
<x>::tied.o.getListTitle(nav=navInfo, target=target, page=pageName, \
|
||||
inPopup=inPopup)</x>
|
||||
<span style=":showSubTitles and 'display:inline' or 'display:none'"
|
||||
name="subTitle" var="sub=tied.o.getSubTitle()" if="sub">::sub</span>
|
||||
</x>''')
|
||||
|
||||
# This PX displays buttons for triggering global actions on several linked
|
||||
# objects (delete many, unlink many,...)
|
||||
|
|
|
@ -951,6 +951,44 @@ class BaseMixin:
|
|||
if hasattr(obj, 'getSubBreadCrumb'): return obj.getSubBreadCrumb()
|
||||
return ''
|
||||
|
||||
def getListTitle(self, mode='link', nav='', target=None, page='main',
|
||||
inPopup=False, selectJs=None):
|
||||
'''Gets the title as it must appear in lists of objects (ie in lists of
|
||||
tied objects in a Ref, in query results...).
|
||||
|
||||
In most cases, a title must appear as a link that leads to the object
|
||||
view layout. In this case (p_mode == "link"):
|
||||
* p_nav is the navigation parameter allowing navigation between
|
||||
this object and others;
|
||||
* p_target specifies if the link must be opened in the popup or not;
|
||||
* p_page specifies which page to show on the target object view;
|
||||
* p_inPopup indicates if we are already in the popup or not.
|
||||
|
||||
Another p_mode is "select". In this case, we are in a popup for
|
||||
selecting objects: every title must not be a link, but clicking on it
|
||||
must trigger Javascript code (in p_selectJs) that will select this
|
||||
object.
|
||||
|
||||
The last p_mode is "text". In this case, we simply show the object
|
||||
title but with no tied action (link, select).
|
||||
'''
|
||||
# Compute common parts
|
||||
cssClass = self.getCssFor('title')
|
||||
title = self.getShownValue('title')
|
||||
if mode == 'link':
|
||||
inPopup = inPopup or (target.target != '_self')
|
||||
url = self.getUrl(page=page, nav=nav, inPopup=inPopup)
|
||||
onClick = target.openPopup and \
|
||||
(' onclick="%s"' % target.openPopup) or ''
|
||||
res = '<a href="%s" class="%s" target="%s"%s>%s</a>' % \
|
||||
(url, cssClass, target.target, onClick, title)
|
||||
elif mode == 'select':
|
||||
res = '<span class="%s clickable" onclick="%s">%s</span>' % \
|
||||
(cssClass, selectJs, title)
|
||||
elif mode == 'text':
|
||||
res = '<span class="%s">%s</span>' % (cssClass, title)
|
||||
return res
|
||||
|
||||
# Workflow methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def initializeWorkflow(self):
|
||||
'''Called when an object is created, be it temp or not, for initializing
|
||||
|
|
|
@ -317,17 +317,13 @@ class ToolWrapper(AbstractWrapper):
|
|||
<x if="mayView"
|
||||
var2="navInfo='search.%s.%s.%d.%d' % \
|
||||
(className, searchName, startNumber+currentNumber, totalNumber);
|
||||
cssClass=zobj.getCssFor('title')">
|
||||
titleMode=inPopup and 'select' or 'link';
|
||||
pageName=zobj.getDefaultViewPage();
|
||||
selectJs=inPopup and 'onSelectObject(%s,%s,%s)' % (q(cbId), \
|
||||
q(rootHookId), q(uiSearch.initiator.url))">
|
||||
<x var="sup=zobj.getSupTitle(navInfo)" if="sup">::sup</x>
|
||||
<a if="enableLinks" class=":cssClass"
|
||||
var2="linkInPopup=inPopup or (target.target != '_self')"
|
||||
target=":target.target" onclick=":target.openPopup"
|
||||
href=":zobj.getUrl(nav=navInfo, page=zobj.getDefaultViewPage(), \
|
||||
inPopup=linkInPopup)">:zobj.getShownValue('title')</a>
|
||||
<span if="not enableLinks"
|
||||
class=":not checkboxes and cssClass or ('%s clickable' % cssClass)"
|
||||
onclick=":checkboxes and ('onSelectObject(%s,%s,%s)' % (q(cbId), \
|
||||
q(rootHookId), q(uiSearch.initiator.url))) or ''">:obj.title</span>
|
||||
<x>::zobj.getListTitle(mode=titleMode, nav=navInfo, target=target, \
|
||||
page=pageName, inPopup=inPopup, selectJs=selectJs)</x>
|
||||
<span style=":showSubTitles and 'display:inline' or 'display:none'"
|
||||
name="subTitle" var="sub=zobj.getSubTitle()" if="sub">::sub</span>
|
||||
|
||||
|
@ -478,7 +474,6 @@ class ToolWrapper(AbstractWrapper):
|
|||
(q(ajaxHookId), q(ztool.absolute_url()), q(className), \
|
||||
q(searchName),int(inPopup));
|
||||
showNewSearch=showNewSearch|True;
|
||||
enableLinks=enableLinks|not inPopup;
|
||||
newSearchUrl='%s/search?className=%s%s' % \
|
||||
(ztool.absolute_url(), className, refUrlPart);
|
||||
showSubTitles=req.get('showSubTitles', 'true') == 'true';
|
||||
|
|
Loading…
Reference in a new issue