Commit 012c4155 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Corrige más elementos de edición, como dominios

parent a826d95b
Loading
Loading
Loading
Loading
+21 −76
Original line number Diff line number Diff line
@@ -24,16 +24,10 @@ define([
				editionViewEvents: {
					ADD: "add",
					EDIT: "edit",
					REMOVE: "remove",
					REMOVE_ITEM: "removeItem",
					COPY: "copy",
					SHOW_FORM: "showForm",
					SAVE: "save",
					SAVED: "saved"
					SHOW_FORM: "showForm"
				},
				editionViewActions: {
					ITEM_AVAILABLE: "itemAvailable",
					GET: "get",
					UPDATE_TARGET_FORM: "updateTargetForm"
				}
			};
@@ -121,23 +115,10 @@ define([

		_defineEditionSubscriptions: function () {

			if (this.persistence) {
				this.subscriptionsConfig.push({
					channel: this.persistence.getChannel("REMOVED"),
					callback: "_subRemoved"
				});
			}
		},

		_defineEditionPublications: function() {

			if (this.persistence) {
				this.publicationsConfig.push({
					event: 'REMOVE_ITEM',
					channel: this.persistence.getChannel("REMOVE"),
					callback: "_pubRemove"
				});
			}
		},

		_setEditionOwnCallbacksForEvents: function() {
@@ -145,7 +126,6 @@ define([
			this._onEvt('ADD', lang.hitch(this, this._addElement));
			this._onEvt('EDIT', lang.hitch(this, this._editElement));
			this._onEvt('COPY', lang.hitch(this, this._copyElement));
			this._onEvt('REMOVE', lang.hitch(this, this._removeElement));
		},

		postCreate: function() {
@@ -167,35 +147,35 @@ define([

		_removeCallback: function(evt) {

			this._emitEvt('REMOVE', evt[this.idProperty]);
		},
			alertify.confirm(this.i18n.deleteConfirmationTitle, this.i18n.deleteConfirmationMessage,
				lang.hitch(this, function(idProperty) {

		_copyCallback: function(evt) {
				this._emitEvt('REMOVE', {
					id: idProperty,
					target: this.target
				});
			}, evt[this.idProperty]),
			lang.hitch(this, function() {

			this._emitEvt('COPY', evt);
				this._emitEvt('COMMUNICATION', {
					description: this.i18n.cancelledAlert
				});
			})).set("labels", {
				ok: this.i18n.ok,
				cancel: this.i18n.cancel
			});
		},

		_subRemoved: function(result) {
		_copyCallback: function(evt) {

			if (result.success) {
				this._emitEvt('REFRESH');
			}
			this._emitEvt('COPY', evt);
		},

		_pubRemove: function(channel, idProperty) {

			var id = idProperty,
				target = this._getTarget();
		_afterRemoved: function(res) {

			if (idProperty && typeof idProperty === 'object') {
				target = idProperty.target || this._getTarget();
				id = idProperty[this.idProperty];
			}
			this.inherited(arguments);

			this._publish(channel, {
				target: target,
				id: id
			});
			this._emitEvt('REFRESH');
		},

		_editElement: function(evt) {
@@ -206,41 +186,6 @@ define([
		_copyElement: function(evt) {

			this._showEditForm("copy", evt[this.idProperty]);
		},

		_removeElement: function(idProperty) {

			alertify.confirm(this.i18n.deleteConfirmationTitle, this.i18n.deleteConfirmationMessage,
				lang.hitch(this, function(idProperty) {

				this._emitEvt('REMOVE_ITEM', idProperty);
			}, idProperty),
			lang.hitch(this, function() {

				this._emitEvt('COMMUNICATION', {
					description: this.i18n.cancelledAlert
				});
			})).set("labels", {
				ok: this.i18n.ok,
				cancel: this.i18n.cancel
			});
		},

		_getTarget: function(target) {

			if (target) {
				return target;
			}

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

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

			return this.target;
		}
	});
});
+2 −1
Original line number Diff line number Diff line
@@ -91,7 +91,8 @@ define([
			});

			this._emitEvt('SAVE', {
				data: res.data
				data: res.data,
				target: this.target
			});
		},

+3 −3
Original line number Diff line number Diff line
@@ -49,10 +49,10 @@ define([
			this.editor = new formDef(this.formConfig);
		},

		_getSavedObjToPublish: function(results) {
		_afterSaved: function(results) {

			results.hide = true;
			return results;
			this.inherited(arguments);
			this._publish(this.editor.getChannel('HIDE'));
		}
	});
});
+4 −7
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ define([
	, _StepNavigation
	, _StepBreadcrumbs
) {

	return declare([_Controller, _Store, _Persistence, _EditionCommons], {
		//	summary:
		//		Controller para vistas de detalle.
@@ -290,13 +291,9 @@ define([
			return this.domNode;
		},

		_subSaved: function(result) {
		_afterSaved: function(result) {

			this._emitEvt('LOADED');

			if (result && result.success) {
				this._emitEvt('SAVED', result);
			}
		}
	});
});
+8 −1
Original line number Diff line number Diff line
@@ -35,7 +35,14 @@ define([

			// TODO eliminar cuando el server no responda con envoltorio body
			var data = obj.body || obj;
			return data && data.target;

			var targetIsValid = data && data.target;

			if (!targetIsValid) {
				console.error('Received publication with invalid target at module "%s":', this.getChannel(), data);
			}

			return targetIsValid;
		},

		_chkTargetIsMine: function(res) {
Loading