1 """abstract component class and base components definition for CubicWeb web client |
1 """abstract component class and base components definition for CubicWeb web client |
2 |
2 |
3 :organization: Logilab |
3 :organization: Logilab |
4 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 """ |
6 """ |
7 __docformat__ = "restructuredtext en" |
7 __docformat__ = "restructuredtext en" |
8 |
8 |
9 from cubicweb.common.appobject import Component, SingletonComponent |
9 from cubicweb.common.appobject import Component, SingletonComponent |
10 from cubicweb.common.utils import merge_dicts |
10 from cubicweb.common.utils import merge_dicts |
11 from cubicweb.common.view import VComponent, SingletonVComponent |
11 from cubicweb.common.view import VComponent, SingletonVComponent |
12 from cubicweb.common.registerers import action_registerer |
12 from cubicweb.common.registerers import action_registerer |
13 from cubicweb.common.selectors import (paginated_rset, one_line_rset, |
13 from cubicweb.common.selectors import (paginated_rset, one_line_rset, |
14 rql_condition, accept, primary_view, |
14 primary_view, match_context_prop, |
15 match_context_prop, has_relation, |
15 condition_compat) |
16 etype_rtype_selector) |
16 #rql_condition, accept, has_relation, etype_rtype_selector |
17 from cubicweb.common.uilib import html_escape |
17 from cubicweb.common.uilib import html_escape |
18 |
18 |
19 _ = unicode |
19 _ = unicode |
20 |
20 |
21 |
21 |
31 """ |
31 """ |
32 |
32 |
33 __registry__ = 'contentnavigation' |
33 __registry__ = 'contentnavigation' |
34 __registerer__ = action_registerer |
34 __registerer__ = action_registerer |
35 __selectors__ = (one_line_rset, primary_view, |
35 __selectors__ = (one_line_rset, primary_view, |
36 match_context_prop, etype_rtype_selector, |
36 match_context_prop, |
37 has_relation, accept, |
37 # etype_rtype_selector, |
38 rql_condition) |
38 # has_relation, accept, |
|
39 # rql_condition) |
|
40 ) |
|
41 registered = accepts_compat(condition_compat(VComponent.registered.im_func)) |
39 |
42 |
40 property_defs = { |
43 property_defs = { |
41 _('visible'): dict(type='Boolean', default=True, |
44 _('visible'): dict(type='Boolean', default=True, |
42 help=_('display the box or not')), |
45 help=_('display the box or not')), |
43 _('order'): dict(type='Int', default=99, |
46 _('order'): dict(type='Int', default=99, |
49 help=_('context where this component should be displayed')), |
52 help=_('context where this component should be displayed')), |
50 _('htmlclass'):dict(type='String', default='mainRelated', |
53 _('htmlclass'):dict(type='String', default='mainRelated', |
51 help=_('html class of the component')), |
54 help=_('html class of the component')), |
52 } |
55 } |
53 |
56 |
54 accepts = ('Any',) |
|
55 context = 'navcontentbottom' # 'footer' | 'header' | 'incontext' |
57 context = 'navcontentbottom' # 'footer' | 'header' | 'incontext' |
56 condition = None |
|
57 |
58 |
58 def call(self, view): |
59 def call(self, view): |
59 return self.cell_call(0, 0, view) |
60 return self.cell_call(0, 0, view) |
60 |
61 |
61 def cell_call(self, row, col, view): |
62 def cell_call(self, row, col, view): |
150 |
151 |
151 |
152 |
152 class RelatedObjectsVComponent(EntityVComponent): |
153 class RelatedObjectsVComponent(EntityVComponent): |
153 """a section to display some related entities""" |
154 """a section to display some related entities""" |
154 __selectors__ = (one_line_rset, primary_view, |
155 __selectors__ = (one_line_rset, primary_view, |
155 etype_rtype_selector, has_relation, |
156 match_context_prop, |
156 match_context_prop, accept) |
157 # etype_rtype_selector, has_relation, |
|
158 # accept) |
|
159 ) |
157 vid = 'list' |
160 vid = 'list' |
158 |
161 |
159 def rql(self): |
162 def rql(self): |
160 """override this method if you want to use a custom rql query. |
163 """override this method if you want to use a custom rql query. |
161 """ |
164 """ |