Ext.define("Portfolio.designer.ui.domainModelEntityColumnGridSmall", {

	extend: "Ext.grid.Panel",

	alias: [
		"widget.ip2DomainModelEntityColumnGridSmall"
	],

	border: 0,

	hideHeaders: true,

	requires: [
		"Portfolio.designer.model.domainModelEntityColumnDataModel",
		"Portfolio.designer.ui.domainModelEntityManager"
	],

	config: {
		entity: null
	},

	initComponent: function() {

		var i_self = this;

		var o_entity = i_self.getEntity();

		var a_columns = [
			{
				header: "",
				dataIndex: "title",
				flex: 1
			}
		];

		var i_store = Ext.create("Ext.data.Store", {
			model: "Portfolio.designer.model.domainModelEntityColumnDataModel"
		});

		Ext.apply(i_self, {
			columns: a_columns,
			store: i_store
		});

		i_self.callParent();

		i_self.reload(o_entity.columns);
	},

	reload: function(a_columns) {

		var i_self = this;
		var i_store = i_self.getStore();

		var a_data = [];

		Ext.Array.each(a_columns, function(o_column) {
			var s_title = "";
			if (Ext.isObject(o_column.title)) {
				s_title = ip2.i18n(o_column.title);
			}
			else {
				s_title = o_column.title;
			}
			a_data.push({
				name: o_column.name,
				title: s_title
			});
		});

		i_store.loadData(a_data);
	}

  });
