[gen] New ajax system: bugfixes.

This commit is contained in:
Gaetan Delannay 2015-02-05 05:21:51 +01:00
parent a985f188e0
commit d23b9be5e5
2 changed files with 82 additions and 89 deletions

View file

@ -231,6 +231,7 @@ class Ref(Field):
# PX that displays referred objects as a list
pxViewList = Px('''
<div id=":ajaxHookId">
<div if="not innerRef or mayAdd or mayLink" style="margin-bottom: 4px">
<x if="field.collapsible and objects">:collapse.px</x>
<span if="subLabel" class="discreet">:_(subLabel)</span>
@ -288,23 +289,21 @@ class Ref(Field):
var2="@currentNumber=currentNumber + 1;
rowCss=loop.tied.odd and 'even' or 'odd'">:obj.pxViewAsTied</x>
</table>
<!-- Global actions -->
<x if="mayEdit and checkboxes">:field.pxGlobalActions</x>
<!-- (Bottom) navigation -->
<x>:tool.pxNavigate</x>
<!-- Init checkboxes if present. -->
<script if="checkboxes"
type="text/javascript">:'initCbs(%s)' % q(ajaxHookId)
</script>''')
<script if="checkboxes">:'initCbs(%s)' % q(ajaxHookId)</script>
</div>''')
# PX that displays the list of objects the user may select to insert into a
# ref field with link="list".
pxViewPickList = Px('''
<x var="innerRef=False;
ajaxHookId=ajaxHookId|'%s_%s_poss' % (zobj.id, field.name);
layoutType='view';
inMenu=False;
inPickList=True;
startNumber=field.getStartNumber('list', req, ajaxHookId);
info=field.getPossibleValues(zobj, startNumber=startNumber, \
@ -326,6 +325,7 @@ class Ref(Field):
(q(ajaxHookId), q(zobj.absolute_url()), q(innerRef));
changeOrder=False;
changeNumber=False;
numbered=False;
checkboxes=field.getAttribute(zobj, 'checkboxes') and \
(totalNumber &gt; 1);
showSubTitles=showSubTitles|\
@ -439,14 +439,12 @@ class Ref(Field):
<!-- JS tables storing checkbox statuses if checkboxes are enabled -->
<script if="checkboxesEnabled and renderAll and (render == 'list')"
type="text/javascript">:field.getCbJsInit(zobj)</script>
<div if="linkList and renderAll and mayEdit"
var2="ajaxHookId='%s_%s_poss' % (zobj.id, field.name)"
id=":ajaxHookId">:field.pxViewPickList</div>
<x if="linkList and renderAll and mayEdit"
var2="ajaxHookId='%s_%s_poss' % \
(zobj.id, field.name)">:field.pxViewPickList</x>
<x if="render == 'list'"
var2="subLabel=linkList and 'selected_objects' or None">
<div if="renderAll" id=":ajaxHookId">:field.pxViewList</div>
<x if="not renderAll">:field.pxViewList</x>
</x>
var2="subLabel=linkList and \
'selected_objects' or None">:field.pxViewList</x>
<x if="render in ('menus','minimal')">:getattr(field, 'pxView%s' % \
render.capitalize())</x>
</x>''')

View file

@ -303,10 +303,10 @@ class AbstractWrapper(object):
# This PX displays an object's history
pxHistory = Px('''
<x var="startNumber=req.get('startNumber', 0);
startNumber=int(startNumber);
<div id="appyHistory"
var="startNumber=int(req.get('startNumber', 0));
batchSize=int(req.get('maxPerPage', 5));
historyInfo=zobj.getHistory(startNumber,batchSize=batchSize)"
historyInfo=zobj.getHistory(startNumber, batchSize=batchSize)"
if="historyInfo.events"
var2="objs=historyInfo.events;
totalNumber=historyInfo.totalNumber;
@ -370,7 +370,7 @@ class AbstractWrapper(object):
</td>
</tr>
</table>
</x>''')
</div>''')
pxTransitions = Px('''
<form var="transitions=targetObj.getTransitions()" if="transitions"
@ -429,12 +429,7 @@ class AbstractWrapper(object):
<!-- Object history -->
<tr if="hasHistory">
<td colspan="2">
<span id=":collapse.id" style=":collapse.style">
<div var="ajaxHookId=zobj.id + '_history'" id=":ajaxHookId">
<script type="text/javascript">::'askObjectHistory(%s,%s,%d,0)' % \
(q(ajaxHookId), q(zobj.absolute_url()), \
historyMaxPerPage)</script>
</div>
<span id=":collapse.id" style=":collapse.style"><x>:obj.pxHistory</x>
</span>
</td>
</tr>