Ext.define("App.view.MeetingWindow", {
    extend: "Ext.window.Window",
    alias: "widget.meetingWindow",
    xtype: "meetingWindow",
    title: App.localeRes("Meeting Details"),
    height: 450,
    width: 600,
    modal: true,

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

    initComponent: function () {
        var me = this;
        Ext.apply(me, {
            items: [
                {
                    xtype: "meetingForm",
                    padding: '16 16 0 16',
                    params: {},
                    callbackOnSave: function(){
                        me.close();
                    }
                },
            ],
            listeners: {
                show: function () {
                    if(me.params.record){
                        me.down('meetingForm').loadRecord(me.params.record);
                        me.down("datetimeField").setDisplayValue(me.params.record.get("date"));
                    }
                    if(me.params.custId){
                        me.down('customerCombo').setValue(me.params.custId);
                        var store = me.down("orderCombo").getStore();
                        Ext.apply(store.getProxy(), {
                            extraParams: {
                                custId: me.params.custId
                            }
                        });
                        store.load();
                    }
                    if(me.params.orderId){
                        me.down("orderCombo").setValue(me.params.orderId);
                    }
                    if(me.params.date){
                        me.down('datefield').setValue(me.params.date);
                    }
                },
                close: function (window, opts) {
                    if (me.callbackOnClose) {
                        me.callbackOnClose();
                    }
                }
            }
        });
        me.callParent(arguments);
    }
});
