2 * Manages the packages entered in a devtools project excluded package form field.
4 * @author Matthias Schmidt
5 * @copyright 2001-2021 WoltLab GmbH
6 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7 * @module WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages
8 * @see module:WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/AbstractPackageList
11 define(["require", "exports", "tslib", "./AbstractPackageList", "../../../../../../Core", "../../../../../../Language", "../../../../../../Dom/Util"], function (require, exports, tslib_1, AbstractPackageList_1, Core, Language, Util_1) {
13 AbstractPackageList_1 = tslib_1.__importDefault(AbstractPackageList_1);
14 Core = tslib_1.__importStar(Core);
15 Language = tslib_1.__importStar(Language);
16 Util_1 = tslib_1.__importDefault(Util_1);
17 class ExcludedPackages extends AbstractPackageList_1.default {
18 constructor(formFieldId, existingPackages) {
19 super(formFieldId, existingPackages);
20 this.version = document.getElementById(`${this.formFieldId}_version`);
21 if (this.version === null) {
22 throw new Error(`Cannot find version form field for packages field with id '${this.formFieldId}'.`);
24 this.version.addEventListener("keypress", (ev) => this.keyPress(ev));
26 createSubmitFields(listElement, index) {
27 super.createSubmitFields(listElement, index);
28 const version = document.createElement("input");
29 version.type = "hidden";
30 version.name = `${this.formFieldId}[${index}][version]`;
31 version.value = listElement.dataset.version;
32 this.form.appendChild(version);
36 this.version.value = "";
39 return Core.extend(super.getInputData(), {
40 version: this.version.value,
43 populateListItem(listItem, packageData) {
44 super.populateListItem(listItem, packageData);
45 listItem.dataset.version = packageData.version;
46 listItem.innerHTML = ` ${Language.get("wcf.acp.devtools.project.excludedPackage.excludedPackage", {
47 packageIdentifier: packageData.packageIdentifier,
48 version: packageData.version,
52 return super.validateInput() && this.validateVersion(this.version);
54 validateVersion(versionElement) {
55 const version = versionElement.value;
57 Util_1.default.innerError(versionElement, Language.get("wcf.global.form.error.empty"));
60 else if (version !== "*") {
61 return super.validateVersion(versionElement);
66 Core.enableLegacyInheritance(ExcludedPackages);
67 return ExcludedPackages;