Last active
July 22, 2021 13:12
-
-
Save buddhaCode/b27a483d6d15aa5ea7ff30dc0de0f32c to your computer and use it in GitHub Desktop.
Shopware postMessage enabled iFrame in a tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//{namespace name=backend/order/main} | |
//{block name="backend/order/view/detail/window"} | |
//{$smarty.block.parent} | |
Ext.define('Shopware.apps.Order.view.detail.Window-MyIframePostMessageApi', { | |
override: 'Shopware.apps.Order.view.detail.Window', | |
createTabPanel: function() { | |
var me = this, tabs; | |
tabs = me.callParent(arguments); | |
tabs.add(me.createTabWithIFrame()); | |
return tabs; | |
}, | |
createTabWithIFrame: function () { | |
var me = this; | |
return me.createPostMessageApiEnabledTabComponent( | |
'Mein Tab', | |
'{url controller=MyController action=index orderId=""}' + me.record.get('id') | |
); | |
}, | |
createPostMessageApiEnabledTabComponent: function(label, url) { | |
var me = this, | |
swModuleManager = Shopware.ModuleManager, | |
// @see Shopware.ModuleManager.createSimplifiedModule() | |
instance = swModuleManager.uuidGenerator.generate(), | |
content = swModuleManager.createContentFrame(url, instance, true), | |
subApp = null, | |
windows = Ext.create('Ext.util.MixedCollection'), | |
contentWindow; | |
contentWindow = Ext.create('Ext.Component', { | |
title: label, | |
component: 'main', | |
content: 'content', | |
style: 'height: 100%', | |
listeners: { | |
render: function(component, eOpts) { | |
component.el.appendChild(content); | |
component.setLoading(true); | |
}, | |
}, | |
}); | |
content.dom._window = contentWindow; | |
windows.add('main', contentWindow); | |
// push component into registry | |
swModuleManager.modules.add(instance, { | |
name: url, | |
instance: instance, | |
subApp: subApp, | |
windows: windows | |
}); | |
return contentWindow; | |
} | |
}); | |
//{/block} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment