# HG changeset patch # User Sylvain Thénault # Date 1259771996 -3600 # Node ID 569771016abb89a0b9a38b2c91fc85c55ae196ec # Parent 1d36d9904c41e9503116850f355796b951ae111b add a fourth item to 'view box' defintion, dispctrl, so that we can later globally sort all boxes instead of having view boxes before component boxes. 'view' boxes order is configured through uicfg.primaryview_display_ctrl, 'component' boxes order through the cwproperty system. diff -r 1d36d9904c41 -r 569771016abb web/views/primary.py --- a/web/views/primary.py Wed Dec 02 16:57:17 2009 +0100 +++ b/web/views/primary.py Wed Dec 02 17:39:56 2009 +0100 @@ -158,7 +158,13 @@ """ for box in boxes: if isinstance(box, tuple): - label, rset, vid = box + try: + label, rset, vid, dispctrl = box + except ValueError: + warn('box views should now be defined as a 4-uple (label, rset, vid, dispctrl), ' + 'please update %s' % self.__class__.__name__, + DeprecationWarning) + label, rset, vid = box self.w(u'') @@ -178,11 +184,19 @@ continue label = display_name(self.req, rschema.type, role) vid = dispctrl.get('vid', 'sidebox') - sideboxes.append( (label, rset, vid) ) + sideboxes.append( (label, rset, vid, dispctrl) ) sideboxes += self.vreg['boxes'].possible_vobjects( self.req, rset=self.rset, row=self.row, view=self, context='incontext') - return sideboxes + # XXX since we've two sorted list, it may be worth using bisect + def get_order(x): + if isinstance(x, tuple): + # x is a view box (label, rset, vid, dispctrl) + # default to 1000 so view boxes occurs after component boxes + return x[-1].get('order', 1000) + # x is a component box + return x.propval('order') + return sorted(sideboxes, key=get_order) def _section_def(self, entity, where): rdefs = []