[gen] Bugfix: getFormattedValue must produce a different value for strings with format=TEXT depending on the layout type.
This commit is contained in:
parent
a4a9acfcfb
commit
4009cf824c
12 changed files with 62 additions and 46 deletions
|
@ -1002,7 +1002,11 @@ class BaseMixin:
|
|||
# Compute common parts
|
||||
cssClass = self.getCssFor('title')
|
||||
# Get the title, with highlighted parts when relevant
|
||||
title = self.getShownValue('title')
|
||||
klass = self.getClass()
|
||||
if hasattr(klass, 'listTitle'):
|
||||
title = klass.listTitle(self.appy(), nav)
|
||||
else:
|
||||
title = self.getShownValue('title')
|
||||
if highlight: title = self.highlight(title)
|
||||
if mode == 'link':
|
||||
inPopup = inPopup or (target.target != '_self')
|
||||
|
@ -1557,23 +1561,22 @@ class BaseMixin:
|
|||
return False
|
||||
if parent.meta_type not in ('Folder', 'Temporary Folder'): return parent
|
||||
|
||||
def getShownValue(self, name='title', language=None):
|
||||
'''Call field.getShownValue on field named p_name.'''
|
||||
def getShownValue(self, name='title', layoutType='view', language=None):
|
||||
'''Call field.getShownValue on field named p_name'''
|
||||
field = self.getAppyType(name)
|
||||
return field.getShownValue(self, field.getValue(self),
|
||||
return field.getShownValue(self, field.getValue(self), layoutType,
|
||||
language=language)
|
||||
|
||||
def getBreadCrumb(self, inPopup=False):
|
||||
'''Gets breadcrumb info about this object and its parents (if it must
|
||||
be shown).'''
|
||||
# Return an empty breadcrumb if it must not be shown.
|
||||
# Return an empty breadcrumb if it must not be shown
|
||||
klass = self.getClass()
|
||||
if hasattr(klass, 'breadcrumb') and not klass.breadcrumb: return ()
|
||||
# Compute the breadcrumb
|
||||
title = self.getAppyType('title')
|
||||
res = [Object(url=self.getUrl(inPopup=inPopup),
|
||||
title=title.getShownValue(self, title.getValue(self)))]
|
||||
# In a popup: limit the breadcrumb to the current object.
|
||||
title=self.getShownValue('title'))]
|
||||
# In a popup, limit the breadcrumb to the current object
|
||||
if inPopup: return res
|
||||
parent = self.getParent()
|
||||
if parent: res = parent.getBreadCrumb() + res
|
||||
|
|
|
@ -150,11 +150,12 @@ class ToolWrapper(AbstractWrapper):
|
|||
</script>''')
|
||||
|
||||
pxLiveSearchResults = Px('''
|
||||
<x var="className=req['className'];
|
||||
klass=ztool.getAppyClass(className);
|
||||
search=ztool.getLiveSearch(klass, req['w_SearchableText']);
|
||||
zobjects=ztool.executeQuery(className, search=search, \
|
||||
maxResults=10).objects">
|
||||
<div var="className=req['className'];
|
||||
klass=ztool.getAppyClass(className);
|
||||
search=ztool.getLiveSearch(klass, req['w_SearchableText']);
|
||||
zobjects=ztool.executeQuery(className, search=search, \
|
||||
maxResults=10).objects"
|
||||
id=":'%s_LSResults' % className">
|
||||
<p if="not zobjects" class="lsNoResult">:_('query_no_result')</p>
|
||||
<div for="zobj in zobjects" style="padding: 3px 5px">
|
||||
<a href=":zobj.absolute_url()"
|
||||
|
@ -167,7 +168,7 @@ class ToolWrapper(AbstractWrapper):
|
|||
onclick=":'document.forms[%s].submit()' % \
|
||||
q('%s_LSForm' % className)">:_('search_results_all') + '...'</a>
|
||||
</div>
|
||||
</x>''')
|
||||
</div>''')
|
||||
|
||||
pxLiveSearch = Px('''
|
||||
<form var="formId='%s_LSForm' % className"
|
||||
|
|
|
@ -44,7 +44,7 @@ class AbstractWrapper(object):
|
|||
<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 -->
|
||||
<span if="nb == len(breadcrumb)-1">:bc.title</span>
|
||||
<span if="nb == len(breadcrumb)-1">::bc.title</span>
|
||||
<!-- Display a link for parent objects -->
|
||||
<a if="nb != len(breadcrumb)-1" href=":bc.url">:bc.title</a>
|
||||
</x>
|
||||
|
@ -874,7 +874,7 @@ class AbstractWrapper(object):
|
|||
|
||||
def getField(self, name): return self.o.getAppyType(name)
|
||||
|
||||
def getValue(self, name, formatted=False, language=None):
|
||||
def getValue(self, name, layoutType='view', formatted=False, language=None):
|
||||
'''Gets the possibly p_formatted value of field p_name. If this
|
||||
formatting implies translating something, it will be done in
|
||||
p_language, or in the user language if not specified. If the "shown"
|
||||
|
@ -887,7 +887,7 @@ class AbstractWrapper(object):
|
|||
if not formatted: return val
|
||||
method = (formatted == 'shown') and 'getShownValue' or \
|
||||
'getFormattedValue'
|
||||
return getattr(field, method)(obj, val, language=language)
|
||||
return getattr(field, method)(obj, val, layoutType, language=language)
|
||||
|
||||
def getLabel(self, name, type='field'):
|
||||
'''Gets the translated label of field named p_name. If p_type is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue