Ext.define("Portfolio.settings.language.view.Window", {

	extend: "Ext.window.Window",

	xtype: "portfolio-settings-language-window",

	title: ip2.i18n({
		da: "Tilføj Sprog",
		en: "Add Language"
	}),

	config: {
		form: null,
		footer: null
	},

	layout: "fit",

	controller: "portfolio-settings-language-window",

	requires: [
		"Portfolio.settings.language.controller.Window"
	],

	initComponent: function() {

		var i_self = this;

		i_self.callParent(arguments);

		i_self.add(i_self.createForm());
	},

	createForm: function() {

		var i_self = this;

		var i_controller = i_self.getController();

		var i_panel = Ext.widget("form", {
			trackResetOnLoad: true,
			bodyPadding: 10,
			layout: "anchor",
			defaults: {
				labelAlign: "top",
				anchor: "100%"
			},
			items: [
				{
					xtype: "localeComboBox",
					name: "LNGID",
					allowBlank: false,
					fieldLabel: ip2.i18n({
						da: "Sprog",
						en: "Language"
					})
				}
			],
			listeners: {
				validitychange: {
					fn: "onValidityChange"
				},
				dirtychange: {
					fn: "onDirtyChange"
				}
			}
		});

		var i_model = ip2.model({
			dmd: "dmd/portfolio.dmd",
			entity: "NAVLNG",
			context: "form",
			view: "portfolio"
		});

		var i_record = i_model.create({});

		i_panel.loadRecord(i_record);

		i_panel.addDocked(i_self.createFooter());

		i_self.setForm(i_panel);

		return i_panel;
	},

	createFooter: function() {

		var i_self = this;

		var i_footer = Ext.widget("toolbar", {
			dock: "bottom",
			ui: "footer",
			defaults: {
				minWidth: 75
			},
			items: [
				"->",
				{
					xtype: "button",
					itemId: "button-save",
					iconCls: "pf-floppy_disk",
					text: ip2.i18n({
						da: "Gem",
						en: "Save"
					}),
					disabled: true,
					handler: "onSave"
				},
				{
					xtype: "button",
					itemId: "button-close",
					iconCls: "pf-navigate_cross",
					text: ip2.i18n({
						da: "Luk",
						en: "Close"
					}),
					handler: function() {

						i_self.close();
					}
				}
			]
		});

		i_self.setFooter(i_footer);

		return i_footer;
	}
});
