yaroslavbr
11/23/2016 - 10:15 AM

update.html.twig

{% extends 'OroUIBundle:actions:update.html.twig' %}
{% import 'OroDataGridBundle::macros.html.twig' as dataGrid %}

{% oro_title_set({params : {"%sku%": entity.sku|default('N/A'|trans) , "%name%": (entity.id ? entity.defaultName.string : '')|default('N/A'|trans) } }) %}

{% set formAction = entity.id ? path('oro_product_update', { 'id': entity.id }) : path('oro_product_create')  %}

{% block navButtons %}
    {{ parent() }}

    {{ UI.cancelButton(path('oro_product_index')) }}
    {% set html = UI.saveAndCloseButton() %}
    {% if resource_granted('oro_product_create') %}
        {% set saveAndDuplicateButton = UI.saveActionButton({
            'label': 'oro.product.ui.save_and_duplicate'|trans,
            'action': 'save_and_duplicate'
        }) %}
        {% set html = html ~ saveAndDuplicateButton %}
    {% endif %}
    {% if entity.id or resource_granted('oro_product_update') %}
        {% set html = html ~ UI.saveAndStayButton() %}
    {% endif %}
    {{ UI.dropdownSaveButton({'html': html}) }}
{% endblock navButtons %}

{% block pageHeader %}
    {% if entity.id %}
        {% set breadcrumbs = {
            'entity':      entity,
            'indexPath':   path('oro_product_index'),
            'indexLabel': 'oro.product.entity_plural_label'|trans,
            'entityTitle': entity.sku ~ ' - ' ~ entity.defaultName
        } %}
        {{ parent() }}
    {% else %}
        {% set title = 'oro.ui.create_entity'|trans({'%entityName%': 'oro.product.entity_label'|trans}) %}
        {% include 'OroUIBundle::page_title_block.html.twig' with { title: title } %}
    {% endif %}
{% endblock pageHeader %}

{% block content_data %}
    {% set id = 'product-edit' %}

    {# Should be returned in scope of BB-2696 #}
    {# set generalData = [
        form_row(form.sku),
        form_row(form.variantFields)
    ] #}
    {%  set generalData = [
        form_row(form.sku)
    ] %}

    {% set generalData = generalData|merge([
        form_row(form.names),
        form_row(form.status),
        form_row(form.inventoryStatus),
        form_row(form.images),
        form_row(form.primaryUnitPrecision),
        form_row(form.additionalUnitPrecisions)
    ]) %}

    {% set generalBlock = {
        'title': 'oro.product.sections.general'|trans,
        'class': 'active',
        'subblocks': [{
            'title': '',
            'data': generalData
        },
        {
            'title': '',
            'data': [
                form_row(form.descriptions),
            ]
        },
        {
            'title': '',
            'data': [
                form_row(form.shortDescriptions),
            ],
            'spanClass': 'responsive-cell'
        }]
    } %}

    {% set dataBlocks = [
        generalBlock
    ] %}

    {% set additionalData = [] %}
    {% for child in form.children if child.vars.extra_field is defined and child.vars.extra_field %}
        {% set additionalData = additionalData|merge([form_row(child)]) %}
    {% endfor %}
    {% if additionalData is not empty %}
        {% set dataBlocks = dataBlocks|merge([{
            'title': 'oro.product.sections.additional'|trans,
            'subblocks': [{
                'title': '',
                'useSpan': false,
                'data' : additionalData
            }]
        }] ) %}
    {% endif %}

    {% set dataBlocks = dataBlocks|merge([{
        'title': 'Attributes',
        'subblocks': [{
            'title': 'Group1',
            'useSpan': false,
            'data' : additionalData
        },

        {
        'title': 'Group2',
        'useSpan': false,
        'data' : additionalData
        },
    {
    'title': 'Group3',
    'useSpan': false,
    'data' : additionalData
    },
    {
    'title': 'Group4',
    'useSpan': false,
    'data' : additionalData
    },
    {
    'title': 'Group5',
    'useSpan': false,
    'data' : additionalData
    }


    ]
    }] ) %}

    {# Should be returned in scope of BB-2696 #}
    {#
    {% set productHasVariants = entity.hasVariants and form.variantFields.vars.choices|length != 0 %}
    {% if productHasVariants %}
        {% set variantLinksForm = form.variantLinks %}
        {% set dataBlocks = dataBlocks|merge([{
            'title' : 'oro.product.sections.productVariants'|trans,
            'subblocks': [{
                'title' : null,
                'useSpan': false,
                'data' : [
                    form_widget(variantLinksForm.appendVariants, {'id': 'productAppendVariants'}),
                    form_widget(variantLinksForm.removeVariants, {'id': 'productRemoveVariants'}),
                    dataGrid.renderGrid('oro_product-product_variants-product_edit', {'parentProduct': entity.id}, { cssClass: 'inner-grid' })
                ]
            }]
        }] ) %}
    {% endif %}
    #}
    {% set data = {
        'formErrors': form_errors(form),
        'dataBlocks': dataBlocks
    }%}

    {{ parent() }}
{% endblock content_data %}