<commit_before>{% set hasImportProcessor = importProcessor is defined and importProcessor is not empty %}
{% set hasExportProcessor = exportProcessor is defined and exportProcessor is not empty %}
{% set hasExportTemplateProcessor = exportTemplateProcessor is defined and exportTemplateProcessor is not empty %}
{% set exportAllowed = hasExportProcessor and resource_granted('oro_importexport_export') %}
{% set importAllowed = hasImportProcessor and resource_granted('oro_importexport_import') %}

{% if exportAllowed or importAllowed %}
    {% if hasExportTemplateProcessor %}
        <div class="btn-group">
            <a type="button"
                class="btn no-hash"
                target="_blank"
                href="{{ path('oro_importexport_export_template', {'processorAlias': exportTemplateProcessor}) }}">
                {{ 'oro.importexport.import.tempate'|trans }}
            </a>
        </div>
    {% endif %}

    <div class="btn-group">
        {% if importAllowed %}
            <a type="button"
                class="btn import-btn icons-holder-text no-hash"
                href="{{ path('oro_importexport_import_form', {'entity': entity_class}) }}">
                <i class="icon-signin hide-text">{{ 'oro.importexport.import.label'|trans }}</i>{{ 'oro.importexport.import.label'|trans }}
            </a>
        {% endif %}

        {% if exportAllowed %}
            <a type="button"
               class="btn export-btn icons-holder-text no-hash"
               href="{{ path('oro_importexport_export_instant', {'processorAlias': exportProcessor}) }}">
                <i class="icon-signout hide-text">{{ 'oro.importexport.export.label'|trans }}</i>{{ 'oro.importexport.export.label'|trans }}
            </a>
        {% endif %}
    </div>

    <script type="text/javascript">
        require(['jquery', 'orotranslation/js/translator', 'oro/dialog-widget', 'oroui/js/mediator', 'oroimportexport/js/export-handler'],
        function($, __, DialogWidget, mediator, exportHandler) {
            {% if hasImportProcessor %}
            $('.import-btn').on('click', function(e) {
                e.preventDefault();

                var widget = new DialogWidget({
                    'url': this.href,
                    'title': {{ importTitle|default('oro.importexport.import.label'|trans)|json_encode|raw }},
                    'stateEnabled': false,
                    'incrementalPosition': false,
                    'dialogOptions': {
                        'width': 650,
                        'autoResize': true,
                        'modal': true,
                        'minHeight': 100
                    }
                });
                widget.render();

                {% if dataGridName is defined %}
                var datagridName = {{ dataGridName|json_encode|raw }};
                widget.on('importComplete', function (data) {
                    if (data.success) {
                        mediator.trigger('datagrid:doReset:' + datagridName);
                    }
                });
                {% endif %}
            });
            {% endif %}

            {% if hasExportProcessor %}
            $('.export-btn').on('click', function(e) {
                e.preventDefault();

                var exportStartedMessage = exportHandler.startExportNotificationMessage();
                $.getJSON(this.href, function(data) {
                    exportStartedMessage.close();
                    exportHandler.handleExportResponse(data);
                });
            });
            {% endif %}
        });
    </script>
{% endif %}
<commit_msg>BAP-4550: Put grid export to mass actions<commit_after>{% set hasImportProcessor = importProcessor is defined and importProcessor is not empty %}
{% set hasExportProcessor = exportProcessor is defined and exportProcessor is not empty %}
{% set hasExportTemplateProcessor = exportTemplateProcessor is defined and exportTemplateProcessor is not empty %}
{% set exportAllowed = hasExportProcessor and resource_granted('oro_importexport_export') %}
{% set importAllowed = hasImportProcessor and resource_granted('oro_importexport_import') %}

{% if exportAllowed or importAllowed %}
    <div class="btn-group">
        {% if exportAllowed %}
            <a type="button"
               class="btn export-btn icons-holder-text no-hash"
               href="{{ path('oro_importexport_export_instant', {'processorAlias': exportProcessor}) }}">
                <i class="icon-signout hide-text">{{ 'oro.importexport.export.label'|trans }}</i>{{ 'oro.importexport.export.label'|trans }}
            </a>
        {% endif %}

        {% if importAllowed %}
            <a type="button"
               class="btn import-btn icons-holder-text no-hash"
               href="{{ path('oro_importexport_import_form', {'entity': entity_class}) }}">
                <i class="icon-signin hide-text">{{ 'oro.importexport.import.label'|trans }}</i>{{ 'oro.importexport.import.label'|trans }}
            </a>
        {% endif %}
        {% if hasExportTemplateProcessor %}
            <a href="#" class="btn dropdown-toggle" data-toggle="dropdown">
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu">
                <li>
                    <a type="button"
                       class="no-hash"
                       target="_blank"
                       href="{{ path('oro_importexport_export_template', {'processorAlias': exportTemplateProcessor}) }}">
                        <i class="icon-file-alt hide-text"></i>{{ 'oro.importexport.import.tempate'|trans }}
                    </a>
                </li>
            </ul>
        {% endif %}
    </div>

    <script type="text/javascript">
        require(['jquery', 'orotranslation/js/translator', 'oro/dialog-widget', 'oroui/js/mediator', 'oroimportexport/js/export-handler'],
        function($, __, DialogWidget, mediator, exportHandler) {
            {% if hasImportProcessor %}
            $('.import-btn').on('click', function(e) {
                e.preventDefault();

                var widget = new DialogWidget({
                    'url': this.href,
                    'title': {{ importTitle|default('oro.importexport.import.label'|trans)|json_encode|raw }},
                    'stateEnabled': false,
                    'incrementalPosition': false,
                    'dialogOptions': {
                        'width': 650,
                        'autoResize': true,
                        'modal': true,
                        'minHeight': 100
                    }
                });
                widget.render();

                {% if dataGridName is defined %}
                var datagridName = {{ dataGridName|json_encode|raw }};
                widget.on('importComplete', function (data) {
                    if (data.success) {
                        mediator.trigger('datagrid:doReset:' + datagridName);
                    }
                });
                {% endif %}
            });
            {% endif %}

            {% if hasExportProcessor %}
            $('.export-btn').on('click', function(e) {
                e.preventDefault();

                var exportStartedMessage = exportHandler.startExportNotificationMessage();
                $.getJSON(this.href, function(data) {
                    exportStartedMessage.close();
                    exportHandler.handleExportResponse(data);
                });
            });
            {% endif %}
        });
    </script>
{% endif %}

{'fraction_non_alphanumeric': 0.1342770207699431, 'fraction_numerical': 0.002116682100806985, 'mean_word_length': 1.793791574279379, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, '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': '6275592', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1822, 'n_words': 366}