From 10994bd3e1faacd4e0453255cb2ccace7c17f811 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 9 Dec 2020 17:33:12 +0100 Subject: [PATCH] Convert `Form/Builder/Field/Button` to TypeScript --- .../Core/Form/Builder/Field/Button.js | 34 +++++++----------- .../Core/Form/Builder/Field/Button.js | 35 ------------------- .../Core/Form/Builder/Field/Button.ts | 24 +++++++++++++ 3 files changed, 37 insertions(+), 56 deletions(-) delete mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.js create mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.ts diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Button.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Button.js index 137aa55518..ff97b3835f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Button.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Button.js @@ -1,32 +1,24 @@ /** * Data handler for a button form builder field in an Ajax form. * - * @author Matthias Schmidt - * @copyright 2001-2020 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Form/Builder/Field/Value - * @since 5.4 + * @author Matthias Schmidt + * @copyright 2001-2020 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Form/Builder/Field/Value + * @since 5.4 */ -define(['Core', './Field'], function (Core, FormBuilderField) { +define(["require", "exports", "tslib", "./Field"], function (require, exports, tslib_1, Field_1) { "use strict"; - /** - * @constructor - */ - function FormBuilderFieldButton(fieldId) { - this.init(fieldId); - } - ; - Core.inherit(FormBuilderFieldButton, FormBuilderField, { - /** - * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData - */ - _getData: function () { - var data = {}; + Object.defineProperty(exports, "__esModule", { value: true }); + Field_1 = tslib_1.__importDefault(Field_1); + class Button extends Field_1.default { + _getData() { + const data = {}; if (this._field.dataset.isClicked === "1") { data[this._fieldId] = this._field.value; } return data; } - }); - return FormBuilderFieldButton; + } + exports.default = Button; }); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.js deleted file mode 100644 index eef0575b71..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Data handler for a button form builder field in an Ajax form. - * - * @author Matthias Schmidt - * @copyright 2001-2020 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Form/Builder/Field/Value - * @since 5.4 - */ -define(['Core', './Field'], function(Core, FormBuilderField) { - "use strict"; - - /** - * @constructor - */ - function FormBuilderFieldButton(fieldId) { - this.init(fieldId); - }; - Core.inherit(FormBuilderFieldButton, FormBuilderField, { - /** - * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData - */ - _getData: function() { - var data = {}; - - if (this._field.dataset.isClicked === "1") { - data[this._fieldId] = this._field.value; - } - - return data; - } - }); - - return FormBuilderFieldButton; -}); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.ts new file mode 100644 index 0000000000..08deadece7 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.ts @@ -0,0 +1,24 @@ +/** + * Data handler for a button form builder field in an Ajax form. + * + * @author Matthias Schmidt + * @copyright 2001-2020 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Form/Builder/Field/Value + * @since 5.4 + */ + +import Field from "./Field"; +import { FormBuilderData } from "../Data"; + +export default class Button extends Field { + protected _getData(): FormBuilderData { + const data = {}; + + if (this._field!.dataset.isClicked === "1") { + data[this._fieldId] = (this._field! as HTMLInputElement).value; + } + + return data; + } +} -- 2.20.1