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

Integra peticiones de topónimos con RestManager

parent f596ef33
Loading
Loading
Loading
Loading
+23 −23
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ define([
	, "app/redmicConfig"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/request"
	, "put-selector/put"
	, "templates/PlaceNamesList"
	, "redmic/modules/browser/bars/Pagination"
@@ -19,7 +18,6 @@ define([
	, redmicConfig
	, declare
	, lang
	, request
	, put
	, TemplateList
	, Pagination
@@ -27,6 +25,7 @@ define([
	, GeoJsonLayerImpl
	, Button
) {

	return declare([Layout, Controller, _Main], {
		//	summary:
		//		main Placename.
@@ -62,10 +61,6 @@ define([

				noFixedZoom: false,

				// timeout: int
				// 	Tiempo en milisegundos de espera por la respuesta antes de dar error.
				timeout: 10000,

				// overflow: Boolean
				// 	Informa sobre si ha habido más resultados que el máximo por página.
				overflow: false
@@ -323,10 +318,7 @@ define([
				this._resetPagination();
			}

			// Buscamos en el servicio
			this._findByText(value).then(
				lang.hitch(this, this._responseDataConversor),
				lang.hitch(this, this._errorDataConversor));
			this._findByText(value);
		},

		_findByText: function(value) {
@@ -335,9 +327,12 @@ define([
				texto: value
			};

			return request(this._generateUrl(params), {
				handleAs: "json",
				timeout: this.timeout
			var targetWithParams = this._generateUrl(params);

			this.target = [this.target, targetWithParams];

			this._emitEvt('GET', {
				target: targetWithParams
			});
		},

@@ -352,8 +347,7 @@ define([
			var query = "";
			for (var key in params) {
				var hasSeveralQuestionMarks = this.target.indexOf("?") !== -1;
				query += hasSeveralQuestionMarks ? "&" : "?";
				query += key + "=" + params[key];
				query += (hasSeveralQuestionMarks ? "&" : "?") + key + "=" + params[key];
			}

			return this.target + query;
@@ -370,11 +364,15 @@ define([
			this._resetTarget();
		},

		_responseDataConversor: function(res) {
		_itemAvailable: function(res) {

			this.target = this.target[0];

			var value = res.data,
				total = res.total,
				urlNext = res.urlnext,
			var responseStatus = res.status,
				responseData = res.data,
				value = responseData.data,
				total = responseData.total,
				urlNext = responseData.urlnext,
				data = [];

			this.overflow = !!urlNext;
@@ -388,13 +386,15 @@ define([
				res: {
					data: data,
					total: total,
					status: 200
					status: responseStatus
				},
				target: this._browserTarget
			});
		},

		_errorDataConversor: function(error) {
		_errorAvailable: function(error) {

			this.target = this.target[0];

			this._emitEvt('COMMUNICATION', {
				type: "alert",
+5 −1
Original line number Diff line number Diff line
@@ -65,7 +65,11 @@ define([
			var targetWithSlash = this._getTargetWithEndingSlash(target),
				id = req.id;

			if (typeof id === 'string' || typeof id === 'number') {
				return targetWithSlash + id;
			}

			return targetWithSlash;
		},

		_getGetRequestOptions: function(req) {