web/views/boxes.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 25 Aug 2010 10:01:11 +0200
changeset 6140 65a619eb31c4
parent 5839 53cbdc5e0426
child 6141 b8287e54b528
permissions -rw-r--r--
[boxes] introduce new boxes system * separate box content generation from its layout * refactor css classes to allow moving boxes and still get consistent ui On the way to contentnavigation/boxes unification (in a later patch) * * * some fixes for the previous (default_new_boxes_system) patch * * * some fixes for the previous (default_new_boxes_system) patch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     1
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
5839
53cbdc5e0426 cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5517
diff changeset
    18
"""Generic boxes for CubicWeb web client:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
* actions box
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    21
* search box
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    23
Additional boxes (disabled by default):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
* schema box
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    25
* possible views box
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
* startup views box
5839
53cbdc5e0426 cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5517
diff changeset
    27
"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
__docformat__ = "restructuredtext en"
1876
b06a797448aa cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1848
diff changeset
    30
_ = unicode
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    32
from warnings import warn
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    33
2312
af4d8f75c5db use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2265
diff changeset
    34
from logilab.mtconverter import xml_escape
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    35
from logilab.common.deprecation import class_deprecated
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    37
from cubicweb import Unauthorized
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    38
from cubicweb.selectors import (match_user_groups, match_context, match_kwargs,
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    39
                                non_final_entity, nonempty_rset)
2265
4c028cb136a4 add import to remove deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    40
from cubicweb.view import EntityView
4c028cb136a4 add import to remove deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    41
from cubicweb.schema import display_name
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    42
from cubicweb.web import box, htmlwidgets
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    44
# XXX bw compat, some cubes import this class from here
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    45
BoxTemplate = box.BoxTemplate
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    46
BoxHtml = htmlwidgets.BoxHtml
1450
8edb0806dde4 fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
    47
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    48
class EditBox(box.Box): # XXX rename to ActionsBox
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    49
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
    box with all actions impacting the entity displayed: edit, copy, delete
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    51
    change state, add related entities
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
    53
    __regid__ = 'edit_box'
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    54
    __select__ = box.Box.__select__ & non_final_entity()
1150
2d1b721fded9 remove rtags/methods to handle the action box from Entity, move it to the action box...
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    55
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
    title = _('actions')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
    order = 2
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    58
    contextual = True
1450
8edb0806dde4 fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
    59
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    60
    def init_rendering(self):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    61
        super(EditBox, self).init_rendering()
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
    62
        _ = self._cw._
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    63
        self._menus_in_order = []
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    64
        self._menus_by_id = {}
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
        # build list of actions
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
    66
        actions = self._cw.vreg['actions'].possible_actions(self._cw, self.cw_rset,
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    67
                                                            **self.cw_extra_kwargs)
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    68
        other_menu = self._get_menu('moreactions', _('more actions'))
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    69
        for category, defaultmenu in (('mainactions', self),
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    70
                                      ('moreactions', other_menu),
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    71
                                      ('addrelated', None)):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
            for action in actions.get(category, ()):
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    73
                if category == 'addrelated':
3511
581de819106f fix warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
    74
                    warn('[3.5] "addrelated" category is deprecated, use '
581de819106f fix warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
    75
                         '"moreactions" category w/ "addrelated" submenu',
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    76
                         DeprecationWarning)
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    77
                    defaultmenu = self._get_menu('addrelated', _('add'), _('add'))
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    78
                if action.submenu:
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    79
                    menu = self._get_menu(action.submenu)
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    80
                else:
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    81
                    menu = defaultmenu
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    82
                action.fill_menu(self, menu)
3916
6e7af0e8e524 more conditions have to be verified before unfolding the 'more actions' menu content directly into the box
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3511
diff changeset
    83
        # if we've nothing but actions in the other_menu, add them directly into the box
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    84
        if not self.items and len(self._menus_by_id) == 1 and not other_menu.is_empty():
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    85
            self.items = other_menu.items
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    86
        else: # ensure 'more actions' menu appears last
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    87
            self._menus_in_order.remove(other_menu)
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
    88
            self._menus_in_order.append(other_menu)
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    89
            for submenu in self._menus_in_order:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    90
                self.add_submenu(self, submenu)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    91
        if not self.items:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    92
            raise box.EmptyComponent()
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    93
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    94
    def render_title(self, w):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    95
        title = self._cw._(self.title)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    96
        if self.cw_rset:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    97
            etypes = self.cw_rset.column_types(0)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    98
            if len(etypes) == 1:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
    99
                plural = self.cw_rset.rowcount > 1 and 'plural' or ''
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   100
                etypelabel = display_name(self._cw, iter(etypes).next(), plural)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   101
                title = u'%s - %s' % (title, etypelabel.lower())
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   102
        w(title)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   103
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   104
    def render_body(self, w):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   105
        self.render_items(w)
1450
8edb0806dde4 fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
   106
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   107
    def _get_menu(self, id, title=None, label_prefix=None):
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   108
        try:
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   109
            return self._menus_by_id[id]
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   110
        except KeyError:
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   111
            if title is None:
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   112
                title = self._cw._(id)
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   113
            self._menus_by_id[id] = menu = htmlwidgets.BoxMenu(title)
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   114
            menu.label_prefix = label_prefix
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   115
            self._menus_in_order.append(menu)
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   116
            return menu
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   117
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   118
    def add_submenu(self, box, submenu, label_prefix=None):
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   119
        appendanyway = getattr(submenu, 'append_anyway', False)
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   120
        if len(submenu.items) == 1 and not appendanyway:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   121
            boxlink = submenu.items[0]
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   122
            if submenu.label_prefix:
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   123
                # XXX iirk
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   124
                if hasattr(boxlink, 'label'):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   125
                    boxlink.label = u'%s %s' % (submenu.label_prefix, boxlink.label)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   126
                else:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   127
                    submenu.items[0] = u'%s %s' % (submenu.label_prefix, boxlink)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   128
            box.append(boxlink)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   129
        elif submenu.items:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   130
            box.append(submenu)
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3084
diff changeset
   131
        elif appendanyway:
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   132
            box.append(xml_escape(submenu.label))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   133
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   134
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   135
class SearchBox(box.Box):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   136
    """display a box with a simple search form"""
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
   137
    __regid__ = 'search_box'
809
31962f99770b fix box selectors
sylvain.thenault@logilab.fr
parents: 742
diff changeset
   138
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   139
    title = _('search')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   140
    order = 0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   141
    formdef = u"""<form action="%s">
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   142
<table id="tsearch"><tr><td>
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   143
<input id="norql" type="text" accesskey="q" tabindex="%s" title="search text" value="%s" name="rql" />
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   144
<input type="hidden" name="__fromsearchbox" value="1" />
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   145
<input type="hidden" name="subvid" value="tsearch" />
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   146
</td><td>
852
105893288777 simplify css style
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 536
diff changeset
   147
<input tabindex="%s" type="submit" id="rqlboxsubmit" class="rqlsubmit" value="" />
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   148
 </td></tr></table>
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   149
 </form>"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   150
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   151
    def render_title(self, w):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   152
        w(u"""<span onclick="javascript: toggleVisibility('rqlinput')">%s</span>"""
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   153
          % self._cw._(self.title))
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   154
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   155
    def render_body(self, w):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   156
        if self._cw.form.pop('__fromsearchbox', None):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   157
            rql = self._cw.form.get('rql', '')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   158
        else:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   159
            rql = ''
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   160
        w(self.formdef % (self._cw.build_url('view'), self._cw.next_tabindex(),
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   161
                          xml_escape(rql), self._cw.next_tabindex()))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   162
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   163
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   164
# boxes disabled by default ###################################################
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   165
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   166
class PossibleViewsBox(box.Box):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   167
    """display a box containing links to all possible views"""
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
   168
    __regid__ = 'possible_views_box'
1450
8edb0806dde4 fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
   169
809
31962f99770b fix box selectors
sylvain.thenault@logilab.fr
parents: 742
diff changeset
   170
    visible = False
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   171
    title = _('possible views')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   172
    order = 10
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   173
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   174
    def init_rendering(self):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   175
        self.views = [v for v in self._cw.vreg['views'].possible_views(self._cw,
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   176
                                                                       rset=self.cw_rset)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   177
                      if v.category != 'startupview']
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   178
        if not self.views:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   179
            raise box.EmptyComponent()
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   180
        self.items = []
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   181
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   182
    def render_body(self, w):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   183
        for category, views in box.sort_by_category(self.views):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   184
            menu = htmlwidgets.BoxMenu(category)
613
e059279de6cf more cleanup
sylvain.thenault@logilab.fr
parents: 612
diff changeset
   185
            for view in views:
e059279de6cf more cleanup
sylvain.thenault@logilab.fr
parents: 612
diff changeset
   186
                menu.append(self.box_action(view))
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   187
            self.append(menu)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   188
        self.render_items(w)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   189
125
979dbe0cade3 views with rss feed
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 107
diff changeset
   190
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   191
class StartupViewsBox(PossibleViewsBox):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   192
    """display a box containing links to all startup views"""
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
   193
    __regid__ = 'startup_views_box'
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   194
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   195
    visible = False # disabled by default
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   196
    title = _('startup views')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   197
    order = 70
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   198
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   199
    def init_rendering(self):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   200
        self.views = [v for v in self._cw.vreg['views'].possible_views(self._cw)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   201
                      if v.category == 'startupview']
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   202
        if not self.views:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   203
            raise box.EmptyComponent()
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   204
        self.items = []
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   205
1263
01152fffd593 backport default branch
sylvain.thenault@logilab.fr
parents: 1181 1247
diff changeset
   206
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   207
class RsetBox(box.Box):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   208
    """helper view class to display an rset in a sidebox"""
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   209
    __select__ = nonempty_rset() & match_kwargs('title', 'vid')
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   210
    __regid__ = 'rsetbox'
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   211
    cw_property_defs = {}
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   212
    context = 'incontext'
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   213
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   214
    @property
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   215
    def domid(self):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   216
        return super(RsetBox, self).domid + unicode(abs(id(self)))
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   217
    def render_title(self, w):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   218
        w(self.cw_extra_kwargs['title'])
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   219
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   220
    def render_body(self, w):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   221
        self._cw.view(self.cw_extra_kwargs['vid'], self.cw_rset, w=w)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   222
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   223
 # helper classes ##############################################################
824
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 811
diff changeset
   224
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 811
diff changeset
   225
class SideBoxView(EntityView):
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 811
diff changeset
   226
    """helper view class to display some entities in a sidebox"""
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   227
    __metaclass__ = class_deprecated
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   228
    __deprecation_warning__ = 'SideBoxView is deprecated, use RsetBox instead'
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   229
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
   230
    __regid__ = 'sidebox'
1450
8edb0806dde4 fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
   231
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   232
    def call(self, **kwargs):
824
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 811
diff changeset
   233
        """display a list of entities by calling their <item_vid> view"""
6140
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   234
        box = self._cw.vreg['boxes'].select('rsetbox', self._cw, rset=self.cw_rset,
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   235
                                            vid='autolimited', title=title,
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   236
                                            **self.cw_extra_kwargs)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   237
        box.render(self.w)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   238
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   239
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   240
class ContextualBoxLayout(box.Layout):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   241
    __select__ = match_context('incontext', 'left', 'right') & box.contextual()
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   242
    # predefined class in cubicweb.css: contextualBox | contextFreeBox
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   243
    # XXX: navigationBox | actionBox
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   244
    cssclass = 'contextualBox'
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   245
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   246
    def render(self, w):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   247
        view = self.cw_extra_kwargs['view']
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   248
        try:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   249
            view.init_rendering()
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   250
        except Unauthorized, ex:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   251
            self.warning("can't render %s: %s", view, ex)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   252
            return
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   253
        except box.EmptyComponent:
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   254
            return
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   255
        w(u'<div class="%s %s" id="%s">' % (self.cssclass, view.cssclass,
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   256
                                            view.domid))
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   257
        w(u'<div class="boxTitle"><span>')
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   258
        view.render_title(w)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   259
        w(u'</span></div>\n<div class="boxBody">')
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   260
        view.render_body(w)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   261
        # boxFooter div is a CSS place holder (for shadow for example)
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   262
        w(u'</div><div class="boxFooter"></div></div>\n')
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   263
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   264
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   265
class ContextFreeBoxLayout(ContextualBoxLayout):
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   266
    __select__ = match_context('incontext', 'left', 'right') & ~box.contextual()
65a619eb31c4 [boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5839
diff changeset
   267
    cssclass = 'contextFreeBox'