From 477f6668abcef42b09b5bcc8cdfd70be8f463983 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 3 Apr 2019 19:20:33 +0200 Subject: [PATCH] Add JavaScript data handlers for form builder forms MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … for easier Ajax form support. See #2509 --- .../templates/__captchaFormField.tpl | 2 + com.woltlab.wcf/templates/__form.tpl | 16 +- .../templates/__formFieldDataHandler.tpl | 16 ++ .../templates/__formFieldFooter.tpl | 1 + .../templates/__labelFormField.tpl | 2 +- .../templates/__ratingFormField.tpl | 2 +- .../templates/uploadFieldComponent.tpl | 2 +- .../acp/templates/__captchaFormField.tpl | 2 + .../install/files/acp/templates/__form.tpl | 16 +- .../acp/templates/__formFieldDataHandler.tpl | 16 ++ .../files/acp/templates/__formFieldFooter.tpl | 1 + .../files/acp/templates/__labelFormField.tpl | 2 +- .../files/acp/templates/__ratingFormField.tpl | 2 +- .../acp/templates/__simpleAclFormField.tpl | 3 + .../acp/templates/uploadFieldComponent.tpl | 2 +- .../WoltLabSuite/Core/Form/Builder/Dialog.js | 195 ++++++++++++++++++ .../Core/Form/Builder/Field/Captcha.js | 49 +++++ .../Core/Form/Builder/Field/Checkboxes.js | 46 +++++ .../Core/Form/Builder/Field/Checked.js | 34 +++ .../Builder/Field/{ => Controller}/Label.js | 3 +- .../Builder/Field/{ => Controller}/Rating.js | 3 +- .../Core/Form/Builder/Field/Date.js | 33 +++ .../Form/Builder/Field/Dependency/Manager.js | 41 ++++ .../Core/Form/Builder/Field/Field.js | 87 ++++++++ .../Core/Form/Builder/Field/ItemList.js | 43 ++++ .../Core/Form/Builder/Field/RadioButton.js | 45 ++++ .../Core/Form/Builder/Field/SimpleAcl.js | 53 +++++ .../Core/Form/Builder/Field/Tag.js | 37 ++++ .../Core/Form/Builder/Field/User.js | 40 ++++ .../Core/Form/Builder/Field/Value.js | 34 +++ .../Core/Form/Builder/Field/ValueI18n.js | 47 +++++ .../WoltLabSuite/Core/Form/Builder/Manager.js | 169 +++++++++++++++ .../js/WoltLabSuite/Core/Language/Input.js | 15 ++ .../form/builder/DialogFormDocument.class.php | 2 + .../form/builder/FormDocument.class.php | 6 +- .../builder/field/AbstractFormField.class.php | 11 +- .../field/AbstractNumericFormField.class.php | 5 + .../builder/field/BooleanFormField.class.php | 5 + .../builder/field/CaptchaFormField.class.php | 5 + .../builder/field/DateFormField.class.php | 5 + .../builder/field/IconFormField.class.php | 5 + .../builder/field/ItemListFormField.class.php | 5 + .../MultipleSelectionFormField.class.php | 5 + .../field/RadioButtonFormField.class.php | 5 + .../builder/field/RatingFormField.class.php | 5 + .../field/SingleSelectionFormField.class.php | 23 ++- .../builder/field/TI18nFormField.class.php | 18 +- .../builder/field/TextFormField.class.php | 5 + .../builder/field/UploadFormField.class.php | 5 + .../acl/simple/SimpleAclFormField.class.php | 7 +- .../field/label/LabelFormField.class.php | 5 + .../builder/field/tag/TagFormField.class.php | 5 + .../field/user/UserFormField.class.php | 5 + .../field/user/UsernameFormField.class.php | 5 + .../field/wysiwyg/WysiwygFormField.class.php | 2 +- .../lib/system/language/I18nHandler.class.php | 14 +- 56 files changed, 1196 insertions(+), 21 deletions(-) create mode 100644 com.woltlab.wcf/templates/__formFieldDataHandler.tpl create mode 100644 wcfsetup/install/files/acp/templates/__formFieldDataHandler.tpl create mode 100644 wcfsetup/install/files/acp/templates/__simpleAclFormField.tpl create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Dialog.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Captcha.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Checkboxes.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Checked.js rename wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/{ => Controller}/Label.js (97%) rename wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/{ => Controller}/Rating.js (98%) create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Date.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Field.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/ItemList.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/RadioButton.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/SimpleAcl.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Tag.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/User.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Value.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/ValueI18n.js create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Manager.js diff --git a/com.woltlab.wcf/templates/__captchaFormField.tpl b/com.woltlab.wcf/templates/__captchaFormField.tpl index f4202f8f1c..360f272abc 100644 --- a/com.woltlab.wcf/templates/__captchaFormField.tpl +++ b/com.woltlab.wcf/templates/__captchaFormField.tpl @@ -1 +1,3 @@ {@$field->getObjectType()->getProcessor()->getFormElement()} + +{include file='__formFieldDataHandler'} diff --git a/com.woltlab.wcf/templates/__form.tpl b/com.woltlab.wcf/templates/__form.tpl index 4a1fcadb94..8719c7e04b 100644 --- a/com.woltlab.wcf/templates/__form.tpl +++ b/com.woltlab.wcf/templates/__form.tpl @@ -1,7 +1,21 @@ diff --git a/com.woltlab.wcf/templates/__formFieldDataHandler.tpl b/com.woltlab.wcf/templates/__formFieldDataHandler.tpl new file mode 100644 index 0000000000..83b9800f29 --- /dev/null +++ b/com.woltlab.wcf/templates/__formFieldDataHandler.tpl @@ -0,0 +1,16 @@ +{if $field->getDocument()->isAjax() && !$javaScriptDataHandlerModule|empty} + +{/if} diff --git a/com.woltlab.wcf/templates/__formFieldFooter.tpl b/com.woltlab.wcf/templates/__formFieldFooter.tpl index bb5c687390..f420d74d3d 100644 --- a/com.woltlab.wcf/templates/__formFieldFooter.tpl +++ b/com.woltlab.wcf/templates/__formFieldFooter.tpl @@ -1,5 +1,6 @@ {include file='__formFieldDescription'} {include file='__formFieldErrors'} {include file='__formFieldDependencies'} + {include file='__formFieldDataHandler'} diff --git a/com.woltlab.wcf/templates/__labelFormField.tpl b/com.woltlab.wcf/templates/__labelFormField.tpl index 071acec516..971066d4b1 100644 --- a/com.woltlab.wcf/templates/__labelFormField.tpl +++ b/com.woltlab.wcf/templates/__labelFormField.tpl @@ -27,7 +27,7 @@ {js application='wcf' file='WCF.Label' bundle='WCF.Combined'} diff --git a/wcfsetup/install/files/acp/templates/__formFieldDataHandler.tpl b/wcfsetup/install/files/acp/templates/__formFieldDataHandler.tpl new file mode 100644 index 0000000000..d4651bd1c2 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/__formFieldDataHandler.tpl @@ -0,0 +1,16 @@ +{if $field->getDocument()->isAjax() && !$javaScriptDataHandlerModule|empty} + +{/if} diff --git a/wcfsetup/install/files/acp/templates/__formFieldFooter.tpl b/wcfsetup/install/files/acp/templates/__formFieldFooter.tpl index bb5c687390..f420d74d3d 100644 --- a/wcfsetup/install/files/acp/templates/__formFieldFooter.tpl +++ b/wcfsetup/install/files/acp/templates/__formFieldFooter.tpl @@ -1,5 +1,6 @@ {include file='__formFieldDescription'} {include file='__formFieldErrors'} {include file='__formFieldDependencies'} + {include file='__formFieldDataHandler'} diff --git a/wcfsetup/install/files/acp/templates/__labelFormField.tpl b/wcfsetup/install/files/acp/templates/__labelFormField.tpl index 071acec516..971066d4b1 100644 --- a/wcfsetup/install/files/acp/templates/__labelFormField.tpl +++ b/wcfsetup/install/files/acp/templates/__labelFormField.tpl @@ -27,7 +27,7 @@ {js application='wcf' file='WCF.Label' bundle='WCF.Combined'}