[PATCH 2 of 3 saem_ref v3] Use JQTree to display Concepts in ConceptScheme tab view

Frank Bessou frank.bessou at logilab.fr
Fri Sep 28 16:33:05 CEST 2018


# HG changeset patch
# User Frank Bessou <frank.bessou at logilab.fr>
# Date 1538042688 -7200
#      Thu Sep 27 12:04:48 2018 +0200
# Node ID f38adb440019343932d45288aeaa7d90d5cdb428
# Parent  72e97e0e43537623076c7d8c6b24a98a68f7724c
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r f38adb440019
Use JQTree to display Concepts in ConceptScheme tab view

We extend the ConceptSchemeConceptsTab to use the jqtree.tree view and
we disable the base class.

The render_tree method is added in an unreleased version of
cubicweb-skos.

diff --git a/cubicweb_saem_ref/views/__init__.py b/cubicweb_saem_ref/views/__init__.py
--- a/cubicweb_saem_ref/views/__init__.py
+++ b/cubicweb_saem_ref/views/__init__.py
@@ -41,6 +41,7 @@ from cubicweb.web.views import (
 
 from cubes.squareui.views.basetemplates import basetemplates
 from cubicweb_seda.views import dropdown_button, has_rel_perm, widgets as sedawidgets
+import cubicweb_skos.views as skos_views
 
 from .. import cwuri_url
 
@@ -475,6 +476,16 @@ class RestPathEvaluator(urlpublishing.Re
         return super(RestPathEvaluator, self).set_vid_for_rset(req, cls, rset)
 
 
+class ConceptSchemeConceptsTab(skos_views.ConceptSchemeConceptsTab):
+    """display a SKOS concept scheme tree"""
+    __regid__ = 'skos_top_concepts_tab'  # don't use '.' in tab's regid
+    __select__ = is_instance('ConceptScheme')
+
+    def render_tree(self, entity, children_rset):
+        self._cw.add_js('cubes.saem_ref.js')
+        entity.view('jqtree.treeview', w=self.w)
+
+
 def registration_callback(vreg):
     from cubicweb.web.views import actions, cwuser, tableview, undohistory
     vreg.register_all(globals().values(), __name__, (
@@ -482,11 +493,13 @@ def registration_callback(vreg):
         SAEMHTMLPageFooter,
         SAEMNoResultView,
         URLAttributeView,
+        ConceptSchemeConceptsTab,
     ))
     vreg.register_and_replace(RestPathEvaluator, urlpublishing.RestPathEvaluator)
     vreg.register_and_replace(URLAttributeView, primary.URLAttributeView)
     vreg.register_and_replace(SAEMHTMLPageFooter, basetemplates.HTMLPageFooter)
     vreg.register_and_replace(SAEMNoResultView, baseviews.NoResultView)
+    vreg.register_and_replace(ConceptSchemeConceptsTab, skos_views.ConceptSchemeConceptsTab)
     vreg.unregister(tableview.TableView)
     vreg.unregister(undohistory.UndoHistoryView)
     vreg.unregister(basecomponents.ApplicationName)
diff --git a/dev-requirements.txt b/dev-requirements.txt
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -3,4 +3,5 @@ psycopg2
 pytest
 webtest
 http://hg.logilab.org/master/cubes/seda/archive/default.tar.bz2#egg=cubicweb-seda
+http://hg.logilab.org/master/cubes/skos/archive/default.tar.bz2#egg=cubicweb-skos
 



More information about the saem-devel mailing list