From 599f1c4006d720e715a8047c51e5b789a86387d5 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 26 Apr 2021 16:11:19 +0200 Subject: [PATCH] Force excluded package version in DevTools and support `*` Close #4151 --- .../Field/Devtools/Project/ExcludedPackages.ts | 15 +++++++++++++++ .../Field/Devtools/Project/ExcludedPackages.js | 14 +++++++++++++- ...oolsProjectExcludedPackagesFormField.class.php | 6 +++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ts/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.ts b/ts/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.ts index 503a259210..3014ba71e9 100644 --- a/ts/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.ts +++ b/ts/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.ts @@ -13,6 +13,7 @@ import AbstractPackageList from "./AbstractPackageList"; import * as Core from "../../../../../../Core"; import * as Language from "../../../../../../Language"; import { ExcludedPackageData } from "./Data"; +import DomUtil from "../../../../../../Dom/Util"; class ExcludedPackages< TPackageData extends ExcludedPackageData = ExcludedPackageData @@ -65,6 +66,20 @@ class ExcludedPackages< protected validateInput(): boolean { return super.validateInput() && this.validateVersion(this.version); } + + protected validateVersion(versionElement: HTMLInputElement): boolean { + const version = versionElement.value; + + if (version === "") { + DomUtil.innerError(versionElement, Language.get("wcf.global.form.error.empty")); + + return false; + } else if (version !== "*") { + return super.validateVersion(versionElement); + } + + return true; + } } Core.enableLegacyInheritance(ExcludedPackages); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.js index 4e2e95bce7..b57cd81d84 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.js @@ -8,11 +8,12 @@ * @see module:WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/AbstractPackageList * @since 5.2 */ -define(["require", "exports", "tslib", "./AbstractPackageList", "../../../../../../Core", "../../../../../../Language"], function (require, exports, tslib_1, AbstractPackageList_1, Core, Language) { +define(["require", "exports", "tslib", "./AbstractPackageList", "../../../../../../Core", "../../../../../../Language", "../../../../../../Dom/Util"], function (require, exports, tslib_1, AbstractPackageList_1, Core, Language, Util_1) { "use strict"; AbstractPackageList_1 = tslib_1.__importDefault(AbstractPackageList_1); Core = tslib_1.__importStar(Core); Language = tslib_1.__importStar(Language); + Util_1 = tslib_1.__importDefault(Util_1); class ExcludedPackages extends AbstractPackageList_1.default { constructor(formFieldId, existingPackages) { super(formFieldId, existingPackages); @@ -50,6 +51,17 @@ define(["require", "exports", "tslib", "./AbstractPackageList", "../../../../../ validateInput() { return super.validateInput() && this.validateVersion(this.version); } + validateVersion(versionElement) { + const version = versionElement.value; + if (version === "") { + Util_1.default.innerError(versionElement, Language.get("wcf.global.form.error.empty")); + return false; + } + else if (version !== "*") { + return super.validateVersion(versionElement); + } + return true; + } } Core.enableLegacyInheritance(ExcludedPackages); return ExcludedPackages; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/devtools/project/DevtoolsProjectExcludedPackagesFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/devtools/project/DevtoolsProjectExcludedPackagesFormField.class.php index 86c3e572d1..6ed90d450b 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/devtools/project/DevtoolsProjectExcludedPackagesFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/devtools/project/DevtoolsProjectExcludedPackagesFormField.class.php @@ -68,7 +68,11 @@ class DevtoolsProjectExcludedPackagesFormField extends AbstractFormField } // validate version - if ($package['version'] !== '' && !Package::isValidVersion($package['version'])) { + if ( + $package['version'] !== '' + && $package['version'] !== '*' + && !Package::isValidVersion($package['version']) + ) { continue; } -- 2.20.1