--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/form/zmi/properties.py Tue Sep 19 11:11:30 2017 +0200
@@ -0,0 +1,82 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.shared.form.interfaces import IWfForm
+from pyams_form.interfaces.form import IInnerSubForm
+from pyams_skin.layer import IPyAMSLayer
+
+# import packages
+from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm
+from pyams_utils.adapter import adapter_config
+from pyams_zmi.form import InnerAdminEditForm
+from z3c.form import field
+from zope.interface import Interface
+
+from pyams_content import _
+
+
+@adapter_config(name='form-settings',
+ context=(IWfForm, IPyAMSLayer, SharedContentPropertiesEditForm),
+ provides=IInnerSubForm)
+class FormPropertiesEditForm(InnerAdminEditForm):
+ """Form properties edit form extension"""
+
+ legend = _("Main form settings")
+ fieldset_class = 'bordered no-x-margin margin-y-10'
+
+ fields = field.Fields(IWfForm).select('user_title', 'header', 'handler', 'auth_only', 'use_captcha', 'submit_label')
+ weight = 1
+
+ def updateWidgets(self, prefix=None):
+ super(FormPropertiesEditForm, self).updateWidgets(prefix)
+ if 'header' in self.widgets:
+ self.widgets['header'].widget_css_class = 'textarea'
+
+ def get_ajax_output(self, changes):
+ if 'handler' in changes.get(IWfForm, ()):
+ return {'status': 'reload',
+ 'message': self.request.localizer.translate(self.successMessage)}
+ else:
+ return super(FormPropertiesEditForm, self).get_ajax_output(changes)
+
+
+@adapter_config(name='handler-settings',
+ context=(IWfForm, IPyAMSLayer, SharedContentPropertiesEditForm),
+ provides=IInnerSubForm)
+class FormHandlerPropertiesEditForm(InnerAdminEditForm):
+ """Form handler properties edit form extension"""
+
+ legend = _("Form handler settings")
+ fieldset_class = 'bordered no-x-margin margin-y-10'
+
+ def __new__(cls, context, request, view):
+ handler = context.query_handler()
+ if handler is None:
+ return None
+ return InnerAdminEditForm.__new__(cls)
+
+ @property
+ def fields(self):
+ handler = self.context.query_handler()
+ if handler is None:
+ interface = Interface
+ else:
+ interface = handler.handler_info
+ return field.Fields(interface)
+
+ weight = 2