Bläddra i källkod

Display message when user wants to choose existing username (Fixes: #16)

Mario Orlicky 8 år sedan
förälder
incheckning
69fbd31abc
3 ändrade filer med 14 tillägg och 4 borttagningar
  1. 2 0
      client/components/users/userHeader.jade
  2. 11 4
      client/components/users/userHeader.js
  3. 1 0
      i18n/en.i18n.json

+ 2 - 0
client/components/users/userHeader.jade

@@ -27,6 +27,8 @@ template(name="editProfilePopup")
       input.js-profile-fullname(type="text" value=profile.fullname autofocus)
     label
       | {{_ 'username'}}
+      span.error.hide.username-taken
+        | {{_ 'error-username-taken'}}
       input.js-profile-username(type="text" value=username)
     label
       | {{_ 'initials'}}

+ 11 - 4
client/components/users/userHeader.js

@@ -26,11 +26,18 @@ Template.editProfilePopup.events({
       'profile.fullname': fullname,
       'profile.initials': initials,
     }});
-    // XXX We should report the error to the user.
+
     if (username !== Meteor.user().username) {
-      Meteor.call('setUsername', username);
-    }
-    Popup.back();
+      Meteor.call('setUsername', username, function(error) {
+        const messageElement = tpl.$('.username-taken');
+        if (error) {
+         messageElement.show();
+        } else {
+          messageElement.hide();
+          Popup.back();
+        }
+      });
+    } else Popup.back();
   },
 });
 

+ 1 - 0
i18n/en.i18n.json

@@ -169,6 +169,7 @@
     "error-user-doesNotExist": "This user does not exist",
     "error-user-notAllowSelf": "This action on self is not allowed",
     "error-user-notCreated": "This user is not created",
+    "error-username-taken": "This username is already taken",
     "export-board": "Export board",
     "filter": "Filter",
     "filter-cards": "Filter Cards",