Commit 50a6e73e authored by CarlosGC1989's avatar CarlosGC1989
Browse files

Arregla issue #8, Fix #8

parent c9e4af79
Loading
Loading
Loading
Loading
+52 −41
Original line number Diff line number Diff line
@@ -169,10 +169,7 @@ define([

			this.subscriptionsConfig.push({
				channel: this.persistence.getChannel("SAVED"),
				callback: "_subSaved",
				options: {
					predicate: lang.hitch(this, this._chkSuccessful)
				}
				callback: "_subSaved"
			});
		},

@@ -196,6 +193,10 @@ define([

			this._emitEvt('LOADED');

			if (!result.success) {
				return;
			}

			result.hide = true;
			this._publish(this.formActive.getChannel("SAVED"), result);

@@ -276,19 +277,53 @@ define([

		_createAndShowForm: function(obj) {

			if (!this[obj.label + 'Form']) {
			this._createForm(obj);

			this.formActive = this[obj.label + 'Form'];

			if (!obj.noData) {
				this._once(this._buildChannel(this.storeChannel, this.actions.AVAILABLE),
					lang.hitch(this, function(item) {
						if (item && item.body && item.body.data) {
							this._showFormAndHideBoxUser(this.formActive, obj.labelNode, item.body.data);
						}
				}));

				this._publish(this._buildChannel(this.storeChannel, this.actions.REQUEST), {
					target: obj.formConfig.target,
					requesterId: this.formActive.getOwnChannel(),
					type: this.type
				});
			} else {
				this._showFormAndHideBoxUser(this.formActive, obj.labelNode);
			}
		},

		_createForm: function(obj) {

			var nameForm = obj.label + 'Form',
				instanceForm = this[nameForm];

			if (instanceForm) {
				return;
			}

			this._setIdDefault(obj);

			var formDef = declare([FormContainerImpl, _ListenModelHasChanged, _CreateKeypad]);

				this[obj.label + 'Form'] = new declare(formDef).extend(_Window)(obj.formConfig);
			this[obj.label + 'Form'] = instanceForm = new declare(formDef).extend(_Window)(obj.formConfig);

			this._createSubscriptionsForm(instanceForm, obj);
		},

		_createSubscriptionsForm: function(instanceForm, obj) {

				this._subscribe(this[obj.label + 'Form'].getChannel("CANCELLED"), lang.hitch(this, function(res) {
			this._subscribe(instanceForm.getChannel("CANCELLED"), lang.hitch(this, function(res) {
				this._showBoxUser(obj.formConfig.targetSave ? obj.formConfig.targetSave : obj.formConfig.target);
			}));

				this._subscribe(this[obj.label + 'Form'].getChannel("SUBMITTED"), lang.hitch(this, function(res) {
			this._subscribe(instanceForm.getChannel("SUBMITTED"), lang.hitch(this, function(res) {

				if (res.error) {
					return;
@@ -304,26 +339,6 @@ define([
					idProperty: this.idProperty
				});
			}));
			}

			this.formActive = this[obj.label + 'Form'];

			if (!obj.noData) {
				this._once(this._buildChannel(this.storeChannel, this.actions.AVAILABLE),
					lang.hitch(this, function(item) {
						if (item && item.body && item.body.data) {
							this._showFormAndHideBoxUser(this.formActive, obj.labelNode, item.body.data);
						}
				}));

				this._publish(this._buildChannel(this.storeChannel, this.actions.REQUEST), {
					target: obj.formConfig.target,
					requesterId: this.formActive.getOwnChannel(),
					type: this.type
				});
			} else {
				this._showFormAndHideBoxUser(this.formActive, obj.labelNode);
			}
		},

		_setIdDefault: function(obj) {
@@ -348,23 +363,19 @@ define([

		_showBoxUser: function(target) {

			var label;
			var label = "userData",
				instanceWidget = this._widgets[label];

			if (target === this.targetImage) {
				label = "userImage";
			} else {
				label = "userData";
			}

			if (target === this.targetImage) {
				this._subscriptionOnceChangeImage();
			}

			this._publish(this._widgets[label].getChannel("SHOW"), {
			this._publish(instanceWidget.getChannel("SHOW"), {
				node: this._nodes[label]
			});

			this._publish(this._widgets[label].getChannel('SHOW_WINDOW'));
			this._publish(instanceWidget.getChannel('SHOW_WINDOW'));
		},

		_subscriptionOnceChangeImage: function() {