Commit 73579b0f authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Corrige búsqueda de texto vacío y shared params

Propaga los campos con valor nulo desde el modelo hasta RestManager,
para permitir la limpieza de parámetros nulos, omitiendo estos valores
justo antes de la petición. Esto corrige, por ejemplo, la búsqueda por
texto cuando se limpia el valor del campo de entrada.

Separa las estructuras de parámetros compartidos y de parámetros propios
de la vista, para evitar entremezclarlos. Esto corrige, por ejemplo, la
petición de capas de monitorización marina y las de su atlas por
separado.
parent cb74cbb3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ define([
			this.modelConfig = this._merge([{
				parentChannel: this.getChannel(),
				target: this._getTarget(),
				noSerializeNullValue: true,
				noSerializeNullValue: false,
				filterSchema: true,
				props: {
					serializeAdditionalProperties: true
+1 −1
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ define([
			var schema = res.data;

			if (this.filterSchema) {
				schema = schema.schema;
				schema = schema?.schema;
			}

			this._buildModelWithSchema(schema);
+22 −9
Original line number Diff line number Diff line
@@ -308,13 +308,8 @@ define([
			const queryData = this._getQueryDataWithQueryParamsReplaced(req.target, requesterChannel);

			if (method === 'POST') {
				options.data = JSON.stringify(queryData, (_key, value) => {
					if (value instanceof Array && !value.length) {
						// evita arrays vacíos entre los valores
						return;
					}
					return value;
				});
				options.data = JSON.stringify(queryData,
					(key, value) => this._filterQueryParamsForRequestBodyData(key, value));
			} else {
				options.query = queryData;
			}
@@ -324,6 +319,19 @@ define([
			return lang.mixin(options, reqOptions);
		},

		_filterQueryParamsForRequestBodyData: function(_key, value) {

			const isEmptyArray = value instanceof Array && !value.length,
				isNullValue = value === null;

			// evita arrays vacíos y valores nulos en los campos de filtro
			if (isEmptyArray || isNullValue) {
				return;
			}

			return value;
		},

		_getRequestRequestHeaders: function(req) {
			// TODO es posible que esta funcionalidad quepa mejor en _Store, antes de publicar, para que aquí se
			// reciban directamente las cabeceras listas para usar.
@@ -593,7 +601,6 @@ define([
				delete req.query;
			}

			// TODO aquí probar a escribir sólo en sharedChannel si es el caso, para no ser redundante!!
			if (sharedParams) {
				const sharedChannel = this._getSharedChannel(requesterChannel);

@@ -634,7 +641,13 @@ define([

		_getSharedChannel: function(requesterChannel) {

			return requesterChannel.split(this.channelSeparator).slice(0, 2).join(this.channelSeparator);
			const splitter = this.channelSeparator,
				viewChannelLength = 3,
				sharedSuffix = '/sharedParams';

			const viewChannel = requesterChannel.split(splitter).slice(0, viewChannelLength).join(splitter);

			return `${viewChannel}${sharedSuffix}`;
		},

		_getTargetWithPathParamsReplaced: function(target, requesterChannel) {