{extends "[shared]window.tpl"}

{block size}
    width = 1400;
    height = 900;
{/block}

{block css}
    {$smarty.block.parent}
    {if $body.enableConfigurator}
        <link rel="stylesheet" href="/web/bundles/feedgenerator/codemirror/lib/codemirror.css"/>
        <link rel="stylesheet" href="/web/bundles/feedgenerator/codemirror/addon/scroll/simplescrollbars.css"/>
        <link rel="stylesheet" href="/web/bundles/feedgenerator/codemirror/addon/lint/lint.css"/>
        <link rel="stylesheet" type="text/css" href="/web/bundles/feedgenerator/css/feedConfigurator.css?15"/>
    {/if}
    <style>
        .wpj-main-panel-title .toggle {
            height: 20px;
        }

        .help-tip.label-help-tip i {
            line-height: 1;
            margin-left: 3px;
        }

        .wpj-main-panel-title .help-tip {
            line-height: 1;
        }

        .form-group.toggle-group {
            margin-top: 25px;
        }

        .help-text {
            text-align: justify;
        }

        .dataInfo-opener {
            position: absolute;
            left: 0;
            top: 5px;
            color: #1358be;
            cursor: pointer;
        }

        .dataInfo, .dataInfo ul {
            list-style-type: none;
            padding-left: 0;
        }

        .dataInfo [data-info-opener] {
            cursor: pointer;
        }

        .dataInfo ul li {
            padding-left: 25px;
        }

        .dataInfo ul li:first-child {
            border-top: 1px solid #dedede;
        }

        .dataInfo li > div {
            position: relative;
            padding: 5px 50px 5px 25px;
        }

        .dataInfo .dataInfo-row:hover {
            background-color: #f5f5f5;
        }

        .dataInfo li:not(:last-child) {
            border-bottom: 1px solid #dedede;
        }

        .dataInfo [data-field-btn-copy] {
            color: #666;
            cursor: copy;
            position: absolute;
            right: 5px;
            top: 5px;
        }

        .dataInfo .help-tip {
            right: 25px;
            padding: 0;
            top: 6px;
        }

        /* swap icons on hover */
        .dataInfo [data-field-btn-copy] > i.bi-clipboard-plus-fill {
            display: none;
        }

        .dataInfo [data-field-btn-copy]:hover i.bi-clipboard-plus-fill,
        .dataInfo [data-field-btn-copy]:focus i.bi-clipboard-plus-fill {
            display: initial;
        }

        .dataInfo [data-field-btn-copy]:hover i.bi-clipboard-fill,
        .dataInfo [data-field-btn-copy]:focus i.bi-clipboard-fill {
            display: none;
        }

        /* animate color on click */
        .dataInfo [data-field-btn-copy]:active {
            color: #56d056; /* change to green immediately when pressed */
            transition: color 0s; /* remove the transition for immediate color change */
        }

        .dataInfo [data-field-btn-copy]:not(:active) {
            transition: color 2s ease; /* slower color transition for reverting to original color */
        }
    </style>
{/block}

{block js}
    {$smarty.block.parent}
    {if $body.enableConfigurator}
        {asset_compile}
            <script src="./static/js/jquery.mjs.nestedSortable.js"></script>
            <script src="../web/bundles/feedgenerator/codemirror/lib/codemirror.js"></script>
            <script src="../web/bundles/feedgenerator/codemirror/addon/scroll/simplescrollbars.js"></script>
            <script src="../web/bundles/feedgenerator/jshint/jshint.js"></script>
            <script src="../web/bundles/feedgenerator/codemirror/addon/lint/lint.js"></script>
            <script src="../web/bundles/feedgenerator/codemirror/addon/lint/javascript-lint.js"></script>
            <script src="../web/bundles/feedgenerator/codemirror/addon/edit/matchbrackets.js"></script>
            <script src="../web/bundles/feedgenerator/codemirror/mode/xml/xml.js"></script>
            <script src="../web/bundles/feedgenerator/codemirror/mode/javascript/javascript.js"></script>
            <script src="../web/bundles/feedgenerator/js/feedConfigurator.js?15"></script>
            <script defer src="./static/js/font-awesome.free.all.js"></script>
        {/asset_compile}
        <script>
            jQuery(document).ready(function () {
                var $feedConfiguratorElement = $('[data-ovalek="feedConfigurator"]');
                var feedConfigurator = $feedConfiguratorElement.feedConfigurator({
                    sampleNodes: {
                        'description': $('<li class="node" data-node="description" data-alias="{'node_description'|translate}"><div class="nodeWrapper"><div class="nodeMove"><i class="far fa-comment-alt"></i></div><div class="nodeContent"><textarea name="value"></textarea></div></div></li>'),
                        'cycle': $('<li class="node" data-node="cycle" data-alias="{'node_cycle'|translate}"><div class="nodeWrapper"><div class="nodeMove"><i class="fas fa-sync-alt"></i></div><div class="nodeContent"><input class="third" type="text" name="value" title="{'node_cycle_expression_title'|translate}" placeholder="{'node_cycle_expression'|translate}"/><input class="third" type="text" name="indexAccessName" pattern="[A-Za-z0-9_\\-]*" placeholder="{'node_cycle_index'|translate}" title="{'node_cycle_index_title'|translate}"/><input class="third" type="text" name="valueAccessName" pattern="[A-Za-z0-9_\\-]*" placeholder="{'node_cycle_value'|translate}" title="{'node_cycle_value_title'|translate}"/></div></div></li>'),
                        'attribute': $('<li class="node" data-node="attribute" data-alias="{'node_attribute'|translate}"><div class="nodeWrapper"><div class="nodeMove"><i class="fas fa-paperclip"></i></div><div class="nodeContent"><input type="text" name="value"/></div></div></li>'),
                        'value': $('<li class="node" data-node="value" data-alias="{'node_value'|translate}"><div class="nodeWrapper"><div class="nodeMove"><i class="fas fa-font"></i></div><div class="nodeContent"><input type="text" name="value"/></div></div></li>'),
                        'element': $('<li class="node" data-node="element" data-alias="{'node_element'|translate}"><div class="nodeWrapper"><div class="nodeMove"><i class="fas fa-code"></i></div><div class="nodeContent"><input type="text" name="value" pattern="[^\ ]*"/></div></div></li>'),
                        'condition': $('<li class="node" data-node="condition" data-alias="{'node_condition'|translate}"><div class="nodeWrapper"><div class="nodeMove"><i class="fas fa-question"></i></div><div class="nodeContent"><input type="text" name="value"/></div></div></li>'),
                        'expression': $('<li class="node" data-node="expression" data-alias="{'node_expression'|translate}"><div class="nodeWrapper"><div class="nodeMove"><i class="fas fa-superscript"></i></div><div class="nodeContent"><input type="text" name="value"/></div></div></li>'),
                        'multiline': $('<li class="node" data-node="multiline" data-alias="{'node_multiline'|translate}"><div class="nodeWrapper"><div class="nodeMove"><i class="fab fa-js-square"></i></div><div class="nodeContent"><textarea name="value"></textarea></div></div></li>')
                    }
                });
                var $dataInfo = $('[data-feed="data-info"]');
                var $consoleLogs = $('[data-feed="console-logs"]');
                $consoleLogs.data('codemirror', CodeMirror.fromTextArea($consoleLogs[0], {
                    mode: {
                        name: 'javascript'
                    },
                    lineNumbers: false,
                    scrollbarStyle: "overlay",
                    json: true,
                    matchBrackets: true,
                    readOnly: true
                }));
                console.log(feedConfigurator.feedConfigurator('serialize'));
                var feedGeneratorForm = $feedConfiguratorElement.closest('form');
                feedGeneratorForm.on('submit', function () {
                    var configuration = feedConfigurator.feedConfigurator('serialize');
                    var $formInput = feedGeneratorForm.find('[name="data[template]"]');
                    if ($formInput.length) {
                        $formInput.val(JSON.stringify(configuration));
                    }
                    console.log(configuration);
                });

                var $previewEl = $('[data-preview="xml"]');
                var $previewErrorEl = $('[data-preview-error]');
                var $previewLanguageEl = $('[data-preview="language"]');
                var $previewCurrencyEl = $('[data-preview="currency"]');
                var $previewDomainEl = $('[data-preview="domain"]');
                $previewEl.data('codemirror', CodeMirror.fromTextArea($previewEl[0], {
                    mode: {
                        name: 'xml',
                        matchClosing: true
                    },
                    readOnly: true
                }));
                var refreshPreview = function () {
                    $('[data-preview-refresh-btn]').addClass('gly-spin');
                    $.post(
                       "launch.php?s=feeds.php&acn=configuratorPreview&ID={$body.data.id}&objectID=" + $('[name="search-object-id"]').val()
                       + "&language=" + $previewLanguageEl.val()
                       + "&currency=" + $previewCurrencyEl.val()
                       + "&domain=" + $previewDomainEl.val(),
                       { 'wipTemplate': JSON.stringify(feedConfigurator.feedConfigurator('serialize')) },
                       function (data) {
                           $previewErrorEl.hide().html('');
                           $previewEl.parent().show();
                           $previewEl.data('codemirror').setValue(data.xmlPreview ? data.xmlPreview : '');

                           $dataInfo.html(data.dataInfo);
                           initializeDataInfo($dataInfo);
                           $('[data-preview-refresh-btn]').removeClass('gly-spin');

                           var consoleLogs = '';
                           if (Array.isArray(data.consoleLogs)) {
                               data.consoleLogs.forEach(function (log, index, array) {
                                   // add arrow character with non-breakable space at the beginning of a log entry
                                   consoleLogs += String.fromCharCode(9658) + String.fromCharCode(160);
                                   // add log and indent its content on following lines (if present) to improve readability
                                   consoleLogs += typeof log === 'string' ? log.replace(/\n/g, String.fromCharCode(13) + String.fromCharCode(160) + String.fromCharCode(160)) : log;
                                   // add new line if there are more following entries
                                   consoleLogs += (index < array.length - 1) ? String.fromCharCode(13) : '';
                               });
                           }
                           $consoleLogs.data('codemirror').setValue(consoleLogs);
                       }
                    ).fail(function (data) {
                        $previewErrorEl.show().html(data.responseText);
                        $previewEl.parent().hide();
                        $previewEl.data('codemirror').setValue('');
                        $('[data-preview-refresh-btn]').removeClass('gly-spin');
                    });
                };
                $feedConfiguratorElement.on('keypress', function (event) {
                    if (event.keyCode == 13 && !$(event.target).is('textarea')) {
                        refreshPreview();
                        return false;
                    }
                });
                $('[data-preview-refresh-btn]').on('click', function (event) {
                    event.preventDefault();
                    refreshPreview();
                });
                refreshPreview();

                // refresh codemirror editor when tab is changed
                // (otherwise it wont be visible if initial tab was different)
                $('#windowTables a').on('shown.bs.tab', function () {
                    $feedConfiguratorElement.find('[data-codemirror="xml"]').each(function (index, element) {
                        $(element).data('codemirror').refresh();
                    });
                    $previewEl.data('codemirror').refresh();
                    $consoleLogs.data('codemirror').refresh();
                    $feedConfiguratorElement.find('[data-node="multiline"] > .nodeWrapper textarea[name]').each(function (i, e) {
                        $(e).data('codemirror').refresh();
                    })
                });

                var copyToClipboard = function (value) {
                    var $temp = $("<input>");
                    $("body").append($temp);
                    $temp.val(value).select();
                    document.execCommand("copy");
                    $temp.remove();
                }

                var initializeDataInfo = function ($dataInfo) {
                    $dataInfo.find("ul.dataInfo li > ul").hide().each(function (index, el) {
                        var $el = $(el);
                        if (!$el.children().length) {
                            $el.remove();
                            return;
                        }
                        $el.parent('li').find('> strong').css({ 'cursor': 'pointer', 'text-decoration': 'underline' });
                    });
                    $dataInfo.find("ul.dataInfo li > strong").click(function () {
                        $(this).closest('li').children('ul').slideToggle(200);
                    });
                    $dataInfo.find("ul.dataInfo [data-info-opener]").click(function (e) {
                        if (!$(e.target).closest('[data-field-btn-copy]').length && !$(e.target).closest('[data-feedDataInfo-toggle="tooltip"]').length) {
                            $(this).find('.dataInfo-opener .bi').toggleClass('bi-plus-circle').toggleClass('bi-dash-circle');
                            $(this).closest('li').children('ul').slideToggle(200);
                        }
                    });
                    $dataInfo.find('ul.dataInfo [data-field-btn-copy]').click(function () {
                        copyToClipboard($(this).data('value'));
                    });

                    $dataInfo.find('[data-feedDataInfo-toggle="tooltip"]').tooltip({
                        container: "body",
                        trigger: "manual",
                        html: true,
                        animation: false
                    }).on("mouseenter", function () {
                        var _this = this;
                        $(this).tooltip("show");
                        $(".tooltip").on("mouseleave", function () {
                            $(_this).tooltip('hide');
                        });
                    }).on("mouseleave", function () {
                        var _this = this;
                        setTimeout(function () {
                            if (!$(".tooltip:hover").length) {
                                $(_this).tooltip("hide");
                            }
                        }, 50);
                    });
                };
                initializeDataInfo($dataInfo);
                initializeDataInfo($('[data-feed="syntax-info"]'));

                $('[data-feedConfigurator-search]').each(function (index, el) {
                    var $el = $(el);
                    var autocompleteConfig = {
                        select: function (e, data) {
                            var item = data.data.items[data.item.data('autocomplete-item')];
                            if (item !== undefined) {
                                $('[name="search-object-id"]').val(
                                   item.hasOwnProperty('id') ? item.id : item.value // product has id, article has value
                                );
                                refreshPreview();
                                return true;
                            } else {
                                return false;
                            }
                        },
                        minLength: 3,
                    };
                    if ($el.attr('data-feedConfigurator-search') !== 'product') {
                        autocompleteConfig.type = $el.attr('data-feedConfigurator-search');
                        // eg. article is NOT compatible with default template
                        {literal}
                        autocompleteConfig.subtemplates = {
                            menuItem: '<div tabindex="-1" data-autocomplete-item="{{=index}}">' +
                               '<p><strong>{{=item.label}}</strong><br> <small>{{=item.value}}</small></p>' +
                               '{{#def.buttons}}' +
                               '</div>' +
                               '{{#def.bottom}}',
                        };
                        {/literal}
                    }
                    $el.adminAutoComplete(autocompleteConfig);
                });

                $('[data-configurator-panel-header] a').on('click', function (event) {
                    event.preventDefault();
                    var $trigger = $(this);
                    $('[data-configurator-panel-header] li').removeClass('active');
                    $trigger.parent().addClass('active');
                    var $selectedPanel = $('[data-configurator-panel="' + $trigger.attr('data-reference-panel') + '"]');
                    $('[data-configurator-panel]').not($selectedPanel).slideUp(150, function () {
                        $selectedPanel.slideDown(150, function () {
                            $previewEl.data('codemirror').refresh();
                            $consoleLogs.data('codemirror').refresh();
                        });
                    });
                });

                $('[data-more-settings-opener]').click(function () {
                    $('[data-more-settings-content]').slideToggle(200);
                });
            });
        </script>
    {/if}
    <script>
        jQuery(document).ready(function () {
            var $ttl = $('#feedFrm_data_ttl');
            var $ttlContainer = $('#feedFrm_data_ttl_container');
            $('#feedFrm_expensive').on('change', function (event) {
                if (this.checked) {
                    $ttl.val('');
                }
                $ttlContainer.slideToggle(this.checked);
            });

            $('[data-template-links-container] a').click(function () {
                if (confirm("{'templateWarning'|translate}")) {
                    window.location.href = $(this).attr('data-url');
                }
            })
        });
    </script>
{/block}

{block tabs}
    {if $body.enableConfigurator}
        {windowTab id='flapConfig' label=translate('header')}
        {windowTab id='flapConfigurator' label=translate('configurator')}
        {windowTab id='flapSettings' label=translate('data_source')}
        {if $body.data.report}
            {windowTab id='flapReport' label=translate('report')}
        {/if}
    {else}
        {windowTab id='flapConfig' label=translate('header')}
        {if $body.data.id}
            {windowTab id='flapSettings' label=translate('data_source')}
        {/if}
    {/if}
{/block}

{block 'form-class'}{/block}

{block tabsContent}
    <div id="flapConfig" class="tab-pane fade active in boxStatic box">
        <div class="wpj-main-panel-title">
            <h4>{'header'|translate}</h4>
            {if $body.data.id}
            <div class="form-group m-b-0">
                <div class="d-flex align-items-center">
                    {print_toggle name="active" value=$body.data.active}
                    <label for="feedFrm_active">{'active'|translate}</label>
                    <a class="help-tip help-tip-left" data-toggle="tooltip" title="{'active_desc'|translate}"><i
                           class="bi bi-question-circle"></i></a>
                </div>
            </div>
            {/if}
        </div>

        {if $body.data.id}
            {include 'window/feeds.config.tpl'}
        {else}
            {include 'window/feeds.config.new.tpl'}
        {/if}
    </div>
    {if $body.enableConfigurator}
        <div id="flapConfigurator" class="tab-pane fade active in boxStatic box">
            <div class="wpj-main-panel-title">
                <h4>
                    {'configurator'|translate}
                    {if !findRight('FEEDS_CONFIGURATOR_EDIT')}
                        [pouze pro čtení]
                    {/if}
                </h4>
            </div>
            {if findRight('FEEDS_CONFIGURATOR_EDIT')}
                <input type="hidden" name="data[template]" value="{$body.data.template}"/>
            {else}
                <p>(změny nebudou uloženy)</p>
            {/if}
            <div class="configurator" data-ovalek="feedConfigurator" data-default="{$body.data.template}">
                <div class="tree">
                    <div class="textareaWrapper">
                        <textarea data-codemirror="xml" data-type="beginning" title="Beginning"></textarea>
                    </div>
                    <ul class="nodesContainer" data-type="nodesContainer"></ul>
                    <div class="textareaWrapper">
                        <textarea data-codemirror="xml" data-type="end" title="End"></textarea>
                    </div>
                </div>
                <div class="toolsContainer">
                    <div class="tools">
                        <ul class="nodesContainer" data-type="sampleElements"></ul>
                        <div class="trashContainer">
                            <ul class="nodesTrash" data-type="trash"></ul>
                            <div class="trashIcon btn btn-default">
                                <i class="glyphicon glyphicon-trash"></i>
                                Smazat prvek
                            </div>
                        </div>

                        <div class="previewDataPanelContainer">
                            <div class="previewContextSwitcher">
                                <div class="d-flex align-center">
                                    <div class="searchProductContainer">
                                        <div class="form-search search-only">
                                            {if is_a($body.feedService, '\KupShop\FeedGeneratorBundle\Feed\IExternalFeed')}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                            {/if}
                                            <input
                                               type="{if is_a($body.feedService, '\KupShop\FeedGeneratorBundle\Feed\IExternalFeed')}text{else}hidden{/if}"
                                               class="form-control search-query" name="search-object-id" value="{$body.objectID}"/>
                                            {if $body.feedService->getObjectType() === 'product'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-product-name"
                                                       data-feedConfigurator-search="product" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít produkt">
                                            {elseif $body.feedService->getObjectType() === 'article'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-article-name"
                                                       data-feedConfigurator-search="article" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít článek">
                                            {elseif $body.feedService->getObjectType() === 'producer'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-producer-name"
                                                       data-feedConfigurator-search="producers" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít výrobce">
                                            {elseif $body.feedService->getObjectType() === 'section'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-section-name"
                                                       data-feedConfigurator-search="category" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít sekci">
                                            {elseif $body.feedService->getObjectType() === 'seller'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-section-name"
                                                       data-feedConfigurator-search="sellers" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít prodejce">
                                            {elseif $body.feedService->getObjectType() === 'page'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-page-name"
                                                       data-feedConfigurator-search="page" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít stránku">
                                            {elseif $body.feedService->getObjectType() === 'order'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-order-name"
                                                       data-feedConfigurator-search="order_id" style="width:100%; padding-left:40px;"
                                                       title="V náhledu se zobrazí pouze taková objednávka, která zároveň splňuje podmínky nastavené ve zdroji dat feedu."
                                                       placeholder="Najít objednávku">
                                            {elseif $body.feedService->getObjectType() === 'review'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-review-name"
                                                       data-feedConfigurator-search="reviews" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít recenzi"
                                                />
                                            {elseif $body.feedService->getObjectType() === 'user'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-user-name"
                                                       data-feedConfigurator-search="user" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít uživatele">
                                            {elseif $body.feedService->getObjectType() === 'sale'}
                                                <i class="search-icon glyphicon glyphicon-search"></i>
                                                <input type="text" class="form-control search-query input-sm" name="search-sale-name"
                                                       data-feedConfigurator-search="sales" style="width:100%; padding-left:40px;"
                                                       placeholder="Najít prodejku">
                                            {/if}
                                        </div>
                                    </div>
                                    <span class="btn btn-default btn-sm" title="more settings" data-more-settings-opener><span
                                           class="glyphicon glyphicon-cog"></span></span>
                                    <span class="btn btn-secondary btn-sm" data-preview-refresh-btn title="refresh">
                                        <span class="glyphicon glyphicon-refresh"></span>
                                        Znovu načíst
                                    </span>
                                </div>

                                <div class="form-group" data-more-settings-content style="display: none;">
                                    <div>
                                        {print_select var=$body.languages selected=$body.data.id_language param='id="preview_id_language" data-preview="language"'}
                                    </div>

                                    <div>
                                        {print_select var=$body.currencies selected=$body.data.id_currency param='id="preview_id_currency" data-preview="currency"'}
                                    </div>

                                    <div>
                                        {print_select var=$body.domains param='id="preview_id_domain" data-preview="domain"'}
                                    </div>
                                </div>
                            </div>
                            <ul class="nav nav-tabs" data-configurator-panel-header>
                                <li role="presentation" class="active"><a href="#"
                                                                          data-reference-panel="1">{'tools_tab_preview'|translate}</a></li>
                                <li role="presentation"><a href="#" data-reference-panel="2">{'tools_tab_data'|translate}</a></li>
                                <li role="presentation"><a href="#" data-reference-panel="3">{'tools_tab_log'|translate}</a></li>
                                <li role="presentation"><a href="#" data-reference-panel="4">{'tools_tab_help'|translate}</a></li>
                            </ul>
                            <div class="panel panel-default" data-configurator-panel="1">
                                <div class="panel-body">
                                    <div data-preview-error class="preview-error"></div>
                                    <div class="textareaWrapper">
                                        <textarea data-preview="xml"></textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="panel panel-default" data-configurator-panel="2" style="display:none;">
                                <div class="panel-body" data-feed="data-info">
                                </div>
                            </div>
                            <div class="panel panel-default" data-configurator-panel="3" style="display:none;">
                                <div class="panel-body">
                                    <textarea data-feed="console-logs" disabled="disabled"></textarea>
                                </div>
                            </div>
                            <div class="panel panel-default" data-configurator-panel="4" style="display:none;">
                                <div class="panel-body" data-feed="syntax-info">
                                    {include 'window/feeds.help.tpl'}
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

            <div class="btn-group pull-left dropup" data-template-links-container>
                <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
                        aria-expanded="false">
                    {'setDefaultTemplate'|translate} <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    {foreach $body.configurableFeedTemplates as $feedTemplate => $feedTemplateName}
                        {if $feedTemplate != ''}
                            <li>
                                <a href="#"
                                   data-url="launch.php?s=feeds.php&acn=loadTemplate&ID={$body.data.id}&feedTemplate={$feedTemplate}&flap=2">{$feedTemplateName}</a>
                            </li>
                        {/if}
                    {/foreach}
                </ul>
            </div>
        </div>
        {if $body.data.report}
            <div id="flapReport" class="tab-pane fade active in boxStatic box">
                <div class="wpj-main-panel-title">
                    <h4>{'report'|translate}</h4>
                </div>
                {include 'window/feeds.report.tpl'}
            </div>
        {/if}
    {/if}
    <div id="flapSettings" class="tab-pane fade active in boxStatic box">
        <div class="wpj-main-panel-title">
            <h4>{'data_source'|translate}</h4>
        </div>
        <input type="hidden" name="data[settings]" value="{$body.data.settings}"/>
        {if $body.feedService}
            {include "window/ConfigurableFeedObjectType/{$body.feedService->getObjectType()}.tpl"}
        {/if}
    </div>
{/block}
