[facets] Fix disappearance of navtop component on facet filtering
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 21 Apr 2017 14:01:46 +0200
changeset 12189 ef46695adb68
parent 12188 fea018b2e056
child 12192 cf5d11ac79fb
[facets] Fix disappearance of navtop component on facet filtering which is because facets are replacing the whole #pageContent div, while this one contains other stuff than the view: * a type selector component that should be dropped for a while, * a computed title, * the page navigation. Then the view content itself is in a #contentmain div. The thing is that the navigation should be rebuilded on filtering (this is not the case for other bullets in the list above). This is currently handled specifically in the ajaxcontroller (except for the type selector which will disappear... who said it should be dropped at once?). So to fix this we: * put the page navigation into the "contentmain" div * don't replace anymore "pageContent" but "contentmain" After that we can even remove from the ajax controller the code that reimplements title handling similarly to the main template. Notice the part that changes the main template has to be ported to squareui. Closes #17074195
cubicweb/web/component.py
cubicweb/web/views/ajaxcontroller.py
cubicweb/web/views/basetemplates.py
cubicweb/web/views/facets.py
--- a/cubicweb/web/component.py	Mon Jun 19 18:15:28 2017 +0200
+++ b/cubicweb/web/component.py	Fri Apr 21 14:01:46 2017 +0200
@@ -126,7 +126,7 @@
         return url
 
     def ajax_page_url(self, **params):
-        divid = params.setdefault('divid', 'pageContent')
+        divid = params.setdefault('divid', 'contentmain')
         params['rql'] = self.cw_rset.printable_rql()
         return js_href("$(%s).loadxhtml(AJAX_PREFIX_URL, %s, 'get', 'swap')" % (
             json_dumps('#'+divid), js.ajaxFuncArgs('view', params)))
--- a/cubicweb/web/views/ajaxcontroller.py	Mon Jun 19 18:15:28 2017 +0200
+++ b/cubicweb/web/views/ajaxcontroller.py	Fri Apr 21 14:01:46 2017 +0200
@@ -241,29 +241,25 @@
             stream = UStringIO()
             kwargs['w'] = stream.write
             assert not paginate
-        if divid == 'pageContent':
+        if divid == 'contentmain':
             # ensure divid isn't reused by the view (e.g. table view)
             del self._cw.form['divid']
-            # mimick main template behaviour
-            stream.write(u'<div id="pageContent">')
-            vtitle = self._cw.form.get('vtitle')
-            if vtitle:
-                stream.write(u'<h1 class="vtitle">%s</h1>\n' % vtitle)
             paginate = True
+        if divid == 'contentmain':
+            stream.write(u'<div id="contentmain">')
         nav_html = UStringIO()
         if paginate and not view.handle_pagination:
             view.paginate(w=nav_html.write)
         stream.write(nav_html.getvalue())
-        if divid == 'pageContent':
-            stream.write(u'<div id="contentmain">')
         view.render(**kwargs)
+        stream.write(nav_html.getvalue())
+        if divid == 'contentmain':
+            stream.write(u'</div>')
         extresources = self._cw.html_headers.getvalue(skiphead=True)
         if extresources:
             stream.write(u'<div class="ajaxHtmlHead">\n') # XXX use a widget?
             stream.write(extresources)
             stream.write(u'</div>\n')
-        if divid == 'pageContent':
-            stream.write(u'</div>%s</div>' % nav_html.getvalue())
         return stream.getvalue()
 
 
--- a/cubicweb/web/views/basetemplates.py	Mon Jun 19 18:15:28 2017 +0200
+++ b/cubicweb/web/views/basetemplates.py	Fri Apr 21 14:01:46 2017 +0200
@@ -158,14 +158,14 @@
             'etypenavigation', self._cw, rset=self.cw_rset)
         if etypefilter and etypefilter.cw_propval('visible'):
             etypefilter.render(w=w)
+        w(u'<div id="contentmain">\n')
         nav_html = UStringIO()
         if view and not view.handle_pagination:
             view.paginate(w=nav_html.write)
         w(nav_html.getvalue())
-        w(u'<div id="contentmain">\n')
         view.render(w=w)
+        w(nav_html.getvalue())
         w(u'</div>\n') # close id=contentmain
-        w(nav_html.getvalue())
         w(u'</div>\n') # closes id=pageContent
         self.template_footer(view)
 
--- a/cubicweb/web/views/facets.py	Mon Jun 19 18:15:28 2017 +0200
+++ b/cubicweb/web/views/facets.py	Fri Apr 21 14:01:46 2017 +0200
@@ -246,7 +246,7 @@
             rset, vid, divid, paginate = context
         else:
             rset = self.cw_rset
-            vid, divid = None, 'pageContent'
+            vid, divid = None, 'contentmain'
             paginate = view and view.paginable
         return rset, vid, divid, paginate