Ext.define("App.view.OrderItemWindow", {
    extend: "Ext.window.Window",
    alias: "widget.orderItemWindow",
    xtype: "orderItemWindow",
    title: App.localeRes("Order Item Details"),
    width: 600,
    modal: true,

    resizable: true,
    layout: "fit",
    constrainHeader: true,

    initComponent: function () {
        var me = this;
        Ext.apply(me, {
            items: [
                {
                    xtype: "orderItemForm",
                    padding: '16 16 0 16',
                    params: {},
                    callbackOnSave: function(){
                        me.close();
                    }
                },
            ],
            listeners: {
                show: function () {
                    if(me.params && me.params.record){
                        me.down('orderItemForm').loadRecord(me.params.record);
                    }else if(me.params && me.params.orderId){
                        me.down('#orderId').setValue(me.params.orderId);
                    }
                },
                close: function (window, opts) {
                    if (me.callbackOnClose) {
                        me.callbackOnClose();
                    }
                }
            }
        });
        me.callParent(arguments);
    }
});
