Updated external videos form to put provider properties inside switchable group
authorThierry Florac <thierry.florac@onf.fr>
Tue, 03 Apr 2018 17:00:58 +0200 (2018-04-03)
changeset 511 47e890a95d41
parent 510 ed78663fc764
child 512 f282127bc420
Updated external videos form to put provider properties inside switchable group
src/pyams_content/component/video/interfaces/__init__.py
src/pyams_content/component/video/zmi/paragraph.py
--- a/src/pyams_content/component/video/interfaces/__init__.py	Tue Apr 03 16:59:57 2018 +0200
+++ b/src/pyams_content/component/video/interfaces/__init__.py	Tue Apr 03 17:00:58 2018 +0200
@@ -31,6 +31,8 @@
 class IExternalVideoSettings(Interface):
     """External video settings"""
 
+    video_id = Attribute("Video ID")
+
 
 class IExternalVideoProvider(Interface):
     """External video provider"""
--- a/src/pyams_content/component/video/zmi/paragraph.py	Tue Apr 03 16:59:57 2018 +0200
+++ b/src/pyams_content/component/video/zmi/paragraph.py	Tue Apr 03 17:00:58 2018 +0200
@@ -163,6 +163,14 @@
         form.input_css_class = 'col-md-8'
         form.fields = field.Fields(provider.settings_interface)
         form.update()
+        form.add_group(NamedWidgetsGroup(form, 'video_id', form.widgets, ('video_id', ), bordered=False))
+        form.add_group(NamedWidgetsGroup(form, 'provider_group', form.widgets,
+                                         getFieldNamesInOrder(provider.settings_interface)[1:],
+                                         bordered=False,
+                                         legend=_("Other settings"),
+                                         css_class="inner switcher padding-right-10 no-y-padding",
+                                         switch=True,
+                                         hide_if_empty=True))
         return Response(form.render())
 
 
@@ -205,12 +213,15 @@
             self.widgets['provider_name'].mode = DISPLAY_MODE
             provider = self.context.get_provider()
             if provider is not None:
+                self.add_group(NamedWidgetsGroup(self, 'video_id', self.widgets, ('video_id',), bordered=False))
                 self.add_group(NamedWidgetsGroup(self, 'provider_group', self.widgets,
-                                                 getFieldNamesInOrder(provider.settings_interface),
+                                                 getFieldNamesInOrder(provider.settings_interface)[1:],
+                                                 bordered=False,
                                                  legend=_("Video provider settings"),
                                                  fieldset_class='margin-top-10 padding-y-5',
-                                                 css_class='inner padding-right-10 no-y-padding pull-left',
-                                                 bordered=False))
+                                                 css_class='inner switcher padding-right-10 no-y-padding pull-left',
+                                                 switch=True,
+                                                 hide_if_empty=True))
 
 
 @view_config(name='properties.json', context=IExternalVideoParagraph, request_type=IPyAMSLayer,