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

Denis Laxalde denis.laxalde at logilab.fr
Wed Oct 3 12:20:50 CEST 2018


Denis Laxalde a écrit :
> Frank Bessou a écrit :
>>
>> On 28/09/2018 18:16, Denis Laxalde wrote:
>>> Frank Bessou a écrit :
>>>> # 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')
>>>
>>> The add_js does not work because, as far as I understand, the page is
>>> already loaded where this statement is executed (i.e. when the tab is
>>> selected). Not sure this is the actual problem, but this does not work
>>> for me...
>>>
>>
>> The js is actually executed when the tab is loaded. This is handled in
>> cubicweb.ajax.js . I don't know why this isn't working on your instance
>> but I will send a new version which move this code to skos.py.
> 
> I don't understand your answer. I'm saying that there is no <script> tag
> with "cubes.saem_ref.js" file on my side, hence the code from this file
> ("canMoveTo" function) fails to execute (I get a TypeError in browser
> console).
> 
> My explanation (I might be wrong) is that the headers list is generated
> and outputted in HTML page *before* tab's code is executed, hence
> self._cw.add_js() call is a no-op.

So it actually works after cleaning a browser cache I wasn't aware of :)

Series applied, thanks.

> 
>>
>>> Also, can you move this class in skos.py file? >
>>>> +        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
>>>
>>
> 



More information about the saem-devel mailing list