Commit afa14490 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Redefine módulo TabsDisplayer, adapta su uso

Para soportar un mayor dinamismo en el módulo TabsDisplayer, se remodela
para delegar la creación de módulos a mostrar anidados al nivel
superior, recibiendo únicamente el canal de la instancia de módulo
anidado y su título.

Modifica la única vista que lo usaba por el momento, para adaptarse a su
nuevo funcionamiento.

Pone los cimientos para que Atlas pueda mostrarse en pestañas, en
respuesta a #67.
parent d43cd9e0
Loading
Loading
Loading
Loading
+94 −64
Original line number Diff line number Diff line
define([
	"app/designs/details/Controller"
	, "app/designs/details/Layout"
	, "app/designs/details/_AddBasicTitle"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "redmic/modules/components/PDFViewer/PDFViewer"
	, "redmic/modules/layout/TabsDisplayer"
	, "redmic/modules/layout/templateDisplayer/TemplateDisplayer"
	, "templates/WhatIsRedmicLongTermChallenge"
	, "templates/WhatIsRedmicInfoType"
	, "templates/WhatIsRedmicUserType"
	, "templates/WhatIsRedmicDataPolicy"
	, "templates/WhatIsRedmicProductsAndServices"
	, "templates/WhatIsRedmicInteroperability"
	'app/designs/details/Controller'
	, 'app/designs/details/Layout'
	, 'app/designs/details/_AddBasicTitle'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'redmic/modules/components/PDFViewer/PDFViewer'
	, 'redmic/modules/layout/TabsDisplayer'
	, 'redmic/modules/layout/templateDisplayer/TemplateDisplayer'
	, 'templates/WhatIsRedmicLongTermChallenge'
	, 'templates/WhatIsRedmicInfoType'
	, 'templates/WhatIsRedmicUserType'
	, 'templates/WhatIsRedmicDataPolicy'
	, 'templates/WhatIsRedmicProductsAndServices'
	, 'templates/WhatIsRedmicInteroperability'
], function(
	Controller
	, Layout
@@ -29,6 +29,7 @@ define([
	, TemplateWhatIsRedmicProductsAndServices
	, TemplateWhatIsRedmicInteroperability
) {

	return declare([Layout, Controller, _AddBasicTitle], {
		//	summary:
		//		Vista detalle de explicación redmic.
@@ -36,27 +37,15 @@ define([
		constructor: function(args) {

			this.config = {
				title: this.i18n.whatIsRedmic,

				noScroll: true,
				propsWidget: {
					omitTitleBar: true,
					resizable: false
				},
				title: this.i18n.whatIsRedmic
			};

			lang.mixin(this, this.config, args);
		},

		_setConfigurations: function() {

			this.widgetConfigs = this._merge([{
				additionalInfo: {
					width: 6,
					height: 6,
					type: TabsDisplayer,
					props: {
						title: ' ',
						childTabs: [{
				_childTabs: [{
					type: TemplateDisplayer,
					title: this.i18n.longTermChallenge,
					props: {
@@ -100,11 +89,52 @@ define([
						template: TemplateWhatIsRedmicInteroperability
					}
				}]
					}
			};

			lang.mixin(this, this.config, args);
		},

		_setConfigurations: function() {

			this.widgetConfigs = this._merge([{
				additionalInfo: {
					width: 6,
					height: 6,
					type: TabsDisplayer
				}
			}, this.widgetConfigs || {}]);
		},

		_afterShow: function() {

			for (var i = 0; i < this._childTabs.length; i++) {
				this._addChildTab(this._childTabs[i]);
			}
		},

		_addChildTab: function(childTabConfig) {

			var title = childTabConfig.title,
				childTabInstance = this._createChildInstance(childTabConfig);

			var tabsDisplayerInstance = this._getWidgetInstance('additionalInfo');

			this._publish(tabsDisplayerInstance.getChannel('ADD_TAB'), {
				title: title,
				channel: childTabInstance.getChannel()
			});
		},

		_createChildInstance: function(config) {

			var type = config.type,
				props = config.props;

			props.parentChannel = this.getChannel();

			return new type(props);
		},

		_putMetaTags: function() {
			// TODO esto es necesario porque se trata de una vista detalle, que define el método original,
			// pero no interesa en este caso. Pisando nuevamente el método, se comporta como define _View.
+34 −32
Original line number Diff line number Diff line
define([
	"dijit/layout/ContentPane"
	, "dijit/layout/TabContainer"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "redmic/modules/base/_Module"
	, "redmic/modules/base/_Show"
	'dijit/layout/ContentPane'
	, 'dijit/layout/TabContainer'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'redmic/modules/base/_Module'
	, 'redmic/modules/base/_Show'
], function(
	ContentPane
	, TabContainer
@@ -13,35 +13,39 @@ define([
	, _Module
	, _Show
) {

	return declare([_Module, _Show], {
		//	summary:
		//		Visualizador de contenido por pestañas.
		//		Visualizador de contenido por pestañas. Recibe publicaciones de módulos que desean mostrarse como una
		//		nueva pestaña.

		constructor: function(args) {

			this.config = {
				ownChannel: "tabsDisplayer",
				childTabs: [],
				childInstances: []
				ownChannel: 'tabsDisplayer',
				actions: {
					'ADD_TAB': 'addTab'
				},

				_tabContainerClass: 'softSolidContainer borderRadiusBottomTabContainer'
			};

			lang.mixin(this, this.config, args);
		},

		_initialize: function() {
		_defineSubscriptions: function() {

			this._container = new TabContainer({
				'class': "softSolidContainer borderRadiusBottomTabContainer"
			this.subscriptionsConfig.push({
				channel : this.getChannel("ADD_TAB"),
				callback: "_subAddTab"
			});
		},

			for (var i = 0; i < this.childTabs.length; i++) {
				var childTabConfig = this.childTabs[i],
					title = childTabConfig.title,
					instance = this._createChildInstance(childTabConfig);
		_initialize: function() {

				this.childInstances.push(instance);
				this._createTab(title, instance);
			}
			this._container = new TabContainer({
				'class': this._tabContainerClass
			});
		},

		_setOwnCallbacksForEvents: function() {
@@ -54,28 +58,26 @@ define([
			this._container.startup();
		},

		_createChildInstance: function(childTabConfig) {
		_subAddTab: function(req) {

			var type = childTabConfig.type,
				props = childTabConfig.props;
			var childContainer = this._getTabContainer(req.title),
				childShowChannel = this._buildChannel(req.channel, this.actions.SHOW);

			props.parentChannel = this.getChannel();

			return new type(props);
			this._publish(childShowChannel, {
				node: childContainer
			});
		},

		_createTab: function(title, instance) {
		_getTabContainer: function(title) {

			var node = new ContentPane({
				title: title,
				region: "center"
				region: 'center'
			});

			this._container.addChild(node);

			this._publish(instance.getChannel("SHOW"), {
				node: node
			});
			return node;
		},

		_onMeOrAncestorResized: function(req) {