Commit 3da7c776 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Limpia y corrige detalles de petición de datos

parent 85cee831
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -124,20 +124,11 @@ define([
			return false;
		},

		_chkTargetIsMine: function(response) {
		_chkTargetIsMine: function(res) {

			if (!this._chkSuccessful(response)) {
				return false;
			}
			var target = res.target;

			var body = response.body,
				target = body ? body.target : null;

			if (target && ((this._isTargetAnyOfMine && this._isTargetAnyOfMine(target)) || this._targetIsMine(target))) {
				return true;
			}

			return false;
			return (this._isTargetAnyOfMine && this._isTargetAnyOfMine(target)) || this._targetIsMine(target);
		},

		_isTargetAnyOfMine: function(target) {
+1 −10
Original line number Diff line number Diff line
@@ -150,16 +150,7 @@ define([

		_chkSelectionTargetIsBrowserWork: function(res) {

			if (!this._chkSuccessful(res)) {
				return false;
			}

			var body = res.body;
			if (body && body.selectionTarget && (body.selectionTarget !== this.targetBrowserWork)) {
				return false;
			}

			return true;
			return res.target === this.targetBrowserWork;
		},

		_fillSideContent: function() {
+5 −9
Original line number Diff line number Diff line
@@ -31,15 +31,6 @@ define([
			return !this.actionsPaused[action];
		},

		_chkSuccessful: function(response) {

			if (response && (response.success === undefined || response.success)) {
				return true;
			}

			return false;
		},

		_chkTargetIsValid: function(obj) {

			// TODO eliminar cuando el server no responda con envoltorio body
@@ -122,6 +113,11 @@ define([
				}));

			return allowedActionsMapped.indexOf(triggeredAction) !== -1;
		},

		_chkSuccessfulStatus: function(status) {

			return status >= 200 && status < 400;
		}
	});
});
+16 −46
Original line number Diff line number Diff line
@@ -70,8 +70,7 @@ define([

			this.publicationsConfig.push({
				event: 'SAVE',
				channel: this._buildChannel(this.storeChannel, this.actions.SAVE)/*,
				callback: '_pubSave'*/
				channel: this._buildChannel(this.storeChannel, this.actions.SAVE)
			},{
				event: 'REMOVE',
				channel: this._buildChannel(this.storeChannel, this.actions.REMOVE)
@@ -80,54 +79,18 @@ define([
			this._deleteDuplicatedChannels(this.publicationsConfig);
		},

		/*_pubSave: function(channel, obj) {

			var target = this._getTarget(obj.target);
			//var target = this._getPersistenceTarget(obj.target);

			this._publish(channel, {
				idInTarget: obj.idInTarget,
				target: target,
				item: obj.data || {},
				idProperty: obj.idProperty || this.idPropertySave || this.idProperty
			});
		},

		_getTarget: function(target) {
		//_getPersistenceTarget: function(target) {

			console.debug('JAMAS DE LOS JAMASES')
			if (target) {
				return target;
			}

			if (this.baseTarget) {
				return this.baseTarget;
			}

			if (this.editionTarget instanceof Array) {
				return this.editionTarget[0];
			}

			if (this.target instanceof Array) {
				return this.target[0];
			}

			return this.editionTarget || this.target;
		},*/

		_subSaved: function(resWrapper) {

			var response = resWrapper.res,
				status = response.status;

			if (!this.omitRefreshAfterSuccess) {
				this._emitEvt('REFRESH');
				this._tryToEmitEvt('REFRESH');
			}

			if (status >= 200 && status < 400) {
			if (this._chkSuccessfulStatus(status)) {
				var savedObj = this._getSavedObjToPublish(response) || response;
				this._emitEvt('SAVED', response);
				this._emitEvt('SAVED', savedObj);

				this._afterSaved(response, resWrapper);
			} else {
@@ -135,16 +98,23 @@ define([
			}
		},

		_subRemoved: function(result) {
		_subRemoved: function(resWrapper) {

			var response = resWrapper.res,
				status = response.status;

			if (!this.omitRefreshAfterSuccess) {
				this._emitEvt('REFRESH');
				this._tryToEmitEvt('REFRESH');
			}

			var removedObj = this._getRemovedObjToPublish(result) || result;
			if (this._chkSuccessfulStatus(status)) {
				var removedObj = this._getRemovedObjToPublish(response) || response;
				this._emitEvt('REMOVED', removedObj);

			this._afterRemoved(result);
				this._afterRemoved(response, resWrapper);
			} else {
				this._afterRemoveError(response.error, status, resWrapper);
			}
		}
	});
});
+4 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ define([
	, lang
	, _Itfc
) {

	return declare(_Itfc, {
		//	summary:
		//		Interfaz de _Persistence.
@@ -21,7 +22,8 @@ define([
				'_afterSaved': {},
				'_afterSaveError': {},
				'_getRemovedObjToPublish': {},
				'_afterRemoved': {}
				'_afterRemoved': {},
				'_afterRemoveError': {}
			});
		}
	});
Loading