Skip to content

Commit

Permalink
Merge pull request #59 from pepf/master
Browse files Browse the repository at this point in the history
Use autoform for avatar updates
  • Loading branch information
Rayman committed Jul 14, 2014
2 parents c41dad9 + 41592d0 commit 3a62e69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
7 changes: 1 addition & 6 deletions client/views/userProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ <h1>{{this.username}}</h1>
<template name="editAvatar">
<div class="row">
<div class="col-md-12">
<div class="input-group">
<input type="text" class="form-control" id="avatarUrl">
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-action="update-avatar">Ok</button>
</span>
</div><!-- /input-group -->
{{> quickForm collection=users doc=currentAvatar id="updateAvatar" type="update" fields="profile.avatar" buttonContent="Ok!"}}
</div>
</div>
</template>
Expand Down
16 changes: 7 additions & 9 deletions client/views/userProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ Template.userPlaylist.songCount = function() {
}
};

Template.editAvatar.events = {
'click [data-action="update-avatar"]': function() {
var avatar = $("input#avatarUrl").val();
check(avatar,String);
Meteor.users.update(
{_id: Meteor.userId()},
{$set: {'profile.avatar':avatar}});
Session.set("showEditAvatarBar",false);
}
Template.editAvatar.currentAvatar = function () {
return Meteor.user();
};

Template.editAvatar.users = function () {
return Meteor.users;
};


Template.addRemoveFriend.isFriend = function() {
return _.contains(Meteor.user().profile.friends,this._id);
};
Expand Down

0 comments on commit 3a62e69

Please sign in to comment.