Ext.define("App.view.WorkshopWindow", {
    extend: "Ext.window.Window",
    alias: "widget.workshopWindow",
    xtype: "workshopWindow",
    title: App.localeRes("Workshop Details"),
    height: '95%',
    width: '90%',
    modal: true,
    scrollable: true,
    resizable: true,
    layout: 'vbox',
    constrainHeader: true,
    params: {},  
    
    initComponent: function() {
        var me = this;

        me.tools= [
            {
                xtype: 'button',
                tooltip: 'Refresh',
                itemId: 'refreshBtn',
                iconCls:'x-fa fa-sync ',
                title: 'Refresh',
                ui: "header",
                margin: '0 20 0 20',
                handler: function() {
                    var workshopForm = me.down("workshopForm");
                    var workshopPhotoPanel = me.down("workshopPhotoPanel");
                    workshopForm.loadForm(me.params.data.id);
                    workshopPhotoPanel.loadPanel(me.params.data.id);
                }
            }
        ];

        me.items = [
            {
                xtype: 'workshopForm',
                padding: '4 16 0 16',
                margin: '4 8 4 4',
                width: '100%',
            },
            {
                xtype: 'workshopPhotoPanel',
                itemId: 'workshopPhotoPanelId',
                margin: '4 4 4 4',
                padding: '4 16 0 16',
                width: '100%',
                refType: 'order',
                minHeight: 300,
                url: App.url('/file/list-order.json'),
            }
        ];

        me.listeners = {
            show: function () {
                var workshopForm = me.down("workshopForm");
                var workshopPhotoPanel = me.down("workshopPhotoPanel");
                workshopForm.loadForm(me.params.data.id);
                workshopPhotoPanel.loadPanel(me.params.data.id);
            },
            close: function(window, opts) {
                if (me.callbackOnClose) {
                    me.callbackOnClose();
                }
            }
        };
        me.callParent(arguments);
    }
})