author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 26 Aug 2010 10:55:08 +0200 | |
branch | stable |
changeset 6159 | 0a1fce8ddc67 |
parent 5839 | 53cbdc5e0426 |
child 6140 | 65a619eb31c4 |
child 6407 | 595e6807dda5 |
permissions | -rw-r--r-- |
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 | 18 |
"""Generic boxes for CubicWeb web client: |
0 | 19 |
|
20 |
* actions box |
|
21 |
* possible views box |
|
22 |
||
23 |
additional (disabled by default) boxes |
|
24 |
* schema box |
|
25 |
* startup views box |
|
5839 | 26 |
""" |
0 | 27 |
|
28 |
__docformat__ = "restructuredtext en" |
|
1876 | 29 |
_ = unicode |
0 | 30 |
|
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
31 |
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
|
32 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2265
diff
changeset
|
33 |
from logilab.mtconverter import xml_escape |
0 | 34 |
|
1132 | 35 |
from cubicweb.selectors import match_user_groups, non_final_entity |
2265
4c028cb136a4
add import to remove deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
36 |
from cubicweb.view import EntityView |
4c028cb136a4
add import to remove deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
37 |
from cubicweb.schema import display_name |
0 | 38 |
from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem |
663 | 39 |
from cubicweb.web.box import BoxTemplate |
0 | 40 |
|
1450
8edb0806dde4
fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1285
diff
changeset
|
41 |
|
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
42 |
class EditBox(BoxTemplate): # XXX rename to ActionsBox |
0 | 43 |
""" |
44 |
box with all actions impacting the entity displayed: edit, copy, delete |
|
45 |
change state, add related entities |
|
46 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
47 |
__regid__ = 'edit_box' |
809 | 48 |
__select__ = BoxTemplate.__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
|
49 |
|
0 | 50 |
title = _('actions') |
51 |
order = 2 |
|
1450
8edb0806dde4
fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1285
diff
changeset
|
52 |
|
1247
3332c92d950c
give view when selecting actions
sylvain.thenault@logilab.fr
parents:
1242
diff
changeset
|
53 |
def call(self, view=None, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
54 |
_ = self._cw._ |
0 | 55 |
title = _(self.title) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
56 |
if self.cw_rset: |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
57 |
etypes = self.cw_rset.column_types(0) |
0 | 58 |
if len(etypes) == 1: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
59 |
plural = self.cw_rset.rowcount > 1 and 'plural' or '' |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
60 |
etypelabel = display_name(self._cw, iter(etypes).next(), plural) |
0 | 61 |
title = u'%s - %s' % (title, etypelabel.lower()) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
62 |
box = BoxWidget(title, self.__regid__, _class="greyBoxFrame") |
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 | 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, |
3491 | 67 |
view=view) |
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')) |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
69 |
for category, defaultmenu in (('mainactions', box), |
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 | 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 |
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
|
84 |
if box.is_empty() and len(self._menus_by_id) == 1 and not other_menu.is_empty(): |
0 | 85 |
box.items = other_menu.items |
86 |
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
|
87 |
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
|
88 |
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
|
89 |
self._menus_in_order.append(other_menu) |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
90 |
for submenu in 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
|
91 |
self.add_submenu(box, submenu) |
0 | 92 |
if not box.is_empty(): |
93 |
box.render(self.w) |
|
1450
8edb0806dde4
fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1285
diff
changeset
|
94 |
|
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
95 |
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
|
96 |
try: |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
97 |
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
|
98 |
except KeyError: |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
99 |
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
|
100 |
title = self._cw._(id) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
101 |
self._menus_by_id[id] = menu = BoxMenu(title) |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
102 |
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
|
103 |
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
|
104 |
return menu |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
105 |
|
0 | 106 |
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
|
107 |
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
|
108 |
if len(submenu.items) == 1 and not appendanyway: |
0 | 109 |
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
|
110 |
if submenu.label_prefix: |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
111 |
boxlink.label = u'%s %s' % (submenu.label_prefix, boxlink.label) |
0 | 112 |
box.append(boxlink) |
113 |
elif submenu.items: |
|
114 |
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
|
115 |
elif appendanyway: |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3084
diff
changeset
|
116 |
box.append(RawBoxItem(xml_escape(submenu.label))) |
0 | 117 |
|
118 |
||
119 |
class SearchBox(BoxTemplate): |
|
120 |
"""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
|
121 |
__regid__ = 'search_box' |
809 | 122 |
|
0 | 123 |
visible = True # enabled by default |
124 |
title = _('search') |
|
125 |
order = 0 |
|
126 |
formdef = u"""<form action="%s"> |
|
127 |
<table id="tsearch"><tr><td> |
|
128 |
<input id="norql" type="text" accesskey="q" tabindex="%s" title="search text" value="%s" name="rql" /> |
|
129 |
<input type="hidden" name="__fromsearchbox" value="1" /> |
|
130 |
<input type="hidden" name="subvid" value="tsearch" /> |
|
131 |
</td><td> |
|
852
105893288777
simplify css style
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
536
diff
changeset
|
132 |
<input tabindex="%s" type="submit" id="rqlboxsubmit" class="rqlsubmit" value="" /> |
0 | 133 |
</td></tr></table> |
134 |
</form>""" |
|
135 |
||
136 |
def call(self, view=None, **kwargs): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
137 |
req = self._cw |
0 | 138 |
if req.form.pop('__fromsearchbox', None): |
139 |
rql = req.form.get('rql', '') |
|
140 |
else: |
|
141 |
rql = '' |
|
142 |
form = self.formdef % (req.build_url('view'), req.next_tabindex(), |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2265
diff
changeset
|
143 |
xml_escape(rql), req.next_tabindex()) |
0 | 144 |
title = u"""<span onclick="javascript: toggleVisibility('rqlinput')">%s</span>""" % req._(self.title) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
145 |
box = BoxWidget(title, self.__regid__, _class="searchBoxFrame", islist=False, escape=False) |
0 | 146 |
box.append(BoxHtml(form)) |
1450
8edb0806dde4
fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1285
diff
changeset
|
147 |
box.render(self.w) |
0 | 148 |
|
149 |
||
150 |
# boxes disabled by default ################################################### |
|
151 |
||
152 |
class PossibleViewsBox(BoxTemplate): |
|
153 |
"""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
|
154 |
__regid__ = 'possible_views_box' |
809 | 155 |
__select__ = BoxTemplate.__select__ & match_user_groups('users', 'managers') |
1450
8edb0806dde4
fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1285
diff
changeset
|
156 |
|
809 | 157 |
visible = False |
0 | 158 |
title = _('possible views') |
159 |
order = 10 |
|
160 |
||
161 |
def call(self, **kwargs): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
162 |
box = BoxWidget(self._cw._(self.title), self.__regid__) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
163 |
views = [v for v in self._cw.vreg['views'].possible_views(self._cw, |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
164 |
rset=self.cw_rset) |
613 | 165 |
if v.category != 'startupview'] |
166 |
for category, views in self.sort_actions(views): |
|
0 | 167 |
menu = BoxMenu(category) |
613 | 168 |
for view in views: |
169 |
menu.append(self.box_action(view)) |
|
0 | 170 |
box.append(menu) |
171 |
if not box.is_empty(): |
|
172 |
box.render(self.w) |
|
173 |
||
125
979dbe0cade3
views with rss feed
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
107
diff
changeset
|
174 |
|
0 | 175 |
class StartupViewsBox(BoxTemplate): |
176 |
"""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
|
177 |
__regid__ = 'startup_views_box' |
0 | 178 |
visible = False # disabled by default |
179 |
title = _('startup views') |
|
180 |
order = 70 |
|
181 |
||
182 |
def call(self, **kwargs): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
183 |
box = BoxWidget(self._cw._(self.title), self.__regid__) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
184 |
for view in self._cw.vreg['views'].possible_views(self._cw, None): |
0 | 185 |
if view.category == 'startupview': |
186 |
box.append(self.box_action(view)) |
|
187 |
if not box.is_empty(): |
|
188 |
box.render(self.w) |
|
189 |
||
1263 | 190 |
|
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
191 |
# helper classes ############################################################## |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
192 |
|
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
193 |
class SideBoxView(EntityView): |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
194 |
"""helper view class to display some entities in a sidebox""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
195 |
__regid__ = 'sidebox' |
1450
8edb0806dde4
fix relation_mode implementation, remove trailing spaces
sylvain.thenault@logilab.fr
parents:
1285
diff
changeset
|
196 |
|
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
197 |
def call(self, boxclass='sideBox', title=u''): |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
198 |
"""display a list of entities by calling their <item_vid> view""" |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
199 |
if title: |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
200 |
self.w(u'<div class="sideBoxTitle"><span>%s</span></div>' % title) |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
201 |
self.w(u'<div class="%s"><div class="sideBoxBody">' % boxclass) |
5517
4b5577515722
[web] refactor side box to use autolimited view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
202 |
self.wview('autolimited', self.cw_rset, **self.cw_extra_kwargs) |
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
203 |
self.w(u'</div>\n</div>\n') |