From: Matthias Schmidt Date: Wed, 3 Jul 2019 16:19:02 +0000 (+0200) Subject: Resolve TODOs in form builder dependency JS code X-Git-Tag: 5.2.0_Alpha_2~49 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=12de1ff429d7e1fdc34d236b8e521fe2cd2491bb;p=GitHub%2FWoltLab%2FWCF.git Resolve TODOs in form builder dependency JS code See #2509 --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Empty.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Empty.js index d14b1ca29b..30e79c8c1d 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Empty.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Empty.js @@ -26,7 +26,6 @@ define(['./Abstract', 'Core'], function(Abstract, Core) { case 'INPUT': switch (this._field.type) { case 'checkbox': - // TODO: check if working return !this._field.checked; case 'radio': @@ -41,11 +40,13 @@ define(['./Abstract', 'Core'], function(Abstract, Core) { } case 'SELECT': - // TODO: check if working for multiselect - return this._field.value.length === 0; + if (this._field.multiple) { + return elBySelAll('option:checked', this._field).length === 0; + } + + return this._field.value == 0 || this._field.value.length === 0; case 'TEXTAREA': - // TODO: check if working return this._field.value.trim().length === 0; } } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/NonEmpty.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/NonEmpty.js index 983e39570d..b84d8def58 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/NonEmpty.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/NonEmpty.js @@ -26,7 +26,6 @@ define(['./Abstract', 'Core'], function(Abstract, Core) { case 'INPUT': switch (this._field.type) { case 'checkbox': - // TODO: check if working return this._field.checked; case 'radio': @@ -41,11 +40,13 @@ define(['./Abstract', 'Core'], function(Abstract, Core) { } case 'SELECT': - // TODO: check if working for multiselect - return this._field.value.length !== 0; + if (this._field.multiple) { + return elBySelAll('option:checked', this._field).length !== 0; + } + + return this._field.value != 0 && this._field.value.length !== 0; case 'TEXTAREA': - // TODO: check if working return this._field.value.trim().length !== 0; } }