author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
Fri, 22 Mar 2013 20:10:19 +0100 | |
changeset 8773 | 21edcb0a5ed7 |
parent 8694 | d901c36bcfce |
child 9445 | 65d93a4fd11c |
permissions | -rw-r--r-- |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8080
diff
changeset
|
1 |
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
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:
5148
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""Bases HTML components: |
19 |
||
20 |
* the rql input form |
|
21 |
* the logged user link |
|
5854 | 22 |
""" |
0 | 23 |
__docformat__ = "restructuredtext en" |
1937 | 24 |
_ = unicode |
0 | 25 |
|
2313 | 26 |
from logilab.mtconverter import xml_escape |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8080
diff
changeset
|
27 |
from logilab.common.registry import yes |
6396
a9e4c51fc1c1
[login ui] cleanup and somewhat bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
28 |
from logilab.common.deprecation import class_renamed |
0 | 29 |
from rql import parse |
30 |
||
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8080
diff
changeset
|
31 |
from cubicweb.predicates import (match_form_params, match_context, |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8080
diff
changeset
|
32 |
multi_etypes_rset, configuration_values, |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8080
diff
changeset
|
33 |
anonymous_user, authenticated_user) |
1699 | 34 |
from cubicweb.schema import display_name |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
35 |
from cubicweb.utils import wrap_on_write |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4004
diff
changeset
|
36 |
from cubicweb.uilib import toggle_action |
8665
e65af61bde7d
[uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8505
diff
changeset
|
37 |
from cubicweb.web import component |
6800
3f3d576b87d9
[web action] refactor box menu handling, fixing #1401943 on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6678
diff
changeset
|
38 |
from cubicweb.web.htmlwidgets import MenuWidget, PopupBoxMenu |
0 | 39 |
|
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
40 |
VISIBLE_PROP_DEF = { |
1968
d3de0f44b57b
components should be visible by default, applmessages components should not be hideable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1937
diff
changeset
|
41 |
_('visible'): dict(type='Boolean', default=True, |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
42 |
help=_('display the component or not')), |
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
43 |
} |
0 | 44 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1514
diff
changeset
|
45 |
class RQLInputForm(component.Component): |
0 | 46 |
"""build the rql input form, usually displayed in the header""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
47 |
__regid__ = 'rqlinput' |
2799
b703639614e7
refactor property handling to avoid name conflicts
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
48 |
cw_property_defs = VISIBLE_PROP_DEF |
2120
ed1cd652b343
rqlinput should have its default visible property to false
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
49 |
visible = False |
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2120
diff
changeset
|
50 |
|
0 | 51 |
def call(self, view=None): |
8044
8ea1ad44ecac
[rqlinput] cleanup (use req everywhere) and fix html validation issue (input outside fieldset)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7437
diff
changeset
|
52 |
req = self._cw |
0 | 53 |
if hasattr(view, 'filter_box_context_info'): |
54 |
rset = view.filter_box_context_info()[0] |
|
55 |
else: |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
56 |
rset = self.cw_rset |
0 | 57 |
# display multilines query as one line |
8044
8ea1ad44ecac
[rqlinput] cleanup (use req everywhere) and fix html validation issue (input outside fieldset)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7437
diff
changeset
|
58 |
rql = rset is not None and rset.printable_rql(encoded=False) or req.form.get('rql', '') |
0 | 59 |
rql = rql.replace(u"\n", u" ") |
8505
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
8326
diff
changeset
|
60 |
rql_suggestion_comp = self._cw.vreg['components'].select_or_none('rql.suggestions', self._cw) |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
8326
diff
changeset
|
61 |
if rql_suggestion_comp is not None: |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
8326
diff
changeset
|
62 |
# enable autocomplete feature only if the rql |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
8326
diff
changeset
|
63 |
# suggestions builder is available |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
8326
diff
changeset
|
64 |
self._cw.add_css('jquery.ui.css') |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
8326
diff
changeset
|
65 |
self._cw.add_js(('cubicweb.ajax.js', 'jquery.ui.js')) |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
8326
diff
changeset
|
66 |
self._cw.add_onload('$("#rql").autocomplete({source: "%s"});' |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
8326
diff
changeset
|
67 |
% (req.build_url('json', fname='rql_suggest'))) |
8044
8ea1ad44ecac
[rqlinput] cleanup (use req everywhere) and fix html validation issue (input outside fieldset)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7437
diff
changeset
|
68 |
self.w(u'''<div id="rqlinput" class="%s"><form action="%s"><fieldset> |
0 | 69 |
<input type="text" id="rql" name="rql" value="%s" title="%s" tabindex="%s" accesskey="q" class="searchField" /> |
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2799
diff
changeset
|
70 |
''' % (not self.cw_propval('visible') and 'hidden' or '', |
8044
8ea1ad44ecac
[rqlinput] cleanup (use req everywhere) and fix html validation issue (input outside fieldset)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7437
diff
changeset
|
71 |
req.build_url('view'), xml_escape(rql), req._('full text or RQL query'), req.next_tabindex())) |
8ea1ad44ecac
[rqlinput] cleanup (use req everywhere) and fix html validation issue (input outside fieldset)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7437
diff
changeset
|
72 |
if req.search_state[0] != 'normal': |
0 | 73 |
self.w(u'<input type="hidden" name="__mode" value="%s"/>' |
74 |
% ':'.join(req.search_state[1])) |
|
8044
8ea1ad44ecac
[rqlinput] cleanup (use req everywhere) and fix html validation issue (input outside fieldset)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7437
diff
changeset
|
75 |
self.w(u'</fieldset></form></div>') |
0 | 76 |
|
77 |
||
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
78 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
79 |
class HeaderComponent(component.CtxComponent): # XXX rename properly along with related context |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
80 |
"""if the user is the anonymous user, build a link to login else display a menu |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
81 |
with user'action (preference, logout, etc...) |
0 | 82 |
""" |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
83 |
__abstract__ = True |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
84 |
cw_property_defs = component.override_ctx( |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
85 |
component.CtxComponent, |
8326
2e793b2cdb57
[view] breadcrumbs layout broken with long elements (closes #1347486)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8244
diff
changeset
|
86 |
vocabulary=['header-center', 'header-left', 'header-right', ]) |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
87 |
# don't want user to hide this component using an cwproperty |
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
88 |
site_wide = True |
8326
2e793b2cdb57
[view] breadcrumbs layout broken with long elements (closes #1347486)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8244
diff
changeset
|
89 |
context = _('header-center') |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
90 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
91 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
92 |
class ApplLogo(HeaderComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
93 |
"""build the instance logo, usually displayed in the header""" |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
94 |
__regid__ = 'logo' |
7428
5338d895b891
[web session] fix session handling so we get a chance to have for instance the 'forgotpwd' feature working on a site where anonymous are not allowed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7101
diff
changeset
|
95 |
__select__ = yes() # no need for a cnx |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
96 |
order = -1 |
8326
2e793b2cdb57
[view] breadcrumbs layout broken with long elements (closes #1347486)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8244
diff
changeset
|
97 |
context = _('header-left') |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
98 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
99 |
def render(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
100 |
w(u'<a href="%s"><img id="logo" src="%s" alt="logo"/></a>' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
101 |
% (self._cw.base_url(), self._cw.uiprops['LOGO'])) |
0 | 102 |
|
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
103 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
104 |
class ApplicationName(HeaderComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
105 |
"""display the instance name""" |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
106 |
__regid__ = 'appliname' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
107 |
|
7101
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6800
diff
changeset
|
108 |
# XXX support kwargs for compat with other components which gets the view as |
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6800
diff
changeset
|
109 |
# argument |
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6800
diff
changeset
|
110 |
def render(self, w, **kwargs): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
111 |
title = self._cw.property_value('ui.site-title') |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
112 |
if title: |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
113 |
w(u'<span id="appliName"><a href="%s">%s</a></span>' % ( |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
114 |
self._cw.base_url(), xml_escape(title))) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
115 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
116 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
117 |
class CookieLoginComponent(HeaderComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
118 |
__regid__ = 'anonuserlink' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
119 |
__select__ = (HeaderComponent.__select__ & anonymous_user() |
6396
a9e4c51fc1c1
[login ui] cleanup and somewhat bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
120 |
& configuration_values('auth-mode', 'cookie')) |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
121 |
context = 'header-right' |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
122 |
loginboxid = 'popupLoginBox' |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
123 |
_html = u"""[<a class="logout" title="%s" href="javascript: |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
124 |
cw.htmlhelpers.popupLoginBox('%s', '__login');">%s</a>]""" |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
125 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
126 |
def render(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
127 |
# XXX bw compat, though should warn about subclasses redefining call |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
128 |
self.w = w |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
129 |
self.call() |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
130 |
|
0 | 131 |
def call(self): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
132 |
self.w(self._html % (self._cw._('login / password'), |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
133 |
self.loginboxid, self._cw._('i18n_login_popup'))) |
6474
745b20ac1a68
[components] remove old deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6462
diff
changeset
|
134 |
self._cw.view('logform', rset=self.cw_rset, id=self.loginboxid, |
745b20ac1a68
[components] remove old deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6462
diff
changeset
|
135 |
klass='%s hidden' % self.loginboxid, title=False, |
745b20ac1a68
[components] remove old deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6462
diff
changeset
|
136 |
showmessage=False, w=self.w) |
0 | 137 |
|
6396
a9e4c51fc1c1
[login ui] cleanup and somewhat bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
138 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
139 |
class HTTPLoginComponent(CookieLoginComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
140 |
__select__ = (HeaderComponent.__select__ & anonymous_user() |
6396
a9e4c51fc1c1
[login ui] cleanup and somewhat bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
141 |
& configuration_values('auth-mode', 'http')) |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
142 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
143 |
def render(self, w): |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
144 |
# this redirects to the 'login' controller which in turn |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
145 |
# will raise a 401/Unauthorized |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
146 |
req = self._cw |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
147 |
w(u'[<a class="logout" title="%s" href="%s">%s</a>]' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
148 |
% (req._('login / password'), req.build_url('login'), req._('login'))) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
149 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
150 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
151 |
_UserLink = class_renamed('_UserLink', HeaderComponent) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
152 |
AnonUserLink = class_renamed('AnonUserLink', CookieLoginComponent) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
153 |
AnonUserLink.__abstract__ = True |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
154 |
AnonUserLink.__select__ &= yes(1) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
155 |
|
0 | 156 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
157 |
class AnonUserStatusLink(HeaderComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
158 |
__regid__ = 'userstatus' |
7428
5338d895b891
[web session] fix session handling so we get a chance to have for instance the 'forgotpwd' feature working on a site where anonymous are not allowed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7101
diff
changeset
|
159 |
__select__ = anonymous_user() |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
160 |
context = _('header-right') |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
161 |
order = HeaderComponent.order - 10 |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
162 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
163 |
def render(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
164 |
w(u'<span class="caption">%s</span>' % self._cw._('anonymous')) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
165 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
166 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
167 |
class AuthenticatedUserStatus(AnonUserStatusLink): |
7428
5338d895b891
[web session] fix session handling so we get a chance to have for instance the 'forgotpwd' feature working on a site where anonymous are not allowed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7101
diff
changeset
|
168 |
__select__ = authenticated_user() |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
169 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
170 |
def render(self, w): |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
171 |
# display useractions and siteactions |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
172 |
actions = self._cw.vreg['actions'].possible_actions(self._cw, rset=self.cw_rset) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
173 |
box = MenuWidget('', 'userActionsBox', _class='', islist=False) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
174 |
menu = PopupBoxMenu(self._cw.user.login, isitem=False) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
175 |
box.append(menu) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
176 |
for action in actions.get('useractions', ()): |
6800
3f3d576b87d9
[web action] refactor box menu handling, fixing #1401943 on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6678
diff
changeset
|
177 |
menu.append(self.action_link(action)) |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
178 |
if actions.get('useractions') and actions.get('siteactions'): |
6800
3f3d576b87d9
[web action] refactor box menu handling, fixing #1401943 on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6678
diff
changeset
|
179 |
menu.append(self.separator()) |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
180 |
for action in actions.get('siteactions', ()): |
6800
3f3d576b87d9
[web action] refactor box menu handling, fixing #1401943 on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6678
diff
changeset
|
181 |
menu.append(self.action_link(action)) |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
182 |
box.render(w=w) |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
183 |
|
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
184 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1514
diff
changeset
|
185 |
class ApplicationMessage(component.Component): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
186 |
"""display messages given using the __message parameter into a special div |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
187 |
section |
0 | 188 |
""" |
7430
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
189 |
__select__ = yes() |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
190 |
__regid__ = 'applmessages' |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
191 |
# don't want user to hide this component using an cwproperty |
2799
b703639614e7
refactor property handling to avoid name conflicts
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
192 |
cw_property_defs = {} |
0 | 193 |
|
7430
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
194 |
def call(self, msg=None): |
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
195 |
if msg is None: |
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
196 |
msgs = [] |
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
197 |
if self._cw.cnx: |
8244
c7d89541e3c5
[web-repo] use transaction data, not session data to inform ui about sources error. Closes #2192577
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8190
diff
changeset
|
198 |
srcmsg = self._cw.get_shared_data('sources_error', pop=True, txdata=True) |
7437
a1f48d7c8a03
[ui message] fix regression introduced by 7429:ef5165fa99e0, leading to 'None' message displayed in the ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7430
diff
changeset
|
199 |
if srcmsg: |
a1f48d7c8a03
[ui message] fix regression introduced by 7429:ef5165fa99e0, leading to 'None' message displayed in the ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7430
diff
changeset
|
200 |
msgs.append(srcmsg) |
7430
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
201 |
reqmsg = self._cw.message # XXX don't call self._cw.message twice |
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
202 |
if reqmsg: |
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
203 |
msgs.append(reqmsg) |
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
204 |
else: |
ef5165fa99e0
[ui messages] make application message component works when request has no cnx set and support for explicit message given through render argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7428
diff
changeset
|
205 |
msgs = [msg] |
0 | 206 |
self.w(u'<div id="appMsg" onclick="%s" class="%s">\n' % |
207 |
(toggle_action('appMsg'), (msgs and ' ' or 'hidden'))) |
|
208 |
for msg in msgs: |
|
6140
65a619eb31c4
[boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5854
diff
changeset
|
209 |
self.w(u'<div class="message" id="%s">%s</div>' % (self.domid, msg)) |
0 | 210 |
self.w(u'</div>') |
211 |
||
212 |
||
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1514
diff
changeset
|
213 |
class EtypeRestrictionComponent(component.Component): |
0 | 214 |
"""displays the list of entity types contained in the resultset |
215 |
to be able to filter accordingly. |
|
216 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
217 |
__regid__ = 'etypenavigation' |
8080
623432dc1deb
[etype restriction component] rql 0.31 doesn't accept anymore a variable ref as add_type_restriction argument. Closes #2086983
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8044
diff
changeset
|
218 |
__select__ = multi_etypes_rset() | match_form_params( |
623432dc1deb
[etype restriction component] rql 0.31 doesn't accept anymore a variable ref as add_type_restriction argument. Closes #2086983
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8044
diff
changeset
|
219 |
'__restrtype', '__restrtypes', '__restrrql') |
2799
b703639614e7
refactor property handling to avoid name conflicts
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
220 |
cw_property_defs = VISIBLE_PROP_DEF |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
221 |
# don't want user to hide this component using an cwproperty |
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
222 |
site_wide = True |
0 | 223 |
visible = False # disabled by default |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
224 |
|
0 | 225 |
def call(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
226 |
_ = self._cw._ |
0 | 227 |
self.w(u'<div id="etyperestriction">') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
228 |
restrtype = self._cw.form.get('__restrtype') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
229 |
restrtypes = self._cw.form.get('__restrtypes', '').split(',') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
230 |
restrrql = self._cw.form.get('__restrrql') |
0 | 231 |
if not restrrql: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
232 |
rqlst = self.cw_rset.syntax_tree() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
233 |
restrrql = rqlst.as_string(self._cw.encoding, self.cw_rset.args) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
234 |
restrtypes = self.cw_rset.column_types(0) |
0 | 235 |
else: |
236 |
rqlst = parse(restrrql) |
|
237 |
html = [] |
|
238 |
on_etype = False |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
239 |
etypes = sorted((display_name(self._cw, etype).capitalize(), etype) |
0 | 240 |
for etype in restrtypes) |
241 |
for elabel, etype in etypes: |
|
242 |
if etype == restrtype: |
|
243 |
html.append(u'<span class="selected">%s</span>' % elabel) |
|
244 |
on_etype = True |
|
245 |
else: |
|
246 |
rqlst.save_state() |
|
247 |
for select in rqlst.children: |
|
8080
623432dc1deb
[etype restriction component] rql 0.31 doesn't accept anymore a variable ref as add_type_restriction argument. Closes #2086983
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8044
diff
changeset
|
248 |
select.add_type_restriction(select.selection[0].variable, etype) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
249 |
newrql = rqlst.as_string(self._cw.encoding, self.cw_rset.args) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
250 |
url = self._cw.build_url(rql=newrql, __restrrql=restrrql, |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
251 |
__restrtype=etype, __restrtypes=','.join(restrtypes)) |
0 | 252 |
html.append(u'<span><a href="%s">%s</a></span>' % ( |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2218
diff
changeset
|
253 |
xml_escape(url), elabel)) |
0 | 254 |
rqlst.recover() |
255 |
if on_etype: |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
256 |
url = self._cw.build_url(rql=restrrql) |
0 | 257 |
html.insert(0, u'<span><a href="%s">%s</a></span>' % ( |
258 |
url, _('Any'))) |
|
259 |
else: |
|
260 |
html.insert(0, u'<span class="selected">%s</span>' % _('Any')) |
|
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2650
diff
changeset
|
261 |
self.w(u' | '.join(html)) |
0 | 262 |
self.w(u'</div>') |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
263 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
264 |
# contextual components ######################################################## |
3840
2eff4348b1e4
prepare support for a 'context toolbar', used in tracker but will much probably be backported in default primary view. Turn pdfview component into a toolbar element
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3818
diff
changeset
|
265 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
266 |
|
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
267 |
class MetaDataComponent(component.EntityCtxComponent): |
4004
c52619c738a5
api renaming update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
268 |
__regid__ = 'metadata' |
3844
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3840
diff
changeset
|
269 |
context = 'navbottom' |
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3840
diff
changeset
|
270 |
order = 1 |
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3840
diff
changeset
|
271 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
272 |
def render_body(self, w): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
273 |
self.entity.view('metadata', w=w) |
3844
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3840
diff
changeset
|
274 |
|
3848 | 275 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
276 |
class SectionLayout(component.Layout): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
277 |
__select__ = match_context('navtop', 'navbottom', |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
278 |
'navcontenttop', 'navcontentbottom') |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
279 |
cssclass = 'section' |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
280 |
|
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
281 |
def render(self, w): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
282 |
if self.init_rendering(): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
283 |
view = self.cw_extra_kwargs['view'] |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
284 |
w(u'<div class="%s %s" id="%s">' % (self.cssclass, view.cssclass, |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
285 |
view.domid)) |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
286 |
with wrap_on_write(w, '<h4>') as wow: |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
287 |
view.render_title(wow) |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
288 |
view.render_body(w) |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
289 |
w(u'</div>\n') |