Explorar o código

Show tab errors

Denis K %!s(int64=8) %!d(string=hai) anos
pai
achega
d959998dea
Modificáronse 1 ficheiros con 21 adicións e 0 borrados
  1. 21 0
      jet/static/jet/js/src/features/changeform-tabs.js

+ 21 - 0
jet/static/jet/js/src/features/changeform-tabs.js

@@ -56,9 +56,30 @@ ChangeFormTabs.prototype = {
 
         this.showTab(location.hash, true);
     },
+    updateErrorState: function() {
+        var $tabItems = this.$changeform.find('.changeform-tabs-item');
+        var $contentWrappers = this.getContentWrappers();
+        var obj = this;
+
+        $tabItems.each(function() {
+            var $tabItem = $(this);
+            var selector = obj.getHashSelector(
+                $tabItem.find('.changeform-tabs-item-link').attr('href')
+            );
+
+            if (selector) {
+                var $contentWrapper = $contentWrappers.filter('.' + selector);
+
+                if ($contentWrapper.find('.form-row.errors').length) {
+                    $tabItem.addClass('errors');
+                }
+            }
+        });
+    },
     run: function() {
         try {
             this.initTabs();
+            this.updateErrorState();
         } catch (e) {
             console.error(e);
         }