From 6096c8845479ef0f3f1049635708e187859f52b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 16 Dec 2014 18:36:28 +0100 Subject: [PATCH] FIX: automatically use uploaded avatar when uploading an avatar --- .../discourse/components/avatar-uploader.js.es6 | 4 ++++ .../discourse/templates/modal/avatar_selector.hbs | 3 ++- .../discourse/templates/user/preferences.hbs | 10 ++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/components/avatar-uploader.js.es6 b/app/assets/javascripts/discourse/components/avatar-uploader.js.es6 index 353fb5a4c..f711802a4 100644 --- a/app/assets/javascripts/discourse/components/avatar-uploader.js.es6 +++ b/app/assets/javascripts/discourse/components/avatar-uploader.js.es6 @@ -19,6 +19,7 @@ export default Em.Component.extend(UploadMixin, { // display a warning whenever the image is not a square this.set("imageIsNotASquare", data.result.width !== data.result.height); + // in order to be as much responsive as possible, we're cheating a bit here // indeed, the server gives us back the url to the file we've just uploaded // often, this file is not a square, so we need to crop it properly @@ -26,5 +27,8 @@ export default Em.Component.extend(UploadMixin, { Discourse.Utilities.cropAvatar(data.result.url, data.files[0].type).then(function(avatarTemplate) { self.set("uploadedAvatarTemplate", avatarTemplate); }); + + // the upload is now done + this.sendAction("done"); } }); diff --git a/app/assets/javascripts/discourse/templates/modal/avatar_selector.hbs b/app/assets/javascripts/discourse/templates/modal/avatar_selector.hbs index de3ca91c5..caad9187a 100644 --- a/app/assets/javascripts/discourse/templates/modal/avatar_selector.hbs +++ b/app/assets/javascripts/discourse/templates/modal/avatar_selector.hbs @@ -24,7 +24,8 @@ {{avatar-uploader username=username uploadedAvatarTemplate=view.uploadedAvatarTemplate - custom_avatar_upload_id=controller.custom_avatar_upload_id}} + custom_avatar_upload_id=controller.custom_avatar_upload_id + done="useUploadedAvatar"}} diff --git a/app/assets/javascripts/discourse/templates/user/preferences.hbs b/app/assets/javascripts/discourse/templates/user/preferences.hbs index 2e6dd5cbc..bb39d301a 100644 --- a/app/assets/javascripts/discourse/templates/user/preferences.hbs +++ b/app/assets/javascripts/discourse/templates/user/preferences.hbs @@ -89,10 +89,12 @@
{{bound-avatar model "large"}} {{#if allowAvatarUpload}} - - {{else}} {{#unless ssoOverridesAvatar}} - - {{/unless}} {{/if}} + + {{else}} + {{#unless ssoOverridesAvatar}} + {{fa-icon "pencil"}} + {{/unless}} + {{/if}}