whitef0x0/tellform

View on GitHub
public/form_modules/forms/base/directives/field-icon.client.directive.js

Summary

Maintainability
A
2 hrs
Test Coverage
'use strict';

angular.module('view-form').directive('fieldIconDirective', function() {

    return {
        template: '<i class="{{typeIcon}}"></i>',
        restrict: 'E',
        scope: {
            typeName: '@'
        },
        controller: function($scope){
            var iconTypeMap = {
                'textfield': 'fa fa-pencil-square-o',
                'dropdown': 'fa fa-th-list',
                'date': 'fa fa-calendar',
                'checkbox': 'fa fa-check-square-o',
                'radio': 'fa fa-dot-circle-o',
                'email': 'fa fa-envelope-o',
                'textarea': 'fa fa-pencil-square',
                'legal': 'fa fa-legal',
                'file': 'fa fa-cloud-upload',
                'rating': 'fa fa-star-half-o',
                'link': 'fa fa-link',
                'scale': 'fa fa-sliders',
                'stripe': 'fa fa-credit-card',
                'statement': 'fa fa-quote-left',
                'yes_no': 'fa fa-toggle-on',
                'number': 'fa fa-slack'
            };
            $scope.typeIcon = iconTypeMap[$scope.typeName];
        }
    };
});