Force excluded package version in DevTools and support `*`
authorMatthias Schmidt <gravatronics@live.com>
Mon, 26 Apr 2021 14:11:19 +0000 (16:11 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 26 Apr 2021 14:12:58 +0000 (16:12 +0200)
Close  #4151

ts/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/ExcludedPackages.js
wcfsetup/install/files/lib/system/form/builder/field/devtools/project/DevtoolsProjectExcludedPackagesFormField.class.php

index 503a2592100e2b7efe9c098fa95663baf1a0984a..3014ba71e966a514e28816fbdf8313f6cc167ac7 100644 (file)
@@ -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);
index 4e2e95bce79eb344f8fe3e05824ab3d6234deb86..b57cd81d84a222f13ac3b7455516706357650083 100644 (file)
@@ -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;
index 86c3e572d1cf3fee55b3bf9630bfd03d4e8c1438..6ed90d450b46a579e130b602d91a458aef593713 100644 (file)
@@ -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;
             }