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

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

	alias: ["widget.widgetpartsplexer"],

	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 || "FLDFLDTKN",
			PARENTID: o_settings.contentKey || "FLDPNTTKN",
			PROPERTIES: o_settings.propertyKey || "FLDPROP"
		};

		o_settings.folderToken += "";

		var o_organizer = {};

		Ext.apply(o_organizer, {
			xpd: o_settings.xpd || "folder.xpd",
			folder: {
				propertyNameMapping: o_settings.folderProperty,
				dmd: o_settings.dmd || "webshop.dmd",
				proxy: o_settings.proxy,
				entity: o_settings.entity || "WSHFLDET00",
				cid: o_settings.folderToken || "50",
				uiName: "portfolio",
				menus: ["edit", "remove"],
				buttons: ["add", "edit", "remove", "refresh"],
				expandToLevel: o_settings.expandToLevel || 1,
				levelSelectFirst: o_settings.levelSelectFirst || 1,
				displayRootNode: true,
				addToAllChildren: {
					allow: true,
					warning: true,
					multiChoiceDialog: {
						title: { da: "Sæt flueben", en: "Check checkboxes" },
						questions: [
						{ da: "Kun på denne række", en: "Check only on this row" },
						{ da: "På alle underliggende rækker", en: "Check all rows below this" },
						{ da: "Fortryd denne funktion", en: "Cancel this operation" }
						],
						guideLine: { da: "Hvor skal der sættes flueben ?", en: "Where to set check marks ?" }
					}
				},

				title: o_settings.folderTitle === false ? false : !Ext.isBoolean(o_settings.folderTitle) ? o_settings.folderTitle : ip2.i18n({
					da: "Modeller",
					en: "Models"
				})
			},
			content: {
				title: o_settings.contentTitle === false ? false : !Ext.isBoolean(o_settings.contentTitle) ? o_settings.contentTitle : ip2.i18n({
					da: "Produkter til modeller",
					en: "Products for models"
				})
			}
		});

		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;
	}
});
