web/views/tableview.py
changeset 8425 b86bdc343c18
parent 8349 fdb796435d7b
parent 8418 3f87aa655466
child 8464 895e34d9ae0d
child 8480 086cff6a306a
equal deleted inserted replaced
8412:09432a572a44 8425:b86bdc343c18
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
   133     * `add_view_actions`, when true, actions returned by view.table_actions()
   133     * `add_view_actions`, when true, actions returned by view.table_actions()
   134       will be included in the actions menu.
   134       will be included in the actions menu.
   135 
   135 
   136     * `header_column_idx`, if not `None`, should be a colum index or a set of
   136     * `header_column_idx`, if not `None`, should be a colum index or a set of
   137       column index where <th> tags should be generated instead of <td>
   137       column index where <th> tags should be generated instead of <td>
   138     """
   138     """ #'# make emacs happier
   139     __regid__ = 'table_layout'
   139     __regid__ = 'table_layout'
   140     cssclass = "listing"
   140     cssclass = "listing"
   141     needs_css = ('cubicweb.tableview.css',)
   141     needs_css = ('cubicweb.tableview.css',)
   142     needs_js = ()
   142     needs_js = ()
   143     display_filter = None    # None / 'top' / 'bottom'
   143     display_filter = None    # None / 'top' / 'bottom'
   330     Attributes on this base class are:
   330     Attributes on this base class are:
   331 
   331 
   332     :attr: `header`, the column header. If None, default to `_(colid)`
   332     :attr: `header`, the column header. If None, default to `_(colid)`
   333     :attr: `addcount`, if True, add the table size in parenthezis beside the header
   333     :attr: `addcount`, if True, add the table size in parenthezis beside the header
   334     :attr: `trheader`, should the header be translated
   334     :attr: `trheader`, should the header be translated
   335     :attr: `escapeheader`, should the header be xml_escape'd
   335     :attr: `escapeheader`, should the header be xml_escaped
   336     :attr: `sortable`, tell if the column is sortable
   336     :attr: `sortable`, tell if the column is sortable
   337     :attr: `view`, the table view
   337     :attr: `view`, the table view
   338     :attr: `_cw`, the request object
   338     :attr: `_cw`, the request object
   339     :attr: `colid`, the column identifier
   339     :attr: `colid`, the column identifier
   340     :attr: `attributes`, dictionary of attributes to put on the HTML tag when
   340     :attr: `attributes`, dictionary of attributes to put on the HTML tag when
   341             the cell is rendered
   341             the cell is rendered
   342     """
   342     """ #'# make emacs
   343     attributes = {}
   343     attributes = {}
   344     empty_cell_content = u'&#160;'
   344     empty_cell_content = u'&#160;'
   345 
   345 
   346     def __init__(self, header=None, addcount=False, trheader=True,
   346     def __init__(self, header=None, addcount=False, trheader=True,
   347                  escapeheader=True, sortable=True):
   347                  escapeheader=True, sortable=True):
   574 
   574 
   575     This table class use the :class:`RsetTableColRenderer` as default column
   575     This table class use the :class:`RsetTableColRenderer` as default column
   576     renderer.
   576     renderer.
   577 
   577 
   578     .. autoclass:: RsetTableColRenderer
   578     .. autoclass:: RsetTableColRenderer
   579     """
   579     """    #'# make emacs happier
   580     __regid__ = 'table'
   580     __regid__ = 'table'
   581     # selector trick for bw compath with the former :class:TableView
   581     # selector trick for bw compath with the former :class:TableView
   582     __select__ = AnyRsetView.__select__ & (~match_kwargs(
   582     __select__ = AnyRsetView.__select__ & (~match_kwargs(
   583         'title', 'subvid', 'displayfilter', 'headers', 'displaycols',
   583         'title', 'subvid', 'displayfilter', 'headers', 'displaycols',
   584         'displayactions', 'actions', 'divid', 'cellvids', 'cellattrs',
   584         'displayactions', 'actions', 'divid', 'cellvids', 'cellattrs',
   597         # specific subclasses of this view usually don't want to be linkable
   597         # specific subclasses of this view usually don't want to be linkable
   598         # since they depends on a particular shape (being linkable meaning view
   598         # since they depends on a particular shape (being linkable meaning view
   599         # may be listed in possible views
   599         # may be listed in possible views
   600         return self.__regid__ == 'table'
   600         return self.__regid__ == 'table'
   601 
   601 
   602     def call(self, headers=None, displaycols=None, cellvids=None, **kwargs):
   602     def call(self, headers=None, displaycols=None, cellvids=None,
       
   603              paginate=None, **kwargs):
   603         if self.headers:
   604         if self.headers:
   604             self.headers = [h and self._cw._(h) for h in self.headers]
   605             self.headers = [h and self._cw._(h) for h in self.headers]
   605         if (headers or displaycols or cellvids):
   606         if (headers or displaycols or cellvids or paginate):
   606             if headers is not None:
   607             if headers is not None:
   607                 self.headers = headers
   608                 self.headers = headers
   608             if displaycols is not None:
   609             if displaycols is not None:
   609                 self.displaycols = displaycols
   610                 self.displaycols = displaycols
   610             if cellvids is not None:
   611             if cellvids is not None:
   611                 self.cellvids = cellvids
   612                 self.cellvids = cellvids
       
   613             if paginate is not None:
       
   614                 self.paginable = paginate
   612         if kwargs:
   615         if kwargs:
   613             # old table view arguments that we can safely ignore thanks to
   616             # old table view arguments that we can safely ignore thanks to
   614             # selectors
   617             # selectors
   615             if len(kwargs) > 1:
   618             if len(kwargs) > 1:
   616                 msg = '[3.14] %s arguments are deprecated' % ', '.join(kwargs)
   619                 msg = '[3.14] %s arguments are deprecated' % ', '.join(kwargs)