[PATCH 5 of 6 seda] [views] Add missing css/js to the ConceptAutoCompleteWidget

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Mar 24 10:48:41 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1490200832 -3600
#      Wed Mar 22 17:40:32 2017 +0100
# Node ID 5013e2e14e23bb22e446a94d2160ed3f4a4754d8
# Parent  a5ea6eb18024bd052547633526d5d8e96c955380
[views] Add missing css/js to the ConceptAutoCompleteWidget

those went unnoticed because in saem they are added by some global widget, but
they are actually necessary. Along the way, declare them using standard
needs_css / needs_js widget class attributes.

Closes #17066562

diff --git a/cubicweb_seda/views/widgets.py b/cubicweb_seda/views/widgets.py
--- a/cubicweb_seda/views/widgets.py
+++ b/cubicweb_seda/views/widgets.py
@@ -159,10 +159,14 @@ class ConceptAutoCompleteWidget(fw.TextI
       affk.set_field_kwargs('Keyword', 'keyword_value',
                             widget=ConceptAutoCompleteWidget(slave_name='keyword_value',
                                                              master_name='keyword_scheme',
                                                              optional=True))
     """
+    needs_css = ('jquery.ui.css',)
+    needs_js = ('jquery.ui.js',
+                'cubicweb.js', 'cubicweb.ajax.js',
+                'cubes.skoscomplete.js')
 
     def __init__(self, slave_name, master_name,
                  ajax_autocomplete_func='scheme_concepts_autocomplete',
                  optional=False,
                  **kwargs):
@@ -179,11 +183,10 @@ class ConceptAutoCompleteWidget(fw.TextI
         if entity.has_eid():
             concept = entity.concept
         else:
             concept = None
         req = form._cw
-        req.add_js(('cubicweb.js', 'cubicweb.ajax.js', 'cubes.skoscomplete.js'))
         req.add_onload(js.concept_autocomplete.initConceptAutoCompleteWidget(
             master_id, slave_id, self.ajax_autocomplete_func))
         if concept is None:
             value = getattr(entity, self.slave_name) if self.optional else None
             eid = u''


More information about the saem-devel mailing list