ManageIQ/manageiq-ui-classic

View on GitHub
app/javascript/oldjs/directives/validation/error_on_tab.js

Summary

Maintainability
B
4 hrs
Test Coverage
ManageIQ.angular.app.directive('errorOnTab', ['$timeout', function($timeout) {
  return {
    link: function(scope, elem) {
      scope.$on('setErrorOnTab', function(e, args) {
        if (elem[0].attributes['error-on-tab'].value === args.tab) {
          $timeout(function() {
            $(elem[0]).addClass('fa fa-exclamation-circle');
          });
        }
      });

      scope.$on('clearErrorOnTab', function(e, args) {
        if (elem[0].attributes['error-on-tab'].value === args.tab) {
          $timeout(function() {
            $(elem[0]).removeClass('fa fa-exclamation-circle');
          });
        }
      });
    },
  };
}]);