Commit 7420b3f3 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Merge branch 'feature-FixUserImageEdition' into 'dev'

Redefine y corrige edición de imagen de usuario

See merge request redmic-project/client/web!55
parents 78e11428 c7aba97d
Loading
Loading
Loading
Loading
+21 −23
Original line number Diff line number Diff line
define([
	"app/designs/details/Controller"
	, "app/designs/details/Layout"
	, "app/designs/details/_AddTitle"
	, "app/redmicConfig"
	, "app/user/models/PasswordModel"
	, "app/user/models/UserImageModel"
@@ -10,7 +9,6 @@ define([
	, "app/user/models/UserSectorModel"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/query"
	, "redmic/base/Credentials"
	, "redmic/modules/base/_Window"
	, "redmic/modules/browser/_ButtonsInRow"
@@ -31,7 +29,6 @@ define([
], function(
	Controller
	, Layout
	, _AddTitle
	, redmicConfig
	, modelSchemaUserPassword
	, modelSchemaUserImage
@@ -40,7 +37,6 @@ define([
	, modelSchemaUserSector
	, declare
	, lang
	, query
	, Credentials
	, _Window
	, _ButtonsInRow
@@ -59,7 +55,8 @@ define([
	, TemplatePassword
	, TaskNotification
) {
	return declare([Layout, Controller/*, _AddTitle*/], {

	return declare([Layout, Controller], {
		//	summary:
		//		Vista detalle de user.

@@ -367,7 +364,6 @@ define([

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

			var instanceWidget = this._widgets[label];
@@ -379,24 +375,28 @@ define([
			this._publish(instanceWidget.getChannel('SHOW_WINDOW'));
		},

		_subscriptionOnceChangeImage: function() {
		_subscribeToWidgets: function() {

			this._once(this._widgets.userImage.getChannel("SHOWN"), lang.hitch(this, this._subUserImageShownOnce));
		},

		_subUserImageShownOnce: function(res) {

			this._once(this._widgets.userImage.getChannel("SHOWN"), lang.hitch(this, this._createOnClickChangeImage));
			this._nodes.userImage.onclick = lang.hitch(this, this._tryToGoToEditImage);
		},

		_createOnClickChangeImage: function() {
		_tryToGoToEditImage: function(evt) {

			setTimeout(lang.hitch(this, function() {
				this.changeImageNode = query("[data-redmic-id='changeImage']", this._nodes.userImage)[0];
			var node = evt.target || evt.srcElement,
				nodeTagName = node.tagName,
				nodeAttribute = node.getAttribute('data-redmic-id');

				if (this.changeImageNode) {
					this.changeImageNode.onclick = lang.hitch(this, this._changeImageOnClick);
					this.changeImageNode.parentNode.firstChild.onclick = lang.hitch(this, this._changeImageOnClick);
			if (nodeTagName === 'IMG' || nodeAttribute === 'changeImage') {
				this._goToEditImage();
			}
			}), 250);
		},

		_changeImageOnClick: function() {
		_goToEditImage: function() {

			var formConfig = this._merge([{
				template: "user/views/templates/forms/UserImage",
@@ -495,8 +495,6 @@ define([
				dataType: "password"
			}, "userData");

			//this._subscriptionOnceChangeImage();

			var envDfd = window.env;
			if (!envDfd) {
				return;
@@ -517,11 +515,11 @@ define([
			}, response.data));
		},

		_buildVisualization: function() {

			this._subscriptionOnceChangeImage();
		_generateWidgets: function() {

			this.inherited(arguments);

			this._subscribeToWidgets();
		},

		_injectItemList: function(data, widget) {