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

    var DictionaryFilter;
    var template = require('tpl!orofilter/templates/filter/dictionary-filter.html');
    var fieldTemplate = require('tpl!orofilter/templates/filter/select-field.html');
    var $ = require('jquery');
    var routing = require('routing');
    var _ = require('underscore');
    var __ = require('orotranslation/js/translator');
    var ChoiceFilter = require('oro/filter/choice-filter');
    var tools = require('oroui/js/tools');
    require('jquery.select2');

    /**
     * Multiple select filter: filter values as multiple select options
     *
     * @export  oro/filter/dictionary-filter
     * @class   oro.filter.DictionaryFilter
     * @extends oro.filter.ChoiceFilter
     */
    DictionaryFilter = ChoiceFilter.extend({
        /* eslint-disable quote-props */
        /**
         * select2 will apply to element with this selector
         */
        elementSelector: '.select-values-autocomplete',

        /**
         * Filter selector template
         *
         * @property
         */
        template: template,
        templateSelector: '#dictionary-filter-template',

        /**
         * Template selector for dictionary field parts
         *
         * @property
         */
        fieldTemplate: fieldTemplate,
        fieldTemplateSelector: '#select-field-template',

        /**
         * Maximum value of count items for drop down menu.
         * If count values will be bigger than this value then
         * this filter will use select2 with autocomplete
         */
        maxCountForDropDownMode: 10,

        /**
         * Selectors for filter data
         *
         * @property
         */
        criteriaValueSelectors: {
            type: 'input[type="hidden"]:last'
        },

        filterParams: null,

        'class': null,

        select2ConfigData: null,

        isInitSelect2: false,

        previousData: [],

        /**
         * Data of selected values
         */
        selectedData: {},

        /**
         * Route name for dictionary values filter
         */
        dictionaryValueRoute: 'oro_dictionary_value',

        /**
         * Route name for dictionary search
         */
        dictionarySearchRoute: 'oro_dictionary_search',

        /**
         * @inheritDoc
         */
        constructor: function DictionaryFilter() {
            DictionaryFilter.__super__.constructor.apply(this, arguments);
        },

        /**
         * @inheritDoc
         */
        initialize: function(options) {
            // Each filter should have own copy,
            // otherwise 2 filters on same page will show same values
            this.selectedData = {};

            if (this.filterParams) {
                this.dictionaryClass = this.filterParams.class.replace(/\\/g, '_');
            } else {
                this.dictionaryClass = this.class.replace(/\\/g, '_');
            }

            this.listenTo(this, 'renderCriteriaLoadValues', this.renderCriteriaLoadValues);
            this.listenTo(this, 'updateCriteriaLabels', this.updateCriteriaLabels);

            DictionaryFilter.__super__.initialize.apply(this, arguments);
        },

        /**
         * @inheritDoc
         */
        reset: function() {
            DictionaryFilter.__super__.reset.apply(this, arguments);
            var select2element = this.$el.find(this.elementSelector);
            var data = select2element.inputWidget('data');
            if (data) {
                this.previousData = data;
            }
            select2element.inputWidget('data', null);
        },

        /**
         * Init render
         */
        render: function() {
            this.renderDeferred = $.Deferred();
            this._wrap('');
            if (this.$el.html() === '') {
                this._renderCriteria();
            }
        },

        /**
         * Execute ajax request to get data of entities by ids.
         *
         * @param successEventName
         */
        loadValuesById: function(successEventName) {
            var self = this;

            if (this.select2ConfigData === null) {
                var $container = self.$(self.elementSelector).parent();

                $container.addClass('loading');

                $.ajax({
                    url: routing.generate(
                        self.dictionaryValueRoute,
                        {
                            dictionary: this.dictionaryClass
                        }
                    ),
                    data: {
                        keys: this.value.value
                    },
                    success: function(response) {
                        $container.removeClass('loading');

                        self.trigger(successEventName, response);
                    }
                });
            } else {
                var select2ConfigData = this.select2ConfigData;
                var value = this.value.value;
                var result = {
                    results: _.filter(select2ConfigData, function(item) {
                        return _.indexOf(value, item.id) !== -1;
                    })
                };<commit_msg>BB-14301: Update dictionary-filter for correct work with consent reports - add fix<commit_after>define(function(require) {
    'use strict';

    var DictionaryFilter;
    var template = require('tpl!orofilter/templates/filter/dictionary-filter.html');
    var fieldTemplate = require('tpl!orofilter/templates/filter/select-field.html');
    var $ = require('jquery');
    var routing = require('routing');
    var _ = require('underscore');
    var __ = require('orotranslation/js/translator');
    var ChoiceFilter = require('oro/filter/choice-filter');
    var tools = require('oroui/js/tools');
    require('jquery.select2');

    /**
     * Multiple select filter: filter values as multiple select options
     *
     * @export  oro/filter/dictionary-filter
     * @class   oro.filter.DictionaryFilter
     * @extends oro.filter.ChoiceFilter
     */
    DictionaryFilter = ChoiceFilter.extend({
        /* eslint-disable quote-props */
        /**
         * select2 will apply to element with this selector
         */
        elementSelector: '.select-values-autocomplete',

        /**
         * Filter selector template
         *
         * @property
         */
        template: template,
        templateSelector: '#dictionary-filter-template',

        /**
         * Template selector for dictionary field parts
         *
         * @property
         */
        fieldTemplate: fieldTemplate,
        fieldTemplateSelector: '#select-field-template',

        /**
         * Maximum value of count items for drop down menu.
         * If count values will be bigger than this value then
         * this filter will use select2 with autocomplete
         */
        maxCountForDropDownMode: 10,

        /**
         * Selectors for filter data
         *
         * @property
         */
        criteriaValueSelectors: {
            type: 'input[type="hidden"]:last'
        },

        filterParams: null,

        'class': null,

        select2ConfigData: null,

        isInitSelect2: false,

        previousData: [],

        /**
         * Data of selected values
         */
        selectedData: {},

        /**
         * Route name for dictionary values filter
         */
        dictionaryValueRoute: 'oro_dictionary_value',

        /**
         * Route name for dictionary search
         */
        dictionarySearchRoute: 'oro_dictionary_search',

        /**
         * @inheritDoc
         */
        constructor: function DictionaryFilter() {
            DictionaryFilter.__super__.constructor.apply(this, arguments);
        },

        /**
         * @inheritDoc
         */
        initialize: function(options) {
            // Each filter should have own copy,
            // otherwise 2 filters on same page will show same values
            this.selectedData = {};

            if (this.filterParams) {
                this.dictionaryClass = this.filterParams.class.replace(/\\/g, '_');
            } else {
                this.dictionaryClass = this.class.replace(/\\/g, '_');
            }

            this.listenTo(this, 'renderCriteriaLoadValues', this.renderCriteriaLoadValues);
            this.listenTo(this, 'updateCriteriaLabels', this.updateCriteriaLabels);

            DictionaryFilter.__super__.initialize.apply(this, arguments);
        },

        /**
         * @inheritDoc
         */
        reset: function() {
            DictionaryFilter.__super__.reset.apply(this, arguments);
            var select2element = this.$el.find(this.elementSelector);
            var data = select2element.inputWidget('data');
            if (data) {
                this.previousData = data;
            }
            select2element.inputWidget('data', null);
        },

        /**
         * Init render
         */
        render: function() {
            this.renderDeferred = $.Deferred();
            this._wrap('');
            if (this.$el.html() === '') {
                this._renderCriteria();
            }
        },

        /**
         * Execute ajax request to get data of entities by ids.
         *
         * @param successEventName
         */
        loadValuesById: function(successEventName) {
            var self = this;

            if (this.select2ConfigData === null) {
                var $container = self.$(self.elementSelector).parent();

                $container.addClass('loading');

                $.ajax({
                    url: routing.generate(
                        self.dictionaryValueRoute,
                        {
                            dictionary: this.dictionaryClass
                        }
                    ),
                    data: {
                        keys: this.value.value
                    },
                    success: function(response) {
                        $container.removeClass('loading');

                        self.trigger(successEventName, response);
                    }
                });
            } else {
                var select2ConfigData = this.select2ConfigData;
                var value = this.value.value;
                var result = {
                    results: _.filter(select2ConfigData, function(item) {
                        var id = item.id.toString();
                        return _.indexOf(value, id) !== -1;
                    })
                };
{'fraction_non_alphanumeric': 0.10573731626363206, 'fraction_numerical': 0.0035087719298245615, 'mean_word_length': 1.4790785143394451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3875061', 'n_tokens_mistral': 2587, 'n_tokens_neox': 2438, 'n_words': 537}