Ext.define("Ext.ux.widget.folderorganizer.Questionaries", {

	extend: "Ext.ux.folderorganizer.Organizer",

	alias: ["widget.widgetquestionaries"],

	initComponent: function () {

		var i_cmp = this,
			o_config = i_cmp.initialConfig,
			o_settings = {};

		var a_proxyMap = [
			"folderTitle", "folderUiName", "folderOrderBy",
			"folderKey", "propertyKey", "contentToken",
			"folderToken", "contentKey", "propertyKey",
			"contentTitle", "contentFilter",
			"folderDataLibrary", "folderUiName"
		];

		// Start building the settings object from the initialConfig
		Ext.apply(o_settings, ip2.pick(i_cmp.initialConfig, [
			"proxy", "dmd", "entity", "xpd", "extraProps", "environment",
			"menus", "buttons",	"expandToLevel", "levelSelectFirst"
		]));

		Ext.apply(o_settings, ip2.pick(o_config, a_proxyMap));

		o_settings.folderProperty = {
			ID: o_settings.folderKey || "QSTQSTTKN",
			PARENTID: o_settings.contentKey || "QSTPNTTKN",
			PROPERTIES: o_settings.propertyKey || "QSTPROP"
		};

		o_settings.folderToken += "";

		var o_organizer = {};
		Ext.apply(o_organizer, {
			xpd: o_settings.xpd || "questionaries.xpd",
			folder: {
				title: o_settings.folderTitle === false ? false : o_settings.folderTitle || {
					da: "Spørgsmål og svar",
					en: "Questionaries"
				},
				propertyNameMapping: o_settings.folderProperty,
				cid: o_settings.folderToken || "1",
				childCid: o_settings.folderChildCid || "2",
				multiAddChoice: o_settings.folderMultiAddChoice === false ? false : o_settings.folderMultiAddChoice || true,
				dmd: o_settings.dmd || "webshop.dmd",
				proxy: o_settings.proxy,
				entity: o_settings.entity || "WSHQSTET00",
				orderBy: o_settings.folderOrderBy || "jsonGetNum(QSTPROP, \'seq\')",
				menus: ["edit", "remove"],
				buttons: ["add", "edit", "remove", "refresh"],
				expandToLevel: o_settings.expandToLevel || 1,
				levelSelectFirst: o_settings.expandToLevel || 1,
				displayRootNode: true,
				allowExport: false
			},
			content: {
				title: o_settings.contentTitle === false ? false : o_settings.contentTitle || ip2.i18n({
					da: "Indhold til spørgsmål",
					en: "Questionaries Content"
				})
			}
		});

		Ext.apply(i_cmp, o_organizer);

		// Clean up;
		ip2.each(a_proxyMap, function (s_property) {
			delete i_cmp[s_property];
		});

		i_cmp.callParent(arguments);

		return i_cmp;
	}
});
