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

Retoca filtros y detalles de inicio

Controla casos concretos en la búsqueda desde la portada, como los
filtros de texto con valor vacío (ahora se recarga la búsqueda sin
ellos) o el cambio de título de la caja de resultados al realizar
cualquier búsqueda.

Se recupera el filtro inicial para mostrar sólo actividades destacadas.

Refactoriza home y modifica canales de widget de búsqueda de texto.
parent 39393b41
Loading
Loading
Loading
Loading
+33 −31
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@ define([
				},
				filterConfig: {
					initQuery: {
						returnFields: redmicConfig.returnFields.activity
						returnFields: redmicConfig.returnFields.activity,
						starred: true
					}
				}
			};
@@ -151,25 +152,31 @@ define([
			if (this._getPreviouslyShown()) {
				return;
			}
			this._listenWidgets();

			var obj = {
				queryChannel: this.queryChannel
			};
			this._listenAfterFirstShow();
			this._publishAfterFirstShow();
		},

			this._publish(this._getWidgetInstance('searchFastFilter').getChannel('SET_PROPS'), obj);
			this._publish(this._getWidgetInstance('searchFilter').getChannel('SET_PROPS'), obj);
			this._publish(this._getWidgetInstance('searchResults').getChannel('SET_PROPS'), obj);
		_listenAfterFirstShow: function() {

			this._once(this.getChannel('ADDED_TO_QUERY'), lang.hitch(this, function() {

				this._once(this.getChannel('ADDED_TO_QUERY'), lang.hitch(this, function() {

					this._publish(this._getWidgetInstance('searchResults').getChannel('SET_PROPS'), {
						windowTitle: 'searchResults'
					});
				}));
			}));

			this._listenWidgets();
		},

		_listenWidgets: function() {

			this._setSubscriptions([{
				channel: this._getWidgetInstance('searchBar').getChannel('SHOW_SEARCH_RESULTS'),
				callback: lang.hitch(this, this._showSearchResults)
			},{
				channel: this._getWidgetInstance('searchBar').getChannel('HIDE_SEARCH_RESULTS'),
				callback: lang.hitch(this, this._hideSearchResults)
				channel: this._getWidgetInstance('searchBar').getChannel('SEARCH_BY_TEXT'),
				callback: lang.hitch(this, this._onSearchByText)
			},{
				channel: this._getWidgetInstance('searchBar').getChannel('TOGGLE_ADVANCED_SEARCH'),
				callback: lang.hitch(this, this._toggleAdvancedSearch)
@@ -179,31 +186,26 @@ define([
			}]);
		},

		_showSearchResults: function(searchDefinition) {
		_publishAfterFirstShow: function() {

			var obj = {
				queryChannel: this.queryChannel
			};

			this._publish(this._getWidgetInstance('searchFastFilter').getChannel('SET_PROPS'), obj);
			this._publish(this._getWidgetInstance('searchFilter').getChannel('SET_PROPS'), obj);
			this._publish(this._getWidgetInstance('searchResults').getChannel('SET_PROPS'), obj);
		},

		_onSearchByText: function(searchDefinition) {

			this._emitEvt('ADD_TO_QUERY', {
				query: {
					text: {
						text: searchDefinition.searchText
						text: searchDefinition.searchText || null
					}
				}
			});

			this._publish(this._getWidgetInstance('searchResults').getChannel('SET_PROPS'), {
				windowTitle: 'searchResults'
			});
		},

		_hideSearchResults: function(searchDefinition) {

			var resultsWidget = this._getWidgetInstance('searchResults');

			this._publish(resultsWidget.getChannel('CLEAR_DATA'), searchDefinition);
			this._publish(resultsWidget.getChannel('SET_PROPS'), {
				windowTitle: 'starredActivities'
			});

			this._hideWidget('searchFilter');
		},

		_toggleAdvancedSearch: function(searchDefinition) {
+6 −11
Original line number Diff line number Diff line
@@ -27,13 +27,11 @@ define([
			this.config = {
				ownChannel: 'searchWidget',
				events: {
					'SHOW_SEARCH_RESULTS': 'showSearchResults',
					'HIDE_SEARCH_RESULTS': 'hideSearchResults',
					'SEARCH_BY_TEXT': 'searchByText',
					'TOGGLE_ADVANCED_SEARCH': 'toggleAdvancedSearch'
				},
				actions: {
					'SHOW_SEARCH_RESULTS': 'showSearchResults',
					'HIDE_SEARCH_RESULTS': 'hideSearchResults',
					'SEARCH_BY_TEXT': 'searchByText',
					'TOGGLE_ADVANCED_SEARCH': 'toggleAdvancedSearch'
				},
				target: redmicConfig.services.activity,
@@ -77,11 +75,8 @@ define([
		_definePublications: function() {

			this.publicationsConfig.push({
				event: 'SHOW_SEARCH_RESULTS',
				channel: this.getChannel('SHOW_SEARCH_RESULTS')
			},{
				event: 'HIDE_SEARCH_RESULTS',
				channel: this.getChannel('HIDE_SEARCH_RESULTS')
				event: 'SEARCH_BY_TEXT',
				channel: this.getChannel('SEARCH_BY_TEXT')
			},{
				event: 'TOGGLE_ADVANCED_SEARCH',
				channel: this.getChannel('TOGGLE_ADVANCED_SEARCH')
@@ -120,10 +115,10 @@ define([
			var textObj = filterParams.text || {},
				searchText = textObj.text || '';

			this._emitEvt('SHOW_SEARCH_RESULTS', {
			this._emitEvt('SEARCH_BY_TEXT', {
				target: this.target,
				searchText: searchText,
				queryChannel: this.queryChannel
				suggestionsQueryChannel: this.queryChannel
			});
		},