author | Katia Saurfelt <katia.saurfelt@logilab.fr> |
Thu, 17 Sep 2009 19:38:04 +0200 | |
branch | stable |
changeset 3298 | caef98aa4a98 |
parent 2391 | 59a2def75e93 |
child 3311 | 6934be37e948 |
permissions | -rw-r--r-- |
928
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
1 |
"""Set of tree-building widgets, based on jQuery treeview plugin |
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
2 |
|
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
3 |
:organization: Logilab |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1844
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
928
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
5 |
: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:
1844
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
928
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
7 |
""" |
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
8 |
__docformat__ = "restructuredtext en" |
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
9 |
|
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
10 |
from logilab.common.decorators import monkeypatch |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2216
diff
changeset
|
11 |
from logilab.mtconverter import xml_escape |
923
7c184924d492
unwanted merge : Backed out changeset 4328bcbd748e
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
12 |
|
1828
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
13 |
from cubicweb.utils import make_uid |
0 | 14 |
from cubicweb.interfaces import ITree |
981
d86d1ee3b60e
fix some imports, update treeview for 3.2
sylvain.thenault@logilab.fr
parents:
939
diff
changeset
|
15 |
from cubicweb.selectors import implements |
d86d1ee3b60e
fix some imports, update treeview for 3.2
sylvain.thenault@logilab.fr
parents:
939
diff
changeset
|
16 |
from cubicweb.view import EntityView |
0 | 17 |
|
928
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
18 |
def treecookiename(treeid): |
2391
59a2def75e93
[treeview] nicer cookie name
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
19 |
return str('%s-treestate' % treeid) |
928
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
20 |
|
0 | 21 |
class TreeView(EntityView): |
22 |
id = 'treeview' |
|
150
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
23 |
itemvid = 'treeitemview' |
443 | 24 |
css_classes = 'treeview widget' |
25 |
title = _('tree view') |
|
916
968f00dd9a24
[treeview] (in progress) use less magic, having something that now allows prepopulating a part of the tree
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
472
diff
changeset
|
26 |
|
3298
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
27 |
def call(self, subvid=None, treeid=None, initial_load=True, initial_thru_ajax=False): |
0 | 28 |
if subvid is None: |
2209
2b91abd9f5a4
[treeview] avoid potential interference with subvid param from form
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1977
diff
changeset
|
29 |
subvid = self.req.form.pop('treesubvid', 'oneline') # consume it |
1828
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
30 |
if treeid is None: |
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
31 |
treeid = self.req.form.pop('treeid', None) |
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
32 |
if treeid is None: |
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
33 |
self.warning('Tree state won\'t be properly restored after next reload') |
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
34 |
treeid = make_uid('throw away uid') |
3298
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
35 |
toplevel_thru_ajax = self.req.form.pop('treeview_top', False) or initial_thru_ajax |
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
36 |
toplevel = toplevel_thru_ajax or (initial_load and not self.req.form.get('fname')) |
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
37 |
ulid = ' ' |
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
38 |
if toplevel: |
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
39 |
ulid = ' id="tree-%s"' % treeid |
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
40 |
self.w(u'<ul%s class="%s">' % (ulid, self.css_classes)) |
0 | 41 |
for rowidx in xrange(len(self.rset)): |
150
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
42 |
self.wview(self.itemvid, self.rset, row=rowidx, col=0, |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
43 |
vid=subvid, parentvid=self.id, treeid=treeid) |
0 | 44 |
self.w(u'</ul>') |
3298
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
45 |
if toplevel: |
1828
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
46 |
self.req.add_css('jquery.treeview.css') |
2379
3fb9ceb5650f
[web] cubicweb.widgets.js was missing in treeview
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2312
diff
changeset
|
47 |
self.req.add_js(('cubicweb.ajax.js', 'cubicweb.widgets.js', 'jquery.treeview.js')) |
1828
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
48 |
self.req.html_headers.add_onload(u""" |
3298
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
49 |
jQuery("#tree-%s").treeview({toggle: toggleTree, prerendered: true});""" % treeid, |
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
50 |
jsoncall=toplevel_thru_ajax) |
150
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
51 |
|
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
52 |
class FileTreeView(TreeView): |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
53 |
"""specific version of the treeview to display file trees |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
54 |
""" |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
55 |
id = 'filetree' |
443 | 56 |
css_classes = 'treeview widget filetree' |
57 |
title = _('file tree view') |
|
150
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
58 |
|
931
7b701df4dbef
[treeview] don't readd stuff to the header, poslish css classes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
930
diff
changeset
|
59 |
def call(self, subvid=None, treeid=None, initial_load=True): |
7b701df4dbef
[treeview] don't readd stuff to the header, poslish css classes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
930
diff
changeset
|
60 |
super(FileTreeView, self).call(treeid=treeid, subvid='filetree-oneline', initial_load=initial_load) |
150
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
61 |
|
443 | 62 |
class FileItemInnerView(EntityView): |
150
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
63 |
"""inner view used by the TreeItemView instead of oneline view |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
64 |
|
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
65 |
This view adds an enclosing <span> with some specific CSS classes |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
66 |
around the oneline view. This is needed by the jquery treeview plugin. |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
67 |
""" |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
68 |
id = 'filetree-oneline' |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
69 |
|
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
70 |
def cell_call(self, row, col): |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
71 |
entity = self.entity(row, col) |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
72 |
if ITree.is_implemented_by(entity.__class__) and not entity.is_leaf(): |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
73 |
self.w(u'<div class="folder">%s</div>\n' % entity.view('oneline')) |
150
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
74 |
else: |
1190261a1f13
provide a specific version of treeview to display files and directories
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
75 |
# XXX define specific CSS classes according to mime types |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
76 |
self.w(u'<div class="file">%s</div>\n' % entity.view('oneline')) |
0 | 77 |
|
78 |
||
79 |
class DefaultTreeViewItemView(EntityView): |
|
981
d86d1ee3b60e
fix some imports, update treeview for 3.2
sylvain.thenault@logilab.fr
parents:
939
diff
changeset
|
80 |
"""default treeitem view for entities which don't implement ITree""" |
0 | 81 |
id = 'treeitemview' |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
82 |
|
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
83 |
def cell_call(self, row, col, vid='oneline', parentvid='treeview', treeid=None): |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
84 |
assert treeid is not None |
0 | 85 |
entity = self.entity(row, col) |
86 |
itemview = self.view(vid, self.rset, row=row, col=col) |
|
87 |
if row == len(self.rset) - 1: |
|
88 |
self.w(u'<li class="last">%s</li>' % itemview) |
|
89 |
else: |
|
472 | 90 |
self.w(u'<li>%s</li>' % itemview) |
0 | 91 |
|
92 |
||
928
57614f333dc6
[treeview] (in progress) treeid has to be produced from outside
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
918
diff
changeset
|
93 |
class TreeViewItemView(EntityView): |
0 | 94 |
"""specific treeitem view for entities which implement ITree |
916
968f00dd9a24
[treeview] (in progress) use less magic, having something that now allows prepopulating a part of the tree
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
472
diff
changeset
|
95 |
|
981
d86d1ee3b60e
fix some imports, update treeview for 3.2
sylvain.thenault@logilab.fr
parents:
939
diff
changeset
|
96 |
(each item should be expandable if it's not a tree leaf) |
0 | 97 |
""" |
98 |
id = 'treeitemview' |
|
3298
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
99 |
default_branch_state_is_open = False |
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
100 |
__select__ = EntityView.__select__ & implements(ITree) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
101 |
|
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
102 |
def open_state(self, eeid, treeid): |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
103 |
cookies = self.req.get_cookie() |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
104 |
treestate = cookies.get(treecookiename(treeid)) |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
105 |
if treestate: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
106 |
return str(eeid) in treestate.value.split(';') |
3298
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
107 |
return self.default_branch_state_is_open |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
108 |
|
3298
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
109 |
def cell_call(self, row, col, treeid, vid='oneline', parentvid='treeview', |
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
110 |
**kwargs): |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
111 |
w = self.w |
0 | 112 |
entity = self.entity(row, col) |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
113 |
liclasses = [] |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
114 |
is_last = row == len(self.rset) - 1 |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
115 |
is_open = self.open_state(entity.eid, treeid) |
2216
b44b06520ddc
[treeview] fix condition
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1977
diff
changeset
|
116 |
is_leaf = not hasattr(entity, 'is_leaf') or entity.is_leaf() |
b44b06520ddc
[treeview] fix condition
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1977
diff
changeset
|
117 |
if is_leaf: |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
118 |
if is_last: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
119 |
liclasses.append('last') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
120 |
w(u'<li class="%s">' % u' '.join(liclasses)) |
0 | 121 |
else: |
122 |
rql = entity.children_rql() % {'x': entity.eid} |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2216
diff
changeset
|
123 |
url = xml_escape(self.build_url('json', rql=rql, vid=parentvid, |
0 | 124 |
pageid=self.req.pageid, |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
125 |
treeid=treeid, |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
126 |
fname='view', |
2209
2b91abd9f5a4
[treeview] avoid potential interference with subvid param from form
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1977
diff
changeset
|
127 |
treesubvid=vid)) |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
128 |
divclasses = ['hitarea'] |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
129 |
if is_open: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
130 |
liclasses.append('collapsable') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
131 |
divclasses.append('collapsable-hitarea') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
132 |
else: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
133 |
liclasses.append('expandable') |
1828
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
134 |
divclasses.append('expandable-hitarea') |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
135 |
if is_last: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
136 |
if is_open: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
137 |
liclasses.append('lastCollapsable') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
138 |
divclasses.append('lastCollapsable-hitarea') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
139 |
else: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
140 |
liclasses.append('lastExpandable') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
141 |
divclasses.append('lastExpandable-hitarea') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
142 |
if is_open: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
143 |
w(u'<li class="%s">' % u' '.join(liclasses)) |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
144 |
else: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
145 |
w(u'<li cubicweb:loadurl="%s" class="%s">' % (url, u' '.join(liclasses))) |
1828
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
146 |
divtail = """ onclick="asyncRemoteExec('node_clicked', '%s', '%s')" """ %\ |
e9e8beb06f01
[treeview] really fix #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1826
diff
changeset
|
147 |
(treeid, entity.eid) |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
148 |
w(u'<div class="%s"%s></div>' % (u' '.join(divclasses), divtail)) |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
149 |
|
0 | 150 |
# add empty <ul> because jquery's treeview plugin checks for |
151 |
# sublists presence |
|
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
152 |
if not is_open: |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
153 |
w(u'<ul class="placeholder"><li>place holder</li></ul>') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
154 |
# the local node info |
3298
caef98aa4a98
backport from 3.5
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2391
diff
changeset
|
155 |
self.wview(vid, self.rset, row=row, col=col, **kwargs) |
2216
b44b06520ddc
[treeview] fix condition
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1977
diff
changeset
|
156 |
if is_open and not is_leaf: # => rql is defined |
1826
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
157 |
self.wview(parentvid, self.req.execute(rql), treeid=treeid, initial_load=False) |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
158 |
w(u'</li>') |
afc563537d8f
[treeview] restore functionnality lost in some previous merge #343232
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1802
diff
changeset
|
159 |