# HG changeset patch # User Sylvain Thénault # Date 1258107384 -3600 # Node ID 2eff4348b1e4748e529224ac9b191f709e6f522a # Parent 84c9aab84d8cb9dba027e6638f22ce9ca0421d03 prepare support for a 'context toolbar', used in tracker but will much probably be backported in default primary view. Turn pdfview component into a toolbar element diff -r 84c9aab84d8c -r 2eff4348b1e4 web/component.py --- a/web/component.py Fri Nov 13 11:14:48 2009 +0100 +++ b/web/component.py Fri Nov 13 11:16:24 2009 +0100 @@ -42,14 +42,14 @@ help=_('display the component or not')), _('order'): dict(type='Int', default=99, help=_('display order of the component')), - _('context'): dict(type='String', default='header', + _('context'): dict(type='String', default='navtop', vocabulary=(_('navtop'), _('navbottom'), - _('navcontenttop'), _('navcontentbottom')), - #vocabulary=(_('header'), _('incontext'), _('footer')), + _('navcontenttop'), _('navcontentbottom'), + _('ctxtoolbar')), help=_('context where this component should be displayed')), } - context = 'navcontentbottom' # 'footer' | 'header' | 'incontext' + context = 'navcontentbottom' def call(self, view=None): return self.cell_call(0, 0, view=view) diff -r 84c9aab84d8c -r 2eff4348b1e4 web/data/cubicweb.css --- a/web/data/cubicweb.css Fri Nov 13 11:14:48 2009 +0100 +++ b/web/data/cubicweb.css Fri Nov 13 11:16:24 2009 +0100 @@ -592,6 +592,15 @@ display: inline; } +div.ctxtoolbar { + float: right; + padding-left: 24px; + position: relative; +} +div.toolbarButton { + display: inline; +} + /***************************************/ /* messages */ /***************************************/ diff -r 84c9aab84d8c -r 2eff4348b1e4 web/views/basecomponents.py --- a/web/views/basecomponents.py Fri Nov 13 11:14:48 2009 +0100 +++ b/web/views/basecomponents.py Fri Nov 13 11:16:24 2009 +0100 @@ -204,21 +204,18 @@ self.w(u' | '.join(html)) self.w(u'') -class PdfViewComponent(component.Component): - id = 'pdfview' - __select__ = yes() + +class PdfViewComponent(component.EntityVComponent): + id = 'view_page_as_pdf' + context = 'ctxtoolbar' - context = 'header' - property_defs = { - _('visible'): dict(type='Boolean', default=True, - help=_('display the pdf icon or not')), - } - - def call(self, vid): - entity = self.entity(0,0) - url = entity.absolute_url(vid=vid, __template='pdf-main-template') - self.w(u'%s' % - (xml_escape(url), self.req._('download page as pdf'))) + def cell_call(self, row, col, view): + entity = self.entity(row, col) + url = entity.absolute_url(vid=view.id, __template='pdf-main-template') + iconurl = self.req.build_url('data/pdf_icon.gif') + label = self.req._('Download page as pdf') + self.w(u'%s' % + (xml_escape(url), label, iconurl, label))