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