[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
|
# 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.
|
# the URL for allowing to navigate from one object to the next/previous one.
|
||||||
pxObjectTitle = Px('''
|
pxObjectTitle = Px('''
|
||||||
<x var="includeShownInfo=includeShownInfo|False;
|
<x var="navInfo='ref.%s.%s:%s.%d.%d' % (zobj.id, field.name, \
|
||||||
navInfo='ref.%s.%s:%s.%d.%d' % (zobj.id, field.name, \
|
|
||||||
field.pageName, loop.tied.nb + 1 + startNumber, totalNumber);
|
field.pageName, loop.tied.nb + 1 + startNumber, totalNumber);
|
||||||
navInfo=(not field.isBack and not inPickList) and navInfo or '';
|
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>
|
<x>::tied.o.getSupTitle(navInfo)</x>
|
||||||
<a var="pageName=field.isBack and field.back.pageName or 'main';
|
<x>::tied.o.getListTitle(nav=navInfo, target=target, page=pageName, \
|
||||||
linkInPopup=inPopup or (target.target != '_self');
|
inPopup=inPopup)</x>
|
||||||
fullUrl=tied.o.getUrl(page=pageName, nav=navInfo, \
|
<span style=":showSubTitles and 'display:inline' or 'display:none'"
|
||||||
inPopup=linkInPopup)"
|
name="subTitle" var="sub=tied.o.getSubTitle()" if="sub">::sub</span>
|
||||||
href=":fullUrl" class=":cssClass" target=":target.target"
|
</x>''')
|
||||||
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>''')
|
|
||||||
|
|
||||||
# This PX displays buttons for triggering global actions on several linked
|
# This PX displays buttons for triggering global actions on several linked
|
||||||
# objects (delete many, unlink many,...)
|
# objects (delete many, unlink many,...)
|
||||||
|
|
|
@ -951,6 +951,44 @@ class BaseMixin:
|
||||||
if hasattr(obj, 'getSubBreadCrumb'): return obj.getSubBreadCrumb()
|
if hasattr(obj, 'getSubBreadCrumb'): return obj.getSubBreadCrumb()
|
||||||
return ''
|
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# Workflow methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
def initializeWorkflow(self):
|
def initializeWorkflow(self):
|
||||||
'''Called when an object is created, be it temp or not, for initializing
|
'''Called when an object is created, be it temp or not, for initializing
|
||||||
|
|
|
@ -317,17 +317,13 @@ class ToolWrapper(AbstractWrapper):
|
||||||
<x if="mayView"
|
<x if="mayView"
|
||||||
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=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>
|
<x var="sup=zobj.getSupTitle(navInfo)" if="sup">::sup</x>
|
||||||
<a if="enableLinks" class=":cssClass"
|
<x>::zobj.getListTitle(mode=titleMode, nav=navInfo, target=target, \
|
||||||
var2="linkInPopup=inPopup or (target.target != '_self')"
|
page=pageName, inPopup=inPopup, selectJs=selectJs)</x>
|
||||||
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>
|
|
||||||
<span style=":showSubTitles and 'display:inline' or 'display:none'"
|
<span style=":showSubTitles and 'display:inline' or 'display:none'"
|
||||||
name="subTitle" var="sub=zobj.getSubTitle()" if="sub">::sub</span>
|
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(ajaxHookId), q(ztool.absolute_url()), q(className), \
|
||||||
q(searchName),int(inPopup));
|
q(searchName),int(inPopup));
|
||||||
showNewSearch=showNewSearch|True;
|
showNewSearch=showNewSearch|True;
|
||||||
enableLinks=enableLinks|not inPopup;
|
|
||||||
newSearchUrl='%s/search?className=%s%s' % \
|
newSearchUrl='%s/search?className=%s%s' % \
|
||||||
(ztool.absolute_url(), className, refUrlPart);
|
(ztool.absolute_url(), className, refUrlPart);
|
||||||
showSubTitles=req.get('showSubTitles', 'true') == 'true';
|
showSubTitles=req.get('showSubTitles', 'true') == 'true';
|
||||||
|
|
Loading…
Reference in a new issue