Commit 855acd39 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Permite cambiar idioma y ver versión desde dentro

Ahora que el login no es la vista inicial, se ubica en el topbar de la
aplicación tanto la numeración de la versión actual como un nuevo widget
de cambio de idioma.
parent c91df7ae
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -40,6 +40,15 @@ define([
					"'><img class='logo' src='/resources/images/logos/redmicSimple.png'></a>"
			});

			var envDfd = window.env;

			if (envDfd) {
				envDfd.then(lang.hitch(this, function(env) {

					put(this.domNode, 'div.versionNumber', env.version);
				}));
			}

			if (this.show.left) {
				this.leftNode = put(this.domNode, "div.manager");
			}
+15 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ define([
	, 'redmic/modules/socket/_Worms'
	, 'redmic/modules/socket/Socket'
	, 'redmic/modules/socket/Task'
	, 'redmic/modules/user/LanguageSelector'
	, 'redmic/modules/user/UserArea'
], function(
	App
@@ -37,6 +38,7 @@ define([
	, _Worms
	, Socket
	, Task
	, LanguageSelector
	, UserArea
) {
	return declare([LayoutContainer, App], {
@@ -104,13 +106,19 @@ define([

			// TODO esto es un abuso, no deberíamos acceder a los nodos de un módulo desde fuera. Crear canal para
			// añadir hijos al topbar
			var topbarRightNode = this.topbar.domNode.children[1];
			//
			// TODO realmente, Topbar habría que replantearlo, ya que no es un módulo sino un ContentPane decorado.
			var topbarRightNode = this.topbar.domNode.lastChild;

			this._publish(this._buildChannel(this.notificationChannel, this.actions.SHOW), {
				node: topbarRightNode
			});

			this._publish(this._buildChannel(this.userAreaChannel, this.actions.SHOW), {
			this._publish(this.languageSelector.getChannel('SHOW'), {
				node: topbarRightNode
			});

			this._publish(this.userArea.getChannel('SHOW'), {
				node: topbarRightNode
			});
		},
@@ -166,7 +174,11 @@ define([
				parentChannel: this.ownChannel
			});

			new UserArea({
			this.userArea = new UserArea({
				parentChannel: this.ownChannel
			});

			this.languageSelector = new LanguageSelector({
				parentChannel: this.ownChannel
			});
		},
+0 −2
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ define([
			QUERY_STORE: "queryStore",
			TASK: "task",
			NOTIFICATION: "notification",
			USER_AREA: "userArea",
			SOCKET: "socket",
			META_TAGS: "metaTags",
			LOADING: "loading",
@@ -195,7 +194,6 @@ define([
				socketChannel: this._buildChannel(this.rootChannel, this.globalOwnChannels.SOCKET),
				metaTagsChannel: this._buildChannel(this.rootChannel, this.globalOwnChannels.META_TAGS),
				notificationChannel: this._buildChannel(this.rootChannel, this.globalOwnChannels.NOTIFICATION),
				userAreaChannel: this._buildChannel(this.rootChannel, this.globalOwnChannels.USER_AREA),
				loadingChannel: this._buildChannel(this.rootChannel, this.globalOwnChannels.LOADING),
				alertChannel: this._buildChannel(this.rootChannel, this.globalOwnChannels.ALERT),
				communicationChannel: this._buildChannel(this.rootChannel, this.globalOwnChannels.COMMUNICATION)
+108 −0
Original line number Diff line number Diff line
define([
	'app/redmicConfig'
	, 'dojo/_base/declare'
	, 'dojo/_base/kernel'
	, 'dojo/_base/lang'
	, 'put-selector/put'
	, 'redmic/modules/base/_Module'
	, 'redmic/modules/base/_Show'
	, 'redmic/modules/base/_ShowInTooltip'
	, 'redmic/modules/base/_ShowOnEvt'
	, 'redmic/modules/layout/listMenu/ListMenu'
], function(
	redmicConfig
	, declare
	, kernel
	, lang
	, put
	, _Module
	, _Show
	, _ShowInTooltip
	, _ShowOnEvt
	, ListMenu
){
	return declare([_Module, _Show], {
		//	summary:
		//		Módulo selector de idioma.
		//	description:
		//		Muestra un listado de idiomas para traducir la app.

		constructor: function(args) {

			this.config = {
				ownChannel: 'languageSelector'
			};

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

		_setConfigurations: function() {

			this.listMenuConfig = this._merge([{
				parentChannel: this.getChannel(),
				items: [{
					icon: 'flag-icon-background.flag-icon-es',
					label: this.i18n.es,
					callback: '_changeLanguage',
					value: 'es'
				},{
					icon: 'flag-icon-background.flag-icon-gb',
					label: this.i18n.en,
					callback: '_changeLanguage',
					value: 'en'
				}]
			}, this.listMenuConfig || {}]);
		},

		_initialize: function() {

			put(this.domNode, '.languageSelector');

			this.containerNode = put(this.domNode, 'div[title=$]', this.i18n.language);

			this.iconNode = put(this.containerNode, 'i.fa.fa-language');

			this.listMenu = new declare([ListMenu, _ShowOnEvt]).extend(_ShowInTooltip)(this.listMenuConfig);
		},

		_defineSubscriptions: function() {

			this.subscriptionsConfig.push({
				channel : this.listMenu.getChannel('EVENT_ITEM'),
				callback: '_subEventItem'
			});
		},

		postCreate: function() {

			this._publish(this.listMenu.getChannel('ADD_EVT'), {
				sourceNode: this.iconNode
			});

			this.inherited(arguments);
		},

		_subEventItem: function(response) {

			var cbk = response.callback;

			cbk && this[cbk](response);
		},

		_changeLanguage: function(itemObj) {

			var language = itemObj.value,
				currentUrl = window.location,
				protocol = currentUrl.protocol,
				hostname = currentUrl.hostname,
				hostnameWithoutLang = hostname.replace(kernel.locale + '.', '');

			window.location.href = protocol + '//' + language + '.' + hostnameWithoutLang;
		},

		_getNodeToShow: function() {

			return this.domNode;
		}
	});
});
Compare f64e853a to 36ab25e5
Original line number Diff line number Diff line
Subproject commit f64e853ab4d4a17807b053f6bb3c1e9b61ca67d6
Subproject commit 36ab25e5fce15ddb19c3718b56ad576d627fc807
Loading