"use strict";
var angular = require("angular");
var sortDirection_1 = require("../../sorts/sortDirection");
exports.moduleName = 'rl.ui.components.cardContainer.columnHeader';
exports.directiveName = 'rlColumnHeader';
cardColumnHeader.$inject = ['$compile'];
function cardColumnHeader($compile) {
    'use strict';
    return {
        restrict: 'E',
        template: "\n\t\t\t<div rl-size-for-breakpoints=\"column.size\" ng-click=\"sort()\" title=\"{{::column.description}}\"\n\t\t\t\t\tclass=\"column-header\">\n\t\t\t\t<div class=\"template-container\"></div>\n\t\t\t\t<i ng-show=\"sorting === sortDirection.ascending\" class=\"fa fa-sort-asc\"></i>\n\t\t\t\t<i ng-show=\"sorting === sortDirection.descending\" class=\"fa fa-sort-desc\"></i>\n\t\t\t</div>\n\t\t",
        scope: {
            column: '=',
            sorting: '=',
            sort: '&',
        },
        compile: function () {
            return {
                pre: function (scope) {
                    var column = scope.column;
                    if (column.headerTemplateUrl != null) {
                        scope.renderedTemplate = $compile('<div ng-include="\'' + column.headerTemplateUrl + '\'"></div>')(scope);
                    }
                    else if (column.headerTemplate != null) {
                        scope.renderedTemplate = $compile(column.headerTemplate)(scope);
                    }
                    else {
                        scope.renderedTemplate = ('<h5>' + column.label + '</h5');
                    }
                },
                post: function (scope, element) {
                    if (scope.column.displayColumnHeader != null && scope.column.displayColumnHeader === false) {
                        element.remove();
                        return;
                    }
                    var container = element.find('.template-container');
                    container.append(scope.renderedTemplate);
                    scope.sortDirection = sortDirection_1.SortDirection;
                },
            };
        }
    };
}
exports.cardColumnHeader = cardColumnHeader;
angular.module(exports.moduleName, [])
    .directive(exports.directiveName, cardColumnHeader);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sdW1uSGVhZGVyLm5nMS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImNvbHVtbkhlYWRlci5uZzEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGlDQUFtQztBQUVuQywyREFBMkU7QUFHa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