{"size": 2287, "ext": "js", "max_stars_repo_path": "Resources/views/backend/adyen_payment_order/view/detail/window.js", "max_stars_repo_name": "DaveBueds/adyen-shopware5", "max_stars_repo_stars_event_min_datetime": "2020-06-19T07:41:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-12T11:27:46.000Z", "max_issues_repo_path": "Resources/views/backend/adyen_payment_order/view/detail/window.js", "max_issues_repo_name": "DaveBueds/adyen-shopware5", "max_issues_repo_issues_event_min_datetime": "2020-06-19T07:19:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-04T11:00:28.000Z", "max_forks_repo_path": "Resources/views/backend/adyen_payment_order/view/detail/window.js", "max_forks_repo_name": "DaveBueds/adyen-shopware5", "max_forks_repo_forks_event_min_datetime": "2020-08-05T11:54:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-23T03:53:27.000Z"}
{"max_stars_count": 9, "max_issues_count": 127, "max_forks_count": 12, "avg_line_length": 29.3205128205, "max_line_length": 120, "alphanum_fraction": 0.4792304329}
//{block name="backend/order/view/detail/window"}
// {$smarty.block.parent}
Ext.define('Shopware.apps.AdyenPaymentOrder.view.detail.Window', {
    /**
     * Override the customer detail window
     * @string
     */
    override: 'Shopware.apps.Order.view.detail.Window',

    initComponent: function () {
        var me = this;
        me.callParent();
    },

    /**
     * Overwrite to add adyen transaction tab if necessary
     */
    createTabPanel: function () {
        var me = this,
            result = me.callParent();

        result.add(me.createAdyenTab(!!me.record.raw.adyenTransaction));

        return result;
    },

    /**
     * Generate Adyen Tab
     */
    createAdyenTab: function (enableTab) {
        var me = this;

        var transactionStore = Ext.create('Shopware.apps.AdyenPaymentNotificationsListingExtension.store.Notification');

        let items = [];
        if (enableTab) {
            items.push(
                    Ext.create('Shopware.apps.AdyenPaymentOrder.view.detail.TransactionDetails', {
                        store: transactionStore,
                        layout: {
                            type: 'vbox',
                            align: 'stretch'
                        },
                        region: 'north'
                    }),
                    Ext.create('Shopware.apps.AdyenPaymentOrder.view.detail.TransactionTabs', {
                        region: 'center',
                        store: transactionStore,
                        record: me.record
                    })
            );
        }

        me.adyenTransactionTab = Ext.create('Ext.container.Container', {
            title: 'Adyen Notifications',
            layout: 'border',
            items: items,
            disabled: !enableTab
        });

        me.adyenTransactionTab.addListener('activate', function () {
            transactionStore.load({
                params: {
                    filter: JSON.stringify([{
                        property: "orderId",
                        value: me.record.get('id'),
                        operator: null,
                        expression: '='
                    }])
                }
            });
        }, me);

        return me.adyenTransactionTab;
    }
});
//{/block}
