<commit_before>{% import 'OroUIBundle::macros.html.twig' as ui %}
{% import 'OroTagBundle::macros.html.twig' as tag %}
{% import 'OroEntityExtendBundle::macros.html.twig' as entityExtend %}

{% macro renderEmail(emailAddress, isPrimary) %}
    {% import 'OroEmailBundle::macros.html.twig' as email %}
    {% if isPrimary %}<strong>{% endif %}
        {{ email.email_address_simple(emailAddress) }}
    {% if isPrimary %}</strong>{% endif %}
{% endmacro %}

{% macro renderApiBlock(user) %}
    <div class="horizontal">
        {{ user.api ? user.api.apiKey : 'N/A' }}
        {% if resource_granted('oro_user_user_update') %}
            <a class="btn btn-small no-hash" id="btn-apigen" href="{{ path('oro_user_apigen', { id: user.id }) }}"
               data-title="{{ 'Generate key'|trans }}" data-message="{{ 'Generate key was successful. New key:'|trans }}">
                {{ 'Generate key'|trans }}
            </a>
        {% endif %}
    </div>
{% endmacro %}

<div class="widget-content form-horizontal box-content row-fluid">
    <div class="responsive-block">
        {{ ui.renderProperty('oro.user.username.label'|trans, entity.username) }}
        {{ ui.renderProperty('oro.user.birthday.label'|trans, entity.birthday ? entity.birthday|oro_format_date : null) }}

        {% set emails = [_self.renderEmail(entity.email, true)] %}
        {% for emailEntity in entity.emails %}
            {% set emails = emails|merge([_self.renderEmail(emailEntity.email)]) %}
        {% endfor %}
        {{ ui.renderProperty('oro.user.emails.label'|trans, emails|join('<br />')) }}

        {{ entityExtend.renderDynamicFields(dynamic) }}
    </div>
    <div class="responsive-block">
        {{ ui.renderProperty('oro.user.api.label'|trans, _self.renderApiBlock(entity)) }}

        {% if resource_granted('oro_tag_view_tag_cloud') %}
            {{ ui.renderProperty('oro.tag.entity_plural_label'|trans, tag.renderView(entity)) }}
        {% endif %}
    </div>
</div>

<script type="text/javascript">
    require(['jquery', 'oro/messenger'],
    function($, messenger){
        'use strict';
        $(function () {
            $(document).on('click', '#btn-apigen', function () {
                var el = $(this);

                $.get(el.attr('href'), function (data) {
                    el.prev().text(data);
                    var messageText = el.attr('data-message') + ' <strong>' + data + '</strong>';
                    messenger.notificationFlashMessage('success', messageText);
                });

                return false;
            });
        });
    });
</script><commit_msg>BAP-2563: Unify all view pages<commit_after>{% import 'OroUIBundle::macros.html.twig' as ui %}
{% import 'OroTagBundle::macros.html.twig' as tag %}
{% import 'OroEntityExtendBundle::macros.html.twig' as entityExtend %}

{% macro renderEmail(emailAddress, isPrimary) %}
    {% import 'OroEmailBundle::macros.html.twig' as email %}
    {% if isPrimary %}<strong>{% endif %}
        {{ email.email_address_simple(emailAddress) }}
    {% if isPrimary %}</strong>{% endif %}
{% endmacro %}

{% macro renderApiBlock(user) %}
    <div class="horizontal">
        {{ user.api ? user.api.apiKey : 'N/A' }}
        {% if resource_granted('oro_user_user_update') %}
            <a class="btn btn-small no-hash" id="btn-apigen" href="{{ path('oro_user_apigen', { id: user.id }) }}"
               data-title="{{ 'Generate key'|trans }}" data-message="{{ 'Generate key was successful. New key:'|trans }}">
                {{ 'Generate key'|trans }}
            </a>
        {% endif %}
    </div>
{% endmacro %}

<div class="widget-content">
    <div class="row-fluid form-horizontal">
        <div class="responsive-block">
            {{ ui.renderProperty('oro.user.username.label'|trans, entity.username) }}

            {% set birthday_string %}
                {{ entity.birthday is empty ? 'N/A'|trans : entity.birthday|oro_format_date }}
                {% if entity.birthday is not empty %}
                    ({{ entity.birthday|age_string({'default': 'N/A'}) }})
                {% endif %}
            {% endset %}
            {{ ui.renderProperty('oro.user.birthday.label'|trans, birthday_string) }}

            {% set emails = [_self.renderEmail(entity.email, true)] %}
            {% for emailEntity in entity.emails %}
                {% set emails = emails|merge([_self.renderEmail(emailEntity.email)]) %}
            {% endfor %}
            {{ ui.renderProperty('oro.user.emails.label'|trans, emails|join('<br />')) }}

            {{ entityExtend.renderDynamicFields(dynamic) }}
        </div>

        <div class="responsive-block">
            {{ ui.renderProperty('oro.user.api.label'|trans, _self.renderApiBlock(entity)) }}
        </div>
    </div>

    {% if resource_granted('oro_tag_view_tag_cloud') %}
        <div class="clearfix">
            <label class="title">{{ 'oro.tag.entity_plural_label'|trans }}</label>
            <div class="clearfix-oro container-fluid">
                {{ tag.renderView(entity) }}
            </div>
        </div>
    {% endif %}

    <script type="text/javascript">
        require(['jquery', 'oro/messenger'],
        function($, messenger){
            'use strict';
            $(function () {
                $(document).on('click', '#btn-apigen', function () {
                    var el = $(this);

                    $.get(el.attr('href'), function (data) {
                        el.prev().text(data);
                        var messageText = el.attr('data-message') + ' <strong>' + data + '</strong>';
                        messenger.notificationFlashMessage('success', messageText);
                    });

                    return false;
                });
            });
        });
    </script>
</div>

{'fraction_non_alphanumeric': 0.17594192879363982, 'fraction_numerical': 0.000691323885240235, 'mean_word_length': 2.325862068965517, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, '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': '6272939', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1665, 'n_words': 296}