# all files / Core/Components/FileTree/ FileTreeDirective.js

54.55% Statements 6/11
0% Branches 0/4
0% Functions 0/2
54.55% Lines 6/11

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44

    1

    1

    1

    1

    1

    1
     'use strict';

    // Utilities:
    var _ = require('lodash');
    var fs = require('fs');

    // Module:
    var Core = require('../../Core');

    // Dependencies:
    require('./FileTreeController');

    var FileTreeDirective = function () {
        return {
            restrict: 'E',

            scope: {
                model: '=',
                type: '@'
            },

            /* eslint-disable no-path-concat */
            template: fs.readFileSync(__dirname + '/FileTree.html', 'utf8'),
            /* eslint-enable no-path-concat */

            controller: 'FileTreeController',
            controllerAs: 'fileTree',
            bindToController: true,
            link: link
        };

        function link ($scope) {
            if (_.isUndefined($scope.fileTree.model)) {
                throw new Error('The "tractor-file-tree" directive requires a "model" attribute.');
            }

            if (_.isUndefined($scope.fileTree.type)) {
                throw new Error('The "tractor-file-tree" directive requires a "type" attribute.');
            }
        }
    };

    Core.directive('tractorFileTree', FileTreeDirective);