From: Matthias Schmidt Date: Wed, 9 Dec 2020 16:33:42 +0000 (+0100) Subject: Convert `Form/Builder/Field/Checked` to TypeScript X-Git-Tag: 5.4.0_Alpha_1~526^2~32 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ce55c8d4699a3e5fbb20ab9e471ff29ba189ce69;p=GitHub%2FWoltLab%2FWCF.git Convert `Form/Builder/Field/Checked` to TypeScript --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Checked.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Checked.js index 090e3975fb..112a4c8a98 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Checked.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Checked.js @@ -2,30 +2,23 @@ * Data handler for a form builder field in an Ajax form that stores its value via a checkbox being * checked or not. * - * @author Matthias Schmidt - * @copyright 2001-2019 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Form/Builder/Field/Checked - * @since 5.2 + * @author Matthias Schmidt + * @copyright 2001-2020 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Form/Builder/Field/Checked + * @since 5.2 */ -define(['Core', './Field'], function (Core, FormBuilderField) { +define(["require", "exports", "tslib", "./Field", "../../../Core"], function (require, exports, tslib_1, Field_1, Core) { "use strict"; - /** - * @constructor - */ - function FormBuilderFieldInput(fieldId) { - this.init(fieldId); - } - ; - Core.inherit(FormBuilderFieldInput, FormBuilderField, { - /** - * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData - */ - _getData: function () { - var data = {}; - data[this._fieldId] = ~~this._field.checked; - return data; + Field_1 = tslib_1.__importDefault(Field_1); + Core = tslib_1.__importStar(Core); + class Checked extends Field_1.default { + _getData() { + return { + [this._fieldId]: this._field.checked ? "1" : "0", + }; } - }); - return FormBuilderFieldInput; + } + Core.enableLegacyInheritance(Checked); + return Checked; }); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Checked.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Checked.js deleted file mode 100644 index 7673985c97..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Checked.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Data handler for a form builder field in an Ajax form that stores its value via a checkbox being - * checked or not. - * - * @author Matthias Schmidt - * @copyright 2001-2019 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Form/Builder/Field/Checked - * @since 5.2 - */ -define(['Core', './Field'], function(Core, FormBuilderField) { - "use strict"; - - /** - * @constructor - */ - function FormBuilderFieldInput(fieldId) { - this.init(fieldId); - }; - Core.inherit(FormBuilderFieldInput, FormBuilderField, { - /** - * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData - */ - _getData: function() { - var data = {}; - - data[this._fieldId] = ~~this._field.checked; - - return data; - } - }); - - return FormBuilderFieldInput; -}); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Checked.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Checked.ts new file mode 100644 index 0000000000..5f5bcedc04 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Checked.ts @@ -0,0 +1,26 @@ +/** + * Data handler for a form builder field in an Ajax form that stores its value via a checkbox being + * checked or not. + * + * @author Matthias Schmidt + * @copyright 2001-2020 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Form/Builder/Field/Checked + * @since 5.2 + */ + +import Field from "./Field"; +import { FormBuilderData } from "../Data"; +import * as Core from "../../../Core"; + +class Checked extends Field { + protected _getData(): FormBuilderData { + return { + [this._fieldId]: (this._field as HTMLInputElement).checked ? "1" : "0", + }; + } +} + +Core.enableLegacyInheritance(Checked); + +export = Checked;