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

View file

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