Commits

Juan Carlos Picado Herrera  committed 996e99e

Fixed toaster widget, restoted upload picture support

  • Participants
  • Parent commits 041af6b

Comments (0)

Files changed (4)

File enme-js/resources-enme-war/src/main/resources/resource/js/me/web/widget/profile/Profile.js

                  template) {
 
 
-//dojo.require("dojox.form.BusyButton");
-
   lang.extend(ValidationTextBox, {
 
-  //
-//	    isValid: function(/*Boolean*/ isFocused){
-//	        // summary:
-//	        //		Tests if value is valid.
-//	        //		Can override with your own routine in a subclass.
-//	        // tags:
-//	        //		protected
-//	        var defaultValid =  this.validator(this.textbox.value, this.constraints);
-//	        var backEndValid =  true;
-//	        if(isFocused){
-//	            backEndValid = this.validateBackEnd(this.textbox.value);
-//	        }
-//	        return (defaultValid && backEndValid);
-//	    },
-
       /*
        * validate back end.
        */
                   }
               });
               var error = function(error) {
-                  console.debug("error", error);
+                  dojo.publish('/encuestame/settings/profile/message', [message, 'error']);
               };
-              encuestame.service.xhrGet(URLServices.service('encuestame.service.list.checkProfile'), {type:type, value: this.textbox.value}, load, error);
+              encuestame.service.xhrGet(URLServices.service('encuestame.service.list.checkProfile'),
+              {
+                type:type,
+                value : this.textbox.value
+              },
+              load, error);
 //              URLServices.get('encuestame.service.list.checkProfile',  {type:type, value: this.textbox.value}, load, error , dojo.hitch(this, function() {
 //
 //              }));
       }
   });
 
-            return declare([ _WidgetBase, _TemplatedMixin, main_widget, _WidgetsInTemplateMixin], {
+  return declare([ _WidgetBase, _TemplatedMixin, main_widget, _WidgetsInTemplateMixin], {
 
-          // template string.
-            templateString : template,
+          /**
+           * template string.
+           * @property templateString
+           */
+           templateString : template,
 
-            /**
-            *
-            */
+          /**
+           *
+           * @property
+           */
            _openBox : false,
 
+           /**
+            *
+            * @property
+            */
            username : "",
 
+           /**
+            *
+            * @method
+            */
            email : "",
 
+           /**
+            *
+            * @method
+            */
            complete_name : "",
 
+           /**
+            *
+            * @method
+            */
            language : "",
 
            /**
                var error = function(error) {
                    console.error("error", error);
                };
-               encuestame.service.xhrGet(this.getURLService().service('encuestame.service.list.profile.my'), {}, load, error);
+              //encuestame.service.xhrGet(this.getURLService().service('encuestame.service.list.profile.my'), {}, load, error);
+              URLServices.get('encuestame.service.list.profile.my',  {
+
+              }, load, error , dojo.hitch(this, function() {
+
+              }));
            },
 
            /*
                var formDijit = registry.byId("profileForm");
                //console.debug("form", formDijit);
                if (formDijit.isValid()) {
-                   var  params = {
-                      //TODO: LLENAR ESTOS PARAMETROS
-                   };
+                   var params = formDijit.getValues();
                    var load = dojo.hitch(this, function(data) {
                        //console.debug(data);
                      if ("success" in data) {
                        var message = data.success.message;
                        if (message != 'undefined') {
-                         dojo.publish('/encuestame/settings/profile/message', [message, 'success']);
+                          this.successMesage(message);
                        }
                      }
-                     this._submit.cancel();
+                     //this._submit.cancel();
                    });
 
                    var error = dojo.hitch(this,function(error) {

File enme-js/resources-enme-war/src/main/resources/resource/js/me/web/widget/profile/UploadProfilePicture.js

          "me/web/widget/pictures/AccountPicture",
          "me/core/main_widgets/EnmeMainLayoutWidget",
          "me/core/enme",
+         "me/core/URLServices",
          "dojo/io/iframe",
          "dojo/text!me/web/widget/profile/templates/profilePicture.html" ],
         function(
                 AccountPicture,
                 main_widget,
                 _ENME,
+                URLServices,
                 ioIframe,
                  template) {
             return declare([ _WidgetBase, _TemplatedMixin, main_widget, _WidgetsInTemplateMixin], {
 
-          // template string.
-            templateString : template,
+                /**
+                 * template string.
+                 * @property templateString
+                 */
+                templateString : template,
 
-            contextPath : _ENME.config('contextPath'),
+                /**
+                 *
+                 * @property contextPath
+                 */
+                contextPath : _ENME.config('contextPath'),
 
+                /**
+                 * i18n Messages
+                 * @property i18nMessage
+                 */
                 i18nMessage : {
                   settings_config_picture_title : _ENME.getMessage("settings_config_picture_title"),
                   settings_config_picture_description : _ENME.getMessage("settings_config_picture_description"),
                   settings_config_picture_own : _ENME.getMessage("settings_config_picture_own"),
-                  settings_config_picture_restrictions : _ENME.getMessage("settings_config_picture_restrictions")
+                  settings_config_picture_restrictions : _ENME.getMessage("settings_config_picture_restrictions"),
+                  commons_update :  _ENME.getMessage("commons_update")
                 },
 
+                /**
+                 *
+                 * @property _size
+                 */
                 _size : ["preview", "default", "web"],
 
+                /**
+                 *
+                 * @property
+                 */
                 upgradeProfileService : 'encuestame.service.list.upgradeProfile',
 
+                /**
+                 *
+                 * @property
+                 */
                 username : "",
 
+                /**
+                 *
+                 * @property
+                 */
                 pictureSource : "",
 
+                /**
+                 *
+                 * @property
+                 */
                 imagePath : '/',
 
                 /**
 
                 /**
                  *
+                 * @method postCreate
                  */
                 postCreate : function() {
                     if (this.username != null) {
                     }
                 },
 
+                /**
+                 *
+                 * @method
+                 */
                 startup : function () {
                   var uploadedRadio = registry.byId("uploaded_radio");
                     uploadedRadio.onChange = dojo.hitch(this, function(e) {
 
                 },
 
-                /*
+
+                /**
                  *
+                 * @method
                  */
                 _updatePictureSource : function(value) {
-                  var parent = this,
-                  params = {
-                            "data" : value
-                   };
-                   //console.debug("params", params);
-
-                   var load = dojo.hitch(this, function(data) {
-                       parent._reloadPicture();
-                       parent.successMesage(data.success.message);
-                   });
-
-                   var error = dojo.hitch(this, function(error) {
-                       //console.error(error);
-                       parent.errorMessage(error);
-                   });
-                   encuestame.service.xhrPostParam(
-                       this.getURLService().service('encuestame.service.list.updatePicture'), params, load, error);
+                      var parent = this,
+                      params = {
+                                "data" : value
+                      };
+
+                      // succes handler
+                       var load = dojo.hitch(this, function(data) {
+                           parent._reloadPicture();
+                           parent.successMesage(data.success.message);
+                       });
+
+                       // error handler
+                       var error = dojo.hitch(this, function(error) {
+                           parent.errorMessage(error);
+                       });
+                       // encuestame.service.xhrPostParam(
+                       //     this.getURLService().service('encuestame.service.list.updatePicture'), params, load, error);
+                       URLServices.post('encuestame.service.list.updatePicture',  params, load, error , dojo.hitch(this, function() {
+
+                        }));
                 },
 
                 /**
                 },
 
 
-                /**
-                 *
-                 */
+               /**
+                * Update the image to the server
+                * @method uploadImage
+                */
                 uploadImage : function() {
+                  var parent = this;
                   ioIframe.send({
                         url:  this.contextPath + "/file/upload/profile",
                         form : "imageForm",
                         method: "POST",
                         handle : dojo.hitch(this, function(ioResponse, args) {
                             if (ioResponse instanceof Error) {
-                                console.error("handle error: " + ioResponse);
-                            } else {
-                                console.debug(args);
+                                this.errorMessage("handle error: " + ioResponse);
                             }
                         }),
+                        // time out
                         timeoutSeconds: 2000,
+                        // error handler
                         error: dojo.hitch(this,function (res,ioArgs) {
                             console.error("handle error: " + res);
                             console.error("handle error: " + ioArgs);
                         }),
                         // Callback on successful call:
                         load: dojo.hitch(this, function(response, ioArgs) {
-                            // do something
-                            // ...
-                            console.debug("response: " + response);
-                            console.debug("ioArgs: " + ioArgs);
-                            this.successMesage(response);
+                            this.successMesage(parent.i18nMessage.commons_update);
                             // return the response for succeeding callbacks
                             return response;
                         })

File enme-js/resources-enme-war/src/main/resources/resource/js/me/web/widget/ui/Toaster.js

  */
 define([
          "dojo/_base/declare",
+         "dojo/dom-construct",
    		 "dojox/widget/Toaster",
-   		 "me/web/widget/ui/Message",
-     	  "me/core/enme"],
-    function(
-    declare,
-    Toaster,
-    Message,
-    _ENME) {
+     	 "me/core/enme"], function(
+	    declare,
+	    domConstruct,
+	    Toaster,
+	    _ENME) {
 
   return declare([Toaster], {
 
 
  	/**
  	 *
- 	 * @method
+ 	 * @methodpostCreate
  	 */
 	postCreate: function() {
 		//this.inherited(arguments);
 	/**
 	 *
 	 * @param method
+	 * @method _setContent
 	 */
 	_setContent: function(message) {
-		var widget = new Message({
-			message : message,
-			descriptiom : "",
-			type : this.messageCurrentType || 'message'
-		});
-
+		var widget = domConstruct.create("div", { innerHTML: "<div> " + message + " </div>" });
+			dojo.addClass(widget, 'message_toaster');
 		if (message && this.isVisible) {
-			this.contentNode.appendChild(widget.domNode);
+			this.contentNode.appendChild(widget);
 		} else {
 			dojo.empty(this.contentNode);
-			this.contentNode.appendChild(widget.domNode);
+			this.contentNode.appendChild(widget);
 		}
 	},
 
 	/**
 	 *
 	 * @param message
+	 * @method _handleMessage
 	 */
 	_handleMessage: function(/*String|Object*/message) {
 		if (dojo.isString(message)) {

File enme-war/enme-views/src/main/webapp/WEB-INF/views/settings/web/profile-settings.jsp

     data-enabled="true"
     data-label="<spring:message code="settings.config.myaccount" />"></div>
   <!-- Upload Profile Image Widget -->
-
+<div id="upload_image_settings"
+     data-dojo-type="me/web/widget/profile/UploadProfilePicture"
+      data-enabled="false"
+      username="${account.username}"
+      pictureSource="${account.pictureSource}"
+      data-label="<spring:message code="settings.config.upload.image" />"></div>
 </div>