Commit 428d1ea5 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Mueve lógica de gestión de ancho reducido a App

En lugar de repartir código entre App, Sidebar y Topbar, se centraliza
en App la detección de ancho de página reducido y las acciones a
realizar. La única excepción es Topbar, que publica hacia App para
forzar el mostrado/ocultado de Sidebar, pero igualmente la lógica reside
en App.
parent d848b8c9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ define([

		_onAppFirstShow: function() {

			// TODO vestigio de dijit, desaparecerá
			this.startup();
		},

+2 −7
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ define([
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/dom"
	, "dojo/dom-class"
	, "put-selector/put"
	, "redmic/modules/base/Manager"
], function(
@@ -11,7 +10,6 @@ define([
	, declare
	, lang
	, dom
	, domClass
	, put
	, Manager
){
@@ -26,7 +24,6 @@ define([
			this.config = {
				region: "top",
				"class": "topbar",
				collapsedSidebarClass: 'collapsedSidebar',
				doLayout: false,
				show: {
					left: true,
@@ -68,10 +65,8 @@ define([

		_onCollapseClicked: function() {

			domClass.toggle(this.ownerDocumentBody, this.collapsedSidebarClass);

			// TODO hacerlo en this en lugar de this.module cuando topbar sea módulo
			this.manager._publish(this.manager._buildChannel(this.manager.rootChannel, this.manager.actions.RESIZE));
			// TODO hacerlo en this en lugar de this.manager cuando topbar sea módulo
			this.manager._publish(this.manager._buildChannel(this.manager.rootChannel, 'toggleSidebar'));
		}
	});
});
+68 −14
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ define([
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/aspect'
	, "dojo/dom-class"
	, 'redmic/base/Credentials'
	, 'redmic/modules/base/Selector'
	, 'redmic/modules/components/Sidebar/MainSidebarImpl'
@@ -27,6 +28,7 @@ define([
	, declare
	, lang
	, aspect
	, domClass
	, Credentials
	, Selector
	, MainSidebarImpl
@@ -54,13 +56,15 @@ define([
			this.config = {
				design: 'sidebar',
				'class': 'mainContainer',
				collapsedSidebarClass: 'collapsedSidebar',
				reducedWidthClass: 'reducedWidth',
				uncollapsedSidebarClass: 'uncollapsedSidebar',
				isLayoutContainer: true,
				innerAppActions: {
					UPDATE_ACTIVE: 'updateActive'
				},
				innerAppEvents: {
					UPDATE_ACTIVE: 'updateActive'
				},
				innerAppActions: {
					UPDATE_ACTIVE: 'updateActive',
					TOGGLE_SIDEBAR: 'toggleSidebar'
				}
			};

@@ -70,10 +74,8 @@ define([
			aspect.after(this, '_setOwnCallbacksForEvents', lang.hitch(this,
				this._setInnerAppOwnCallbacksForEvents));

			aspect.before(this, '_defineSubscriptions', lang.hitch(this, this._defineInnerAppSubscriptions));
			aspect.before(this, '_definePublications', lang.hitch(this, this._defineInnerAppPublications));

			this._createStructure();
			this._createModules();
		},

		_mixEventsAndActionsInnerApp: function () {
@@ -90,6 +92,17 @@ define([
			this._onEvt('RESIZE', lang.hitch(this, this._onAppResize));
		},

		_defineInnerAppSubscriptions: function() {

			this.subscriptionsConfig.push({
				channel: this.getChannel('TOGGLE_SIDEBAR'),
				callback: '_subToggleSidebar',
				options: {
					predicate: lang.hitch(this, this._chkModuleCanResize)
				}
			});
		},

		_defineInnerAppPublications: function() {

			this.publicationsConfig.push({
@@ -98,6 +111,12 @@ define([
			});
		},

		_initialize: function() {

			this._createStructure();
			this._createModules();
		},

		postCreate: function() {

			this.inherited(arguments);
@@ -127,6 +146,18 @@ define([
			this._publish(this.userArea.getChannel('SHOW'), {
				node: topbarRightNode
			});

			this._evaluateAppSize();
		},

		_subToggleSidebar: function(req) {

			domClass.toggle(this.ownerDocumentBody, this.uncollapsedSidebarClass);

			// TODO vestigio de dijit, desaparecerá
			this.layout();

			this._propagateActionToChildren('RESIZE', {});
		},

		_updateActiveSidebarItem: function(evt) {
@@ -148,8 +179,7 @@ define([
			//		private

			this.sidebar = new MainSidebarImpl({
				parentChannel: this.ownChannel,
				collapsedSidebarClass: this.collapsedSidebarClass
				parentChannel: this.ownChannel
			});

			new QueryStore({
@@ -207,8 +237,7 @@ define([

			this.topbar = new Topbar({
				parentChannel: this.ownChannel,
				i18n: this.i18n,
				collapsedSidebarClass: this.collapsedSidebarClass
				i18n: this.i18n
			});

			this.bc = new ContentPane({
@@ -230,12 +259,37 @@ define([

		_onAppResize: function(evt) {

			if (this._getNodeToShow()) {
			if (!this._getNodeToShow()) {
				return;
			}

			this._evaluateAppSize();

			// TODO vestigio de dijit, desaparecerá
			this.layout();
		},

		_evaluateAppSize: function() {

			if (this._getLowWidth()) {
				this._setReducedWidth();
			} else {
				this._unsetReducedWidth();
			}
		},

		_setReducedWidth: function() {

			domClass.add(this.ownerDocumentBody, this.reducedWidthClass);
			domClass.remove(this.ownerDocumentBody, this.uncollapsedSidebarClass);
		},

		_unsetReducedWidth: function() {

			domClass.remove(this.ownerDocumentBody, this.reducedWidthClass);
			domClass.add(this.ownerDocumentBody, this.uncollapsedSidebarClass);
		},

		_onAppHide: function() {

			// TODO reemplazo a destroy de todo 'app', eliminar cuando router no comparta canal y destruir solo 'app'
+0 −2
Original line number Diff line number Diff line
@@ -723,8 +723,6 @@ define({
	, "maintenance": "Mantenimiento"
	, "data-loader": "Carga de datos"
	, "user": "Rincón del usuario"
	, "menuTextReduce": "Reducir menú"
	, "menuTextExpand": "Expandir menú"
	, "taxonomy": "Taxonomía"
	, "bibliography": "Biblioteca"
	, "species-distribution": "Distribución de especies"
+0 −2
Original line number Diff line number Diff line
@@ -725,8 +725,6 @@ define({
		, "admin": "Metadata"
		, "data-loader": "Data loading"
		, "user": "Users corner"
		, "menuTextReduce": "Reduce menu"
		, "menuTextExpand": "Expand menu"
		, "taxonomy": "Taxonomy"
		, "bibliography": "Library"
		, "species-distribution": "Species distribution"
Loading