Changed widget CSS class attribute
authorThierry Florac <thierry.florac@onf.fr>
Tue, 15 Nov 2016 09:49:27 +0100
changeset 61 e5d6ea4dc839
parent 60 da1454d7d358
child 62 8106bd960bcd
Changed widget CSS class attribute
src/pyams_content/component/extfile/zmi/__init__.py
src/pyams_content/component/gallery/zmi/__init__.py
src/pyams_content/component/gallery/zmi/gallery.py
src/pyams_content/component/links/zmi/__init__.py
src/pyams_content/component/paragraph/zmi/html.py
src/pyams_content/shared/common/zmi/__init__.py
src/pyams_content/shared/common/zmi/properties.py
src/pyams_content/shared/common/zmi/review.py
src/pyams_content/shared/common/zmi/templates/advanced-search.pt
--- a/src/pyams_content/component/extfile/zmi/__init__.py	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/component/extfile/zmi/__init__.py	Tue Nov 15 09:49:27 2016 +0100
@@ -92,7 +92,8 @@
 
     def updateWidgets(self, prefix=None):
         super(ExtFileAddForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
 
     def create(self, data):
         factory = EXTERNAL_FILES_FACTORIES.get(data.get('factory'))
@@ -160,7 +161,8 @@
 
     def updateWidgets(self, prefix=None):
         super(ExtFilePropertiesEditForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
 
     def update_content(self, content, data):
         changes = super(ExtFilePropertiesEditForm, self).update_content(content, data)
--- a/src/pyams_content/component/gallery/zmi/__init__.py	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/component/gallery/zmi/__init__.py	Tue Nov 15 09:49:27 2016 +0100
@@ -81,8 +81,10 @@
 
     def updateWidgets(self, prefix=None):
         super(GalleryAddForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
-        self.widgets['author_comments'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
+        if 'author_comments' in self.widgets:
+            self.widgets['author_comments'].widget_css_class = 'textarea'
 
     def create(self, data):
         gallery = Gallery()
@@ -165,7 +167,8 @@
 
     def updateWidgets(self, prefix=None):
         super(GalleryPropertiesEditForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.comments:
+            self.widgets['description'].widget_css_class = 'textarea'
 
 
 @view_config(name='properties.json', context=IGallery, request_type=IPyAMSLayer,
--- a/src/pyams_content/component/gallery/zmi/gallery.py	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/component/gallery/zmi/gallery.py	Tue Nov 15 09:49:27 2016 +0100
@@ -83,7 +83,8 @@
 
     def updateWidgets(self, prefix=None):
         super(GalleryImageAddForm, self).updateWidgets(prefix)
-        self.widgets['author_comments'].label_css_class = 'textarea'
+        if 'author_comments' in self.widgets:
+            self.widgets['author_comments'].widget_css_class = 'textarea'
 
     def create(self, data):
         medias = []
@@ -195,9 +196,12 @@
 
     def updateWidgets(self, prefix=None):
         super(GalleryFilePropertiesEditForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
-        self.widgets['author_comments'].label_css_class = 'textarea'
-        self.widgets['sound_description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
+        if 'author_comments' in self.widgets:
+            self.widgets['author_comments'].widget_css_class = 'textarea'
+        if 'sound_description' in self.widgets:
+            self.widgets['sound_description'].widget_css_class = 'textarea'
 
 
 @view_config(name='gallery-file-properties.json', context=IGalleryFile, request_type=IPyAMSLayer,
--- a/src/pyams_content/component/links/zmi/__init__.py	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/component/links/zmi/__init__.py	Tue Nov 15 09:49:27 2016 +0100
@@ -78,7 +78,8 @@
 
     def updateWidgets(self, prefix=None):
         super(InternalLinkAddForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
 
     def create(self, data):
         return InternalLink()
@@ -128,7 +129,8 @@
 
     def updateWidgets(self, prefix=None):
         super(InternalLinkPropertiesEditForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
 
 
 @view_config(name='properties.json', context=IInternalLink, request_type=IPyAMSLayer,
@@ -183,7 +185,8 @@
 
     def updateWidgets(self, prefix=None):
         super(ExternalLinkAddForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
 
     def create(self, data):
         return ExternalLink()
@@ -233,7 +236,8 @@
 
     def updateWidgets(self, prefix=None):
         super(ExternalLinkPropertiesEditForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
 
 
 @view_config(name='properties.json', context=IExternalLink, request_type=IPyAMSLayer,
@@ -289,7 +293,8 @@
 
     def updateWidgets(self, prefix=None):
         super(MailtoLinkAddForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
 
     def create(self, data):
         return MailtoLink()
@@ -339,7 +344,8 @@
 
     def updateWidgets(self, prefix=None):
         super(MailtoLinkPropertiesEditForm, self).updateWidgets(prefix)
-        self.widgets['description'].label_css_class = 'textarea'
+        if 'description' in self.widgets:
+            self.widgets['description'].widget_css_class = 'textarea'
 
 
 @view_config(name='properties.json', context=IMailtoLink, request_type=IPyAMSLayer,
--- a/src/pyams_content/component/paragraph/zmi/html.py	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/component/paragraph/zmi/html.py	Tue Nov 15 09:49:27 2016 +0100
@@ -79,7 +79,8 @@
 
     def updateWidgets(self, prefix=None):
         super(HTMLParagraphAddForm, self).updateWidgets(prefix)
-        self.widgets['body'].label_css_class = 'textarea'
+        if 'body' in self.widgets:
+            self.widgets['body'].widget_css_class = 'textarea'
 
     def create(self, data):
         return HTMLParagraph()
@@ -120,10 +121,11 @@
 
     def updateWidgets(self, prefix=None):
         super(HTMLParagraphPropertiesEditForm, self).updateWidgets(prefix)
-        for lang in self.widgets['body'].langs:
-            widget = self.widgets['body'].widgets[lang]
-            widget.id = '{id}_{name}'.format(id=widget.id, name=self.context.__name__)
-        self.widgets['body'].label_css_class = 'textarea'
+        if 'body' in self.widgets:
+            for lang in self.widgets['body'].langs:
+                widget = self.widgets['body'].widgets[lang]
+                widget.id = '{id}_{name}'.format(id=widget.id, name=self.context.__name__)
+            self.widgets['body'].widget_css_class = 'textarea'
 
 
 @adapter_config(context=(IHTMLParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
--- a/src/pyams_content/shared/common/zmi/__init__.py	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/shared/common/zmi/__init__.py	Tue Nov 15 09:49:27 2016 +0100
@@ -76,8 +76,10 @@
 
     def updateWidgets(self, prefix=None):
         super(SharedContentAddForm, self).updateWidgets(prefix)
-        self.widgets['title'].description = _("This title can be modified afterwards")
-        self.widgets['notepad'].label_css_class = 'textarea'
+        if 'title' in self.widgets:
+            self.widgets['title'].description = _("This title can be modified afterwards")
+        if 'notepad' in self.widgets:
+            self.widgets['notepad'].widget_css_class = 'textarea'
 
     def create(self, data):
         return self.context.shared_content_factory.content_class()
@@ -264,7 +266,8 @@
 
     def updateWidgets(self, prefix=None):
         super(WfSharedContentDuplicateForm, self).updateWidgets(prefix)
-        self.widgets['comment'].label_css_class = 'textarea'
+        if 'comment' in self.widgets:
+            self.widgets['comment'].widget_css_class = 'textarea'
 
     def updateActions(self):
         super(WfSharedContentDuplicateForm, self).updateActions()
--- a/src/pyams_content/shared/common/zmi/properties.py	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/shared/common/zmi/properties.py	Tue Nov 15 09:49:27 2016 +0100
@@ -80,9 +80,9 @@
     def updateWidgets(self, prefix=None):
         super(SharedContentPropertiesEditForm, self).updateWidgets(prefix)
         if 'description' in self.widgets:
-            self.widgets['description'].label_css_class = 'textarea'
+            self.widgets['description'].widget_css_class = 'textarea'
         if 'notepad' in self.widgets:
-            self.widgets['notepad'].label_css_class = 'textarea'
+            self.widgets['notepad'].widget_css_class = 'textarea'
 
 
 @view_config(name='properties.json', context=IWfSharedContent, request_type=IPyAMSLayer,
--- a/src/pyams_content/shared/common/zmi/review.py	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/shared/common/zmi/review.py	Tue Nov 15 09:49:27 2016 +0100
@@ -110,8 +110,9 @@
 
     def updateWidgets(self, prefix=None):
         super(WfSharedContentReviewForm, self).updateWidgets(prefix)
-        self.widgets['comment'].label_css_class = 'textarea'
-        self.widgets['comment'].addClass('height-100')
+        if 'comment' in self.widgets:
+            self.widgets['comment'].widget_css_class = 'textarea'
+            self.widgets['comment'].addClass('height-100')
 
     def updateActions(self):
         super(WfSharedContentReviewForm, self).updateActions()
--- a/src/pyams_content/shared/common/zmi/templates/advanced-search.pt	Tue Nov 15 09:47:14 2016 +0100
+++ b/src/pyams_content/shared/common/zmi/templates/advanced-search.pt	Tue Nov 15 09:49:27 2016 +0100
@@ -74,7 +74,7 @@
 								</label>
 								<div class="col-md-9">
 									<label class="input"
-										   tal:attributes="class widget.label_css_class | default;
+										   tal:attributes="class widget.widget_css_class | default;
 														   data-ams-data extension:object_data(widget);
 														   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
 										<input tal:replace="structure widget.render()" />
@@ -95,7 +95,7 @@
 									</label>
 									<div class="col-md-4">
 										<label class="input"
-											   tal:attributes="class widget.label_css_class | default;
+											   tal:attributes="class widget.widget_css_class | default;
 															   data-ams-data extension:object_data(widget);
 															   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
 											<input tal:replace="structure widget.render()" />
@@ -115,7 +115,7 @@
 									</label>
 									<div class="col-md-4">
 										<label class="input"
-											   tal:attributes="class widget.label_css_class | default;
+											   tal:attributes="class widget.widget_css_class | default;
 															   data-ams-data extension:object_data(widget);
 															   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
 											<input tal:replace="structure widget.render()" />
@@ -130,7 +130,7 @@
 								<div class="col-md-4">
 									<label class="input"
 											tal:define="widget view.widgets['created_after']"
-										   tal:attributes="class widget.label_css_class | default;
+										   tal:attributes="class widget.widget_css_class | default;
 														   data-ams-data extension:object_data(widget);
 														   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
 										<input tal:replace="structure widget.render()" />
@@ -142,7 +142,7 @@
 								<div class="col-md-4">
 									<label class="input"
 											tal:define="widget view.widgets['created_before']"
-										   tal:attributes="class widget.label_css_class | default;
+										   tal:attributes="class widget.widget_css_class | default;
 														   data-ams-data extension:object_data(widget);
 														   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
 										<input tal:replace="structure widget.render()" />
@@ -156,7 +156,7 @@
 								<div class="col-md-4">
 									<label class="input"
 											tal:define="widget view.widgets['modified_after']"
-										   tal:attributes="class widget.label_css_class | default;
+										   tal:attributes="class widget.widget_css_class | default;
 														   data-ams-data extension:object_data(widget);
 														   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
 										<input tal:replace="structure widget.render()" />
@@ -168,7 +168,7 @@
 								<div class="col-md-4">
 									<label class="input"
 											tal:define="widget view.widgets['modified_before']"
-										   tal:attributes="class widget.label_css_class | default;
+										   tal:attributes="class widget.widget_css_class | default;
 														   data-ams-data extension:object_data(widget);
 														   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
 										<input tal:replace="structure widget.render()" />