Improved check for missing i18n input values
authorAlexander Ebert <ebert@woltlab.com>
Tue, 20 Sep 2016 18:37:37 +0000 (20:37 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 20 Sep 2016 18:37:43 +0000 (20:37 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Language/Input.js

index 05e323e377c37004240f993b5380d07585e519f4..27b1089cb43a1a82f8a4889a5ccabe6b26e5791d 100644 (file)
@@ -242,6 +242,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver
                        
                        var dropdownMenu = UiSimpleDropdown.getDropdownMenu(containerId);
                        var elementId = elData(elById(containerId), 'input-id');
+                       var data = _elements.get(elementId);
                        var values = _values.get(elementId);
                        
                        var item, languageId;
@@ -250,7 +251,17 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver
                                languageId = ~~elData(item, 'language-id');
                                
                                if (languageId) {
-                                       item.classList[(values.get(languageId) || !values.size ? 'remove' : 'add')]('missingValue');
+                                       var hasMissingValue = false;
+                                       if (data.languageId) {
+                                               if (languageId === data.languageId) {
+                                                       hasMissingValue = (data.element.value.trim() === '');
+                                               }
+                                               else {
+                                                       hasMissingValue = (!values.get(languageId));
+                                               }
+                                       }
+                                       
+                                       item.classList[(hasMissingValue ? 'add' : 'remove')]('missingValue');
                                }
                        }
                },