4 :copyright: 2001-2009 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.selectors import (paginated_rset, one_line_rset, |
9 from cubicweb.selectors import ( |
10 primary_view, match_context_prop, |
10 paginated_rset, one_line_rset, primary_view, match_context_prop, |
11 condition_compat, accepts_compat) |
11 condition_compat, accepts_compat, has_relation_compat) |
12 from cubicweb.common.appobject import Component, SingletonComponent |
12 from cubicweb.common.appobject import Component, SingletonComponent, ComponentMixIn |
13 from cubicweb.common.utils import merge_dicts |
13 from cubicweb.common.utils import merge_dicts |
14 from cubicweb.common.view import VComponent, SingletonVComponent |
14 from cubicweb.common.view import View |
15 from cubicweb.common.registerers import action_registerer |
15 from cubicweb.common.registerers import action_registerer |
16 #rql_condition, accept, has_relation, etype_rtype_selector |
|
17 from cubicweb.common.uilib import html_escape |
16 from cubicweb.common.uilib import html_escape |
18 |
17 |
19 _ = unicode |
18 _ = unicode |
20 |
19 |
21 |
20 |
22 class EntityVComponent(VComponent): |
21 class EntityVComponent(ComponentMixIn, View): |
23 """abstract base class for additinal components displayed in content |
22 """abstract base class for additinal components displayed in content |
24 headers and footer according to: |
23 headers and footer according to: |
25 |
24 |
26 * the displayed entity's type |
25 * the displayed entity's type |
27 * a context (currently 'header' or 'footer') |
26 * a context (currently 'header' or 'footer') |
30 .context class attributes |
29 .context class attributes |
31 """ |
30 """ |
32 |
31 |
33 __registry__ = 'contentnavigation' |
32 __registry__ = 'contentnavigation' |
34 __registerer__ = action_registerer |
33 __registerer__ = action_registerer |
35 __selectors__ = (one_line_rset, primary_view, |
34 __selectors__ = (one_line_rset, primary_view, match_context_prop,) |
36 match_context_prop, |
35 registered = accepts_compat(has_relation_compat(condition_compat(View.registered.im_func))) |
37 # etype_rtype_selector, |
|
38 # has_relation, accept, |
|
39 # rql_condition) |
|
40 ) |
|
41 registered = accepts_compat(condition_compat(VComponent.registered.im_func)) |
|
42 |
36 |
43 property_defs = { |
37 property_defs = { |
44 _('visible'): dict(type='Boolean', default=True, |
38 _('visible'): dict(type='Boolean', default=True, |
45 help=_('display the box or not')), |
39 help=_('display the box or not')), |
46 _('order'): dict(type='Int', default=99, |
40 _('order'): dict(type='Int', default=99, |
61 |
55 |
62 def cell_call(self, row, col, view): |
56 def cell_call(self, row, col, view): |
63 raise NotImplementedError() |
57 raise NotImplementedError() |
64 |
58 |
65 |
59 |
66 class NavigationComponent(VComponent): |
60 class NavigationComponent(ComponentMixIn, View): |
67 """abstract base class for navigation components""" |
61 """abstract base class for navigation components""" |
|
62 id = 'navigation' |
68 __selectors__ = (paginated_rset,) |
63 __selectors__ = (paginated_rset,) |
69 id = 'navigation' |
64 |
70 page_size_property = 'navigation.page-size' |
65 page_size_property = 'navigation.page-size' |
71 start_param = '__start' |
66 start_param = '__start' |
72 stop_param = '__stop' |
67 stop_param = '__stop' |
73 page_link_templ = u'<span class="slice"><a href="%s" title="%s">%s</a></span>' |
68 page_link_templ = u'<span class="slice"><a href="%s" title="%s">%s</a></span>' |
74 selected_page_link_templ = u'<span class="selectedSlice"><a href="%s" title="%s">%s</a></span>' |
69 selected_page_link_templ = u'<span class="selectedSlice"><a href="%s" title="%s">%s</a></span>' |
150 return self.next_page_link_templ % (url, title, content) |
145 return self.next_page_link_templ % (url, title, content) |
151 |
146 |
152 |
147 |
153 class RelatedObjectsVComponent(EntityVComponent): |
148 class RelatedObjectsVComponent(EntityVComponent): |
154 """a section to display some related entities""" |
149 """a section to display some related entities""" |
155 __selectors__ = (one_line_rset, primary_view, |
|
156 match_context_prop, |
|
157 # etype_rtype_selector, has_relation, |
|
158 # accept) |
|
159 ) |
|
160 vid = 'list' |
150 vid = 'list' |
161 |
151 |
162 def rql(self): |
152 def rql(self): |
163 """override this method if you want to use a custom rql query. |
153 """override this method if you want to use a custom rql query""" |
164 """ |
|
165 return None |
154 return None |
166 |
155 |
167 def cell_call(self, row, col, view=None): |
156 def cell_call(self, row, col, view=None): |
168 rql = self.rql() |
157 rql = self.rql() |
169 if rql is None: |
158 if rql is None: |