/**
* Data handler for an item list form builder field in an Ajax form.
*
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Form/Builder/Field/ItemList
- * @since 5.2
+ * @author Matthias Schmidt
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Form/Builder/Field/ItemList
+ * @since 5.2
*/
-define(['Core', './Field', 'WoltLabSuite/Core/Ui/ItemList/Static'], function (Core, FormBuilderField, UiItemListStatic) {
+define(["require", "exports", "tslib", "./Field", "../../../Ui/ItemList/Static", "../../../Core"], function (require, exports, tslib_1, Field_1, UiItemListStatic, Core) {
"use strict";
- /**
- * @constructor
- */
- function FormBuilderFieldItemList(fieldId) {
- this.init(fieldId);
- }
- ;
- Core.inherit(FormBuilderFieldItemList, FormBuilderField, {
- /**
- * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData
- */
- _getData: function () {
- var data = {};
- data[this._fieldId] = [];
- var values = UiItemListStatic.getValues(this._fieldId);
- for (var i = 0, length = values.length; i < length; i++) {
- if (values[i].objectId) {
- data[this._fieldId][values[i].objectId] = values[i].value;
+ Field_1 = tslib_1.__importDefault(Field_1);
+ UiItemListStatic = tslib_1.__importStar(UiItemListStatic);
+ Core = tslib_1.__importStar(Core);
+ class ItemList extends Field_1.default {
+ _getData() {
+ const values = [];
+ UiItemListStatic.getValues(this._fieldId).forEach((item) => {
+ if (item.objectId) {
+ values[item.objectId] = item.value;
}
else {
- data[this._fieldId].push(values[i].value);
+ values.push(item.value);
}
- }
- return data;
+ });
+ return {
+ [this._fieldId]: values,
+ };
}
- });
- return FormBuilderFieldItemList;
+ }
+ Core.enableLegacyInheritance(ItemList);
+ return ItemList;
});
+++ /dev/null
-/**
- * Data handler for an item list form builder field in an Ajax form.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Form/Builder/Field/ItemList
- * @since 5.2
- */
-define(['Core', './Field', 'WoltLabSuite/Core/Ui/ItemList/Static'], function(Core, FormBuilderField, UiItemListStatic) {
- "use strict";
-
- /**
- * @constructor
- */
- function FormBuilderFieldItemList(fieldId) {
- this.init(fieldId);
- };
- Core.inherit(FormBuilderFieldItemList, FormBuilderField, {
- /**
- * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData
- */
- _getData: function() {
- var data = {};
- data[this._fieldId] = [];
-
- var values = UiItemListStatic.getValues(this._fieldId);
- for (var i = 0, length = values.length; i < length; i++) {
- if (values[i].objectId) {
- data[this._fieldId][values[i].objectId] = values[i].value;
- }
- else {
- data[this._fieldId].push(values[i].value);
- }
- }
-
- return data;
- }
- });
-
- return FormBuilderFieldItemList;
-});
--- /dev/null
+/**
+ * Data handler for an item list form builder field in an Ajax form.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Form/Builder/Field/ItemList
+ * @since 5.2
+ */
+
+import Field from "./Field";
+import * as UiItemListStatic from "../../../Ui/ItemList/Static";
+import { FormBuilderData } from "../Data";
+import * as Core from "../../../Core";
+
+class ItemList extends Field {
+ protected _getData(): FormBuilderData {
+ const values: string[] = [];
+ UiItemListStatic.getValues(this._fieldId).forEach((item) => {
+ if (item.objectId) {
+ values[item.objectId] = item.value;
+ } else {
+ values.push(item.value);
+ }
+ });
+
+ return {
+ [this._fieldId]: values,
+ };
+ }
+}
+
+Core.enableLegacyInheritance(ItemList);
+
+export = ItemList;