# HG changeset patch # User David Douard # Date 1478078142 -3600 # Node ID 9f7949b63ab2214827a873cc26068cadb658142f # Parent 2f885861cb8418684ab4ac6b75874184e92ea803 [views] simplify and fix the TreeView (closes #16055814) Simplify the (internal) TreeView._init_params() method to get rid of the useless 'initial_thru_ajax' argument. The ajax tree view was not working properly when loaded via ajax, for instance from a lazy tab. This was due to the buggy protection against double javascript/ css inclusion, which is no more needed server-side as it is now implemented client-side. Deprecate use of the initial_thru_ajax argument of the TreeView.call() method. diff -r 2f885861cb84 -r 9f7949b63ab2 cubicweb/web/views/treeview.py --- a/cubicweb/web/views/treeview.py Thu Oct 13 15:39:48 2016 +0200 +++ b/cubicweb/web/views/treeview.py Wed Nov 02 10:15:42 2016 +0100 @@ -128,10 +128,10 @@ cssclass = 'treeview widget' title = _('tree view') - def _init_params(self, subvid, treeid, initial_load, initial_thru_ajax, morekwargs): + def _init_params(self, subvid, treeid, initial_load, morekwargs): form = self._cw.form if subvid is None: - subvid = form.pop('treesubvid', self.subvid) # consume it + subvid = form.pop('treesubvid', self.subvid) # consume it if treeid is None: treeid = form.pop('treeid', None) if treeid is None: @@ -141,9 +141,7 @@ # got unicode & python keywords must be strings morekwargs.update(dict((str(k), v) for k, v in ajaxargs.items())) - toplevel_thru_ajax = form.pop('treeview_top', False) or initial_thru_ajax - toplevel = toplevel_thru_ajax or (initial_load and not form.get('fname')) - return subvid, treeid, toplevel_thru_ajax, toplevel + return subvid, treeid def _init_headers(self, treeid): self._cw.add_css(('jquery-treeview/jquery.treeview.css', 'cubicweb.treeview.css')) @@ -152,13 +150,16 @@ jQuery("#tree-%s").treeview({toggle: toggleTree, prerendered: true});""" % treeid) def call(self, subvid=None, treeid=None, - initial_load=True, initial_thru_ajax=False, **morekwargs): - subvid, treeid, toplevel_thru_ajax, toplevel = self._init_params( - subvid, treeid, initial_load, initial_thru_ajax, morekwargs) + initial_load=True, initial_thru_ajax=None, **morekwargs): + if initial_thru_ajax is not None: + msg = '[3.24] initial_thru_ajax argument is deprecated' + warn(msg, DeprecationWarning, stacklevel=2) + + subvid, treeid = self._init_params(subvid, treeid, + initial_load, morekwargs) ulid = ' ' - if toplevel: - self._init_headers(treeid) - ulid = ' id="tree-%s"' % treeid + self._init_headers(treeid) + ulid = ' id="tree-%s"' % treeid self.w(u'' % (ulid, self.cssclass)) # XXX force sorting on x.sortvalue() (which return dc_title by default) # we need proper ITree & co specification to avoid this.