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