export default function maFilterButton() {
    return {
        restrict: 'E',
        scope: {
            filters: '&',
            enabledFilters: '=',
            enableFilter: '&'
        },
        link: function(scope) {
            scope.notYetEnabledFilters = () => scope.filters().filter(filter =>
                scope.enabledFilters.indexOf(filter) === -1
            );
            scope.hasFilters = () => scope.notYetEnabledFilters().length > 0;
        },
        template:
`<span class="btn-group" dropdown is-open="isopen" ng-if="hasFilters()">
    <button type="button" class="btn btn-default dropdown-toggle" dropdown-toggle >
        <span class="glyphicon glyphicon-filter" aria-hidden="true"></span>&nbsp;<span class="hidden-xs">Add filter </span><span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu">
        <li ng-repeat="filter in notYetEnabledFilters()" ng-switch="button">
            <a ng-click="enableFilter()(filter)">{{ filter.label() }}</a>
        </li>
    </ul>
</span>`
    };
}

maFilterButton.$inject = [];

export default function maFilterButton() {
    return {
        restrict: 'E',
        scope: {
            filters: '&',
            enabledFilters: '=',
            enableFilter: '&',
            label: '@'
        },
        link: function(scope) {
            scope.label = scope.label || 'Add filter';
            scope.notYetEnabledFilters = () => scope.filters().filter(filter =>
                scope.enabledFilters.indexOf(filter) === -1
            );
            scope.hasFilters = () => scope.notYetEnabledFilters().length > 0;
        },
        template:
`<span class="btn-group" dropdown is-open="isopen" ng-if="hasFilters()">
    <button type="button" class="btn btn-default dropdown-toggle" dropdown-toggle >
        <span class="glyphicon glyphicon-filter" aria-hidden="true"></span>&nbsp;<span class="hidden-xs">{{ ::label }} </span><span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu">
        <li ng-repeat="filter in notYetEnabledFilters()" ng-switch="button">
            <a ng-click="enableFilter()(filter)">{{ filter.label() }}</a>
        </li>
    </ul>
</span>`
    };
}

maFilterButton.$inject = [];

Allow setting label to ma-filter-button
Allow setting label to ma-filter-button

As it can be done with other ma-*-button ma-filter-button can get it's
label set now
