<commit_before>(function () {
    'use strict';

    angular.module('chaise.faceting', ['plotly', 'chaise.utils'])

        .factory('facetingUtils', ['defaultDisplayname', function (defaultDisplayname) {

            /**
             * Returns an object that can be used for showing the null filter
             * @param  {boolean} selected whether it should be selected
             * @param  {boolean} disabled whether it should be disabled
             */
            function getNullFilter(selected, disabled) {
                return {
                    selected: (typeof selected == 'boolean') ? selected: false,
                    disabled: (typeof disabled == 'boolean') ? disabled: false,
                    uniqueId: null,
                    displayname: {"value": null, "isHTML": false}
                };
            }

            /**
             * Returns an object that can be used for showing the not-null filter
             * @param  {boolean} selected whether it should be selected
             * @param  {boolean} disabled whether it should be disabled
             */
            function getNotNullFilter(selected) {
                return {
                    selected: (typeof selected == 'boolean') ? selected: false,
                    isNotNull: true,
                    displayname: {"value": defaultDisplayname.notNull, "isHTML": true}
                };
            }

            return {
                getNotNullFilter: getNotNullFilter,
                getNullFilter: getNullFilter
            };
        }])

        .directive('faceting', ['recordTableUtils', '$timeout', '$rootScope', 'UriUtils', function (recordTableUtils, $timeout, $rootScope, UriUtils) {

            return {
                restrict: 'AE',
                templateUrl:  UriUtils.chaiseDeploymentPath() + 'common/templates/faceting/faceting.html',
                scope: {
                    vm: "="
                },
                controller: ['$scope', function ($scope) {
                    var ctrl = this;

                    ctrl.childCtrls = []; // child controllers

                    ctrl.facetingCount = 0;

                    // register a children controller in here
                    ctrl.register = function (childCtrl, facetColumn, index) {
                        ctrl.childCtrls[index] = childCtrl;
                        ctrl.facetingCount++;

                        $scope.vm.facetModels[index] = {
                            facetError: false,
                            initialized: false,
                            isOpen: false,
                            isLoading: false,
                            processed: true,
                            noConstraints: false,
                            appliedFilters: [],
                            updateFacet: childCtrl.updateFacet,
                            initializeFacet: childCtrl.initializeFacet
                        };

                        if (ctrl.facetingCount === $scope.vm.reference.facetColumns.length) {
                            $scope.$emit("facetsLoaded");
                        }
                    };

                    ctrl.updateVMReference = function (reference, index, keepRef) {
                        return $scope.updateReference(reference, index, keepRef);
                    };

                    ctrl.setInitialized = function () {
                        $scope.vm.facetModels.forEach(function (fm, index) {
                            if (fm.isOpen) fm.initialized = false;
                        });
                    };

                    /**
                     * @param {int} index index of facetColumn
                     **/
                    ctrl.updateFacetColumn = function (index) {
                        var fm = $scope.vm.facetModels[index];
                        fm.processed = false;
                        fm.isLoading = true;
                        recordTableUtils.update($scope.vm);
                    };

                    ctrl.focusOnFacet = function (index) {
                        $scope.focusOnFacet(index);
                    };
                }],
                require: 'faceting',
                link: function (scope, element, attr, currentCtrl) {
                    scope.updateReference = function (reference, index, keepRef) {
                        if (!scope.$root.checkReferenceURL(reference)) {
                            return false;
                        }

                        if (!keepRef) {
                            scope.vm.lastActiveFacet = index;
                            scope.vm.reference = reference;
                            scope.$emit('facet-modified');
                        }
                        return true;
                    };

                    scope.hasFilter = function (index) {
                        if (!scope.vm.facetModels || (index !== undefined && !scope.vm.facetModels[index])) {
                            return false;
                        }

                        if (typeof index === 'undefined') {
                            return scope.vm.facetModels.some(function (fm) {
                                return fm.appliedFilters.length > 0;
                            })
                        } else {
                            return scope.vm.facetModels[index].appliedFilters.length > 0;
                        }
                    };

                    scope.removeFilter = function (index) {
                        var newRef;
                        if (index === "filters") {
                            // only delete custom filters on the reference (not the facet)
                            newRef = scope.vm.reference.removeAllFacetFilters(false, true, true);
                        } else if (index === "cfacets") { // remove custom facet
                            // TODO change This
                            newRef = scope.vm.reference.removeAllFacetFilters(true, false, true);
                        } else if (typeof index === 'undefined') {
                            // // delete all filters and facets
                            newRef = scope.vm.reference.removeAllFacetFilters();
                            scope.vm.facetModels.forEach(function (fm) {
                                fm.appliedFilters = [];
                            });

                            scope.vm.search = null;
                            if (scope.vm.reference.location.searchTerm) {
                                newRef = newRef.search();
                            }

                        } else {
                            // delete all fitler for one column
                            newRef = scope.vm.reference.facetColumns[index].removeAllFilters();
                            scope.vm.facetModels[index].appliedFilters = [];
                        }

                        scope.updateReference(newRef, -1);
                    };
<commit_msg>fix comments in the removeFilter function<commit_after>(function () {
    'use strict';

    angular.module('chaise.faceting', ['plotly', 'chaise.utils'])

        .factory('facetingUtils', ['defaultDisplayname', function (defaultDisplayname) {

            /**
             * Returns an object that can be used for showing the null filter
             * @param  {boolean} selected whether it should be selected
             * @param  {boolean} disabled whether it should be disabled
             */
            function getNullFilter(selected, disabled) {
                return {
                    selected: (typeof selected == 'boolean') ? selected: false,
                    disabled: (typeof disabled == 'boolean') ? disabled: false,
                    uniqueId: null,
                    displayname: {"value": null, "isHTML": false}
                };
            }

            /**
             * Returns an object that can be used for showing the not-null filter
             * @param  {boolean} selected whether it should be selected
             * @param  {boolean} disabled whether it should be disabled
             */
            function getNotNullFilter(selected) {
                return {
                    selected: (typeof selected == 'boolean') ? selected: false,
                    isNotNull: true,
                    displayname: {"value": defaultDisplayname.notNull, "isHTML": true}
                };
            }

            return {
                getNotNullFilter: getNotNullFilter,
                getNullFilter: getNullFilter
            };
        }])

        .directive('faceting', ['recordTableUtils', '$timeout', '$rootScope', 'UriUtils', function (recordTableUtils, $timeout, $rootScope, UriUtils) {

            return {
                restrict: 'AE',
                templateUrl:  UriUtils.chaiseDeploymentPath() + 'common/templates/faceting/faceting.html',
                scope: {
                    vm: "="
                },
                controller: ['$scope', function ($scope) {
                    var ctrl = this;

                    ctrl.childCtrls = []; // child controllers

                    ctrl.facetingCount = 0;

                    // register a children controller in here
                    ctrl.register = function (childCtrl, facetColumn, index) {
                        ctrl.childCtrls[index] = childCtrl;
                        ctrl.facetingCount++;

                        $scope.vm.facetModels[index] = {
                            facetError: false,
                            initialized: false,
                            isOpen: false,
                            isLoading: false,
                            processed: true,
                            noConstraints: false,
                            appliedFilters: [],
                            updateFacet: childCtrl.updateFacet,
                            initializeFacet: childCtrl.initializeFacet
                        };

                        if (ctrl.facetingCount === $scope.vm.reference.facetColumns.length) {
                            $scope.$emit("facetsLoaded");
                        }
                    };

                    ctrl.updateVMReference = function (reference, index, keepRef) {
                        return $scope.updateReference(reference, index, keepRef);
                    };

                    ctrl.setInitialized = function () {
                        $scope.vm.facetModels.forEach(function (fm, index) {
                            if (fm.isOpen) fm.initialized = false;
                        });
                    };

                    /**
                     * @param {int} index index of facetColumn
                     **/
                    ctrl.updateFacetColumn = function (index) {
                        var fm = $scope.vm.facetModels[index];
                        fm.processed = false;
                        fm.isLoading = true;
                        recordTableUtils.update($scope.vm);
                    };

                    ctrl.focusOnFacet = function (index) {
                        $scope.focusOnFacet(index);
                    };
                }],
                require: 'faceting',
                link: function (scope, element, attr, currentCtrl) {
                    scope.updateReference = function (reference, index, keepRef) {
                        if (!scope.$root.checkReferenceURL(reference)) {
                            return false;
                        }

                        if (!keepRef) {
                            scope.vm.lastActiveFacet = index;
                            scope.vm.reference = reference;
                            scope.$emit('facet-modified');
                        }
                        return true;
                    };

                    scope.hasFilter = function (index) {
                        if (!scope.vm.facetModels || (index !== undefined && !scope.vm.facetModels[index])) {
                            return false;
                        }

                        if (typeof index === 'undefined') {
                            return scope.vm.facetModels.some(function (fm) {
                                return fm.appliedFilters.length > 0;
                            })
                        } else {
                            return scope.vm.facetModels[index].appliedFilters.length > 0;
                        }
                    };

                    scope.removeFilter = function (index) {
                        var newRef;
                        if (index === "filters") {
                            // only remove custom filters on the reference (not the facet)
                            newRef = scope.vm.reference.removeAllFacetFilters(false, true, true);
                        } else if (index === "cfacets") {
                            // only remove custom facets on the reference
                            newRef = scope.vm.reference.removeAllFacetFilters(true, false, true);
                        } else if (typeof index === 'undefined') {
                            // // delete all filters and facets
                            newRef = scope.vm.reference.removeAllFacetFilters();
                            scope.vm.facetModels.forEach(function (fm) {
                                fm.appliedFilters = [];
                            });

                            scope.vm.search = null;
                            if (scope.vm.reference.location.searchTerm) {
                                newRef = newRef.search();
                            }

                        } else {
                            // delete all fitler for one column
                            newRef = scope.vm.reference.facetColumns[index].removeAllFilters();
                            scope.vm.facetModels[index].appliedFilters = [];
                        }

                        scope.updateReference(newRef, -1);
                    };

{'fraction_non_alphanumeric': 0.0899020939040949, 'fraction_numerical': 0.0005717144286428928, 'mean_word_length': 1.0135251798561151, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4966325', 'n_tokens_mistral': 3105, 'n_tokens_neox': 2882, 'n_words': 674}