<#import "/spring.ftl" as spring>
Ext.define('App.view.CustomFormWindow',{
	extend: 'Ext.window.Window',
	alias: 'widget.customFormWindow',

	scrollable: true,
	constrainHeader: true,
	modal: true,
	resizable: true,
	title: null,
	layout: 'hbox',

	config:{
		saveBtnText: '<@spring.message "COMMON.save" />',
		formItems: [],

		callback: function(values,form){},
	},

	onSaveBtnClick: function(button){
		var me = this,
			f = me.down('form');
		if(f.isValid()){
			if(me.callback) me.callback(f.getValues(),f);
			me.close();
		}
	},

	initComponent: function(){
		var me = this;
		Ext.apply(me,{
			items:[{
				xtype: 'form',
				bodyPadding: 10,
				buttonAlign: 'left',
				defaults: {
					selectOnFocus: true,
					labelWidth: 150,
					width: 400
				},
				items: me.formItems,
				buttons:[
					{
						xtype: 'button',
						text: me.saveBtnText,
						iconCls: 'silk-disk',
						formBind: true,
						handler: me.onSaveBtnClick,
						scope: me
					},
					{
						xtype: 'button',
						text: '<@spring.message "COMMON.close" />',
						handler: function(button, event) {
							me.close();
						}
					},
				]
			}]
		});
		me.callParent();
	}
});
