[gen] Allow for ajax-based master-slave relationships within the search screen for Ref fields.

This commit is contained in:
Gaetan Delannay 2014-03-05 13:25:36 +01:00
parent 584e38abef
commit 6d6c842f12
16 changed files with 79 additions and 88 deletions

View file

@ -495,6 +495,7 @@ class ToolWrapper(AbstractWrapper):
refInfo=req.get('ref', None);
searchInfo=ztool.getSearchInfo(className, refInfo);
cssJs={};
layoutType='search';
x=ztool.getCssJs(searchInfo.fields, 'edit', cssJs)">
<!-- Include type-specific CSS and JS. -->
@ -506,7 +507,6 @@ class ToolWrapper(AbstractWrapper):
<!-- Search title -->
<h1><x>:_('%s_plural'%className)</x> &ndash;
<x>:_('search_title')</x></h1>
<br/>
<!-- Form for searching objects of request/className. -->
<form name="search" action=":ztool.absolute_url()+'/do'" method="post">
<input type="hidden" name="action" value="SearchObjects"/>
@ -516,13 +516,11 @@ class ToolWrapper(AbstractWrapper):
<table width="100%">
<tr for="searchRow in ztool.getGroupedSearchFields(searchInfo)"
valign="top">
<td for="field in searchRow"
<td for="field in searchRow" class="search"
var2="scolspan=field and field.scolspan or 1"
colspan=":scolspan"
width=":'%d%%' % ((100/searchInfo.nbOfColumns)*scolspan)">
<x if="field"
var2="name=field.name;
widgetName='w_%s' % name">:field.pxSearch</x>
<x if="field">:field.pxRender</x>
<br class="discreet"/>
</td>
</tr>

View file

@ -575,7 +575,9 @@ class AbstractWrapper(object):
lang=ztool.getUserLanguage(); q=ztool.quote;
action=req.get('action', None);
px=req['px'].split(':');
field=(len(px) == 2) and zobj.getAppyType(px[0]) or None;
className=(len(px) == 3) and px[0] or None;
field=className and zobj.getAppyType(px[1], className) or None;
field=(len(px) == 2) and zobj.getAppyType(px[0]) or field;
dir=ztool.getLanguageDirection(lang);
dleft=(dir == 'ltr') and 'left' or 'right';
dright=(dir == 'ltr') and 'right' or 'left';
@ -590,7 +592,7 @@ class AbstractWrapper(object):
<!-- Then, call the PX on p_obj or on p_field. -->
<x if="not field">:getattr(obj, px[0])</x>
<x if="field">:getattr(field, px[1])</x>
<x if="field">:getattr(field, px[-1])</x>
</x>''')
# --------------------------------------------------------------------------