Resolve TODOs in form builder dependency JS code
authorMatthias Schmidt <gravatronics@live.com>
Wed, 3 Jul 2019 16:19:02 +0000 (18:19 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 3 Jul 2019 16:19:02 +0000 (18:19 +0200)
See #2509

wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Empty.js
wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/NonEmpty.js

index d14b1ca29b3b36d7633f9019b32f9b7dc1674271..30e79c8c1dbb6c25c73add45f0dc69ecca23605b 100644 (file)
@@ -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;
                        }
                }
index 983e39570d8b17adf50527fce24ce1c07018fd67..b84d8def587c4fbdaec881288803ff64bc579ad6 100644 (file)
@@ -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;
                        }
                }